forked from PennyLaneAI/pennylane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maintain stable versions of dependencies (PennyLaneAI#5158)
**Context:** There are many difficulties with dependency management, and this PR tries to address two of them: - reproducible versions of PL+deps from a past version - ability to view which deps have been auto-updated (eg. a new version of an unbound dep is released) and when **Description of the Change:** - Factor out the python environment setup to its own file. All default package versions are here now - Update `interface-unit-tests` to trigger the upload of `pip freeze` results as artifacts for later use. happens in the `core`, `jax`, `tf`, `torch`, `all-interfaces` and `external` test suites today (ensured that it only occurs on one worker using `strategy.job-index`) - Add the `upload-stable-deps` workflow to run after tests complete. The action only runs on merge commits to master, so users shouldn't see it. This is the real new feature, and here's how it works: 1. create the branch `bot/stable-deps-update` (or rebases it on master if it already existed) 2. delete the existing requirement files in `.github/stable/` to avoid merge conflicts 3. download the previously-uploaded requirement files generated in this flow to that same folder and check if there's a diff 4. if no diff, do nothing! 5. if there's a diff and no PR exists, it opens one and tags me (and hopefully the team because of CODEOWNERS) 6. if there's a diff and a PR already exists, it just pushes to the existing PR branch (confirmed this is the case despite the open-pr step running - it just does nothing in that case) **Benefits:** Helps with both difficulties mentioned in the context section above **Possible Drawbacks:** - the team will have to review this PR (if it becomes too noisy, we can turn this into a cronjob) - commits made by bots (eg. actions that use `${{ secrets.GITHUB_TOKEN }}`) will not trigger CI, so the automated PRs need to have it triggered manually. A hack to fix this is proposed [here](peter-evans/create-pull-request#48 (comment)) if we want to consider that, but this is a feature of GitHub (not a bug), intended to avoid infinite CI loops I will do something similar for the docs builds after this PR is merged, it's complex enough for now. [sc-56376]
- Loading branch information
Showing
5 changed files
with
202 additions
and
78 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.github/stable/ @PennyLaneAI/Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.