Skip to content

Commit

Permalink
Merge branch 'master' into remove-shadow-expval
Browse files Browse the repository at this point in the history
  • Loading branch information
andrijapau authored Nov 8, 2024
2 parents 7a52a63 + 38a1d9e commit cf4e662
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 61 deletions.
47 changes: 30 additions & 17 deletions .github/workflows/check_in_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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..."
Expand All @@ -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'
Expand All @@ -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
64 changes: 24 additions & 40 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -113,6 +113,7 @@
# built documents.

import pennylane

pennylane.Hamiltonian = pennylane.ops.Hamiltonian

# The full version, including alpha/beta/rc tags.
Expand Down Expand Up @@ -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."
],
Expand Down
2 changes: 1 addition & 1 deletion pennylane/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.40.0-dev8"
__version__ = "0.40.0-dev9"

0 comments on commit cf4e662

Please sign in to comment.