Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
nni | nni-master/test/ut/tools/nnictl/test_nnictl_utils.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
sys.path.append(os.path.dirname(__file__))
from mock.restful_server import init_response
from mock.experiment import create_mock_experiment, stop_mock_experiment, generate_args_parser, generate_args
from nni.tools.nnictl.nn... | 2,235 | 29.630137 | 109 | py |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/custom-tuner-1.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
# error: no className
tuner:
codeDir: ./
classFileName: mytuner.py
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ./
c... | 435 | 15.769231 | 36 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/custom-tuner-2.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
# error: builtinTunerName conflicts with custom tuner settings
tuner:
codeDir: ./
classFileName: mytuner.py
className: MyTuner
builtinTunerName: Random
assessor:
builtinA... | 524 | 17.75 | 62 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/mytuner.py | from nni import Tuner
class MyTuner(Tuner):
def __init__(self):
pass
| 82 | 12.833333 | 23 | py |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/no-tuner.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
# error: no tuner or advisor
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ./
command: python3 main.py
useAnnotation: fal... | 392 | 16.863636 | 36 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/searchspace-path.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
# error: searchSpacePath can not be found
searchSpacePath: ./wrong_search_space.json
tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
code... | 474 | 18 | 54 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/tuner-wrong-key.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
tuner:
# error: wrong key
wrongTunerKey: abc
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ./
command: python3 main.p... | 413 | 15.56 | 36 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/wrong-class-args.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
# wrong class args, should be detected by assessor validator
optimize_mode: aaaaaa... | 460 | 18.208333 | 64 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/invalid/wrong-training-service.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ./
command: python3 main.py
useAnnotation... | 437 | 17.25 | 36 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/test_files/test_yaml.yml | field: test
| 12 | 5.5 | 11 | yml |
nni | nni-master/test/ut/tools/nnictl/config_files/valid/main.py | print('my trial')
| 18 | 8.5 | 17 | py |
nni | nni-master/test/ut/tools/nnictl/config_files/valid/test.yml | authorName: nni
experimentName: default_test
maxExecDuration: 15m
maxTrialNum: 2
trialConcurrency: 2
searchSpacePath: ./search_space.json
tuner:
builtinTunerName: Random
assessor:
builtinAssessorName: Medianstop
classArgs:
optimize_mode: maximize
trial:
codeDir: ./
command: python3 main.py
useAnnotation... | 397 | 16.304348 | 36 | yml |
nni | nni-master/test/ut/tools/nnictl/mock/__init__.py | 0 | 0 | 0 | py | |
nni | nni-master/test/ut/tools/nnictl/mock/experiment.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import argparse
from pathlib import Path
from subprocess import Popen, PIPE, STDOUT
from nni.tools.nnictl.config_utils import Experiments
from nni.tools.nnictl.common_utils import print_green
from nni.tools.nnictl.command_utils import kill_comman... | 1,797 | 39.863636 | 97 | py |
nni | nni-master/test/ut/tools/nnictl/mock/restful_server.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import responses
def mock_check_status():
responses.add(
responses.GET,
"http://localhost:8080/api/v1/nni/check-status",
json={"status":"RUNNING","errors":[]},
status=200
)
def mock_version():
respons... | 7,434 | 38.759358 | 120 | py |
nni | nni-master/test/ut/tools/trial_tool/__init__.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
os.environ['NNI_PLATFORM'] = 'unittest'
os.environ['NNI_TRIAL_JOB_ID'] = 'test_trial_job_id'
os.environ["NNI_OUTPUT_DIR"] = "./unittest"
os.environ["NNI_SYS_DIR"] = "./unittest"
os.environ["NNI_EXP_ID"] = "test_exp_id"
os.environ["MULT... | 339 | 27.333333 | 52 | py |
nni | nni-master/test/ut/tools/trial_tool/test_file_channel.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import json
import os
import random
import shutil
import string
import sys
import time
import unittest
from argparse import Namespace
from datetime import datetime
from nni.tools.trial_tool.base_channel import CommandType
from nni.tools.trial_to... | 4,567 | 33.089552 | 115 | py |
nni | nni-master/test/vso_tools/_common.py | from pathlib import Path
import os
import subprocess
import sys
nni_root = str(Path(__file__).parents[2])
def build_wheel():
python = sys.executable
version = sys.argv[1]
os_spec = {
'linux': 'manylinux1_x86_64',
'darwin': 'macosx_10_9_x86_64',
'win32': 'win_amd64'
}[sys.platfo... | 1,085 | 27.578947 | 85 | py |
nni | nni-master/test/vso_tools/build_wheel.py | from _common import build_wheel
build_wheel()
| 47 | 11 | 31 | py |
nni | nni-master/test/vso_tools/copyright_check.py | import os
import sys
invalid_files = []
copyright_headers = [
'# Copyright (c) Microsoft Corporation.\n# Licensed under the MIT license.',
'# Copyright (c) Microsoft Corporation. All rights reserved.\n#\n# MIT License',
]
whitelist = [
'nni/version.py',
'nni/algorithms/hpo/bohb_advisor/config_generat... | 1,187 | 30.263158 | 86 | py |
nni | nni-master/test/vso_tools/fix_shebang.py | """
Change "#!" line to "#!/usr/bin/env python" for all files in directory sys.argv[1].
"""
from pathlib import Path
import sys
if sys.platform == 'win32':
exit()
for file in Path(sys.argv[1]).iterdir():
try:
text = file.read_text()
assert text.startswith('#!'), 'no shebang'
shebang, ... | 535 | 25.8 | 83 | py |
nni | nni-master/test/vso_tools/generate_nni_version.py | from datetime import datetime
from _common import set_variable
time = datetime.now().strftime('%Y%m%d%H%M%S')
set_variable('NNI_RELEASE', '999.' + time)
| 155 | 21.285714 | 46 | py |
nni | nni-master/test/vso_tools/install_nni.py | import sys
from _common import build_wheel, run_command
if len(sys.argv) <= 2:
extra_dep = ''
else:
extra_dep = f'[{sys.argv[2]}]'
wheel = build_wheel()
run_command(f'{sys.executable} -m pip install {wheel}{extra_dep}')
| 231 | 18.333333 | 66 | py |
nni | nni-master/test/vso_tools/interim_patch.py | # fix setuptools.distutils import in torch
import os
from torch import utils
file_name = os.path.join(os.path.dirname(utils.__file__), 'tensorboard/__init__.py')
dummy_file_name = os.path.join(os.path.dirname(file_name), '__dummy_init__.py')
if os.path.exists(file_name):
with open(file_name, 'r') as fr, open(dummy... | 807 | 43.888889 | 141 | py |
nni | nni-master/test/vso_tools/pack_dependencies.py | """
Create a zip archive named sys.argv[1], containing python-packages and node_modules.
Use unpack_dependencies.py to extract the archive.
Example usage:
python test/vso_tools/pack_dependencies.py dependencies.zip
"""
import json
import os
from pathlib import Path
import shutil
import site
import sys
from zipfi... | 1,424 | 30.666667 | 94 | py |
nni | nni-master/test/vso_tools/pack_testdata.py | """
Hosting some commonly used datasets in tests on NNI blob.
If --sas-token is set, the script will attempt to upload archives.
See YAMLs in pipelines/ folder for instructions on how to generate an SAS token.
"""
import argparse
import glob
import os
import random
import shutil
import subprocess
import warnings
from... | 3,572 | 32.083333 | 88 | py |
nni | nni-master/test/vso_tools/pip_use_prefix.py | """
0. Create a directory whose name is sys.argv[1].
1. Create a "pip-install" script that uses this directory as prefix.
2. Set PYTHONPATH to use this prefix, via VSO variable.
"""
import os
from pathlib import Path
import sys
import typing
prefix = Path(sys.argv[1])
prefix.mkdir(parents=True, exist_ok=True)
pref... | 1,297 | 32.282051 | 110 | py |
nni | nni-master/test/vso_tools/ssl_patch.py | """Fix the issue: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129).
I think it's caused by some incorrect certificates injected by WinRM,
but I guess disabling the check is a simpler way.
"""
import ssl
from pathlib import Path
ssl_file_path = ssl.__fil... | 740 | 38 | 131 | py |
nni | nni-master/test/vso_tools/start_docker.py | """
Build docker image, start container, then set its SSH service port to VSO variable "docker_port".
Usage:
python start_docker.py <nni-version> <container-name> <password-in-docker>
"""
import argparse
import os
import random
import socket
from _common import build_wheel, run_command, set_variable
# find idle... | 1,939 | 38.591837 | 147 | py |
nni | nni-master/test/vso_tools/stop_docker.py | import sys
from _common import run_command
name = sys.argv[1]
run_command(f'docker container stop {name}')
run_command(f'docker container rm {name}')
| 152 | 18.125 | 44 | py |
nni | nni-master/test/vso_tools/trigger_import.py | """Trigger import of some modules to write some caches,
so that static analysis (e.g., pyright) can know the type."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
import nni
import nni.nas.nn.pytorch
| 249 | 21.727273 | 69 | py |
nni | nni-master/test/vso_tools/unpack_dependencies.py | """
Extract archive sys.argv[1] created by pack_dependencies.py.
"""
from __future__ import annotations
import json
import os
from pathlib import Path
import shutil
import site
import sys
from zipfile import ZipFile
def main() -> None:
if sys.platform == 'win32':
# Strangely user site is not enabled on W... | 1,711 | 29.035088 | 81 | py |
nni | nni-master/test/vso_tools/unpack_testdata.py | """
Unpacked the downloaded zipped datasets.
Opposite to ``pack_testdata.py``.
"""
import argparse
import glob
import os
import shutil
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--data-dir', default='./data', type=str)
args = parser.parse_args()
for zipfile in glob.glob(os.... | 500 | 19.04 | 67 | py |
nni | nni-master/test/vso_tools/build_vm/change_ssh_port.sh | #!/bin/bash
# Microsoft internal subscription has a firewall (network security group),
# to deny traffic from low ports (maybe less than 10000).
# We have to change the port at VM provision, so that the VM can be connected and build scripts can run.
CONFIG_PATH=/etc/ssh/sshd_config
sudo sed -i -e "s/#Port 22/Port 100... | 364 | 35.5 | 104 | sh |
nni | nni-master/test/vso_tools/build_vm/disable_apt_daily.sh | #!/bin/bash
# Disable the periodical apt-get upgrade, as it will break the GPU driver.
sed -i -e "s/Update-Package-Lists \"1\"/Update-Package-Lists \"0\"/g" /etc/apt/apt.conf.d/10periodic
sed -i -e "s/Update-Package-Lists \"1\"/Update-Package-Lists \"0\"/g" /etc/apt/apt.conf.d/20auto-upgrades
sed -i -e "s/Unattended-... | 1,891 | 45.146341 | 107 | sh |
nni | nni-master/test/vso_tools/build_vm/packer_build_windows.py | """Start and monitor a packer building process, and change WinRM ports at an appropriate time.
It first catches the name of the VM. It's a randomly generated string by packer.
It then catches the signal of packer's waiting for WinRM ready.
Actually, it will be ready soon, but packer is waiting on the wrong port.
Invok... | 3,509 | 37.152174 | 121 | py |
nni | nni-master/test/vso_tools/build_vm/setup_linux.sh | #!/bin/bash
set -e
set -x
# Build essentials are required.
# But clean first...
sudo apt-get clean
sudo rm -rvf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-get update
sudo apt-get install -y build-essential cmake uidmap
# Install azcli for A... | 3,524 | 44.779221 | 154 | sh |
nni | nni-master/ts/jupyter_extension/README.md | NNI is under development to support JupyterLab.
You can install this extension to preview the feature.
Currently you can view NNI web UI inside JupyterLab.
## Install ##
To preview the extension, you need to have `nni` and `jupyterlab` installed at first:
```
$ pip install nni jupyterlab
```
Then run following com... | 1,370 | 24.388889 | 120 | md |
nni | nni-master/ts/jupyter_extension/src/index.ts | import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { ICommandPalette, IFrame, Dialog, showDialog } from '@jupyterlab/apputils';
import { PageConfig } from '@jupyterlab/coreutils';
import { ILauncher } from '@jupyterlab/launcher';
import { LabIcon } from '@jupyterlab/ui-components';... | 2,661 | 33.128205 | 165 | ts |
nni | nni-master/ts/nni_manager/main.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Entry point of NNI manager.
*
* NNI manager is normally started by "nni/experiment/launcher.py".
* It requires command line arguments defined as NniManagerArgs in "common/globals/arguments.ts".
*
* Example usage:
*
* node... | 2,994 | 33.425287 | 98 | ts |
nni | nni-master/ts/nni_manager/common/datastore.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { ExperimentProfile, TrialJobStatistics } from './manager';
import { TrialJobDetail, TrialJobStatus } from './trainingService';
type TrialJobEvent = TrialJobStatus | 'USER_TO_CANCEL' | 'ADD_CUSTOMIZED' | 'ADD_HYPERPARAMETER' | 'IMPORT_D... | 4,012 | 37.586538 | 137 | ts |
nni | nni-master/ts/nni_manager/common/default_map.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export class DefaultMap<K, V> extends Map<K, V> {
private defaultFactory: () => V;
constructor(defaultFactory: () => V) {
super();
this.defaultFactory = defaultFactory;
}
public get(key: K): V {
const v... | 541 | 22.565217 | 51 | ts |
nni | nni-master/ts/nni_manager/common/deferred.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* An augmented version of ts-deferred.
*
* 1. Support `await deferred.promise` more than once.
*
* const deferred = new Deferred<void>;
* deferred.promise.then(() => { console.log('hello'); });
* deferre... | 3,660 | 33.866667 | 99 | ts |
nni | nni-master/ts/nni_manager/common/errors.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export namespace NNIErrorNames {
export const NOT_FOUND: string = 'NOT_FOUND';
export const INVALID_JOB_DETAIL: string = 'NO_VALID_JOB_DETAIL_FOUND';
export const RESOURCE_NOT_AVAILABLE: string = 'RESOURCE_NOT_AVAILABLE';
}
export ... | 1,412 | 31.113636 | 95 | ts |
nni | nni-master/ts/nni_manager/common/experimentConfig.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { KubeflowOperator, OperatorApiVersion } from '../training_service/kubernetes/kubeflow/kubeflowConfig'
export interface TrainingServiceConfig {
platform: string;
trialCommand: string;
trialCodeDirectory: string;
trialGpu... | 6,707 | 25.939759 | 109 | ts |
nni | nni-master/ts/nni_manager/common/experimentStartupInfo.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import globals from 'common/globals';
export class ExperimentStartupInfo {
public experimentId: string = globals.args.experimentId;
public newExperiment: boolean = (globals.args.action === 'create');
public basePort: number = globa... | 1,265 | 27.772727 | 71 | ts |
nni | nni-master/ts/nni_manager/common/ioc_shim.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'node:assert/strict';
type AbstractClass = {
name: string;
};
type Class = {
name: string;
new(): any;
};
class IocShimClass {
private singletons: Map<string, any> = new Map();
private snapshots: Map<st... | 1,450 | 24.910714 | 68 | ts |
nni | nni-master/ts/nni_manager/common/log.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Python-like logging interface.
*
* const logger = getLogger('moduleName');
* logger.info('hello', { to: 'world' });
*
* Outputs:
*
* [1970-01-01 00:00:00] INFO (moduleName) hello { to: 'world' }
*
* Loggers use... | 3,806 | 29.214286 | 109 | ts |
nni | nni-master/ts/nni_manager/common/manager.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { MetricDataRecord, MetricType, TrialJobInfo } from './datastore';
import { TrialJobStatus } from './trainingService';
import { ExperimentConfig } from './experimentConfig';
type ProfileUpdateType = 'TRIAL_CONCURRENCY' | 'MAX_EXEC_DURAT... | 2,894 | 42.208955 | 154 | ts |
nni | nni-master/ts/nni_manager/common/nniConfig.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import { runPythonScript } from './pythonScript';
export interface CustomEnvironmentServiceConfig {
name: string;
nodeModulePath: string;
nodeClassName... | 1,161 | 31.277778 | 119 | ts |
nni | nni-master/ts/nni_manager/common/pythonScript.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { spawn } from 'child_process';
import globals from './globals';
import { Logger, getLogger } from './log';
const logger: Logger = getLogger('pythonScript');
export function runPythonScript(script: string, logTag?: string): Promise<str... | 1,439 | 31 | 87 | ts |
nni | nni-master/ts/nni_manager/common/restServer.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import express from 'express';
import http from 'http';
import { Deferred } from 'ts-deferred';
import { getLogger, Logger } from './log';
import { getBasePort } from './experimentStartupInfo';
/**
* Abstraction ... | 3,345 | 32.128713 | 102 | ts |
nni | nni-master/ts/nni_manager/common/shellUtils.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import fsPromises from 'fs/promises';
// for readability
const singleQuote = "'";
const doubleQuote = '"';
const backtick = '`';
const backslash = '\\';
const doubleBacktick = '``';
const doubleBackslash = '\\\\';
const newline = '\n';
/**
*... | 2,707 | 35.594595 | 106 | ts |
nni | nni-master/ts/nni_manager/common/tarball.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Utility to create .tgz archive for trial code directory.
**/
import type { Stats } from 'node:fs';
import fs from 'node:fs/promises';
import path from 'node:path';
import ignore, { Ignore } from 'ignore';
import tar from 'tar';
impo... | 2,715 | 29.177778 | 117 | ts |
nni | nni-master/ts/nni_manager/common/tensorboardManager.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
interface TensorboardParams {
trials: string;
}
type TensorboardTaskStatus = 'RUNNING' | 'DOWNLOADING_DATA' | 'STOPPING' | 'STOPPED' | 'ERROR' | 'FAIL_DOWNLOAD_DATA';
interface TensorboardTaskInfo {
readonly id: string;
readonly s... | 1,214 | 36.96875 | 118 | ts |
nni | nni-master/ts/nni_manager/common/trainingService.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* define TrialJobStatus
*/
type TrialJobStatus = 'UNKNOWN' | 'WAITING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'USER_CANCELED' | 'SYS_CANCELED' | 'EARLY_STOPPED';
interface TrainingServiceMetadata {
readonly key: string;
readonly ... | 3,894 | 29.912698 | 134 | ts |
nni | nni-master/ts/nni_manager/common/training_service_v3.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* TODO
* This type is planned to be an interface.
* To minimize the change, it is currently identical to TrialJobMetric.data
**/
export type Metric = string;
/**
* TODO
* This type is planned to be an interface.
* To minimize ... | 4,265 | 31.318182 | 119 | ts |
nni | nni-master/ts/nni_manager/common/utils.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import { randomBytes } from 'crypto';
import cpp from 'child-process-promise';
import cp from 'child_process';
import { ChildProcess, spawn, StdioOptions } from 'child_process';
import dgram from 'dgram';
import fs ... | 11,072 | 28.062992 | 171 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/http.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* HTTP based command channel. Inefficient but simple.
*
* Client to server command is implemented by naive PUT request.
*
* Server to client command is implemented by polling with GET requests.
* The client should repeat GET reque... | 5,364 | 32.955696 | 109 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/interface.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Common interface of command channels.
*
* A command channel is a duplex connection which supports sending and receiving JSON commands.
*
* Typically a command channel implementation consists of a server and a client.
*
* The se... | 5,456 | 33.320755 | 120 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/rpc_util.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Add RPC capability to WebSocket command channel.
*
* Suppose you want to run `new Foo(1, 2).on('event', localListener)` on a remote worker,
* use the following steps:
*
* 0. Create RPC helper on each side of the channel:
*
* ... | 9,650 | 35.011194 | 126 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/websocket/channel.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* WebSocket command channel.
*
* A WsChannel operates on one WebSocket connection at a time.
* But when the network is unstable, it may close the underlying connection and create a new one.
* This is generally transparent to the us... | 7,968 | 31.004016 | 104 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/websocket/client.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* WebSocket command channel client.
**/
import { setTimeout } from 'node:timers/promises';
import { WebSocket } from 'ws';
import { Logger, getLogger } from 'common/log';
import { WsChannel } from './channel';
// need large message b... | 2,165 | 27.5 | 95 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/websocket/connection.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Internal helper class which handles one WebSocket connection.
**/
import { EventEmitter } from 'node:events';
import util from 'node:util';
import type { WebSocket } from 'ws';
import type { Command } from 'common/command_channel/in... | 5,747 | 29.094241 | 88 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/websocket/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { WsChannel } from './channel';
export { WsChannelClient } from './client';
export { WsChannelServer } from './server';
| 203 | 28.142857 | 43 | ts |
nni | nni-master/ts/nni_manager/common/command_channel/websocket/server.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* WebSocket command channel server.
**/
import { EventEmitter } from 'events';
import type { WebSocket } from 'ws';
import type { Command } from 'common/command_channel/interface';
import { Deferred } from 'common/deferred';
import gl... | 4,128 | 32.569106 | 115 | ts |
nni | nni-master/ts/nni_manager/common/globals/arguments.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Parse NNI manager's command line arguments.
**/
import assert from 'assert/strict';
import yargs from 'yargs/yargs';
/**
* Command line arguments provided by "nni/experiment/launcher.py".
*
* Hyphen-separated words are automati... | 3,033 | 29.646465 | 110 | ts |
nni | nni-master/ts/nni_manager/common/globals/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Collection of global objects.
*
* Although global is anti-pattern in OOP, there are two scenarios NNI uses globals.
*
* 1. Some constant configs (like command line args) are accessed here and there with util functions.
* It... | 2,667 | 31.536585 | 106 | ts |
nni | nni-master/ts/nni_manager/common/globals/log_stream.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* The underlying IO stream of loggers.
*
* Normal modules should not use this directly. Use "common/log.ts" instead.
**/
import fs from 'fs';
import { setTimeout } from 'timers/promises';
import util from 'util';
import type { NniMa... | 2,167 | 25.765432 | 84 | ts |
nni | nni-master/ts/nni_manager/common/globals/paths.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Manage experiment paths.
*
* Ideally all path constants should be put here so other modules (especially training services)
* do not need to know file hierarchy of nni-experiments folder, which is an implicit undocumented protocol.
... | 1,629 | 30.960784 | 109 | ts |
nni | nni-master/ts/nni_manager/common/globals/rest.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* WIP REST API manager.
* Functions will be added when used.
**/
import express, { Express, Request, Response, Router } from 'express';
import expressWs, { Router as WsRouter } from 'express-ws';
import type { WebSocket } from 'ws';
... | 2,230 | 29.561644 | 99 | ts |
nni | nni-master/ts/nni_manager/common/globals/shutdown.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Shutdown manager.
*
* Each standalone module should register its clean up method with:
*
* globals.shutdown.register('MyModule', async () => { this.cleanUp(); });
*
* If a module is a children of another module (for example... | 4,003 | 33.222222 | 112 | ts |
nni | nni-master/ts/nni_manager/common/globals/unittest.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Unit test helper.
* It should be inside "test", but must be here for compatibility, until we refactor all test cases.
*
* Use this module to replace NNI globals with mocked values:
*
* import 'common/globals/unittest';
*
*... | 3,094 | 29.048544 | 116 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/collect_platform_info.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import fs from 'node:fs/promises';
import os from 'node:os';
import util from 'node:util';
import { globals } from 'common/globals';
import { getLogger } from 'common/log';
import { runPythonModule } from 'common/pythonScript';
import { getIPV... | 4,164 | 25.194969 | 106 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { TrialKeeper } from './keeper';
export { RemoteTrialKeeper } from './rpc';
| 159 | 25.666667 | 42 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/keeper.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* The helper class to implement a "reuse" training service.
*
* For reuse training services, each machine (or VM) will have a long run daemon, the trial keeper.
* Trial keeper takes responsibility for:
*
* 1. Spawning and killing... | 7,881 | 36.35545 | 113 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/main.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Entry point of trial keeper daemon.
*
* This script should be run via "nni/tools/nni_manager_scripts/launch_trial_keeper.py".
**/
import fs from 'node:fs/promises';
import path from 'node:path';
import util from 'node:util';
impor... | 3,660 | 32.281818 | 102 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/process.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Manage the lifecycle of a trial process.
*
* This is trial keeper's internal helper.
* Should not be used elsewhere.
**/
import child_process, { ChildProcess, SpawnOptions } from 'child_process';
import events from 'events';
impo... | 8,324 | 33.832636 | 120 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/rpc.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Helper class to manipulate a trial keeper through WebSocket command channel.
* Provides similar interface to TrialKeeper class.
*
* Example:
*
* const trialKeeper = new RemoteTrialKeeper(...);
* trialKeeper.onTrialStar... | 4,810 | 36.585938 | 111 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/task_scheduler_client.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* FIXME: This is a placeholder.
*
* In near future (before 3.0 release) GPU scheduler will become a shared daemon so
* multiple NNI experiments can gracefully share GPUs on one machine,
* and this class is the client to communicate... | 2,166 | 29.521127 | 109 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/task_scheduler/collect_info.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { getLogger } from 'common/log';
import { runPythonModule } from 'common/pythonScript';
const logger = getLogger('GpuInfoCollector');
export interface GpuSystemInfo {
success: boolean;
gpuNumber: number;
gpus: GpuInfo[];
... | 1,677 | 23.318841 | 92 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/task_scheduler/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { TaskScheduler } from './scheduler';
| 121 | 23.4 | 44 | ts |
nni | nni-master/ts/nni_manager/common/trial_keeper/task_scheduler/scheduler.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* A simple GPU scheduler used by local and remote training services.
**/
import { EventEmitter } from 'node:events';
import { getLogger } from 'common/log';
import type { TrialKeeper } from 'common/trial_keeper/keeper';
import { GpuSys... | 10,002 | 33.02381 | 111 | ts |
nni | nni-master/ts/nni_manager/config/aml/amlUtil.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
import sys
import time
import json
import warnings
from argparse import ArgumentParser
from azureml.core import Experiment, RunConfiguration, ScriptRunConfig, Workspace
from azureml.core.authentication import (
AzureCliAuthenticatio... | 3,245 | 40.088608 | 110 | py |
nni | nni-master/ts/nni_manager/config/dlc/dlcUtil.py | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import logging
import os
import pathlib
import sys
import traceback
import time
import ast
from argparse import ArgumentParser
# ref: https://help.aliyun.com/document_detail/203290.html?spm=a2c4g.11186623.6.727.6f9b5db6bzJh4x
from alibabacloud_p... | 6,688 | 37.889535 | 130 | py |
nni | nni-master/ts/nni_manager/core/commands.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const INITIALIZE = 'IN';
const REQUEST_TRIAL_JOBS = 'GE';
const REPORT_METRIC_DATA = 'ME';
const UPDATE_SEARCH_SPACE = 'SS';
const IMPORT_DATA = 'FD'
const ADD_CUSTOMIZED_TRIAL_JOB = 'AD';
const TRIAL_END = 'EN';
const TERMINATE = 'TE';
const ... | 1,660 | 18.313953 | 48 | ts |
nni | nni-master/ts/nni_manager/core/ipcInterface.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { IpcInterface, getTunerServer } from './tuner_command_channel';
export { IpcInterface } from './tuner_command_channel';
let tunerDisabled: boolean = false;
export async function createDispatcherInterface(): Promise<IpcInterface> {
... | 1,257 | 34.942857 | 103 | ts |
nni | nni-master/ts/nni_manager/core/nniDataStore.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import { Deferred } from 'ts-deferred';
import { IocShim } from 'common/ioc_shim';
import { Database, DataStore, MetricData, MetricDataRecord, MetricType,
TrialJobEvent, TrialJobEventRecord, TrialJobInfo, Hyper... | 14,969 | 39.459459 | 124 | ts |
nni | nni-master/ts/nni_manager/core/nnimanager.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import { ChildProcess, StdioOptions } from 'child_process';
import { Deferred } from 'ts-deferred';
import { IocShim } from 'common/ioc_shim';
import { DataStore, MetricDataRecord, MetricType, TrialJobInfo } from '.... | 42,679 | 43.458333 | 169 | ts |
nni | nni-master/ts/nni_manager/core/sqlDatabase.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import fs from 'fs';
import path from 'path';
import sqlite3 from 'sqlite3';
import { Deferred } from 'ts-deferred';
import {
Database,
MetricDataRecord,
MetricType,
TrialJobEvent,
TrialJobEvent... | 10,242 | 35.978339 | 138 | ts |
nni | nni-master/ts/nni_manager/core/tuner_command_channel.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { EventEmitter } from 'node:events';
import { WsChannel, WsChannelServer } from 'common/command_channel/websocket';
import { Deferred } from 'common/deferred';
import { Logger, getLogger } from 'common/log';
export interface IpcInterfa... | 3,429 | 31.056075 | 108 | ts |
nni | nni-master/ts/nni_manager/extensions/nniTensorboardManager.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import fs from 'fs';
import cp from 'child_process';
import path from 'path';
import { ChildProcess } from 'child_process';
import { getLogger, Logger } from '../common/log';
import { getTunerProc, isAlive, uniqueString, mkDirPSync, getFreePor... | 10,157 | 43.552632 | 138 | ts |
nni | nni-master/ts/nni_manager/extensions/experiments_manager/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { ExperimentsManager } from './manager';
export { ExperimentsManager } from './manager';
let singleton: ExperimentsManager | null = null;
export function initExperimentsManager(): void {
getExperimentsManager();
}
export function ... | 631 | 24.28 | 74 | ts |
nni | nni-master/ts/nni_manager/extensions/experiments_manager/manager.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert/strict';
import fs from 'fs';
import * as timersPromises from 'timers/promises';
import { Deferred } from 'ts-deferred';
import { getLogger, Logger } from 'common/log';
import globals from 'common/globals';
import {... | 5,939 | 42.357664 | 150 | ts |
nni | nni-master/ts/nni_manager/extensions/experiments_manager/utils.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import fs from 'fs';
import path from 'path';
import * as timersPromises from 'timers/promises';
import glob from 'glob';
import lockfile from 'lockfile';
const lockStale: number = 2000;
const retry: number = 100;
export function withLockNoW... | 1,582 | 34.977273 | 115 | ts |
nni | nni-master/ts/nni_manager/rest_server/core.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* RestServerCore, a rest server which has no built-in handlers.
* All handlers will be registered with `globals.rest` APIs.
*
* Currently it's a copy-paste of the main RestServer.
* In future RestServer will inherit this class.
**... | 2,909 | 35.835443 | 104 | ts |
nni | nni-master/ts/nni_manager/rest_server/index.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/**
* Currently the REST server that dispatches web UI and `Experiment` requests.
* In future it should handle WebSocket connections as well.
*
* To add new APIs to REST server, modify `rootRouter()` function.
*
* This file contains A... | 6,440 | 35.805714 | 121 | ts |
nni | nni-master/ts/nni_manager/rest_server/restHandler.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { Request, Response, Router } from 'express';
import path from 'path';
import { IocShim } from 'common/ioc_shim';
import { DataStore, MetricDataRecord, TrialJobInfo } from '../common/datastore';
import { NNIError, NNIErrorNames } from '... | 16,799 | 38.160839 | 140 | ts |
nni | nni-master/ts/nni_manager/rest_server/restValidationSchemas.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const joi = require('joi');
export namespace ValidationSchemas {
export const SETCLUSTERMETADATA = {
body: {
machine_list: joi.array().items(joi.object({
username: joi.string().required(),
... | 12,199 | 42.41637 | 129 | ts |
nni | nni-master/ts/nni_manager/test/common/getIpv4Address.test.ts | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import assert from 'assert';
import { getIPV4Address } from '../../common/utils';
it('getIpv4Address', async () => {
const ip1 = await getIPV4Address();
const ip2 = await getIPV4Address();
assert.match(ip1, /^\d+\.\d+\.\d+\.\d+$/);... | 353 | 26.230769 | 52 | ts |