def create_experiment( config: Optional[Dict[str, Any]], context_dir: str, command: Optional[List[str]], test_mode: bool = False, master_url: Optional[str] = None, ) -> Optional[int]: """Submit an experiment to the Determined master. Alternatively, use det.create() with a mode argument of "submit". Args: name (Optional[str]): The URL of the Determined master node. If None (default), then the master address will be inferred from the environment. Returns: The ID of the created experiment. """ if context_dir == "": raise errors.InvalidExperimentException( "Cannot specify the context directory to be empty.") context_path = pathlib.Path(context_dir) config = {**constants.DEFAULT_EXP_CFG, **(config or {})} config.setdefault("internal", {}) config["internal"]["native"] = { "command": set_command_default(context_path, command) } print("Creating an experiment with config: {}".format(config)) if master_url is None: master_url = util.get_default_master_address() exp_context = context.Context.from_local(context_path) # When a requested_user isn't specified to initialize_session(), the # authentication module will attempt to use the token store to grab the # current logged-in user. If there is no logged in user found, it will # default to constants.DEFAULT_DETERMINED_USER. auth.initialize_session(master_url, requested_user=None, try_reauth=True) if test_mode: exp_id = api.create_test_experiment(master_url, config, exp_context) else: exp_id = api.create_experiment(master_url, config, exp_context) print("Created experiment {}".format(exp_id)) return exp_id
def _submit_experiment( config: Optional[Dict[str, Any]], context_dir: str, command: Optional[List[str]], test: bool = False, master_url: Optional[str] = None, ) -> Optional[int]: if context_dir == "": raise errors.InvalidExperimentException( "Cannot specify the context directory to be empty.") context_path = pathlib.Path(context_dir) config = {**constants.DEFAULT_EXP_CFG, **(config or {})} config.setdefault("internal", {}) config["internal"]["native"] = { "command": _set_command_default(context_path, command) } logging.info(f"Creating an experiment with config: {config}") if master_url is None: master_url = util.get_default_master_address() exp_context = context.Context.from_local(context_path) # When a requested_user isn't specified to initialize_session(), the # authentication module will attempt to use the token store to grab the # current logged-in user. If there is no logged in user found, it will # default to constants.DEFAULT_DETERMINED_USER. auth.initialize_session(master_url, requested_user=None, try_reauth=True) if test: print(colored("Validating experiment configuration...", "yellow"), end="\r") api.create_experiment(master_url, config, exp_context, None, True) print( colored("Experiment configuration validation succeeded! 🎉", "green")) exp_id = api.create_test_experiment(master_url, config, exp_context) print(colored("Test experiment ID: {}".format(exp_id), "green")) api.follow_test_experiment_logs(master_url, exp_id) else: exp_id = api.create_experiment(master_url, config, exp_context) logging.info(f"Created experiment {exp_id}") api.follow_experiment_logs(master_url, exp_id) return exp_id
print(tabulate.tabulate(values, headers, tablefmt="presto"), flush=False) # fmt: off args_description = [ Arg("-u", "--user", help="run as the given user", metavar="username", default=None), Arg("-m", "--master", help="master address", metavar="address", default=get_default_master_address()), Arg("-v", "--version", action="version", help="print CLI version and exit", version="%(prog)s {}".format(determined_cli.__version__)), experiment.args_description, checkpoint.args_description, Cmd( "task", None, "manage tasks (commands, experiments, notebooks, shells, tensorboards)", [ Cmd("list", list_tasks, "list tasks in cluster", [ Arg("--csv", action="store_true", help="print as CSV"),
def __init__(self, master: Optional[str], user: Optional[str]): self._master = master or util.get_default_master_address() self._user = user auth.initialize_session(self._master, self._user, try_reauth=True)