damccorm commented on code in PR #41494: URL: https://github.com/apache/beam/pull/41494#discussion_r4687226947
########## .github/workflows/update_ml_dependency_bounds.yml: ########## @@ -0,0 +1,108 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This workflow raises the exclusive upper bounds of ML dependencies in +# setup.py and tox.ini when PyPI has a newer stable release, and opens a pull +# request with the result. It never merges the pull request. It does not +# regenerate the container requirements; see update_python_dependencies.yml. +# If an open pull request from this workflow already exists, the run is +# skipped so that reviewer changes on its branch are not overwritten. Close +# that pull request to get a new run. + +name: Update ML Dependency Bounds + +on: + schedule: + - cron: "0 0 1 * *" + workflow_dispatch: +permissions: + contents: write + pull-requests: write + +concurrency: + group: '${{ github.workflow }} @ ${{ github.ref }}' + cancel-in-progress: true + +jobs: + update_ml_dependency_bounds: + runs-on: [self-hosted, ubuntu-24.04, main] + name: Update ML Dependency Bounds + timeout-minutes: 30 + steps: + - name: Checkout code + uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Setup environment + uses: $/.github/actions/setup-environment-action + with: + python-version: "3.11" + # The script does not use tox. + tox-cache: false + - name: Install script dependencies + run: pip install packaging pyyaml pytest + - name: Install gh cli + uses: $/.github/actions/setup-gh-cli-linux + - name: Check for an open pull request from this workflow + id: existing_pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + existingPr=$(gh pr list --state open --limit 100 \ + --json number,title,isCrossRepository \ + --jq '[.[] | select((.title | startswith("Update ML dependency bounds")) and (.isCrossRepository | not))] | .[0].number // empty') + echo "number=$existingPr" >> "$GITHUB_OUTPUT" + if [ -n "$existingPr" ]; then + message="Open pull request #$existingPr from this workflow exists. Skipping this run. Close that pull request to get a new run." + echo "$message" + echo "$message" >> "$GITHUB_STEP_SUMMARY" + fi + - name: Test the update script + if: steps.existing_pr.outputs.number == '' + run: python -m pytest scripts/tools/update_ml_dependency_bounds_test.py + - name: Update ML dependency bounds Review Comment: As part of this, we should trigger all Python-related postcommits (probably this should be done programatically so new workflows with Python in the name are picked up) ########## .github/workflows/update_ml_dependency_bounds.yml: ########## @@ -0,0 +1,108 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This workflow raises the exclusive upper bounds of ML dependencies in +# setup.py and tox.ini when PyPI has a newer stable release, and opens a pull +# request with the result. It never merges the pull request. It does not +# regenerate the container requirements; see update_python_dependencies.yml. +# If an open pull request from this workflow already exists, the run is +# skipped so that reviewer changes on its branch are not overwritten. Close +# that pull request to get a new run. + +name: Update ML Dependency Bounds + +on: + schedule: + - cron: "0 0 1 * *" Review Comment: Can we update to run weekly? ########## scripts/tools/update_ml_dependency_bounds.py: ########## @@ -0,0 +1,425 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Raises the exclusive upper bounds of ML dependencies. + +For every site listed in ml_dependency_bounds.yaml the script reads the current +requirement from the repository files, compares it with the latest stable +release on PyPI, and rewrites only the bound token that has to move. Tox +environments and Gradle tasks that carry the version of the highest tested +window are renamed together with the window. + +Run it from anywhere: + + python scripts/tools/update_ml_dependency_bounds.py +""" + +import argparse +import http.client +import json +import re +import sys +import time +import urllib.request +from dataclasses import dataclass +from dataclasses import field +from pathlib import Path +from typing import Callable +from typing import Optional + +import yaml +from packaging.requirements import Requirement +from packaging.utils import canonicalize_name +from packaging.version import InvalidVersion +from packaging.version import Version + +PR_TITLE = 'Update ML dependency bounds' + +# Same wording as the PR created by update_python_dependencies.yml. +PR_REVIEW_SENTENCE = ( + 'This PR was created by automation - by default this does not execute ' + 'tests due to a limitation in GitHub Actions. To review this PR, please ' + '(1) review the contents to make sure all dependency upgrades are ' + 'formatted correctly, (2) close and reopen the PR (3) Approve/merge if ' + 'tests pass successfully.') + +TOKENIZERS_NOTE = ( + 'tokenizers stays below 0.22 in the same requirement list as ' + 'transformers in ml_base_core. The two can conflict. If a test fails ' + 'for that reason, hold transformers instead of raising tokenizers.') Review Comment: Why is this the case? ########## .github/workflows/update_ml_dependency_bounds.yml: ########## @@ -0,0 +1,108 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This workflow raises the exclusive upper bounds of ML dependencies in +# setup.py and tox.ini when PyPI has a newer stable release, and opens a pull +# request with the result. It never merges the pull request. It does not +# regenerate the container requirements; see update_python_dependencies.yml. +# If an open pull request from this workflow already exists, the run is +# skipped so that reviewer changes on its branch are not overwritten. Close +# that pull request to get a new run. + +name: Update ML Dependency Bounds Review Comment: Could you update the description with an example PR created by the script? ########## scripts/tools/update_ml_dependency_bounds.py: ########## @@ -0,0 +1,425 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Raises the exclusive upper bounds of ML dependencies. + +For every site listed in ml_dependency_bounds.yaml the script reads the current +requirement from the repository files, compares it with the latest stable +release on PyPI, and rewrites only the bound token that has to move. Tox +environments and Gradle tasks that carry the version of the highest tested +window are renamed together with the window. + +Run it from anywhere: + + python scripts/tools/update_ml_dependency_bounds.py +""" + +import argparse +import http.client +import json +import re +import sys +import time +import urllib.request +from dataclasses import dataclass +from dataclasses import field +from pathlib import Path +from typing import Callable +from typing import Optional + +import yaml +from packaging.requirements import Requirement +from packaging.utils import canonicalize_name +from packaging.version import InvalidVersion +from packaging.version import Version + +PR_TITLE = 'Update ML dependency bounds' + +# Same wording as the PR created by update_python_dependencies.yml. +PR_REVIEW_SENTENCE = ( + 'This PR was created by automation - by default this does not execute ' + 'tests due to a limitation in GitHub Actions. To review this PR, please ' Review Comment: Lets update this to make it clear that it has not been reviewed at all. ########## scripts/tools/update_ml_dependency_bounds.py: ########## @@ -0,0 +1,425 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +"""Raises the exclusive upper bounds of ML dependencies. + +For every site listed in ml_dependency_bounds.yaml the script reads the current +requirement from the repository files, compares it with the latest stable +release on PyPI, and rewrites only the bound token that has to move. Tox Review Comment: > rewrites only the bound token that has to move Could you elaborate on this more? We should also link to this explanation (or better, a README) in the PR description that we generate. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
