From 8795871d512e8f4eabd27d4a98275072a0ba01a4 Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:00:24 -0800 Subject: [PATCH] Check if toolkit version changed before attempting publish (#198) # PR Description Changes to a toolkit without changes to the toolkit's version fail the 'Publish Toolkit' workflow with `HTTP Error 400: File already exists ('arcade_zoom-0.1.7.tar.gz', with blake2_256 hash '02183cda607f06616e7edb17e3d22bc11d1d83b074b3e44066b78ec72602fb37'). See https://pypi.org/help/#file-name-reuse for more information.`, for example. This PR adds the `--skip-existing` flag to `poetry publish` to avoid attempting to publish an existing version. Skips slack notification if publish is skipped. The `grep`'d string comes from https://github.com/python-poetry/poetry/blob/main/src/poetry/publishing/uploader.py#L246-L249 --- .github/workflows/publish-toolkit.yml | 11 +++++++++-- toolkits/math/evals/eval_math_tools.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-toolkit.yml b/.github/workflows/publish-toolkit.yml index 4e9375a4..f940a5b9 100644 --- a/.github/workflows/publish-toolkit.yml +++ b/.github/workflows/publish-toolkit.yml @@ -50,6 +50,7 @@ jobs: make test - name: Publish Toolkit + # Publish the toolkit to PyPI if the version is not already published id: Publish_Toolkit working-directory: toolkits/${{ steps.set-toolkit.outputs.toolkit }} run: | @@ -58,10 +59,16 @@ jobs: VERSION=$(poetry version -s) echo "version=$VERSION" >> $GITHUB_OUTPUT poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} - poetry publish + # Attempt to publish the toolkit to PyPI. Skip if the version already exists + if poetry publish --skip-existing 2>&1 | grep -q "File exists. Skipping"; then + echo "Version already exists on PyPI. Skipping publish." + echo "skip_publish=true" >> $GITHUB_OUTPUT + else + echo "skip_publish=false" >> $GITHUB_OUTPUT + fi - name: Send status to Slack - if: always() + if: steps.Publish_Toolkit.outputs.skip_publish != 'true' uses: slackapi/slack-github-action@v2.0.0 with: webhook: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/toolkits/math/evals/eval_math_tools.py b/toolkits/math/evals/eval_math_tools.py index ebb57fe1..07b55d5f 100644 --- a/toolkits/math/evals/eval_math_tools.py +++ b/toolkits/math/evals/eval_math_tools.py @@ -25,7 +25,7 @@ catalog.add_module(arcade_math) def math_eval_suite(): suite = EvalSuite( name="Math Tools Evaluation", - system_message="You are an AI assistant with access to math tools. Use them to help the user with their math-related tasks.", + system_message="You're an AI assistant with access to math tools. Use them to help the user with their math-related tasks.", catalog=catalog, rubric=rubric, )