[go: nahoru, domu]

Skip to content

[FR] Raise an exception if mlflow.get_artifact_uri() used outside of an active run #26084

[FR] Raise an exception if mlflow.get_artifact_uri() used outside of an active run

[FR] Raise an exception if mlflow.get_artifact_uri() used outside of an active run #26084

Workflow file for this run

# See .github/workflows/autoformat.md for instructions on how to test this workflow.
name: Autoformat
on:
issue_comment:
types: [created, edited]
permissions:
contents: read
defaults:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
check-comment:
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '@mlflow-automation') && contains(github.event.comment.body, 'autoformat') }}
permissions:
statuses: write # autoformat.createStatus
pull-requests: write # autoformat.createReaction on PRs
outputs:
should_autoformat: ${{ fromJSON(steps.judge.outputs.result).shouldAutoformat }}
repository: ${{ fromJSON(steps.judge.outputs.result).repository }}
head_ref: ${{ fromJSON(steps.judge.outputs.result).head_ref }}
head_sha: ${{ fromJSON(steps.judge.outputs.result).head_sha }}
base_ref: ${{ fromJSON(steps.judge.outputs.result).base_ref }}
base_sha: ${{ fromJSON(steps.judge.outputs.result).base_sha }}
base_repo: ${{ fromJSON(steps.judge.outputs.result).base_repo }}
pull_number: ${{ fromJSON(steps.judge.outputs.result).pull_number }}
steps:
- uses: actions/checkout@v4
- name: judge
id: judge
uses: actions/github-script@v7
with:
script: |
core.debug(JSON.stringify(context, null, 2));
const autoformat = require('./.github/workflows/autoformat.js');
const { comment } = context.payload;
const pullInfo = await autoformat.getPullInformation(context, github);
const isMaintainer = autoformat.isMlflowMaintainer(comment.author_association) && autoformat.isMlflowMaintainer(pullInfo.author_association);
if (!isMaintainer) {
core.setFailed("Only MLflow maintainers can trigger this workflow in their PRs.");
}
const shouldAutoformat = autoformat.shouldAutoformat(comment);
if (shouldAutoformat) {
await autoformat.createReaction(context, github);
await autoformat.createStatus(context, github, core);
}
return { ...pullInfo, shouldAutoformat };
format:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: check-comment
if: ${{ needs.check-comment.outputs.should_autoformat == 'true' }}
permissions:
pull-requests: read # view files modified in PR
outputs:
reformatted: ${{ steps.patch.outputs.reformatted }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ needs.check-comment.outputs.repository }}
ref: ${{ needs.check-comment.outputs.head_ref }}
# Set fetch-depth to merge the base branch
fetch-depth: 300
- name: Check diff
id: diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
changed_files="$(gh pr view --repo ${{ github.repository }} ${{ needs.check-comment.outputs.pull_number }} --json files --jq '.files.[].path')"
protos=$([[ -z $(echo "$changed_files" | grep '^\(mlflow/protos\|tests/protos\)') ]] && echo "false" || echo "true")
js=$([[ -z $(echo "$changed_files" | grep '^mlflow/server/js') ]] && echo "false" || echo "true")
r=$([[ -z $(echo "$changed_files" | grep '^mlflow/R/mlflow') ]] && echo "false" || echo "true")
echo "protos=$protos" >> $GITHUB_OUTPUT
echo "js=$js" >> $GITHUB_OUTPUT
echo "r=$r" >> $GITHUB_OUTPUT
# Merge the base branch (which is usually master) to apply formatting using the latest configurations.
- name: Merge base branch
run: |
git config user.name 'mlflow-automation'
git config user.email 'mlflow-automation@users.noreply.github.com'
git remote add base https://github.com/${{ needs.check-comment.outputs.base_repo }}.git
git fetch base ${{ needs.check-comment.outputs.base_ref }}
git merge base/${{ needs.check-comment.outputs.base_ref }}
- uses: ./.github/actions/setup-python
# ************************************************************************
# pre-commit
# ************************************************************************
- run: |
pip install -r requirements/lint-requirements.txt
# TODO: Use a precompiled binary once it's available: https://github.com/tamasfe/taplo/issues/542
cargo install taplo-cli@0.9.0 --locked
pre-commit install
pre-commit run --all-files --color=always || true
# ************************************************************************
# protos
# ************************************************************************
- if: steps.diff.outputs.protos == 'true'
env:
DOCKER_BUILDKIT: 1
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip -O /tmp/protoc.zip
sudo unzip /tmp/protoc.zip -d /tmp/protoc
sudo chmod -R 777 /tmp/protoc
echo "/tmp/protoc/bin" >> $GITHUB_PATH
pip install --upgrade pip
pip install -e .
- if: steps.diff.outputs.protos == 'true'
run: |
python ./dev/generate_protos.py
# ************************************************************************
# js
# ************************************************************************
- if: steps.diff.outputs.js == 'true'
uses: actions/setup-node@v3
with:
node-version: "16"
- if: steps.diff.outputs.js == 'true'
working-directory: mlflow/server/js
run: |
yarn install
- if: steps.diff.outputs.js == 'true'
working-directory: mlflow/server/js
run: |
yarn lint:fix
yarn prettier:fix
- if: steps.diff.outputs.js == 'true'
working-directory: mlflow/server/js
run: |
yarn i18n
# ************************************************************************
# R
# ************************************************************************
- if: steps.diff.outputs.r == 'true'
working-directory: docs
run: |
./build-rdoc.sh
# ************************************************************************
# Upload patch
# ************************************************************************
- name: Create patch
id: patch
run: |
git diff > ${{ github.run_id }}.diff
reformatted=$([[ -s ${{ github.run_id }}.diff ]] && echo "true" || echo "false")
echo "reformatted=$reformatted" >> $GITHUB_OUTPUT
- name: Upload patch
uses: actions/upload-artifact@v4
with:
name: ${{ github.run_id }}.diff
path: ${{ github.run_id }}.diff
push:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [check-comment, format]
if: ${{ needs.format.outputs.reformatted == 'true' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ needs.check-comment.outputs.repository }}
ref: ${{ needs.check-comment.outputs.head_ref }}
# Set fetch-depth to merge the base branch
fetch-depth: 300
token: ${{ secrets.MLFLOW_AUTOMATION_TOKEN }}
- name: Merge base branch
run: |
git config user.name 'mlflow-automation'
git config user.email 'mlflow-automation@users.noreply.github.com'
git remote add base https://github.com/${{ needs.check-comment.outputs.base_repo }}.git
git fetch base ${{ needs.check-comment.outputs.base_ref }}
git merge base/${{ needs.check-comment.outputs.base_ref }}
- name: Download patch
uses: actions/download-artifact@v4
with:
name: ${{ github.run_id }}.diff
path: /tmp
- name: Apply patch and push
run: |
git apply /tmp/${{ github.run_id }}.diff
git commit -sam "Autoformat: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
git push
update-status:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [check-comment, format, push]
if: always() && needs.check-comment.outputs.should_autoformat == 'true'
permissions:
statuses: write # autoformat.updateStatus
steps:
- uses: actions/checkout@v4
- name: Update status
uses: actions/github-script@v7
with:
script: |
const needs = ${{ toJson(needs) }};
const head_sha = '${{ needs.check-comment.outputs.head_sha }}'
const autoformat = require('./.github/workflows/autoformat.js');
await autoformat.updateStatus(context, github, head_sha, needs);