Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintain stable versions of dependencies #5158

Merged
merged 38 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c0e71d2
just run pip freeze
timmysilv Feb 5, 2024
44777af
only run on one worker
timmysilv Feb 5, 2024
dd6eff7
dbg: print the strategy index
timmysilv Feb 5, 2024
907c202
Revert "dbg: print the strategy index"
timmysilv Feb 5, 2024
7449cb8
see if job-index is set earlier
timmysilv Feb 6, 2024
02d3eb4
try to get the name automatically
timmysilv Feb 6, 2024
6533fa2
trigger ci
timmysilv Feb 6, 2024
be360f9
make a freeze job
timmysilv Feb 6, 2024
1b0eb9f
remove ref input
timmysilv Feb 6, 2024
b2ca3ab
try new way of doing things
timmysilv Feb 6, 2024
8a9ea24
fix workflow files
timmysilv Feb 6, 2024
1ed55d3
put inputs in braces
timmysilv Feb 6, 2024
1aeb600
use strings that look like bools
timmysilv Feb 6, 2024
cd56826
upload, download and list changes
timmysilv Feb 6, 2024
ab81f1e
fix typo; delete unused action
timmysilv Feb 6, 2024
a081638
checkout repo; use latest action
timmysilv Feb 6, 2024
85786db
use git status; run anyway
timmysilv Feb 6, 2024
0fc748f
merge multiple
timmysilv Feb 6, 2024
89d40af
use same action version
timmysilv Feb 6, 2024
b5f85b3
remove debug stuff; add current freeze files
timmysilv Feb 6, 2024
13dbe59
remove stable files; try to create PR
timmysilv Feb 6, 2024
f0bd664
add the changed files
timmysilv Feb 6, 2024
6edd61f
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 7, 2024
3220a48
use the same branch from now on
timmysilv Feb 7, 2024
40b33a8
add git fetch
timmysilv Feb 7, 2024
51ccdbc
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 7, 2024
cd6810e
rebase on origin
timmysilv Feb 7, 2024
fe2eedb
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 7, 2024
49e2844
force-push in case of rebase
timmysilv Feb 7, 2024
a2cee14
give the bot credentials earlier
timmysilv Feb 7, 2024
dfba495
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 7, 2024
551cfb9
add codeowners
timmysilv Feb 7, 2024
26cd329
only run on merge to master
timmysilv Feb 7, 2024
20ad7f3
remind reviewers to trigger an empty commit
timmysilv Feb 7, 2024
a198c71
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 8, 2024
dd0a445
update advice to use copyable code
timmysilv Feb 8, 2024
92efc1f
put back merge-only trigger
timmysilv Feb 8, 2024
1ac2c55
Merge branch 'master' into pip-freeze-stable
timmysilv Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.github/stable/ @PennyLaneAI/Core
113 changes: 113 additions & 0 deletions .github/workflows/install_deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Install Dependencies
description: |
This workflow installs Python, PennyLane and all its dependencies. If a
requirements file is provided, it will upload the results of pip freeze
as well.
inputs:
python_version:
description: The version of Python to use in order to run unit tests
required: false
default: '3.9'
install_jax:
description: Indicate if JAX should be installed or not
required: false
default: 'true'
jax_version:
description: The version of JAX to install for any job that requires JAX
required: false
default: 0.4.23
install_tensorflow:
description: Indicate if TensorFlow should be installed or not
required: false
default: 'true'
tensorflow_version:
description: The version of TensorFlow to install for any job that requires TensorFlow
required: false
default: 2.15.0
install_pytorch:
description: Indicate if PyTorch should be installed or not
required: false
default: 'true'
pytorch_version:
description: The version of PyTorch to install for any job that requires PyTorch
required: false
default: 2.2.0
install_pennylane_lightning_master:
description: Indicate if PennyLane-Lightning should be installed from the master branch
required: false
default: 'true'
additional_pip_packages:
description: Additional packages to install. Values will be passed to pip install {value}
required: false
default: ''
requirements_file:
description: File name to store stable version of requirements for a test group
required: false
default: ''

runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '${{ inputs.python_version }}'

- name: Upgrade PIP
shell: bash
run: pip install --upgrade pip && pip install wheel --upgrade

