-
Notifications
You must be signed in to change notification settings - Fork 216
Daily qml builds with RC environment #1587
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
base: master
Are you sure you want to change the base?
Conversation
andrijapau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried this out?
yep, I tried it out here |
| run: | | ||
| sed -i -E "s#git\+https://github.com/PennyLaneAI/pennylane.git\#egg=pennylane\",#pennylane<=${{ steps.setup-rc-versions.outputs.pennylane-version }}\",\\n\\t\\t\\t\"—extra-index-url\",\\n\\t\\t\\t\"https://test.pypi.org/simple/\",\\n\\t\\t\\tpre=True,#" lib/qml/lib/demo.py | ||
| sed -i "s/PennyLane-Lightning/pennylane-lightning<=${{ steps.setup-rc-versions.outputs.lightning-version }}/" lib/qml/lib/demo.py | ||
| sed -i "s/PennyLane-Catalyst/pennylane-catalyst<=${{ steps.setup-rc-versions.outputs.catalyst-version }}/" lib/qml/lib/demo.py | ||
| git commit -am "Set up RC versions for demo builds" | ||
| git push --set-upstream origin ${{ steps.setup-rc-versions.outputs.rc-build-branch }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the logic here, but I don't think manipulating the qml build tool files directly with sed in an Action is the right approach. I would prefer instead to add new command line argument(s) to the tool. We could even make this more general so you can build any version for PLC by passing in the arguments. We can then keep the logic that parses out the RC branches here in the Action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
| runs-on: ubuntu-latest | ||
| needs: check-for-rc-branches | ||
| # if: needs.check-for-rc-branches.outputs.branch_exists == 'true' | ||
| outputs: | ||
| pennylane-version: ${{ steps.setup-rc-versions.outputs.pennylane-version }} | ||
| lightning-version: ${{ steps.setup-rc-versions.outputs.lightning-version }} | ||
| catalyst-version: ${{ steps.setup-rc-versions.outputs.catalyst-version }} | ||
| rc-build-branch: ${{ steps.setup-rc-versions.outputs.rc-build-branch }} | ||
| steps: | ||
| - name: Checkout QML repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Set up rc versions | ||
| id: setup-rc-versions | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| rc_build_branch=rc-daily-build-$(date +'%Y-%m-%d-%H%M%S') | ||
| git checkout -b $rc_build_branch | ||
| python -m pip index versions pennylane 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true | ||
| pennylane_version=$(python -m pip index versions pennylane 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) | ||
| lightning_version=$(python -m pip index versions pennylane-lightning 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 ||true ) | ||
| catalyst_version=$(python -m pip index versions pennylane-catalyst 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) | ||
| echo "lightning-version=$lightning_version" >> $GITHUB_OUTPUT | ||
| echo "catalyst-version=$catalyst_version" >> $GITHUB_OUTPUT | ||
| echo "pennylane-version=$pennylane_version" >> $GITHUB_OUTPUT | ||
| echo "rc-build-branch=$rc_build_branch" >> $GITHUB_OUTPUT | ||
| echo "PennyLane version: $pennylane_version, PennyLane-Lightning version: $lightning_version, PennyLane-Catalyst version: $catalyst_version" | ||
|
|
||
| - name: Update demo versions | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| sed -i -E "s#git\+https://github.com/PennyLaneAI/pennylane.git\#egg=pennylane\",#pennylane<=${{ steps.setup-rc-versions.outputs.pennylane-version }}\",\\n\\t\\t\\t\"—extra-index-url\",\\n\\t\\t\\t\"https://test.pypi.org/simple/\",\\n\\t\\t\\tpre=True,#" lib/qml/lib/demo.py | ||
| sed -i "s/PennyLane-Lightning/pennylane-lightning<=${{ steps.setup-rc-versions.outputs.lightning-version }}/" lib/qml/lib/demo.py | ||
| sed -i "s/PennyLane-Catalyst/pennylane-catalyst<=${{ steps.setup-rc-versions.outputs.catalyst-version }}/" lib/qml/lib/demo.py | ||
| git commit -am "Set up RC versions for demo builds" | ||
| # git push --set-upstream origin ${{ steps.setup-rc-versions.outputs.rc-build-branch }} | ||
|
|
||
| build-demos: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix this problem, add a permissions block at the root level of the workflow—in this case, at the top of .github/workflows/v2-build-rc-demos-daily.yml, below the name and above the on keys. This block should specify the least privilege necessary for each job. As a starting point, set contents: read globally, which is the minimal safe default. For jobs that require additional permissions (such as pushing/deleting branches), add job-level permissions blocks (e.g., contents: write for jobs that push, and possibly delete-branch: write if required). The main places requiring more than read access are likely build-demos-with-rc-branches (which pushes a branch) and cleanup (which deletes a branch). Add job-level permission overrides for these two jobs, while leaving the others at the default read-only (inherited from the root).
Lines to change:
- Insert at the top of
.github/workflows/v2-build-rc-demos-daily.yml:- Add a global permissions block:
permissions: contents: read
- Add a global permissions block:
- In
build-demos-with-rc-branchesjob:
Add apermissions:block:permissions: contents: write
- In
cleanupjob:
Add apermissions:block:permissions: contents: write
No external libraries or package changes are required.
-
Copy modified lines R2-R3 -
Copy modified lines R47-R48 -
Copy modified lines R109-R110
| @@ -1,4 +1,6 @@ | ||
| name: Build Daily RC Demos | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| schedule: | ||
| - cron: '0 11 * * 1-5' # Runs weekdays 6 am ET | ||
| @@ -42,6 +44,8 @@ | ||
| fi | ||
|
|
||
| build-demos-with-rc-branches: | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-latest | ||
| needs: check-for-rc-branches | ||
| # if: needs.check-for-rc-branches.outputs.branch_exists == 'true' | ||
| @@ -102,6 +106,8 @@ | ||
| batch_size: 10 | ||
|
|
||
| cleanup: | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - build-demos |
Title:
Daily QML builds with the RC environment when it exists.
Summary:
demo.pyfile with them, and builds the demos.Relevant references:
Example demo.py configuration for an RC build
Possible Drawbacks:
None
Related GitHub Issues:
1579