Skip to content

air run: catch report_to set through a dict in the Trainer MLflow check - #8283

Open
anshul0713 wants to merge 1 commit into
mainfrom
anshul0713/air-run-mlflow-report-to-dict
Open

anshul0713 wants to merge 1 commit into
mainfrom
anshul0713/air-run-mlflow-report-to-dict

Conversation

@anshul0713

Copy link
Copy Markdown
Contributor

Changes

The Trainer MLflow check from #8234 now also finds report_to when it's set through a dict:

  • A dict item: extra["report_to"] = ["mlflow"].
  • A dict literal entry: {"report_to": "mlflow"}, typically passed to TrainingArguments(**kw).

Before, both patterns needed report_to=. A comparison such as cfg.report_to == "mlflow" still doesn't count.

No changelog fragment: #8234's entry hasn't been released and still describes the check.

Why

In an agent trial on the CLI from main (feed854), the HF Trainer fine-tune still crashed with Run with UUID ... is already active. The script called mlflow.start_run(run_id=mlflow_run_id) and then trainer.train(), but built its training arguments as a dict with extra["report_to"] = ["mlflow"]. --dry-run printed no warning. The crash cost one GPU queue and setup cycle (about 4.5 minutes) and a rewrite of the logging.

I ran the check on that trial's original train.py: it warns with this change and stays silent on main.

Tests

  • New TestTrainerMLflowRunWarning cases:
    • Warns: a dict item, and a dict literal entry.
    • Quiet: report_to == "mlflow", and extra["report_to"] = [].
  • go test ./cmd/air/... and go test ./acceptance -run TestAccept/air pass.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
@anshul0713
anshul0713 requested review from a team as code owners December 2, 2026 07:43
@anshul0713
anshul0713 enabled auto-merge December 2, 2026 07:44
@github-actions github-actions Bot added the AIR Databricks AI Runtime CLI label Dec 2, 2026

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at ea22234. Each finding was verified against the code.

Not ready yet: 1 blocking issue(s), tagged [blocking].

This PR extends the Trainer MLflow check so it also catches report_to set through a dict item (extra["report_to"] = ...) or a dict literal entry ("report_to": ...), which is the case that crashed the agent trial. The dict-item part works. Letting : follow a bare report_to goes further than needed, though, and it regresses the check in both directions. On transformers 4.x AI environments, lines like if args.report_to: now turn off the default-reporting warning. Annotated dataclass fields can now set off a false warning. Accepting : only after a closing quote fixes both, and each case needs a test.

Comment thread cmd/air/mlflowcheck.go
// report_to set as a keyword argument (report_to=...), a dict item
// (args["report_to"] = ...) or a dict literal entry ("report_to": ...), but
// not compared with ==.
reportToPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=]|$)`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] Because [=:]([^=]|$) accepts a colon right after a bare report_to, lines that only read the value now count as setting it. Examples are if args.report_to:, print("report_to:", args.report_to) and report_to: list[str]. On databricks_ai_v5, a script with mlflow.start_run(run_id=...), TrainingArguments(output_dir='o'), one of those lines and trainer.train() warned at base. Now trainerMLflowConflict (line 91) skips the default branch and the check stays silent, so the job still crashes with Run ... is already active. Could the colon form require a closing quote, as in ["']report_to["'][[:space:]]*:, while the dict-item form keeps \]?[[:space:]]*=? A v5 default-path test containing if args.report_to: would pin this.

Comment thread cmd/air/mlflowcheck.go
// (args["report_to"] = ...) or a dict literal entry ("report_to": ...), but
// not compared with ==.
reportToPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=]|$)`
trainerReportsMLflowPattern = `^[^#]*report_to["']?[[:space:]]*\]?[[:space:]]*[=:]([^=][^#]*)?(mlflow|["']all["'])`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] The colon match causes the opposite problem in trainerReportsMLflowPattern. A common HF argument dataclass line is report_to: str = field(default="none", metadata={"help": "... mlflow, wandb"}). It now matches, because [^=][^#]* runs on to the mlflow inside the help string. Any script that also passes a run ID to start_run and calls .train() gets a warning even though reporting is "none", and at base it didn't. The same quoted-key restriction as on line 30 fixes this. Can you add this annotated line as a no-warning case?

@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: ea22234

Run: 46835162060

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 60 6 1:32
💚​ aws-windows-latest-4core-16gb 1 60 6 2:36
💚​ azure linux-2core-8gb 1 60 6 1:34
💚​ azure-windows-latest-4core-16gb 1 60 6 3:09
💚​ gcp linux-2core-8gb 1 60 6 1:40
💚​ gcp-windows-latest-4core-16gb 1 60 6 3:11
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:10 gcp-windows-latest-4core-16gb TestAccept
3:07 azure-windows-latest-4core-16gb TestAccept
2:35 aws-windows-latest-4core-16gb TestAccept

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIR Databricks AI Runtime CLI

2 participants