- name: Install PennyLane dependencies
shell: bash
run: |
pip install -r requirements-ci.txt --upgrade
pip install -r requirements-dev.txt --upgrade

- name: Install PyTorch
shell: bash
if: inputs.install_pytorch == 'true'
env:
TORCH_VERSION: ${{ inputs.pytorch_version != '' && format('=={0}', inputs.pytorch_version) || '' }}
run: pip install "torch${{ env.TORCH_VERSION }}" -f https://download.pytorch.org/whl/torch_stable.html

- name: Install TensorFlow
shell: bash
if: inputs.install_tensorflow == 'true'
env:
TF_VERSION: ${{ inputs.tensorflow_version != '' && format('~={0}', inputs.tensorflow_version) || '' }}
run: pip install "tensorflow${{ env.TF_VERSION }}" "keras${{ env.TF_VERSION }}"

- name: Install JAX
shell: bash
if: inputs.install_jax == 'true'
env:
JAX_VERSION: ${{ inputs.jax_version != '' && format('=={0}', inputs.jax_version) || '' }}
run: pip install "jax${{ env.JAX_VERSION}}" "jaxlib${{ env.JAX_VERSION }}"

- name: Install additional PIP packages
shell: bash
if: inputs.additional_pip_packages != ''
run: pip install ${{ inputs.additional_pip_packages }}

- name: Install PennyLane
shell: bash
run: |
python setup.py bdist_wheel
pip install dist/PennyLane*.whl

- name: Install PennyLane-Lightning master
shell: bash
if: inputs.install_pennylane_lightning_master == 'true'
run: pip install -i https://test.pypi.org/simple/ PennyLane-Lightning --pre --upgrade

- name: Freeze dependencies
shell: bash
if: inputs.requirements_file != ''
run: pip freeze | grep -v "file:///" > ${{ inputs.requirements_file }}

- name: Upload frozen requirements
if: inputs.requirements_file != ''
uses: actions/upload-artifact@v4
with:
name: frozen-${{ inputs.requirements_file }}
path: ${{ inputs.requirements_file }}
40 changes: 7 additions & 33 deletions .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ on:
required: false
type: string
default: 'unit-tests'
jax_version:
description: The version of JAX to install for any job that requires JAX
required: false
type: string
default: 0.4.23
tensorflow_version:
description: The version of TensorFlow to install for any job that requires TensorFlow
required: false
type: string
default: 2.15.0
pytorch_version:
description: The version of PyTorch to install for any job that requires PyTorch
required: false
type: string
default: 2.2.0
pytest_coverage_flags:
description: PyTest Coverage flags to pass to all jobs
required: false
Expand Down Expand Up @@ -162,10 +147,10 @@ jobs:
install_jax: false
install_tensorflow: false
install_pytorch: true
pytorch_version: ${{ inputs.pytorch_version }}
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: torch and not qcut and not finite-diff and not param-shift
requirements_file: ${{ strategy.job-index == 0 && 'torch.txt' || '' }}


autograd-tests:
Expand Down Expand Up @@ -225,13 +210,13 @@ jobs:
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: false
install_tensorflow: true
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: false
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: tf and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 3 --group ${{ matrix.group }} --durations-path='.github/workflows/tf_tests_durations.json'
additional_pip_packages: pytest-split
requirements_file: ${{ strategy.job-index == 0 && 'tf.txt' || '' }}


jax-tests:
Expand Down Expand Up @@ -259,14 +244,14 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: true
jax_version: ${{ inputs.jax_version }}
install_tensorflow: false
install_pytorch: false
install_pennylane_lightning_master: true
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: jax and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 5 --group ${{ matrix.group }} --durations-path='.github/workflows/jax_tests_durations.json'
additional_pip_packages: pytest-split
requirements_file: ${{ strategy.job-index == 0 && 'jax.txt' || '' }}


core-tests:
Expand Down Expand Up @@ -303,6 +288,7 @@ jobs:
pytest_markers: core and not qcut and not finite-diff and not param-shift
pytest_additional_args: --splits 2 --group ${{ matrix.group }}
additional_pip_packages: pytest-split
requirements_file: ${{ strategy.job-index == 0 && 'core.txt' || '' }}


