From 8468d369954aad447c981bfcf81a1b37165ffcdd Mon Sep 17 00:00:00 2001 From: Mudit Pandey Date: Thu, 7 Nov 2024 17:55:11 -0500 Subject: [PATCH 1/2] Fix docs workflow (#6546) Docs workflow has been failing quite consistently on the step that updates the stable dependencies. This PR updates the workflow to use the new `check_in_artifact.yml` workflow for the dependency update instead of doing it on its own. Successful workflow run [here](https://github.com/PennyLaneAI/pennylane/actions/runs/11725687588) Successful stable deps PR [here](https://github.com/PennyLaneAI/pennylane/pull/6547) image [sc-77818] --------- Co-authored-by: Rashid N H M <95639609+rashidnhm@users.noreply.github.com> --- .github/workflows/check_in_artifact.yml | 47 +++++++++++------- .github/workflows/docs.yml | 64 ++++++++++--------------- .github/workflows/tests.yml | 2 +- doc/conf.py | 4 +- 4 files changed, 57 insertions(+), 60 deletions(-) diff --git a/.github/workflows/check_in_artifact.yml b/.github/workflows/check_in_artifact.yml index de24731f239..ad84b13c69f 100644 --- a/.github/workflows/check_in_artifact.yml +++ b/.github/workflows/check_in_artifact.yml @@ -56,29 +56,39 @@ on: required: false type: string default: '41898282+github-actions[bot]@users.noreply.github.com' + merge_multiple: + description: | + When multiple artifacts are matched, this changes the behavior of the destination directories. + If true, the downloaded artifacts will be in the same directory specified by path. + If false, the downloaded artifacts will be extracted into individual named directories within the specified path. + Optional. Default is 'true' + required: false + type: boolean + default: true jobs: check_in_artifact: runs-on: ubuntu-latest - + steps: - name: Checkout master uses: actions/checkout@v4 with: fetch-depth: ${{ inputs.master_branch_fetch_depth }} ref: master - + - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: ${{ inputs.artifact_name_pattern }} path: ${{ inputs.artifact_save_path }} - + merge-multiple: ${{ inputs.merge_multiple }} + - name: Determine if changes have been made id: changed run: | echo "has_changes=$(git status --porcelain | wc -l | awk '{print $1}')" >> $GITHUB_OUTPUT - + - name: Prepare Commit Author if: steps.changed.outputs.has_changes != '0' env: @@ -88,7 +98,8 @@ jobs: run: | git config user.name "$COMMIT_AUTHOR_NAME" git config user.email "$COMMIT_AUTHOR_EMAIL" - + git stash push --all + echo "Checking if $HEAD_BRANCH_NAME exists..." if git ls-remote --exit-code origin "refs/heads/$HEAD_BRANCH_NAME"; then echo "$HEAD_BRANCH_NAME exists! Checking out..." @@ -97,17 +108,18 @@ jobs: echo "$HEAD_BRANCH_NAME does not exist! Creating..." git checkout -b "$HEAD_BRANCH_NAME" fi - + - name: Stage changes if: steps.changed.outputs.has_changes != '0' env: HEAD_BRANCH_NAME: ${{ inputs.pull_request_head_branch_name }} COMMIT_MESSAGE_DESCRIPTION: ${{ inputs.commit_message_description != '' && format('-> {0}', inputs.commit_message_description) || '' }} run: | + git checkout stash -- . git add ${{ inputs.artifact_save_path }} git commit -m "Check in artifacts$COMMIT_MESSAGE_DESCRIPTION" git push -f --set-upstream origin "$HEAD_BRANCH_NAME" - + # Create PR to master - name: Create Pull Request to master if: steps.changed.outputs.has_changes != '0' @@ -117,20 +129,21 @@ jobs: PR_TITLE: ${{ inputs.pull_request_title }} PR_BODY: ${{ inputs.pull_request_body }} run: | - EXISTING_CLOSED_PR="$(gh pr list --state closed --base master --head $HEAD_BRANCH_NAME --json url --jq '.[].url')" - - if [ -n "${EXISTING_CLOSED_PR}" ]; then - echo "Reopening PR... ${EXISTING_CLOSED_PR}" - gh pr reopen "${EXISTING_CLOSED_PR}" - exit 0 - fi - - EXISTING_PR="$(gh pr list --state open --base master --head $HEAD_BRANCH_NAME --json url --jq '.[].url')" - + EXISTING_PR="$(gh pr list --state open --base master --head $HEAD_BRANCH_NAME --json 'url' --jq '.[].url' | head -n 1)" + if [ -n "${EXISTING_PR}" ]; then echo "PR already exists ==> ${EXISTING_PR}" exit 0 else echo "Creating PR..." gh pr create --title "$PR_TITLE" --body "$PR_BODY" + exit 0 + fi + + EXISTING_CLOSED_PR="$(gh pr list --state closed --base master --head $HEAD_BRANCH_NAME --json 'mergedAt,url' --jq '.[] | select(.mergedAt == null).url' | head -n 1)" + + if [ -n "${EXISTING_CLOSED_PR}" ]; then + echo "Reopening PR... ${EXISTING_CLOSED_PR}" + gh pr reopen "${EXISTING_CLOSED_PR}" + exit 0 fi diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 71b47ff09a3..0711a0c292d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -35,8 +35,6 @@ jobs: sphinx: if: github.event.pull_request.draft == false - env: - DEPS_BRANCH: bot/stable-deps-update needs: [determine_runner] runs-on: ${{ needs.determine_runner.outputs.runner_group }} steps: @@ -50,46 +48,32 @@ jobs: && pip3 install . && pip3 install openfermionpyscf && pip3 install aiohttp fsspec h5py - && pip freeze | grep -v 'file:///' > .github/stable/doc.txt.tmp build-command: "sphinx-build -b html . _build -W --keep-going" - - name: Prepare local repo - if: github.event.pull_request.head.repo.full_name == 'PennyLaneAI/pennylane' + - name: Freeze dependencies + shell: bash 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 }}" - else - git checkout master - git pull - git checkout -b "${{ env.DEPS_BRANCH }}" - fi - mv -f .github/stable/doc.txt.tmp .github/stable/doc.txt + pip freeze | grep -v 'file:///' > doc.txt + cat doc.txt - - name: Determine if changes have been made - if: github.event.pull_request.head.repo.full_name == 'PennyLaneAI/pennylane' - id: changed - run: | - echo "has_changes=$(git status --porcelain | wc -l | awk '{print $1}')" >> $GITHUB_OUTPUT - - - name: Stage changes - if: github.event.pull_request.head.repo.full_name == 'PennyLaneAI/pennylane' && steps.changed.outputs.has_changes != '0' - run: | - git add .github/stable/doc.txt - git commit -m "Update stable docs dependencies" - git push -f --set-upstream origin "${{ env.DEPS_BRANCH }}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload frozen requirements + uses: actions/upload-artifact@v4 + with: + name: frozen-doc + path: doc.txt - # Create PR to master - - name: Create pull request - if: github.event.pull_request.head.repo.full_name == 'PennyLaneAI/pennylane' && steps.changed.outputs.has_changes != '0' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - function gh_pr_up() { - gh pr create $* || gh pr edit $* - } - gh_pr_up --title \"Update stable doc dependency files\" --body \".\" + upload-stable-deps: + if: github.event.pull_request.draft == false + needs: + - determine_runner + - sphinx + uses: ./.github/workflows/check_in_artifact.yml + with: + artifact_name_pattern: "frozen-doc" + artifact_save_path: ".github/stable/" + merge_multiple: true + pull_request_head_branch_name: bot/stable-deps-update + commit_message_description: Frozen Doc Dependencies Update + pull_request_title: Update stable dependency files + pull_request_body: | + Automatic update of stable requirement files to snapshot valid python environments. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bca7aa27c59..8a607060930 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,7 +39,7 @@ jobs: upload-stable-deps: needs: tests uses: ./.github/workflows/check_in_artifact.yml - if: github.event_name == 'push' + if: github.event_name == 'schedule' with: artifact_name_pattern: "frozen-*" artifact_save_path: ".github/stable/" diff --git a/doc/conf.py b/doc/conf.py index 0e61021a768..99063fdf06d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -83,7 +83,7 @@ intersphinx_mapping = { "demo": ("https://pennylane.ai/qml/", None), - "catalyst": ("https://docs.pennylane.ai/projects/catalyst/en/stable", None) + "catalyst": ("https://docs.pennylane.ai/projects/catalyst/en/stable", None), } mathjax_path = ( @@ -113,6 +113,7 @@ # built documents. import pennylane + pennylane.Hamiltonian = pennylane.ops.Hamiltonian # The full version, including alpha/beta/rc tags. @@ -254,7 +255,6 @@ # Xanadu theme options (see theme.conf for more information). html_theme_options = { - "navbar_active_link": 4, "extra_copyrights": [ "TensorFlow, the TensorFlow logo, and any related marks are trademarks " "of Google Inc." ], From 38a1d9eb7a9e47ba8d5d4d66b1b37ad2584f6be7 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Fri, 8 Nov 2024 09:51:44 +0000 Subject: [PATCH 2/2] [no ci] bump nightly version --- pennylane/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane/_version.py b/pennylane/_version.py index 8a038f25c6b..4012d0f128d 100644 --- a/pennylane/_version.py +++ b/pennylane/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev8" +__version__ = "0.40.0-dev9"