def testExperimentTagTruncation(self): ray.init() def train(config, reporter): reporter(timesteps_total=1) trial_executor = RayTrialExecutor() register_trainable("f1", train) experiments = { "foo": { "run": "f1", "config": { "a" * 50: lambda spec: 5.0 / 7, "b" * 50: lambda spec: "long" * 40 }, } } for name, spec in experiments.items(): trial_generator = BasicVariantGenerator() trial_generator.add_configurations({name: spec}) for trial in trial_generator.next_trials(): trial_executor.start_trial(trial) self.assertLessEqual(len(trial.logdir), 200) trial_executor.stop_trial(trial)
def _add_trials(self, name, spec): """Add trial by invoking TrialRunner.""" resource = {} resource["trials"] = [] trial_generator = BasicVariantGenerator() trial_generator.add_configurations({name: spec}) for trial in trial_generator.next_trials(): runner.add_trial(trial) resource["trials"].append(self._trial_info(trial)) return resource
def execute_command(self, args): def get_trial(): trial = runner.get_trial(args["trial_id"]) if trial is None: error = "Trial ({}) not found.".format(args["trial_id"]) raise TuneManagerError(error) else: return trial command = args["command"] response = {} try: if command == TuneClient.GET_LIST: response["trials"] = [ self.trial_info(t) for t in runner.get_trials() ] elif command == TuneClient.GET_TRIAL: trial = get_trial() response["trial_info"] = self.trial_info(trial) elif command == TuneClient.STOP: trial = get_trial() runner.request_stop_trial(trial) elif command == TuneClient.ADD: name = args["name"] spec = args["spec"] trial_generator = BasicVariantGenerator() trial_generator.add_configurations({name: spec}) for trial in trial_generator.next_trials(): runner.add_trial(trial) else: raise TuneManagerError("Unknown command.") status = True except TuneError as e: status = False response["message"] = str(e) return status, response
def generate_trials(self, spec, name): suggester = BasicVariantGenerator() suggester.add_configurations({name: spec}) return suggester.next_trials()
def generate_trials(self, spec, name): suggester = BasicVariantGenerator({name: spec}) return suggester.next_trials()