Skip to content

fix: log multirun failures to job files#3227

Merged
omry merged 2 commits into
facebookresearch:mainfrom
suzunn:fix-multirun-job-error-logs
Jul 22, 2026
Merged

fix: log multirun failures to job files#3227
omry merged 2 commits into
facebookresearch:mainfrom
suzunn:fix-multirun-job-error-logs

Conversation

@suzunn

@suzunn suzunn commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Failed jobs in a basic multirun sweep were captured in JobReturn without being written while the job logging configuration was active. This left per-job log files empty and made failures other than the first one difficult to diagnose.

Solution

I added a focused file-handler path that records the active exception in the job log without emitting another traceback to the console. I also extended the partial-failure regression test and added a bugfix news fragment.

Fixes #3215

Testing

  • .venv/Scripts/python -m pytest tests/test_basic_sweeper.py tests/test_basic_launcher.py tests/test_callbacks.py -q (42 passed)
  • Black, isort, Flake8, and Pyrefly checks for the touched Python files
  • git diff --check

@meta-cla

meta-cla Bot commented Jun 21, 2026

Copy link
Copy Markdown

Hi @suzunn!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@omry
omry requested a review from Copilot June 21, 2026 11:05
@omry

omry commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks. overall looks good. I'll take a closer look when it hits my queue.
In the mean time CLA please.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR ensures that exceptions raised during a basic multirun sweep are logged while the per-job logging configuration is still active, so each failed job’s *.log file contains actionable failure details.

Changes:

  • Add a small internal helper in run_job() to emit the active exception to file handlers only (avoiding extra console tracebacks).
  • Extend the partial-failure multirun regression test to assert the failed job log contains the exception.
  • Add a bugfix news fragment for the user-visible behavior change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
hydra/core/utils.py Logs job exceptions to per-job file handlers inside the job’s logging context before storing the exception in JobReturn.
tests/test_basic_sweeper.py Extends the multirun partial-failure test to validate per-job log content for the failing job.
news/3215.bugfix Documents the bugfix in release notes.

@omry

omry commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks, this is in the right direction.
Please add coverage for the case where multiple jobs fail in the same multirun, and verify that each failed job’s own log file contains the traceback. The original issue is not only that one failed job lacks a log, but also that failures are captured and surfaced later, making later failed jobs hard to diagnose.

@omry omry added the awaiting_response Awaiting response label Jun 21, 2026
@omry

omry commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Also, please accept the CLA, I cannot accept the change with it.

@omry

omry commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Hi, are you planning to finish this?

@suzunn
suzunn force-pushed the fix-multirun-job-error-logs branch from dbaeb70 to 757e2a5 Compare July 21, 2026 16:17
@suzunn

suzunn commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Yes — sorry for the delay. Just pushed an update:

  • Rebased onto latest main (resolved the conflict with the new test_glob_uses_primary_config_searchpath test).
  • Added test_multiple_failures_log_to_own_job_files: a multirun where two jobs fail with different errors (ZeroDivisionError and TypeError) and one succeeds. It verifies each failed job's own log file contains its traceback, and the successful job's log does not.

Both tests pass locally. Will sort out the CLA next.

@suzunn
suzunn force-pushed the fix-multirun-job-error-logs branch from 757e2a5 to c8cf4a4 Compare July 21, 2026 17:53
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 21, 2026
@omry

omry commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks for following up and adding the multiple-failure coverage. This now covers the case I was concerned about. The change looks good.

@omry omry removed the awaiting_response Awaiting response label Jul 22, 2026
@omry
omry merged commit 1193682 into facebookresearch:main Jul 22, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log multirun job failures in per-job logs

3 participants