Exemplo n.º 1
0
 def go(url_str: str, registry_url: str = "https://registry-dev.neu.ro") -> Client:
     url = URL(url_str)
     cluster_config = _ClusterConfig(
         registry_url=URL(registry_url),
         monitoring_url=(url / "jobs"),
         storage_url=(url / "storage"),
         users_url=url,
         resource_presets={
             "gpu-small": Preset(
                 cpu=7, memory_mb=30 * 1024, gpu=1, gpu_model="nvidia-tesla-k80"
             ),
             "gpu-large": Preset(
                 cpu=7, memory_mb=60 * 1024, gpu=1, gpu_model="nvidia-tesla-v100"
             ),
             "cpu-small": Preset(cpu=7, memory_mb=2 * 1024),
             "cpu-large": Preset(cpu=7, memory_mb=14 * 1024),
         },
     )
     config = _Config(
         auth_config=auth_config,
         auth_token=_AuthToken.create_non_expiring(token),
         pypi=_PyPIVersion.create_uninitialized(),
         url=URL(url),
         cluster_config=cluster_config,
         cookie_session=_CookieSession.create_uninitialized(),
         version=neuromation.__version__,
     )
     connector = aiohttp.TCPConnector()
     return Client._create(connector, config)
Exemplo n.º 2
0
def nmrc_path(tmp_path: Path, token: str, auth_config: _AuthConfig) -> Path:
    nmrc_path = tmp_path / "conftest.nmrc"
    cluster_config = Cluster(
        registry_url=URL("https://registry-dev.neu.ro"),
        storage_url=URL("https://storage-dev.neu.ro"),
        users_url=URL("https://users-dev.neu.ro"),
        monitoring_url=URL("https://monitoring-dev.neu.ro"),
        presets={
            "gpu-small":
            Preset(cpu=7,
                   memory_mb=30 * 1024,
                   gpu=1,
                   gpu_model="nvidia-tesla-k80"),
            "gpu-large":
            Preset(cpu=7,
                   memory_mb=60 * 1024,
                   gpu=1,
                   gpu_model="nvidia-tesla-v100"),
            "cpu-small":
            Preset(cpu=7, memory_mb=2 * 1024),
            "cpu-large":
            Preset(cpu=7, memory_mb=14 * 1024),
        },
        name="default",
    )
    config = _ConfigData(
        auth_config=auth_config,
        auth_token=_AuthToken.create_non_expiring(token),
        url=URL("https://dev.neu.ro/api/v1"),
        version=neuromation.__version__,
        cluster_name="default",
        clusters={cluster_config.name: cluster_config},
    )
    Factory(nmrc_path)._save(config)
    return nmrc_path
Exemplo n.º 3
0
 async def _refresh_token_mock(
     connector: aiohttp.BaseConnector,
     config: _AuthConfig,
     token: _AuthToken,
     timeout: aiohttp.ClientTimeout,
 ) -> _AuthToken:
     return _AuthToken.create_non_expiring(new_token)
Exemplo n.º 4
0
def nmrc_path(tmp_path: Path, token: str, auth_config: _AuthConfig) -> Path:
    nmrc_path = tmp_path / "conftest.nmrc"
    cluster_config = _ClusterConfig.create(
        registry_url=URL("https://registry-dev.neu.ro"),
        storage_url=URL("https://storage-dev.neu.ro"),
        users_url=URL("https://users-dev.neu.ro"),
        monitoring_url=URL("https://monitoring-dev.neu.ro"),
        resource_presets={
            "gpu-small":
            Preset(cpu=7,
                   memory_mb=30 * 1024,
                   gpu=1,
                   gpu_model="nvidia-tesla-k80"),
            "gpu-large":
            Preset(cpu=7,
                   memory_mb=60 * 1024,
                   gpu=1,
                   gpu_model="nvidia-tesla-v100"),
            "cpu-small":
            Preset(cpu=7, memory_mb=2 * 1024),
            "cpu-large":
            Preset(cpu=7, memory_mb=14 * 1024),
        },
    )
    config = _Config(
        auth_config=auth_config,
        auth_token=_AuthToken.create_non_expiring(token),
        cluster_config=cluster_config,
        pypi=_PyPIVersion.create_uninitialized(),
        url=URL("https://dev.neu.ro/api/v1"),
        cookie_session=_CookieSession.create_uninitialized(),
        version=neuromation.__version__,
    )
    Factory(nmrc_path)._save(config)
    return nmrc_path
Exemplo n.º 5
0
def _create_config(nmrc_path: Path, token: str, auth_config: _AuthConfig,
                   cluster_config: Cluster) -> str:
    config = _ConfigData(
        auth_config=auth_config,
        auth_token=_AuthToken.create_non_expiring(token),
        url=URL("https://dev.neu.ro/api/v1"),
        version=neuromation.__version__,
        cluster_name=cluster_config.name,
        clusters={cluster_config.name: cluster_config},
    )
    Factory(nmrc_path)._save(config)
    assert nmrc_path.exists()
    return token
Exemplo n.º 6
0
 def go(url_str: str,
        *,
        registry_url: str = "https://registry-dev.neu.ro",
        trace_id: str = "bd7a977555f6b982",
        clusters: Optional[Dict[str, Cluster]] = None,
        token_url: Optional[URL] = None) -> Client:
     url = URL(url_str)
     if clusters is None:
         cluster_config = Cluster(
             registry_url=URL(registry_url),
             monitoring_url=(url / "jobs"),
             storage_url=(url / "storage"),
             users_url=url,
             presets={
                 "gpu-small":
                 Preset(cpu=7,
                        memory_mb=30 * 1024,
                        gpu=1,
                        gpu_model="nvidia-tesla-k80"),
                 "gpu-large":
                 Preset(cpu=7,
                        memory_mb=60 * 1024,
                        gpu=1,
                        gpu_model="nvidia-tesla-v100"),
                 "cpu-small":
                 Preset(cpu=7, memory_mb=2 * 1024),
                 "cpu-large":
                 Preset(cpu=7, memory_mb=14 * 1024),
             },
             name="default",
         )
         clusters = {cluster_config.name: cluster_config}
     if token_url is not None:
         real_auth_config = replace(auth_config, token_url=token_url)
     else:
         real_auth_config = auth_config
     config = _ConfigData(
         auth_config=real_auth_config,
         auth_token=_AuthToken.create_non_expiring(token),
         url=URL(url),
         version=neuromation.__version__,
         cluster_name=next(iter(clusters)),
         clusters=clusters,
     )
     config_dir = tmp_path / ".neuro"
     _save(config, config_dir)
     session = aiohttp.ClientSession(trace_configs=[_make_trace_config()])
     return Client._create(session, config_dir, trace_id)
Exemplo n.º 7
0
def _create_config(
    nmrc_path: Path,
    token: str,
    auth_config: _AuthConfig,
    cluster_config: _ClusterConfig,
) -> str:
    config = _Config(
        auth_config=auth_config,
        auth_token=_AuthToken.create_non_expiring(token),
        cluster_config=cluster_config,
        pypi=_PyPIVersion.create_uninitialized(),
        url=URL("https://dev.neu.ro/api/v1"),
        cookie_session=_CookieSession.create_uninitialized(),
        version=neuromation.__version__,
    )
    Factory(nmrc_path)._save(config)
    assert nmrc_path.exists()
    return token