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
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
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)