Source code for ax.runners.synthetic

#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

from collections.abc import Iterable
from typing import Any

from ax.core.base_trial import BaseTrial, TrialStatus
from ax.core.runner import Runner


[docs] class SyntheticRunner(Runner): """Class for synthetic or dummy runner. Currently acts as a shell runner, only creating a name. """ def __init__(self, dummy_metadata: str | None = None) -> None: self.dummy_metadata = dummy_metadata
[docs] def run(self, trial: BaseTrial) -> dict[str, Any]: deployed_name = ( trial.experiment.name + "_" + str(trial.index) if trial.experiment.has_name else str(trial.index) ) metadata = {"name": deployed_name} # Add dummy metadata if needed for testing if self.dummy_metadata: metadata["dummy_metadata"] = self.dummy_metadata return metadata
[docs] def poll_trial_status( self, trials: Iterable[BaseTrial] ) -> dict[TrialStatus, set[int]]: return {TrialStatus.COMPLETED: {t.index for t in trials}}
@property def run_metadata_report_keys(self) -> list[str]: return ["name"]