all-interfaces-tests:
Expand All @@ -329,14 +315,12 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: true
jax_version: ${{ inputs.jax_version }}
install_tensorflow: true
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: true
pytorch_version: ${{ inputs.pytorch_version }}
install_pennylane_lightning_master: false
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: all_interfaces
requirements_file: ${{ strategy.job-index == 0 && 'all_interfaces.txt' || '' }}


external-libraries-tests:
Expand All @@ -363,14 +347,13 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: true
jax_version: ${{ inputs.jax_version }}
install_tensorflow: true
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: false
install_pennylane_lightning_master: false
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: external
additional_pip_packages: git+https://github.com/Quantomatic/pyzx.git@master pennylane-catalyst matplotlib stim
additional_pip_packages: pyzx pennylane-catalyst matplotlib stim
requirements_file: ${{ strategy.job-index == 0 && 'external.txt' || '' }}


qcut-tests:
Expand All @@ -397,11 +380,8 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: true
jax_version: ${{ inputs.jax_version }}
install_tensorflow: true
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: true
pytorch_version: ${{ inputs.pytorch_version }}
install_pennylane_lightning_master: false
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: qcut
Expand Down Expand Up @@ -466,11 +446,8 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: true
jax_version: ${{ inputs.jax_version }}
install_tensorflow: true
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: true
pytorch_version: ${{ inputs.pytorch_version }}
install_pennylane_lightning_master: false
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
pytest_markers: ${{ matrix.config.suite }}
Expand Down Expand Up @@ -543,11 +520,8 @@ jobs:
python_version: ${{ matrix.python-version }}
pipeline_mode: ${{ inputs.pipeline_mode }}
install_jax: ${{ contains(matrix.config.device, 'jax') }}
jax_version: ${{ inputs.jax_version }}
install_tensorflow: ${{ contains(matrix.config.device, 'tf') }}
tensorflow_version: ${{ inputs.tensorflow_version }}
install_pytorch: ${{ contains(matrix.config.device, 'torch') }}
pytorch_version: ${{ inputs.pytorch_version }}
install_pennylane_lightning_master: false
pytest_test_directory: pennylane/devices/tests
pytest_coverage_flags: ${{ inputs.pytest_coverage_flags }}
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ concurrency:
group: unit-tests-${{ github.ref }}
cancel-in-progress: true

env:
DEPS_BRANCH: bot/stable-deps-update

jobs:
tests:
uses: ./.github/workflows/interface-unit-tests.yml
Expand All @@ -24,3 +27,61 @@ jobs:
&& !contains(github.event.pull_request.labels.*.name, 'ci:run-full-test-suite')
|| false
}}

upload-stable-deps:
needs: tests
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-tags: true
sparse-checkout: .github

- name: Prepare local repo
run: |
git fetch
git config user.name "GitHub Actions Bot"
git config user.email "<>"
if git ls-remote --exit-code origin "refs/heads/${{ env.DEPS_BRANCH }}"; then
git checkout "${{ env.DEPS_BRANCH }}"
git rebase origin/master
else
git checkout master
git checkout -b "${{ env.DEPS_BRANCH }}"
fi
rm -f .github/stable/*.txt

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: frozen-*
path: .github/stable/
merge-multiple: true

- name: Determine if changes have been made
id: changed
run: |
echo "has_changes=$(git status --porcelain | wc -l | awk '{print $1}')" >> $GITHUB_OUTPUT

- name: Stage changes
if: steps.changed.outputs.has_changes != '0'
run: |
git add .github/stable/
git commit -m "Update changed dependencies"
git push -f --set-upstream origin "${{ env.DEPS_BRANCH }}"

# Create PR to master
- name: Create pull request
if: steps.changed.outputs.has_changes != '0'
uses: repo-sync/pull-request@v2
with:
source_branch: "${{ env.DEPS_BRANCH }}"
destination_branch: "master"
github_token: "${{ secrets.GITHUB_TOKEN }}"
pr_title: "Update stable dependency files"
pr_body: "Automatic update of stable requirement files to snapshot valid python environments. Please push an empty commit using `git commit --allow-empty -m 'trigger ci'` as bots are not able to trigger CI on their own."
pr_allow_empty: false
pr_draft: false
pr_reviewer: "timmysilv"
Loading
Loading