コード例 #1
0
ファイル: _native.py プロジェクト: AustinInBoston/determined
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
コード例 #2
0
ファイル: _native.py プロジェクト: takabayashi/determined
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