コード例 #1
0
ファイル: _native.py プロジェクト: wbwatkinson/determined
def _submit_experiment(
    config: Optional[Dict[str, Any]],
    context_dir: str,
    command: Optional[List[str]],
    test: bool = False,
    master_url: Optional[str] = None,
) -> 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:
        return api.create_test_experiment_and_follow_logs(master_url, config, exp_context)
    else:
        return api.create_experiment_and_follow_logs(master_url, config, exp_context)
コード例 #2
0
    def __init__(
        self,
        master: Optional[str] = None,
        user: Optional[str] = None,
        password: Optional[str] = None,
        cert_path: Optional[str] = None,
        cert_name: Optional[str] = None,
        noverify: bool = False,
    ):
        master = master or util.get_default_master_address()

        cert = certs.default_load(
            master_url=master,
            explicit_path=cert_path,
            explicit_cert_name=cert_name,
            explicit_noverify=noverify,
        )

        # TODO: This should probably be try_reauth=False, but it appears that would break the case
        # where the default credentials are available from the master and could be discovered by
        # a REST API call against the master.
        auth = authentication.Authentication(master,
                                             user,
                                             password,
                                             try_reauth=True,
                                             cert=cert)

        self._session = session.Session(master, user, auth, cert)
コード例 #3
0
 def __init__(
     self,
     master: Optional[str],
     user: Optional[str],
     auth: Optional[authentication.Authentication],
     cert: Optional[certs.Cert],
 ) -> None:
     self._master = master or util.get_default_master_address()
     self._user = user
     self._auth = auth
     self._cert = cert
コード例 #4
0
 def __init__(
     self,
     master: Optional[str],
     user: Optional[str],
     auth: Optional[authentication.Authentication],
     cert: Optional[certs.Cert],
     max_retries: Optional[urllib3.util.retry.Retry] = None,
 ) -> None:
     self._master = master or util.get_default_master_address()
     self._user = user
     self._auth = auth
     self._cert = cert
     self._max_retries = max_retries
コード例 #5
0
ファイル: authentication.py プロジェクト: shiyuann/determined
    def __init__(
        self,
        master_address: Optional[str] = None,
        requested_user: Optional[str] = None,
        password: Optional[str] = None,
        try_reauth: bool = False,
        cert: Optional[certs.Cert] = None,
    ) -> None:
        self.master_address = master_address or util.get_default_master_address(
        )
        self.token_store = TokenStore(self.master_address)

        self.session = self._init_session(requested_user, password, try_reauth,
                                          cert)
コード例 #6
0
ファイル: cli.py プロジェクト: wbwatkinson/determined
    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.__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"),
コード例 #7
0
ファイル: session.py プロジェクト: wbwatkinson/determined
 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)
コード例 #8
0
def setup_session(args: Namespace) -> session.Session:
    master_url = args.master or util.get_default_master_address()
    cert = certs.default_load(master_url)

    return session.Session(master_url, args.user, authentication.cli_auth,
                           cert)