Пример #1
0
    def runner_to_sqa(self, runner: Runner) -> SQARunner:
        """Convert Ax Runner to SQLAlchemy."""
        runner_type = RUNNER_REGISTRY.get(type(runner))
        if runner_type is None:
            raise SQAEncodeError(
                "Cannot encode runner to SQLAlchemy because runner's "
                "subclass is invalid.")  # pragma: no cover
        properties = get_object_properties(object=runner)

        # pyre-fixme: Expected `Base` for 1st...t `typing.Type[Runner]`.
        runner_class: SQARunner = self.config.class_to_sqa_class[Runner]
        # pyre-fixme[29]: `SQARunner` is not a function.
        return runner_class(runner_type=runner_type, properties=properties)
Пример #2
0
    def runner_to_sqa(self,
                      runner: Runner,
                      trial_type: Optional[str] = None) -> SQARunner:
        """Convert Ax Runner to SQLAlchemy."""
        runner_class = type(runner)
        runner_type = RUNNER_REGISTRY.get(runner_class)
        if runner_type is None:
            raise SQAEncodeError(
                "Cannot encode runner to SQLAlchemy because runner's "
                f"subclass ({runner_class}) is missing from the registry. "
                "The runner registry currently contains the following: "
                f"{','.join(map(str, RUNNER_REGISTRY.keys()))}"
            )  # pragma: no cover
        properties = runner_class.serialize_init_args(runner=runner)

        # pyre-fixme: Expected `Base` for 1st...t `typing.Type[Runner]`.
        runner_class: SQARunner = self.config.class_to_sqa_class[Runner]
        # pyre-fixme[29]: `SQARunner` is not a function.
        return runner_class(runner_type=runner_type,
                            properties=properties,
                            trial_type=trial_type)