Skip to content

Commit

Permalink
update run_metadata in BaseTrial.run instead of overwriting (#2328)
Browse files Browse the repository at this point in the history
Summary:

see title. This enables storing metadata from multiple runners.

Reviewed By: Balandat

Differential Revision: D55767138
  • Loading branch information
sdaulton authored and facebook-github-bot committed Apr 8, 2024
1 parent adcf3a4 commit 1b11390
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ax/core/base_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def run(self) -> BaseTrial:
if self._runner is None:
raise ValueError("No runner set on trial or experiment.")

self._run_metadata = not_none(self._runner).run(self)
self.update_run_metadata(not_none(self._runner).run(self))

if not_none(self._runner).staging_required:
self.mark_staged()
Expand Down
15 changes: 15 additions & 0 deletions ax/core/tests/test_trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ def test_failed(self) -> None:
self.assertTrue(self.trial.did_not_complete)
self.assertEqual(self.trial.failed_reason, fail_reason)

def test_trial_run_does_not_overwrite_existing_metadata(self) -> None:
self.trial.runner = SyntheticRunner(dummy_metadata="y")
self.trial.update_run_metadata({"orig_metadata": "x"})
self.trial.run()
self.assertDictEqual(
self.trial.run_metadata,
{
"name": "test_0",
"orig_metadata": "x",
"dummy_metadata": "y",
# this is set in setUp
"foo": "bar",
},
)

def test_mark_as(self) -> None:
for terminal_status in (
TrialStatus.ABANDONED,
Expand Down

0 comments on commit 1b11390

Please sign in to comment.