partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
init_bn_weight
initilize batch norm layer weight.
src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py
def init_bn_weight(layer): '''initilize batch norm layer weight. ''' n_filters = layer.num_features new_weights = [ add_noise(np.ones(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters,...
def init_bn_weight(layer): '''initilize batch norm layer weight. ''' n_filters = layer.num_features new_weights = [ add_noise(np.ones(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters, dtype=np.float32), np.array([0, 1])), add_noise(np.zeros(n_filters,...
[ "initilize", "batch", "norm", "layer", "weight", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/networkmorphism_tuner/layer_transformer.py#L263-L273
[ "def", "init_bn_weight", "(", "layer", ")", ":", "n_filters", "=", "layer", ".", "num_features", "new_weights", "=", "[", "add_noise", "(", "np", ".", "ones", "(", "n_filters", ",", "dtype", "=", "np", ".", "float32", ")", ",", "np", ".", "array", "(",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_log_path
parse log path
tools/nni_cmd/tensorboard_utils.py
def parse_log_path(args, trial_content): '''parse log path''' path_list = [] host_list = [] for trial in trial_content: if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id: continue pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)' mat...
def parse_log_path(args, trial_content): '''parse log path''' path_list = [] host_list = [] for trial in trial_content: if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id: continue pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)' mat...
[ "parse", "log", "path" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L38-L53
[ "def", "parse_log_path", "(", "args", ",", "trial_content", ")", ":", "path_list", "=", "[", "]", "host_list", "=", "[", "]", "for", "trial", "in", "trial_content", ":", "if", "args", ".", "trial_id", "and", "args", ".", "trial_id", "!=", "'all'", "and",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
copy_data_from_remote
use ssh client to copy data from remote machine to local machien
tools/nni_cmd/tensorboard_utils.py
def copy_data_from_remote(args, nni_config, trial_content, path_list, host_list, temp_nni_path): '''use ssh client to copy data from remote machine to local machien''' machine_list = nni_config.get_config('experimentConfig').get('machineList') machine_dict = {} local_path_list = [] for machine in ma...
def copy_data_from_remote(args, nni_config, trial_content, path_list, host_list, temp_nni_path): '''use ssh client to copy data from remote machine to local machien''' machine_list = nni_config.get_config('experimentConfig').get('machineList') machine_dict = {} local_path_list = [] for machine in ma...
[ "use", "ssh", "client", "to", "copy", "data", "from", "remote", "machine", "to", "local", "machien" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L55-L69
[ "def", "copy_data_from_remote", "(", "args", ",", "nni_config", ",", "trial_content", ",", "path_list", ",", "host_list", ",", "temp_nni_path", ")", ":", "machine_list", "=", "nni_config", ".", "get_config", "(", "'experimentConfig'", ")", ".", "get", "(", "'mac...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_path_list
get path list according to different platform
tools/nni_cmd/tensorboard_utils.py
def get_path_list(args, nni_config, trial_content, temp_nni_path): '''get path list according to different platform''' path_list, host_list = parse_log_path(args, trial_content) platform = nni_config.get_config('experimentConfig').get('trainingServicePlatform') if platform == 'local': print_norm...
def get_path_list(args, nni_config, trial_content, temp_nni_path): '''get path list according to different platform''' path_list, host_list = parse_log_path(args, trial_content) platform = nni_config.get_config('experimentConfig').get('trainingServicePlatform') if platform == 'local': print_norm...
[ "get", "path", "list", "according", "to", "different", "platform" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L71-L84
[ "def", "get_path_list", "(", "args", ",", "nni_config", ",", "trial_content", ",", "temp_nni_path", ")", ":", "path_list", ",", "host_list", "=", "parse_log_path", "(", "args", ",", "trial_content", ")", "platform", "=", "nni_config", ".", "get_config", "(", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
start_tensorboard_process
call cmds to start tensorboard process in local machine
tools/nni_cmd/tensorboard_utils.py
def start_tensorboard_process(args, nni_config, path_list, temp_nni_path): '''call cmds to start tensorboard process in local machine''' if detect_port(args.port): print_error('Port %s is used by another process, please reset port!' % str(args.port)) exit(1) stdout_file = open(os.path.j...
def start_tensorboard_process(args, nni_config, path_list, temp_nni_path): '''call cmds to start tensorboard process in local machine''' if detect_port(args.port): print_error('Port %s is used by another process, please reset port!' % str(args.port)) exit(1) stdout_file = open(os.path.j...
[ "call", "cmds", "to", "start", "tensorboard", "process", "in", "local", "machine" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L92-L109
[ "def", "start_tensorboard_process", "(", "args", ",", "nni_config", ",", "path_list", ",", "temp_nni_path", ")", ":", "if", "detect_port", "(", "args", ".", "port", ")", ":", "print_error", "(", "'Port %s is used by another process, please reset port!'", "%", "str", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
stop_tensorboard
stop tensorboard
tools/nni_cmd/tensorboard_utils.py
def stop_tensorboard(args): '''stop tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) tensorb...
def stop_tensorboard(args): '''stop tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) tensorb...
[ "stop", "tensorboard" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L111-L129
[ "def", "stop_tensorboard", "(", "args", ")", ":", "experiment_id", "=", "check_experiment_id", "(", "args", ")", "experiment_config", "=", "Experiments", "(", ")", "experiment_dict", "=", "experiment_config", ".", "get_all_experiments", "(", ")", "config_file_name", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
start_tensorboard
start tensorboard
tools/nni_cmd/tensorboard_utils.py
def start_tensorboard(args): '''start tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) rest_...
def start_tensorboard(args): '''start tensorboard''' experiment_id = check_experiment_id(args) experiment_config = Experiments() experiment_dict = experiment_config.get_all_experiments() config_file_name = experiment_dict[experiment_id]['fileName'] nni_config = Config(config_file_name) rest_...
[ "start", "tensorboard" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/tensorboard_utils.py#L132-L165
[ "def", "start_tensorboard", "(", "args", ")", ":", "experiment_id", "=", "check_experiment_id", "(", "args", ")", "experiment_config", "=", "Experiments", "(", ")", "experiment_dict", "=", "experiment_config", ".", "get_all_experiments", "(", ")", "config_file_name", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
_ratio_scores
The ratio is smaller the better
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
def _ratio_scores(parameters_value, clusteringmodel_gmm_good, clusteringmodel_gmm_bad): ''' The ratio is smaller the better ''' ratio = clusteringmodel_gmm_good.score([parameters_value]) / clusteringmodel_gmm_bad.score([parameters_value]) sigma = 0 return ratio, sigma
def _ratio_scores(parameters_value, clusteringmodel_gmm_good, clusteringmodel_gmm_bad): ''' The ratio is smaller the better ''' ratio = clusteringmodel_gmm_good.score([parameters_value]) / clusteringmodel_gmm_bad.score([parameters_value]) sigma = 0 return ratio, sigma
[ "The", "ratio", "is", "smaller", "the", "better" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L37-L43
[ "def", "_ratio_scores", "(", "parameters_value", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ")", ":", "ratio", "=", "clusteringmodel_gmm_good", ".", "score", "(", "[", "parameters_value", "]", ")", "/", "clusteringmodel_gmm_bad", ".", "score", "(...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
selection_r
Call selection
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
def selection_r(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, num_starting_points=100, minimize_constraints_fun=None): ''' Call selection ''' minimize_starting_points = [lib_data.rand(x_bounds, x_type...
def selection_r(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, num_starting_points=100, minimize_constraints_fun=None): ''' Call selection ''' minimize_starting_points = [lib_data.rand(x_bounds, x_type...
[ "Call", "selection" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L45-L61
[ "def", "selection_r", "(", "x_bounds", ",", "x_types", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ",", "num_starting_points", "=", "100", ",", "minimize_constraints_fun", "=", "None", ")", ":", "minimize_starting_points", "=", "[", "lib_data", "....
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
selection
Select the lowest mu value
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
def selection(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, minimize_starting_points, minimize_constraints_fun=None): ''' Select the lowest mu value ''' results = lib_acquisition_function.next_hyperparameter_lo...
def selection(x_bounds, x_types, clusteringmodel_gmm_good, clusteringmodel_gmm_bad, minimize_starting_points, minimize_constraints_fun=None): ''' Select the lowest mu value ''' results = lib_acquisition_function.next_hyperparameter_lo...
[ "Select", "the", "lowest", "mu", "value" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L63-L77
[ "def", "selection", "(", "x_bounds", ",", "x_types", ",", "clusteringmodel_gmm_good", ",", "clusteringmodel_gmm_bad", ",", "minimize_starting_points", ",", "minimize_constraints_fun", "=", "None", ")", ":", "results", "=", "lib_acquisition_function", ".", "next_hyperparam...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
_minimize_constraints_fun_summation
Minimize constraints fun summation
src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py
def _minimize_constraints_fun_summation(x): ''' Minimize constraints fun summation ''' summation = sum([x[i] for i in CONSTRAINT_PARAMS_IDX]) return CONSTRAINT_UPPERBOUND >= summation >= CONSTRAINT_LOWERBOUND
def _minimize_constraints_fun_summation(x): ''' Minimize constraints fun summation ''' summation = sum([x[i] for i in CONSTRAINT_PARAMS_IDX]) return CONSTRAINT_UPPERBOUND >= summation >= CONSTRAINT_LOWERBOUND
[ "Minimize", "constraints", "fun", "summation" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/Selection.py#L99-L104
[ "def", "_minimize_constraints_fun_summation", "(", "x", ")", ":", "summation", "=", "sum", "(", "[", "x", "[", "i", "]", "for", "i", "in", "CONSTRAINT_PARAMS_IDX", "]", ")", "return", "CONSTRAINT_UPPERBOUND", ">=", "summation", ">=", "CONSTRAINT_LOWERBOUND" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
load_data
Load dataset, use 20newsgroups dataset
examples/trials/sklearn/classification/main.py
def load_data(): '''Load dataset, use 20newsgroups dataset''' digits = load_digits() X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=0.25) ss = StandardScaler() X_train = ss.fit_transform(X_train) X_test = ss.transform(X_test) retu...
def load_data(): '''Load dataset, use 20newsgroups dataset''' digits = load_digits() X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=0.25) ss = StandardScaler() X_train = ss.fit_transform(X_train) X_test = ss.transform(X_test) retu...
[ "Load", "dataset", "use", "20newsgroups", "dataset" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/sklearn/classification/main.py#L29-L38
[ "def", "load_data", "(", ")", ":", "digits", "=", "load_digits", "(", ")", "X_train", ",", "X_test", ",", "y_train", ",", "y_test", "=", "train_test_split", "(", "digits", ".", "data", ",", "digits", ".", "target", ",", "random_state", "=", "99", ",", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_model
Get model according to parameters
examples/trials/sklearn/classification/main.py
def get_model(PARAMS): '''Get model according to parameters''' model = SVC() model.C = PARAMS.get('C') model.keral = PARAMS.get('keral') model.degree = PARAMS.get('degree') model.gamma = PARAMS.get('gamma') model.coef0 = PARAMS.get('coef0') return model
def get_model(PARAMS): '''Get model according to parameters''' model = SVC() model.C = PARAMS.get('C') model.keral = PARAMS.get('keral') model.degree = PARAMS.get('degree') model.gamma = PARAMS.get('gamma') model.coef0 = PARAMS.get('coef0') return model
[ "Get", "model", "according", "to", "parameters" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/sklearn/classification/main.py#L51-L60
[ "def", "get_model", "(", "PARAMS", ")", ":", "model", "=", "SVC", "(", ")", "model", ".", "C", "=", "PARAMS", ".", "get", "(", "'C'", ")", "model", ".", "keral", "=", "PARAMS", ".", "get", "(", "'keral'", ")", "model", ".", "degree", "=", "PARAMS...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
Bracket.get_hyperparameter_configurations
generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- list a list of hyperparameter configurations. Format: [[key1, valu...
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def get_hyperparameter_configurations(self, num, r, config_generator): """generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- ...
def get_hyperparameter_configurations(self, num, r, config_generator): """generate num hyperparameter configurations from search space using Bayesian optimization Parameters ---------- num: int the number of hyperparameter configurations Returns ------- ...
[ "generate", "num", "hyperparameter", "configurations", "from", "search", "space", "using", "Bayesian", "optimization" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L215-L237
[ "def", "get_hyperparameter_configurations", "(", "self", ",", "num", ",", "r", ",", "config_generator", ")", ":", "global", "_KEY", "assert", "self", ".", "i", "==", "0", "hyperparameter_configs", "=", "dict", "(", ")", "for", "_", "in", "range", "(", "num...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_initialize
Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ ValueError Error: Search space is None
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_initialize(self, data): """Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ Value...
def handle_initialize(self, data): """Initialize Tuner, including creating Bayesian optimization-based parametric models and search space formations Parameters ---------- data: search space search space of this experiment Raises ------ Value...
[ "Initialize", "Tuner", "including", "creating", "Bayesian", "optimization", "-", "based", "parametric", "models", "and", "search", "space", "formations" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L344-L375
[ "def", "handle_initialize", "(", "self", ",", "data", ")", ":", "logger", ".", "info", "(", "'start to handle_initialize'", ")", "# convert search space jason to ConfigSpace", "self", ".", "handle_update_search_space", "(", "data", ")", "# generate BOHB config_generator usi...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.generate_new_bracket
generate a new bracket
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def generate_new_bracket(self): """generate a new bracket""" logger.debug( 'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s) if self.curr_s < 0: logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round") se...
def generate_new_bracket(self): """generate a new bracket""" logger.debug( 'start to create a new SuccessiveHalving iteration, self.curr_s=%d', self.curr_s) if self.curr_s < 0: logger.info("s < 0, Finish this round of Hyperband in BOHB. Generate new round") se...
[ "generate", "a", "new", "bracket" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L377-L392
[ "def", "generate_new_bracket", "(", "self", ")", ":", "logger", ".", "debug", "(", "'start to create a new SuccessiveHalving iteration, self.curr_s=%d'", ",", "self", ".", "curr_s", ")", "if", "self", ".", "curr_s", "<", "0", ":", "logger", ".", "info", "(", "\"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_request_trial_jobs
recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_request_trial_jobs(self, data): """recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate """ # Receive new request self.credit += data for _ in rang...
def handle_request_trial_jobs(self, data): """recerive the number of request and generate trials Parameters ---------- data: int number of trial jobs that nni manager ask to generate """ # Receive new request self.credit += data for _ in rang...
[ "recerive", "the", "number", "of", "request", "and", "generate", "trials" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L394-L406
[ "def", "handle_request_trial_jobs", "(", "self", ",", "data", ")", ":", "# Receive new request", "self", ".", "credit", "+=", "data", "for", "_", "in", "range", "(", "self", ".", "credit", ")", ":", "self", ".", "_request_one_trial_job", "(", ")" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB._request_one_trial_job
get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparameter 'parameter_source': 'algorithm'...
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def _request_one_trial_job(self): """get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparamete...
def _request_one_trial_job(self): """get one trial job, i.e., one hyperparameter configuration. If this function is called, Command will be sent by BOHB: a. If there is a parameter need to run, will return "NewTrialJob" with a dict: { 'parameter_id': id of new hyperparamete...
[ "get", "one", "trial", "job", "i", ".", "e", ".", "one", "hyperparameter", "configuration", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L408-L442
[ "def", "_request_one_trial_job", "(", "self", ")", ":", "if", "not", "self", ".", "generated_hyper_configs", ":", "ret", "=", "{", "'parameter_id'", ":", "'-1_0_0'", ",", "'parameter_source'", ":", "'algorithm'", ",", "'parameters'", ":", "''", "}", "send", "(...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_update_search_space
change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_update_search_space(self, data): """change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment """ search_space = data cs = CS.ConfigurationSpace() for ...
def handle_update_search_space(self, data): """change json format to ConfigSpace format dict<dict> -> configspace Parameters ---------- data: JSON object search space of this experiment """ search_space = data cs = CS.ConfigurationSpace() for ...
[ "change", "json", "format", "to", "ConfigSpace", "format", "dict<dict", ">", "-", ">", "configspace" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L444-L496
[ "def", "handle_update_search_space", "(", "self", ",", "data", ")", ":", "search_space", "=", "data", "cs", "=", "CS", ".", "ConfigurationSpace", "(", ")", "for", "var", "in", "search_space", ":", "_type", "=", "str", "(", "search_space", "[", "var", "]", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_trial_end
receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service event: the job's state hyper_params: ...
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_trial_end(self, data): """receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service even...
def handle_trial_end(self, data): """receive the information of trial end and generate next configuaration. Parameters ---------- data: dict() it has three keys: trial_job_id, event, hyper_params trial_job_id: the id generated by training service even...
[ "receive", "the", "information", "of", "trial", "end", "and", "generate", "next", "configuaration", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L498-L526
[ "def", "handle_trial_end", "(", "self", ",", "data", ")", ":", "logger", ".", "debug", "(", "'Tuner handle trial end, result is %s'", ",", "data", ")", "hyper_params", "=", "json_tricks", ".", "loads", "(", "data", "[", "'hyper_params'", "]", ")", "s", ",", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_report_metric_data
reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ValueError Data type not supported
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_report_metric_data(self, data): """reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ...
def handle_report_metric_data(self, data): """reveice the metric data and update Bayesian optimization with final result Parameters ---------- data: it is an object which has keys 'parameter_id', 'value', 'trial_job_id', 'type', 'sequence'. Raises ------ ...
[ "reveice", "the", "metric", "data", "and", "update", "Bayesian", "optimization", "with", "final", "result" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L528-L572
[ "def", "handle_report_metric_data", "(", "self", ",", "data", ")", ":", "logger", ".", "debug", "(", "'handle report metric data = %s'", ",", "data", ")", "assert", "'value'", "in", "data", "value", "=", "extract_scalar_reward", "(", "data", "[", "'value'", "]",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
BOHB.handle_import_data
Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have required key 'parameter' and 'value'
src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py
def handle_import_data(self, data): """Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have requir...
def handle_import_data(self, data): """Import additional data for tuning Parameters ---------- data: a list of dictionarys, each of which has at least two keys, 'parameter' and 'value' Raises ------ AssertionError data doesn't have requir...
[ "Import", "additional", "data", "for", "tuning" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/bohb_advisor/bohb_advisor.py#L577-L617
[ "def", "handle_import_data", "(", "self", ",", "data", ")", ":", "_completed_num", "=", "0", "for", "trial_info", "in", "data", ":", "logger", ".", "info", "(", "\"Importing data, current processing progress %s / %s\"", "%", "(", "_completed_num", ",", "len", "(",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
data_transforms_cifar10
data_transforms for cifar10 dataset
examples/trials/network_morphism/FashionMNIST/utils.py
def data_transforms_cifar10(args): """ data_transforms for cifar10 dataset """ cifar_mean = [0.49139968, 0.48215827, 0.44653124] cifar_std = [0.24703233, 0.24348505, 0.26158768] train_transform = transforms.Compose( [ transforms.RandomCrop(32, padding=4), transforms...
def data_transforms_cifar10(args): """ data_transforms for cifar10 dataset """ cifar_mean = [0.49139968, 0.48215827, 0.44653124] cifar_std = [0.24703233, 0.24348505, 0.26158768] train_transform = transforms.Compose( [ transforms.RandomCrop(32, padding=4), transforms...
[ "data_transforms", "for", "cifar10", "dataset" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L116-L137
[ "def", "data_transforms_cifar10", "(", "args", ")", ":", "cifar_mean", "=", "[", "0.49139968", ",", "0.48215827", ",", "0.44653124", "]", "cifar_std", "=", "[", "0.24703233", ",", "0.24348505", ",", "0.26158768", "]", "train_transform", "=", "transforms", ".", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
data_transforms_mnist
data_transforms for mnist dataset
examples/trials/network_morphism/FashionMNIST/utils.py
def data_transforms_mnist(args, mnist_mean=None, mnist_std=None): """ data_transforms for mnist dataset """ if mnist_mean is None: mnist_mean = [0.5] if mnist_std is None: mnist_std = [0.5] train_transform = transforms.Compose( [ transforms.RandomCrop(28, paddin...
def data_transforms_mnist(args, mnist_mean=None, mnist_std=None): """ data_transforms for mnist dataset """ if mnist_mean is None: mnist_mean = [0.5] if mnist_std is None: mnist_std = [0.5] train_transform = transforms.Compose( [ transforms.RandomCrop(28, paddin...
[ "data_transforms", "for", "mnist", "dataset" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L140-L163
[ "def", "data_transforms_mnist", "(", "args", ",", "mnist_mean", "=", "None", ",", "mnist_std", "=", "None", ")", ":", "if", "mnist_mean", "is", "None", ":", "mnist_mean", "=", "[", "0.5", "]", "if", "mnist_std", "is", "None", ":", "mnist_std", "=", "[", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_mean_and_std
Compute the mean and std value of dataset.
examples/trials/network_morphism/FashionMNIST/utils.py
def get_mean_and_std(dataset): """Compute the mean and std value of dataset.""" dataloader = torch.utils.data.DataLoader( dataset, batch_size=1, shuffle=True, num_workers=2 ) mean = torch.zeros(3) std = torch.zeros(3) print("==> Computing mean and std..") for inputs, _ in dataloader:...
def get_mean_and_std(dataset): """Compute the mean and std value of dataset.""" dataloader = torch.utils.data.DataLoader( dataset, batch_size=1, shuffle=True, num_workers=2 ) mean = torch.zeros(3) std = torch.zeros(3) print("==> Computing mean and std..") for inputs, _ in dataloader:...
[ "Compute", "the", "mean", "and", "std", "value", "of", "dataset", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L166-L180
[ "def", "get_mean_and_std", "(", "dataset", ")", ":", "dataloader", "=", "torch", ".", "utils", ".", "data", ".", "DataLoader", "(", "dataset", ",", "batch_size", "=", "1", ",", "shuffle", "=", "True", ",", "num_workers", "=", "2", ")", "mean", "=", "to...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
init_params
Init layer parameters.
examples/trials/network_morphism/FashionMNIST/utils.py
def init_params(net): """Init layer parameters.""" for module in net.modules(): if isinstance(module, nn.Conv2d): init.kaiming_normal(module.weight, mode="fan_out") if module.bias: init.constant(module.bias, 0) elif isinstance(module, nn.BatchNorm2d): ...
def init_params(net): """Init layer parameters.""" for module in net.modules(): if isinstance(module, nn.Conv2d): init.kaiming_normal(module.weight, mode="fan_out") if module.bias: init.constant(module.bias, 0) elif isinstance(module, nn.BatchNorm2d): ...
[ "Init", "layer", "parameters", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L183-L196
[ "def", "init_params", "(", "net", ")", ":", "for", "module", "in", "net", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "module", ",", "nn", ".", "Conv2d", ")", ":", "init", ".", "kaiming_normal", "(", "module", ".", "weight", ",", "mode", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
EarlyStopping.step
EarlyStopping step on each epoch Arguments: metrics {float} -- metric value
examples/trials/network_morphism/FashionMNIST/utils.py
def step(self, metrics): """ EarlyStopping step on each epoch Arguments: metrics {float} -- metric value """ if self.best is None: self.best = metrics return False if np.isnan(metrics): return True if self.is_better(metri...
def step(self, metrics): """ EarlyStopping step on each epoch Arguments: metrics {float} -- metric value """ if self.best is None: self.best = metrics return False if np.isnan(metrics): return True if self.is_better(metri...
[ "EarlyStopping", "step", "on", "each", "epoch", "Arguments", ":", "metrics", "{", "float", "}", "--", "metric", "value" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/utils.py#L43-L65
[ "def", "step", "(", "self", ",", "metrics", ")", ":", "if", "self", ".", "best", "is", "None", ":", "self", ".", "best", "=", "metrics", "return", "False", "if", "np", ".", "isnan", "(", "metrics", ")", ":", "return", "True", "if", "self", ".", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
check_feasibility
This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7.
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
def check_feasibility(x_bounds, lowerbound, upperbound): ''' This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7. ''' # x_bounds should be sorted, so even for "discrete_int" type, # the smallest and the largest number should...
def check_feasibility(x_bounds, lowerbound, upperbound): ''' This can have false positives. For examples, parameters can only be 0 or 5, and the summation constraint is between 6 and 7. ''' # x_bounds should be sorted, so even for "discrete_int" type, # the smallest and the largest number should...
[ "This", "can", "have", "false", "positives", ".", "For", "examples", "parameters", "can", "only", "be", "0", "or", "5", "and", "the", "summation", "constraint", "is", "between", "6", "and", "7", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py#L27-L40
[ "def", "check_feasibility", "(", "x_bounds", ",", "lowerbound", ",", "upperbound", ")", ":", "# x_bounds should be sorted, so even for \"discrete_int\" type,", "# the smallest and the largest number should the first and the last element", "x_bounds_lowerbound", "=", "sum", "(", "[", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
rand
Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound
src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py
def rand(x_bounds, x_types, lowerbound, upperbound, max_retries=100): ''' Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound ''' outputs = None ...
def rand(x_bounds, x_types, lowerbound, upperbound, max_retries=100): ''' Key idea is that we try to move towards upperbound, by randomly choose one value for each parameter. However, for the last parameter, we need to make sure that its value can help us get above lowerbound ''' outputs = None ...
[ "Key", "idea", "is", "that", "we", "try", "to", "move", "towards", "upperbound", "by", "randomly", "choose", "one", "value", "for", "each", "parameter", ".", "However", "for", "the", "last", "parameter", "we", "need", "to", "make", "sure", "that", "its", ...
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/lib_constraint_summation.py#L42-L115
[ "def", "rand", "(", "x_bounds", ",", "x_types", ",", "lowerbound", ",", "upperbound", ",", "max_retries", "=", "100", ")", ":", "outputs", "=", "None", "if", "check_feasibility", "(", "x_bounds", ",", "lowerbound", ",", "upperbound", ")", "is", "True", ":"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
expand_path
Change '~' to user home directory
tools/nni_cmd/launcher_utils.py
def expand_path(experiment_config, key): '''Change '~' to user home directory''' if experiment_config.get(key): experiment_config[key] = os.path.expanduser(experiment_config[key])
def expand_path(experiment_config, key): '''Change '~' to user home directory''' if experiment_config.get(key): experiment_config[key] = os.path.expanduser(experiment_config[key])
[ "Change", "~", "to", "user", "home", "directory" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L29-L32
[ "def", "expand_path", "(", "experiment_config", ",", "key", ")", ":", "if", "experiment_config", ".", "get", "(", "key", ")", ":", "experiment_config", "[", "key", "]", "=", "os", ".", "path", ".", "expanduser", "(", "experiment_config", "[", "key", "]", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_relative_path
Change relative path to absolute path
tools/nni_cmd/launcher_utils.py
def parse_relative_path(root_path, experiment_config, key): '''Change relative path to absolute path''' if experiment_config.get(key) and not os.path.isabs(experiment_config.get(key)): absolute_path = os.path.join(root_path, experiment_config.get(key)) print_normal('expand %s: %s to %s ' % (key,...
def parse_relative_path(root_path, experiment_config, key): '''Change relative path to absolute path''' if experiment_config.get(key) and not os.path.isabs(experiment_config.get(key)): absolute_path = os.path.join(root_path, experiment_config.get(key)) print_normal('expand %s: %s to %s ' % (key,...
[ "Change", "relative", "path", "to", "absolute", "path" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L34-L39
[ "def", "parse_relative_path", "(", "root_path", ",", "experiment_config", ",", "key", ")", ":", "if", "experiment_config", ".", "get", "(", "key", ")", "and", "not", "os", ".", "path", ".", "isabs", "(", "experiment_config", ".", "get", "(", "key", ")", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_time
Change the time to seconds
tools/nni_cmd/launcher_utils.py
def parse_time(time): '''Change the time to seconds''' unit = time[-1] if unit not in ['s', 'm', 'h', 'd']: print_error('the unit of time could only from {s, m, h, d}') exit(1) time = time[:-1] if not time.isdigit(): print_error('time format error!') exit(1) parse...
def parse_time(time): '''Change the time to seconds''' unit = time[-1] if unit not in ['s', 'm', 'h', 'd']: print_error('the unit of time could only from {s, m, h, d}') exit(1) time = time[:-1] if not time.isdigit(): print_error('time format error!') exit(1) parse...
[ "Change", "the", "time", "to", "seconds" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L41-L52
[ "def", "parse_time", "(", "time", ")", ":", "unit", "=", "time", "[", "-", "1", "]", "if", "unit", "not", "in", "[", "'s'", ",", "'m'", ",", "'h'", ",", "'d'", "]", ":", "print_error", "(", "'the unit of time could only from {s, m, h, d}'", ")", "exit", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_path
Parse path in config file
tools/nni_cmd/launcher_utils.py
def parse_path(experiment_config, config_path): '''Parse path in config file''' expand_path(experiment_config, 'searchSpacePath') if experiment_config.get('trial'): expand_path(experiment_config['trial'], 'codeDir') if experiment_config.get('tuner'): expand_path(experiment_config['tuner'...
def parse_path(experiment_config, config_path): '''Parse path in config file''' expand_path(experiment_config, 'searchSpacePath') if experiment_config.get('trial'): expand_path(experiment_config['trial'], 'codeDir') if experiment_config.get('tuner'): expand_path(experiment_config['tuner'...
[ "Parse", "path", "in", "config", "file" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L54-L80
[ "def", "parse_path", "(", "experiment_config", ",", "config_path", ")", ":", "expand_path", "(", "experiment_config", ",", "'searchSpacePath'", ")", "if", "experiment_config", ".", "get", "(", "'trial'", ")", ":", "expand_path", "(", "experiment_config", "[", "'tr...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_search_space_content
Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file
tools/nni_cmd/launcher_utils.py
def validate_search_space_content(experiment_config): '''Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file''' try: search_space_content = json.load(open...
def validate_search_space_content(experiment_config): '''Validate searchspace content, if the searchspace file is not json format or its values does not contain _type and _value which must be specified, it will not be a valid searchspace file''' try: search_space_content = json.load(open...
[ "Validate", "searchspace", "content", "if", "the", "searchspace", "file", "is", "not", "json", "format", "or", "its", "values", "does", "not", "contain", "_type", "and", "_value", "which", "must", "be", "specified", "it", "will", "not", "be", "a", "valid", ...
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L82-L94
[ "def", "validate_search_space_content", "(", "experiment_config", ")", ":", "try", ":", "search_space_content", "=", "json", ".", "load", "(", "open", "(", "experiment_config", ".", "get", "(", "'searchSpacePath'", ")", ",", "'r'", ")", ")", "for", "value", "i...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_kubeflow_operators
Validate whether the kubeflow operators are valid
tools/nni_cmd/launcher_utils.py
def validate_kubeflow_operators(experiment_config): '''Validate whether the kubeflow operators are valid''' if experiment_config.get('kubeflowConfig'): if experiment_config.get('kubeflowConfig').get('operator') == 'tf-operator': if experiment_config.get('trial').get('master') is not None: ...
def validate_kubeflow_operators(experiment_config): '''Validate whether the kubeflow operators are valid''' if experiment_config.get('kubeflowConfig'): if experiment_config.get('kubeflowConfig').get('operator') == 'tf-operator': if experiment_config.get('trial').get('master') is not None: ...
[ "Validate", "whether", "the", "kubeflow", "operators", "are", "valid" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L96-L125
[ "def", "validate_kubeflow_operators", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ":", "if", "experiment_config", ".", "get", "(", "'kubeflowConfig'", ")", ".", "get", "(", "'operator'", ")", "==", "'t...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_common_content
Validate whether the common values in experiment_config is valid
tools/nni_cmd/launcher_utils.py
def validate_common_content(experiment_config): '''Validate whether the common values in experiment_config is valid''' if not experiment_config.get('trainingServicePlatform') or \ experiment_config.get('trainingServicePlatform') not in ['local', 'remote', 'pai', 'kubeflow', 'frameworkcontroller']: ...
def validate_common_content(experiment_config): '''Validate whether the common values in experiment_config is valid''' if not experiment_config.get('trainingServicePlatform') or \ experiment_config.get('trainingServicePlatform') not in ['local', 'remote', 'pai', 'kubeflow', 'frameworkcontroller']: ...
[ "Validate", "whether", "the", "common", "values", "in", "experiment_config", "is", "valid" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L127-L182
[ "def", "validate_common_content", "(", "experiment_config", ")", ":", "if", "not", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "or", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "not", "in", "[", "'local'", ",",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_customized_file
check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor'
tools/nni_cmd/launcher_utils.py
def validate_customized_file(experiment_config, spec_key): ''' check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor' ''' if experiment_config[spec_key].get('codeDir') and \ experiment_config[spec_key].get('classFileName') and \ ex...
def validate_customized_file(experiment_config, spec_key): ''' check whether the file of customized tuner/assessor/advisor exists spec_key: 'tuner', 'assessor', 'advisor' ''' if experiment_config[spec_key].get('codeDir') and \ experiment_config[spec_key].get('classFileName') and \ ex...
[ "check", "whether", "the", "file", "of", "customized", "tuner", "/", "assessor", "/", "advisor", "exists", "spec_key", ":", "tuner", "assessor", "advisor" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L184-L199
[ "def", "validate_customized_file", "(", "experiment_config", ",", "spec_key", ")", ":", "if", "experiment_config", "[", "spec_key", "]", ".", "get", "(", "'codeDir'", ")", "and", "experiment_config", "[", "spec_key", "]", ".", "get", "(", "'classFileName'", ")",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_assessor_content
Validate whether assessor in experiment_config is valid
tools/nni_cmd/launcher_utils.py
def parse_assessor_content(experiment_config): '''Validate whether assessor in experiment_config is valid''' if experiment_config.get('assessor'): if experiment_config['assessor'].get('builtinAssessorName'): experiment_config['assessor']['className'] = experiment_config['assessor']['builtinA...
def parse_assessor_content(experiment_config): '''Validate whether assessor in experiment_config is valid''' if experiment_config.get('assessor'): if experiment_config['assessor'].get('builtinAssessorName'): experiment_config['assessor']['className'] = experiment_config['assessor']['builtinA...
[ "Validate", "whether", "assessor", "in", "experiment_config", "is", "valid" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L208-L214
[ "def", "parse_assessor_content", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'assessor'", ")", ":", "if", "experiment_config", "[", "'assessor'", "]", ".", "get", "(", "'builtinAssessorName'", ")", ":", "experiment_config", "["...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_annotation_content
Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName'
tools/nni_cmd/launcher_utils.py
def validate_annotation_content(experiment_config, spec_key, builtin_name): ''' Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName' ''' if experiment_config.get('useAnnotation'): if experiment_...
def validate_annotation_content(experiment_config, spec_key, builtin_name): ''' Valid whether useAnnotation and searchSpacePath is coexist spec_key: 'advisor' or 'tuner' builtin_name: 'builtinAdvisorName' or 'builtinTunerName' ''' if experiment_config.get('useAnnotation'): if experiment_...
[ "Valid", "whether", "useAnnotation", "and", "searchSpacePath", "is", "coexist", "spec_key", ":", "advisor", "or", "tuner", "builtin_name", ":", "builtinAdvisorName", "or", "builtinTunerName" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L223-L241
[ "def", "validate_annotation_content", "(", "experiment_config", ",", "spec_key", ",", "builtin_name", ")", ":", "if", "experiment_config", ".", "get", "(", "'useAnnotation'", ")", ":", "if", "experiment_config", ".", "get", "(", "'searchSpacePath'", ")", ":", "pri...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_pai_trial_conifg
validate the trial config in pai platform
tools/nni_cmd/launcher_utils.py
def validate_pai_trial_conifg(experiment_config): '''validate the trial config in pai platform''' if experiment_config.get('trainingServicePlatform') == 'pai': if experiment_config.get('trial').get('shmMB') and \ experiment_config['trial']['shmMB'] > experiment_config['trial']['memoryMB']: ...
def validate_pai_trial_conifg(experiment_config): '''validate the trial config in pai platform''' if experiment_config.get('trainingServicePlatform') == 'pai': if experiment_config.get('trial').get('shmMB') and \ experiment_config['trial']['shmMB'] > experiment_config['trial']['memoryMB']: ...
[ "validate", "the", "trial", "config", "in", "pai", "platform" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L249-L255
[ "def", "validate_pai_trial_conifg", "(", "experiment_config", ")", ":", "if", "experiment_config", ".", "get", "(", "'trainingServicePlatform'", ")", "==", "'pai'", ":", "if", "experiment_config", ".", "get", "(", "'trial'", ")", ".", "get", "(", "'shmMB'", ")",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
validate_all_content
Validate whether experiment_config is valid
tools/nni_cmd/launcher_utils.py
def validate_all_content(experiment_config, config_path): '''Validate whether experiment_config is valid''' parse_path(experiment_config, config_path) validate_common_content(experiment_config) validate_pai_trial_conifg(experiment_config) experiment_config['maxExecDuration'] = parse_time(experiment_...
def validate_all_content(experiment_config, config_path): '''Validate whether experiment_config is valid''' parse_path(experiment_config, config_path) validate_common_content(experiment_config) validate_pai_trial_conifg(experiment_config) experiment_config['maxExecDuration'] = parse_time(experiment_...
[ "Validate", "whether", "experiment_config", "is", "valid" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/launcher_utils.py#L257-L274
[ "def", "validate_all_content", "(", "experiment_config", ",", "config_path", ")", ":", "parse_path", "(", "experiment_config", ",", "config_path", ")", "validate_common_content", "(", "experiment_config", ")", "validate_pai_trial_conifg", "(", "experiment_config", ")", "e...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_local_urls
get urls of local machine
tools/nni_cmd/url_utils.py
def get_local_urls(port): '''get urls of local machine''' url_list = [] for name, info in psutil.net_if_addrs().items(): for addr in info: if AddressFamily.AF_INET == addr.family: url_list.append('http://{}:{}'.format(addr.address, port)) return url_list
def get_local_urls(port): '''get urls of local machine''' url_list = [] for name, info in psutil.net_if_addrs().items(): for addr in info: if AddressFamily.AF_INET == addr.family: url_list.append('http://{}:{}'.format(addr.address, port)) return url_list
[ "get", "urls", "of", "local", "machine" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/url_utils.py#L76-L83
[ "def", "get_local_urls", "(", "port", ")", ":", "url_list", "=", "[", "]", "for", "name", ",", "info", "in", "psutil", ".", "net_if_addrs", "(", ")", ".", "items", "(", ")", ":", "for", "addr", "in", "info", ":", "if", "AddressFamily", ".", "AF_INET"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_annotation
Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@')
tools/nni_annotation/code_generator.py
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
[ "Parse", "an", "annotation", "string", ".", "Return", "an", "AST", "Expr", "node", ".", "code", ":", "annotation", "string", "(", "excluding" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L29-L38
[ "def", "parse_annotation", "(", "code", ")", ":", "module", "=", "ast", ".", "parse", "(", "code", ")", "assert", "type", "(", "module", ")", "is", "ast", ".", "Module", ",", "'internal error #1'", "assert", "len", "(", "module", ".", "body", ")", "=="...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_annotation_function
Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name
tools/nni_annotation/code_generator.py
def parse_annotation_function(code, func_name): """Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name """ expr = parse_annotation(code) call = expr.value assert type(call) is ast.Call, 'Annotation is not a functi...
def parse_annotation_function(code, func_name): """Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name """ expr = parse_annotation(code) call = expr.value assert type(call) is ast.Call, 'Annotation is not a functi...
[ "Parse", "an", "annotation", "function", ".", "Return", "the", "value", "of", "name", "keyword", "argument", "and", "the", "AST", "Call", "node", ".", "func_name", ":", "expected", "function", "name" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L41-L59
[ "def", "parse_annotation_function", "(", "code", ",", "func_name", ")", ":", "expr", "=", "parse_annotation", "(", "code", ")", "call", "=", "expr", ".", "value", "assert", "type", "(", "call", ")", "is", "ast", ".", "Call", ",", "'Annotation is not a functi...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_nni_variable
Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string
tools/nni_annotation/code_generator.py
def parse_nni_variable(code): """Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string """ name, call = parse_annotation_function(code, 'variable') assert len(call.args) == 1, 'nni.variable contains more than one arguments' a...
def parse_nni_variable(code): """Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string """ name, call = parse_annotation_function(code, 'variable') assert len(call.args) == 1, 'nni.variable contains more than one arguments' a...
[ "Parse", "nni", ".", "variable", "expression", ".", "Return", "the", "name", "argument", "and", "AST", "node", "of", "annotated", "expression", ".", "code", ":", "annotation", "string" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L62-L82
[ "def", "parse_nni_variable", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'variable'", ")", "assert", "len", "(", "call", ".", "args", ")", "==", "1", ",", "'nni.variable contains more than one arguments'", "ar...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_nni_function
Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string
tools/nni_annotation/code_generator.py
def parse_nni_function(code): """Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string """ name, call = parse_annotation_function(code, 'function_choice') funcs = [ast.dump(func, False) for func...
def parse_nni_function(code): """Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string """ name, call = parse_annotation_function(code, 'function_choice') funcs = [ast.dump(func, False) for func...
[ "Parse", "nni", ".", "function_choice", "expression", ".", "Return", "the", "AST", "node", "of", "annotated", "expression", "and", "a", "list", "of", "dumped", "function", "call", "expressions", ".", "code", ":", "annotation", "string" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L85-L97
[ "def", "parse_nni_function", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'function_choice'", ")", "funcs", "=", "[", "ast", ".", "dump", "(", "func", ",", "False", ")", "for", "func", "in", "call", "."...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
convert_args_to_dict
Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary
tools/nni_annotation/code_generator.py
def convert_args_to_dict(call, with_lambda=False): """Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary """ keys, values = list(), list() for arg in call.args: if type(ar...
def convert_args_to_dict(call, with_lambda=False): """Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary """ keys, values = list(), list() for arg in call.args: if type(ar...
[ "Convert", "all", "args", "to", "a", "dict", "such", "that", "every", "key", "and", "value", "in", "the", "dict", "is", "the", "same", "as", "the", "value", "of", "the", "arg", ".", "Return", "the", "AST", "Call", "node", "with", "only", "one", "arg"...
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L100-L118
[ "def", "convert_args_to_dict", "(", "call", ",", "with_lambda", "=", "False", ")", ":", "keys", ",", "values", "=", "list", "(", ")", ",", "list", "(", ")", "for", "arg", "in", "call", ".", "args", ":", "if", "type", "(", "arg", ")", "in", "[", "...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
make_lambda
Wrap an AST Call node to lambda expression node. call: ast.Call node
tools/nni_annotation/code_generator.py
def make_lambda(call): """Wrap an AST Call node to lambda expression node. call: ast.Call node """ empty_args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) return ast.Lambda(args=empty_args, body=call)
def make_lambda(call): """Wrap an AST Call node to lambda expression node. call: ast.Call node """ empty_args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) return ast.Lambda(args=empty_args, body=call)
[ "Wrap", "an", "AST", "Call", "node", "to", "lambda", "expression", "node", ".", "call", ":", "ast", ".", "Call", "node" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L121-L126
[ "def", "make_lambda", "(", "call", ")", ":", "empty_args", "=", "ast", ".", "arguments", "(", "args", "=", "[", "]", ",", "vararg", "=", "None", ",", "kwarg", "=", "None", ",", "defaults", "=", "[", "]", ")", "return", "ast", ".", "Lambda", "(", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
replace_variable_node
Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string
tools/nni_annotation/code_generator.py
def replace_variable_node(node, annotation): """Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string """ assert type(node) is ast.Assign, 'nni.variable is not annotating assignment expression' assert len(node.targets) == 1, 'Annotated assignment...
def replace_variable_node(node, annotation): """Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string """ assert type(node) is ast.Assign, 'nni.variable is not annotating assignment expression' assert len(node.targets) == 1, 'Annotated assignment...
[ "Replace", "a", "node", "annotated", "by", "nni", ".", "variable", ".", "node", ":", "the", "AST", "node", "to", "replace", "annotation", ":", "annotation", "string" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L148-L158
[ "def", "replace_variable_node", "(", "node", ",", "annotation", ")", ":", "assert", "type", "(", "node", ")", "is", "ast", ".", "Assign", ",", "'nni.variable is not annotating assignment expression'", "assert", "len", "(", "node", ".", "targets", ")", "==", "1",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
replace_function_node
Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string
tools/nni_annotation/code_generator.py
def replace_function_node(node, annotation): """Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string """ target, funcs = parse_nni_function(annotation) FuncReplacer(funcs, target).visit(node) return node
def replace_function_node(node, annotation): """Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string """ target, funcs = parse_nni_function(annotation) FuncReplacer(funcs, target).visit(node) return node
[ "Replace", "a", "node", "annotated", "by", "nni", ".", "function_choice", ".", "node", ":", "the", "AST", "node", "to", "replace", "annotation", ":", "annotation", "string" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L161-L168
[ "def", "replace_function_node", "(", "node", ",", "annotation", ")", ":", "target", ",", "funcs", "=", "parse_nni_function", "(", "annotation", ")", "FuncReplacer", "(", "funcs", ",", "target", ")", ".", "visit", "(", "node", ")", "return", "node" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse
Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str)
tools/nni_annotation/code_generator.py
def parse(code): """Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') transformer = Transformer() try: ...
def parse(code): """Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str) """ try: ast_tree = ast.parse(code) except Exception: raise RuntimeError('Bad Python code') transformer = Transformer() try: ...
[ "Annotate", "user", "code", ".", "Return", "annotated", "code", "(", "str", ")", "if", "annotation", "detected", ";", "return", "None", "if", "not", ".", "code", ":", "original", "user", "code", "(", "str", ")" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_annotation/code_generator.py#L254-L281
[ "def", "parse", "(", "code", ")", ":", "try", ":", "ast_tree", "=", "ast", ".", "parse", "(", "code", ")", "except", "Exception", ":", "raise", "RuntimeError", "(", "'Bad Python code'", ")", "transformer", "=", "Transformer", "(", ")", "try", ":", "trans...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
main
main function.
src/sdk/pynni/nni/__main__.py
def main(): ''' main function. ''' args = parse_args() if args.multi_thread: enable_multi_thread() if args.advisor_class_name: # advisor is enabled and starts to run if args.multi_phase: raise AssertionError('multi_phase has not been supported in advisor') ...
def main(): ''' main function. ''' args = parse_args() if args.multi_thread: enable_multi_thread() if args.advisor_class_name: # advisor is enabled and starts to run if args.multi_phase: raise AssertionError('multi_phase has not been supported in advisor') ...
[ "main", "function", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/__main__.py#L121-L198
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "if", "args", ".", "multi_thread", ":", "enable_multi_thread", "(", ")", "if", "args", ".", "advisor_class_name", ":", "# advisor is enabled and starts to run", "if", "args", ".", "multi_phase", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_yml_content
Load yaml file content
tools/nni_cmd/common_utils.py
def get_yml_content(file_path): '''Load yaml file content''' try: with open(file_path, 'r') as file: return yaml.load(file, Loader=yaml.Loader) except yaml.scanner.ScannerError as err: print_error('yaml file format error!') exit(1) except Exception as exception: ...
def get_yml_content(file_path): '''Load yaml file content''' try: with open(file_path, 'r') as file: return yaml.load(file, Loader=yaml.Loader) except yaml.scanner.ScannerError as err: print_error('yaml file format error!') exit(1) except Exception as exception: ...
[ "Load", "yaml", "file", "content" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/common_utils.py#L30-L40
[ "def", "get_yml_content", "(", "file_path", ")", ":", "try", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "file", ":", "return", "yaml", ".", "load", "(", "file", ",", "Loader", "=", "yaml", ".", "Loader", ")", "except", "yaml", ".",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
detect_port
Detect if the port is used
tools/nni_cmd/common_utils.py
def detect_port(port): '''Detect if the port is used''' socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
def detect_port(port): '''Detect if the port is used''' socket_test = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: socket_test.connect(('127.0.0.1', int(port))) socket_test.close() return True except: return False
[ "Detect", "if", "the", "port", "is", "used" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/common_utils.py#L71-L79
[ "def", "detect_port", "(", "port", ")", ":", "socket_test", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "socket_test", ".", "connect", "(", "(", "'127.0.0.1'", ",", "int", "(", "port", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
create_model
Create the Gaussian Mixture Model
src/sdk/pynni/nni/metis_tuner/Regression_GMM/CreateModel.py
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34): ''' Create the Gaussian Mixture Model ''' samples = [samples_x[i] + [samples_y_aggregation[i]] for i in range(0, len(samples_x))] # Sorts so that we can get the top samples samples = sorted(samples, key=itemgetter(-1...
def create_model(samples_x, samples_y_aggregation, percentage_goodbatch=0.34): ''' Create the Gaussian Mixture Model ''' samples = [samples_x[i] + [samples_y_aggregation[i]] for i in range(0, len(samples_x))] # Sorts so that we can get the top samples samples = sorted(samples, key=itemgetter(-1...
[ "Create", "the", "Gaussian", "Mixture", "Model" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GMM/CreateModel.py#L30-L57
[ "def", "create_model", "(", "samples_x", ",", "samples_y_aggregation", ",", "percentage_goodbatch", "=", "0.34", ")", ":", "samples", "=", "[", "samples_x", "[", "i", "]", "+", "[", "samples_y_aggregation", "[", "i", "]", "]", "for", "i", "in", "range", "(...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
selection_r
Selecte R value
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
def selection_r(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, num_starting_points=100, minimize_constraints_fun=None): ''' Selecte R value ''' minimize_starting_points = [lib_d...
def selection_r(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, num_starting_points=100, minimize_constraints_fun=None): ''' Selecte R value ''' minimize_starting_points = [lib_d...
[ "Selecte", "R", "value" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py#L37-L54
[ "def", "selection_r", "(", "acquisition_function", ",", "samples_y_aggregation", ",", "x_bounds", ",", "x_types", ",", "regressor_gp", ",", "num_starting_points", "=", "100", ",", "minimize_constraints_fun", "=", "None", ")", ":", "minimize_starting_points", "=", "[",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
selection
selection
src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py
def selection(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, minimize_starting_points, minimize_constraints_fun=None): ''' selection ''' outputs = None sys.stderr.write("[%s] Exercise \"%s\" acquisi...
def selection(acquisition_function, samples_y_aggregation, x_bounds, x_types, regressor_gp, minimize_starting_points, minimize_constraints_fun=None): ''' selection ''' outputs = None sys.stderr.write("[%s] Exercise \"%s\" acquisi...
[ "selection" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/metis_tuner/Regression_GP/Selection.py#L56-L83
[ "def", "selection", "(", "acquisition_function", ",", "samples_y_aggregation", ",", "x_bounds", ",", "x_types", ",", "regressor_gp", ",", "minimize_starting_points", ",", "minimize_constraints_fun", "=", "None", ")", ":", "outputs", "=", "None", "sys", ".", "stderr"...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
report_intermediate_result
Reports intermediate result to Assessor. metric: serializable object.
src/sdk/pynni/nni/trial.py
def report_intermediate_result(metric): """Reports intermediate result to Assessor. metric: serializable object. """ global _intermediate_seq assert _params is not None, 'nni.get_next_parameter() needs to be called before report_intermediate_result' metric = json_tricks.dumps({ 'paramete...
def report_intermediate_result(metric): """Reports intermediate result to Assessor. metric: serializable object. """ global _intermediate_seq assert _params is not None, 'nni.get_next_parameter() needs to be called before report_intermediate_result' metric = json_tricks.dumps({ 'paramete...
[ "Reports", "intermediate", "result", "to", "Assessor", ".", "metric", ":", "serializable", "object", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/trial.py#L60-L74
[ "def", "report_intermediate_result", "(", "metric", ")", ":", "global", "_intermediate_seq", "assert", "_params", "is", "not", "None", ",", "'nni.get_next_parameter() needs to be called before report_intermediate_result'", "metric", "=", "json_tricks", ".", "dumps", "(", "{...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
report_final_result
Reports final result to tuner. metric: serializable object.
src/sdk/pynni/nni/trial.py
def report_final_result(metric): """Reports final result to tuner. metric: serializable object. """ assert _params is not None, 'nni.get_next_parameter() needs to be called before report_final_result' metric = json_tricks.dumps({ 'parameter_id': _params['parameter_id'], 'trial_job_id...
def report_final_result(metric): """Reports final result to tuner. metric: serializable object. """ assert _params is not None, 'nni.get_next_parameter() needs to be called before report_final_result' metric = json_tricks.dumps({ 'parameter_id': _params['parameter_id'], 'trial_job_id...
[ "Reports", "final", "result", "to", "tuner", ".", "metric", ":", "serializable", "object", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/src/sdk/pynni/nni/trial.py#L77-L89
[ "def", "report_final_result", "(", "metric", ")", ":", "assert", "_params", "is", "not", "None", ",", "'nni.get_next_parameter() needs to be called before report_final_result'", "metric", "=", "json_tricks", ".", "dumps", "(", "{", "'parameter_id'", ":", "_params", "[",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
get_args
get args from command line
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
def get_args(): """ get args from command line """ parser = argparse.ArgumentParser("FashionMNIST") parser.add_argument("--batch_size", type=int, default=128, help="batch size") parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer") parser.add_argument("--epochs", type=int...
def get_args(): """ get args from command line """ parser = argparse.ArgumentParser("FashionMNIST") parser.add_argument("--batch_size", type=int, default=128, help="batch size") parser.add_argument("--optimizer", type=str, default="SGD", help="optimizer") parser.add_argument("--epochs", type=int...
[ "get", "args", "from", "command", "line" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L47-L62
[ "def", "get_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "\"FashionMNIST\"", ")", "parser", ".", "add_argument", "(", "\"--batch_size\"", ",", "type", "=", "int", ",", "default", "=", "128", ",", "help", "=", "\"batch size\"",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
build_graph_from_json
build model from json representation
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
def build_graph_from_json(ir_model_json): """build model from json representation """ graph = json_to_graph(ir_model_json) logging.debug(graph.operation_history) model = graph.produce_torch_model() return model
def build_graph_from_json(ir_model_json): """build model from json representation """ graph = json_to_graph(ir_model_json) logging.debug(graph.operation_history) model = graph.produce_torch_model() return model
[ "build", "model", "from", "json", "representation" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L75-L81
[ "def", "build_graph_from_json", "(", "ir_model_json", ")", ":", "graph", "=", "json_to_graph", "(", "ir_model_json", ")", "logging", ".", "debug", "(", "graph", ".", "operation_history", ")", "model", "=", "graph", ".", "produce_torch_model", "(", ")", "return",...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_rev_args
parse reveive msgs to global variable
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") raw_train_data = torchvision.datasets.FashionMNIST( root="./d...
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") raw_train_data = torchvision.datasets.FashionMNIST( root="./d...
[ "parse", "reveive", "msgs", "to", "global", "variable" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L84-L145
[ "def", "parse_rev_args", "(", "receive_msg", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "# Loading Data", "logger", ".", "debug", "(", "\"Preparing data..\"", ")", "raw_train_data", "=", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
train
train model on each epoch in trainset
examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py
def train(epoch): """ train model on each epoch in trainset """ global trainloader global testloader global net global criterion global optimizer logger.debug("Epoch: %d", epoch) net.train() train_loss = 0 correct = 0 total = 0 for batch_idx, (inputs, targets) in e...
def train(epoch): """ train model on each epoch in trainset """ global trainloader global testloader global net global criterion global optimizer logger.debug("Epoch: %d", epoch) net.train() train_loss = 0 correct = 0 total = 0 for batch_idx, (inputs, targets) in e...
[ "train", "model", "on", "each", "epoch", "in", "trainset" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/FashionMNIST/FashionMNIST_pytorch.py#L149-L188
[ "def", "train", "(", "epoch", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "logger", ".", "debug", "(", "\"Epoch: %d\"", ",", "epoch", ")", "net", ".", "train", "(", ")", "train_los...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
UNetResNetV4.freeze_bn
Freeze BatchNorm layers.
examples/trials/kaggle-tgs-salt/models.py
def freeze_bn(self): '''Freeze BatchNorm layers.''' for layer in self.modules(): if isinstance(layer, nn.BatchNorm2d): layer.eval()
def freeze_bn(self): '''Freeze BatchNorm layers.''' for layer in self.modules(): if isinstance(layer, nn.BatchNorm2d): layer.eval()
[ "Freeze", "BatchNorm", "layers", "." ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/kaggle-tgs-salt/models.py#L210-L214
[ "def", "freeze_bn", "(", "self", ")", ":", "for", "layer", "in", "self", ".", "modules", "(", ")", ":", "if", "isinstance", "(", "layer", ",", "nn", ".", "BatchNorm2d", ")", ":", "layer", ".", "eval", "(", ")" ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
parse_rev_args
parse reveive msgs to global variable
examples/trials/network_morphism/cifar10/cifar10_pytorch.py
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") transform_train, transform_test = utils.data_transforms_cifar10(args)...
def parse_rev_args(receive_msg): """ parse reveive msgs to global variable """ global trainloader global testloader global net global criterion global optimizer # Loading Data logger.debug("Preparing data..") transform_train, transform_test = utils.data_transforms_cifar10(args)...
[ "parse", "reveive", "msgs", "to", "global", "variable" ]
Microsoft/nni
python
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/network_morphism/cifar10/cifar10_pytorch.py#L83-L136
[ "def", "parse_rev_args", "(", "receive_msg", ")", ":", "global", "trainloader", "global", "testloader", "global", "net", "global", "criterion", "global", "optimizer", "# Loading Data", "logger", ".", "debug", "(", "\"Preparing data..\"", ")", "transform_train", ",", ...
c7cc8db32da8d2ec77a382a55089f4e17247ce41
train
WebTrader.prepare
登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 :param portfolio_market: [雪球登录需要]交易市场, 可选['cn', 'us', 'hk'] 默认 'cn'
easytrader/webtrader.py
def prepare(self, config_file=None, user=None, password=None, **kwargs): """登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 ...
def prepare(self, config_file=None, user=None, password=None, **kwargs): """登录的统一接口 :param config_file 登录数据文件,若无则选择参数登录模式 :param user: 各家券商的账号或者雪球的用户名 :param password: 密码, 券商为加密后的密码,雪球为明文密码 :param account: [雪球登录需要]雪球手机号(邮箱手机二选一) :param portfolio_code: [雪球登录需要]组合代码 ...
[ "登录的统一接口", ":", "param", "config_file", "登录数据文件,若无则选择参数登录模式", ":", "param", "user", ":", "各家券商的账号或者雪球的用户名", ":", "param", "password", ":", "密码", "券商为加密后的密码,雪球为明文密码", ":", "param", "account", ":", "[", "雪球登录需要", "]", "雪球手机号", "(", "邮箱手机二选一", ")", ":", "param", ...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L40-L54
[ "def", "prepare", "(", "self", ",", "config_file", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "config_file", "is", "not", "None", ":", "self", ".", "read_config", "(", "config_file", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.autologin
实现自动登录 :param limit: 登录次数限制
easytrader/webtrader.py
def autologin(self, limit=10): """实现自动登录 :param limit: 登录次数限制 """ for _ in range(limit): if self.login(): break else: raise exceptions.NotLoginError( "登录失败次数过多, 请检查密码是否正确 / 券商服务器是否处于维护中 / 网络连接是否正常" ) self...
def autologin(self, limit=10): """实现自动登录 :param limit: 登录次数限制 """ for _ in range(limit): if self.login(): break else: raise exceptions.NotLoginError( "登录失败次数过多, 请检查密码是否正确 / 券商服务器是否处于维护中 / 网络连接是否正常" ) self...
[ "实现自动登录", ":", "param", "limit", ":", "登录次数限制" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L60-L71
[ "def", "autologin", "(", "self", ",", "limit", "=", "10", ")", ":", "for", "_", "in", "range", "(", "limit", ")", ":", "if", "self", ".", "login", "(", ")", ":", "break", "else", ":", "raise", "exceptions", ".", "NotLoginError", "(", "\"登录失败次数过多, 请检查...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.keepalive
启动保持在线的进程
easytrader/webtrader.py
def keepalive(self): """启动保持在线的进程 """ if self.heart_thread.is_alive(): self.heart_active = True else: self.heart_thread.start()
def keepalive(self): """启动保持在线的进程 """ if self.heart_thread.is_alive(): self.heart_active = True else: self.heart_thread.start()
[ "启动保持在线的进程" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L76-L81
[ "def", "keepalive", "(", "self", ")", ":", "if", "self", ".", "heart_thread", ".", "is_alive", "(", ")", ":", "self", ".", "heart_active", "=", "True", "else", ":", "self", ".", "heart_thread", ".", "start", "(", ")" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.__read_config
读取 config
easytrader/webtrader.py
def __read_config(self): """读取 config""" self.config = helpers.file2dict(self.config_path) self.global_config = helpers.file2dict(self.global_config_path) self.config.update(self.global_config)
def __read_config(self): """读取 config""" self.config = helpers.file2dict(self.config_path) self.global_config = helpers.file2dict(self.global_config_path) self.config.update(self.global_config)
[ "读取", "config" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L116-L120
[ "def", "__read_config", "(", "self", ")", ":", "self", ".", "config", "=", "helpers", ".", "file2dict", "(", "self", ".", "config_path", ")", "self", ".", "global_config", "=", "helpers", ".", "file2dict", "(", "self", ".", "global_config_path", ")", "self...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.exchangebill
默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return:
easytrader/webtrader.py
def exchangebill(self): """ 默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return: """ # TODO 目前仅在 华泰子类 中实现 start_date, end_date = helpers.get_30_date() return self.get_exchangebill(start_date, end_date)
def exchangebill(self): """ 默认提供最近30天的交割单, 通常只能返回查询日期内最新的 90 天数据。 :return: """ # TODO 目前仅在 华泰子类 中实现 start_date, end_date = helpers.get_30_date() return self.get_exchangebill(start_date, end_date)
[ "默认提供最近30天的交割单", "通常只能返回查询日期内最新的", "90", "天数据。", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L156-L163
[ "def", "exchangebill", "(", "self", ")", ":", "# TODO 目前仅在 华泰子类 中实现", "start_date", ",", "end_date", "=", "helpers", ".", "get_30_date", "(", ")", "return", "self", ".", "get_exchangebill", "(", "start_date", ",", "end_date", ")" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.do
发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数
easytrader/webtrader.py
def do(self, params): """发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数""" request_params = self.create_basic_params() request_params.update(params) response_data = self.request(request_params) try: format_json_data = self.format_response_data(response_data) ...
def do(self, params): """发起对 api 的请求并过滤返回结果 :param params: 交易所需的动态参数""" request_params = self.create_basic_params() request_params.update(params) response_data = self.request(request_params) try: format_json_data = self.format_response_data(response_data) ...
[ "发起对", "api", "的请求并过滤返回结果", ":", "param", "params", ":", "交易所需的动态参数" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L182-L199
[ "def", "do", "(", "self", ",", "params", ")", ":", "request_params", "=", "self", ".", "create_basic_params", "(", ")", "request_params", ".", "update", "(", "params", ")", "response_data", "=", "self", ".", "request", "(", "request_params", ")", "try", ":...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
WebTrader.format_response_data_type
格式化返回的值为正确的类型 :param response_data: 返回的数据
easytrader/webtrader.py
def format_response_data_type(self, response_data): """格式化返回的值为正确的类型 :param response_data: 返回的数据 """ if isinstance(response_data, list) and not isinstance( response_data, str ): return response_data int_match_str = "|".join(self.config["response_f...
def format_response_data_type(self, response_data): """格式化返回的值为正确的类型 :param response_data: 返回的数据 """ if isinstance(response_data, list) and not isinstance( response_data, str ): return response_data int_match_str = "|".join(self.config["response_f...
[ "格式化返回的值为正确的类型", ":", "param", "response_data", ":", "返回的数据" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/webtrader.py#L220-L240
[ "def", "format_response_data_type", "(", "self", ",", "response_data", ")", ":", "if", "isinstance", "(", "response_data", ",", "list", ")", "and", "not", "isinstance", "(", "response_data", ",", "str", ")", ":", "return", "response_data", "int_match_str", "=", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
RemoteClient.prepare
登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 r'C:\\htzqzyb2\\xiadan.exe', 默认 r'C:\\htzqzyb2\\xiadan.exe' :param comm_password: 通讯密码 :return:
easytrader/remoteclient.py
def prepare( self, config_path=None, user=None, password=None, exe_path=None, comm_password=None, **kwargs ): """ 登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path:...
def prepare( self, config_path=None, user=None, password=None, exe_path=None, comm_password=None, **kwargs ): """ 登陆客户端 :param config_path: 登陆配置文件,跟参数登陆方式二选一 :param user: 账号 :param password: 明文密码 :param exe_path:...
[ "登陆客户端", ":", "param", "config_path", ":", "登陆配置文件,跟参数登陆方式二选一", ":", "param", "user", ":", "账号", ":", "param", "password", ":", "明文密码", ":", "param", "exe_path", ":", "客户端路径类似", "r", "C", ":", "\\\\", "htzqzyb2", "\\\\", "xiadan", ".", "exe", "默认", "r", ...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/remoteclient.py#L17-L48
[ "def", "prepare", "(", "self", ",", "config_path", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "exe_path", "=", "None", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "locals", "(", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
RiceQuantFollower.follow
跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_id: ricequant 的模拟交易ID,支持使用 [] 指定多个模拟交易 :param track_interval: 轮训模拟交易时间,单位为秒 :param trade_cmd_expire_seconds: 交易指令过期时间, 单位为秒 :param cmd_cache: 是否读取存储历史执行过的指令,防止重启时重复执行已经交易过的指令 :param entr...
easytrader/ricequant_follower.py
def follow( self, users, run_id, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, entrust_prop="limit", send_interval=0, ): """跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_...
def follow( self, users, run_id, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, entrust_prop="limit", send_interval=0, ): """跟踪ricequant对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param run_...
[ "跟踪ricequant对应的模拟交易,支持多用户多策略", ":", "param", "users", ":", "支持easytrader的用户对象,支持使用", "[]", "指定多个用户", ":", "param", "run_id", ":", "ricequant", "的模拟交易ID,支持使用", "[]", "指定多个模拟交易", ":", "param", "track_interval", ":", "轮训模拟交易时间,单位为秒", ":", "param", "trade_cmd_expire_seconds...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/ricequant_follower.py#L20-L61
[ "def", "follow", "(", "self", ",", "users", ",", "run_id", ",", "track_interval", "=", "1", ",", "trade_cmd_expire_seconds", "=", "120", ",", "cmd_cache", "=", "True", ",", "entrust_prop", "=", "\"limit\"", ",", "send_interval", "=", "0", ",", ")", ":", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
GJClientTrader.login
登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 :return:
easytrader/gj_clienttrader.py
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ 登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 ...
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ 登陆客户端 :param user: 账号 :param password: 明文密码 :param exe_path: 客户端路径类似 'C:\\中国银河证券双子星3.2\\Binarystar.exe', 默认 'C:\\中国银河证券双子星3.2\\Binarystar.exe' :param comm_password: 通讯密码, 华泰需要,可不设 ...
[ "登陆客户端" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/gj_clienttrader.py#L17-L69
[ "def", "login", "(", "self", ",", "user", ",", "password", ",", "exe_path", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_app", "=", "pywinauto", ".", "Application", "(", ")", ".", "connect", "(", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
HTClientTrader.login
:param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return:
easytrader/ht_clienttrader.py
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ :param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return: """ if comm_password is None: raise Val...
def login(self, user, password, exe_path, comm_password=None, **kwargs): """ :param user: 用户名 :param password: 密码 :param exe_path: 客户端路径, 类似 :param comm_password: :param kwargs: :return: """ if comm_password is None: raise Val...
[ ":", "param", "user", ":", "用户名", ":", "param", "password", ":", "密码", ":", "param", "exe_path", ":", "客户端路径", "类似", ":", "param", "comm_password", ":", ":", "param", "kwargs", ":", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/ht_clienttrader.py#L13-L55
[ "def", "login", "(", "self", ",", "user", ",", "password", ",", "exe_path", ",", "comm_password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "comm_password", "is", "None", ":", "raise", "ValueError", "(", "\"华泰必须设置通讯密码\")\r", "", "try", ":", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuFollower.login
雪球登陆, 需要设置 cookies :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :return:
easytrader/xq_follower.py
def login(self, user=None, password=None, **kwargs): """ 雪球登陆, 需要设置 cookies :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :return: """ cookies = kwargs.get('cookies') if cookies is None: raise TypeErro...
def login(self, user=None, password=None, **kwargs): """ 雪球登陆, 需要设置 cookies :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :return: """ cookies = kwargs.get('cookies') if cookies is None: raise TypeErro...
[ "雪球登陆,", "需要设置", "cookies", ":", "param", "cookies", ":", "雪球登陆需要设置", "cookies,", "具体见", "https", ":", "//", "smalltool", ".", "github", ".", "io", "/", "2016", "/", "08", "/", "02", "/", "cookie", "/", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xq_follower.py#L27-L46
[ "def", "login", "(", "self", ",", "user", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "cookies", "=", "kwargs", ".", "get", "(", "'cookies'", ")", "if", "cookies", "is", "None", ":", "raise", "TypeError", "(", "'雪球...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuFollower.follow
跟踪 joinquant 对应的模拟交易,支持多用户多策略 :param users: 支持 easytrader 的用户对象,支持使用 [] 指定多个用户 :param strategies: 雪球组合名, 类似 ZH123450 :param total_assets: 雪球组合对应的总资产, 格式 [组合1对应资金, 组合2对应资金] 若 strategies=['ZH000001', 'ZH000002'], 设置 total_assets=[10000, 10000], 则表明每个组合对应的资产为 1w 元 ...
easytrader/xq_follower.py
def follow( # type: ignore self, users, strategies, total_assets=10000, initial_assets=None, adjust_sell=False, track_interval=10, trade_cmd_expire_seconds=120, cmd_cache=True, slippage: float = 0.0)...
def follow( # type: ignore self, users, strategies, total_assets=10000, initial_assets=None, adjust_sell=False, track_interval=10, trade_cmd_expire_seconds=120, cmd_cache=True, slippage: float = 0.0)...
[ "跟踪", "joinquant", "对应的模拟交易,支持多用户多策略", ":", "param", "users", ":", "支持", "easytrader", "的用户对象,支持使用", "[]", "指定多个用户", ":", "param", "strategies", ":", "雪球组合名", "类似", "ZH123450", ":", "param", "total_assets", ":", "雪球组合对应的总资产,", "格式", "[", "组合1对应资金", "组合2对应资金", ...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xq_follower.py#L48-L117
[ "def", "follow", "(", "# type: ignore", "self", ",", "users", ",", "strategies", ",", "total_assets", "=", "10000", ",", "initial_assets", "=", "None", ",", "adjust_sell", "=", "False", ",", "track_interval", "=", "10", ",", "trade_cmd_expire_seconds", "=", "1...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuFollower._adjust_sell_amount
根据实际持仓值计算雪球卖出股数 因为雪球的交易指令是基于持仓百分比,在取近似值的情况下可能出现不精确的问题。 导致如下情况的产生,计算出的指令为买入 1049 股,取近似值买入 1000 股。 而卖出的指令计算出为卖出 1051 股,取近似值卖出 1100 股,超过 1000 股的买入量, 导致卖出失败 :param stock_code: 证券代码 :type stock_code: str :param amount: 卖出股份数 :type amount: int :return:...
easytrader/xq_follower.py
def _adjust_sell_amount(self, stock_code, amount): """ 根据实际持仓值计算雪球卖出股数 因为雪球的交易指令是基于持仓百分比,在取近似值的情况下可能出现不精确的问题。 导致如下情况的产生,计算出的指令为买入 1049 股,取近似值买入 1000 股。 而卖出的指令计算出为卖出 1051 股,取近似值卖出 1100 股,超过 1000 股的买入量, 导致卖出失败 :param stock_code: 证券代码 :type stock_code: str ...
def _adjust_sell_amount(self, stock_code, amount): """ 根据实际持仓值计算雪球卖出股数 因为雪球的交易指令是基于持仓百分比,在取近似值的情况下可能出现不精确的问题。 导致如下情况的产生,计算出的指令为买入 1049 股,取近似值买入 1000 股。 而卖出的指令计算出为卖出 1051 股,取近似值卖出 1100 股,超过 1000 股的买入量, 导致卖出失败 :param stock_code: 证券代码 :type stock_code: str ...
[ "根据实际持仓值计算雪球卖出股数", "因为雪球的交易指令是基于持仓百分比,在取近似值的情况下可能出现不精确的问题。", "导致如下情况的产生,计算出的指令为买入", "1049", "股,取近似值买入", "1000", "股。", "而卖出的指令计算出为卖出", "1051", "股,取近似值卖出", "1100", "股,超过", "1000", "股的买入量,", "导致卖出失败", ":", "param", "stock_code", ":", "证券代码", ":", "type", "stock_code", ":",...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xq_follower.py#L192-L223
[ "def", "_adjust_sell_amount", "(", "self", ",", "stock_code", ",", "amount", ")", ":", "stock_code", "=", "stock_code", "[", "-", "6", ":", "]", "user", "=", "self", ".", "_users", "[", "0", "]", "position", "=", "user", ".", "position", "try", ":", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuFollower._get_portfolio_info
获取组合信息
easytrader/xq_follower.py
def _get_portfolio_info(self, portfolio_code): """ 获取组合信息 """ url = self.PORTFOLIO_URL + portfolio_code portfolio_page = self.s.get(url) match_info = re.search(r'(?<=SNB.cubeInfo = ).*(?=;\n)', portfolio_page.text) if match_info is N...
def _get_portfolio_info(self, portfolio_code): """ 获取组合信息 """ url = self.PORTFOLIO_URL + portfolio_code portfolio_page = self.s.get(url) match_info = re.search(r'(?<=SNB.cubeInfo = ).*(?=;\n)', portfolio_page.text) if match_info is N...
[ "获取组合信息" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xq_follower.py#L225-L240
[ "def", "_get_portfolio_info", "(", "self", ",", "portfolio_code", ")", ":", "url", "=", "self", ".", "PORTFOLIO_URL", "+", "portfolio_code", "portfolio_page", "=", "self", ".", "s", ".", "get", "(", "url", ")", "match_info", "=", "re", ".", "search", "(", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
parse_cookies_str
parse cookies str to dict :param cookies: cookies str :type cookies: str :return: cookie dict :rtype: dict
easytrader/helpers.py
def parse_cookies_str(cookies): """ parse cookies str to dict :param cookies: cookies str :type cookies: str :return: cookie dict :rtype: dict """ cookie_dict = {} for record in cookies.split(";"): key, value = record.strip().split("=", 1) cookie_dict[key] = value ...
def parse_cookies_str(cookies): """ parse cookies str to dict :param cookies: cookies str :type cookies: str :return: cookie dict :rtype: dict """ cookie_dict = {} for record in cookies.split(";"): key, value = record.strip().split("=", 1) cookie_dict[key] = value ...
[ "parse", "cookies", "str", "to", "dict", ":", "param", "cookies", ":", "cookies", "str", ":", "type", "cookies", ":", "str", ":", "return", ":", "cookie", "dict", ":", "rtype", ":", "dict" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L12-L24
[ "def", "parse_cookies_str", "(", "cookies", ")", ":", "cookie_dict", "=", "{", "}", "for", "record", "in", "cookies", ".", "split", "(", "\";\"", ")", ":", "key", ",", "value", "=", "record", ".", "strip", "(", ")", ".", "split", "(", "\"=\"", ",", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
get_stock_type
判断股票ID对应的证券市场 匹配规则 ['50', '51', '60', '90', '110'] 为 sh ['00', '13', '18', '15', '16', '18', '20', '30', '39', '115'] 为 sz ['5', '6', '9'] 开头的为 sh, 其余为 sz :param stock_code:股票ID, 若以 'sz', 'sh' 开头直接返回对应类型,否则使用内置规则判断 :return 'sh' or 'sz
easytrader/helpers.py
def get_stock_type(stock_code): """判断股票ID对应的证券市场 匹配规则 ['50', '51', '60', '90', '110'] 为 sh ['00', '13', '18', '15', '16', '18', '20', '30', '39', '115'] 为 sz ['5', '6', '9'] 开头的为 sh, 其余为 sz :param stock_code:股票ID, 若以 'sz', 'sh' 开头直接返回对应类型,否则使用内置规则判断 :return 'sh' or 'sz'""" stock_code = s...
def get_stock_type(stock_code): """判断股票ID对应的证券市场 匹配规则 ['50', '51', '60', '90', '110'] 为 sh ['00', '13', '18', '15', '16', '18', '20', '30', '39', '115'] 为 sz ['5', '6', '9'] 开头的为 sh, 其余为 sz :param stock_code:股票ID, 若以 'sz', 'sh' 开头直接返回对应类型,否则使用内置规则判断 :return 'sh' or 'sz'""" stock_code = s...
[ "判断股票ID对应的证券市场", "匹配规则", "[", "50", "51", "60", "90", "110", "]", "为", "sh", "[", "00", "13", "18", "15", "16", "18", "20", "30", "39", "115", "]", "为", "sz", "[", "5", "6", "9", "]", "开头的为", "sh,", "其余为", "sz", ":", "param", "stock_code", ":...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L32-L53
[ "def", "get_stock_type", "(", "stock_code", ")", ":", "stock_code", "=", "str", "(", "stock_code", ")", "if", "stock_code", ".", "startswith", "(", "(", "\"sh\"", ",", "\"sz\"", ")", ")", ":", "return", "stock_code", "[", ":", "2", "]", "if", "stock_code...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
recognize_verify_code
识别验证码,返回识别后的字符串,使用 tesseract 实现 :param image_path: 图片路径 :param broker: 券商 ['ht', 'yjb', 'gf', 'yh'] :return recognized: verify code string
easytrader/helpers.py
def recognize_verify_code(image_path, broker="ht"): """识别验证码,返回识别后的字符串,使用 tesseract 实现 :param image_path: 图片路径 :param broker: 券商 ['ht', 'yjb', 'gf', 'yh'] :return recognized: verify code string""" if broker == "gf": return detect_gf_result(image_path) if broker in ["yh_client", "gj_clie...
def recognize_verify_code(image_path, broker="ht"): """识别验证码,返回识别后的字符串,使用 tesseract 实现 :param image_path: 图片路径 :param broker: 券商 ['ht', 'yjb', 'gf', 'yh'] :return recognized: verify code string""" if broker == "gf": return detect_gf_result(image_path) if broker in ["yh_client", "gj_clie...
[ "识别验证码,返回识别后的字符串,使用", "tesseract", "实现", ":", "param", "image_path", ":", "图片路径", ":", "param", "broker", ":", "券商", "[", "ht", "yjb", "gf", "yh", "]", ":", "return", "recognized", ":", "verify", "code", "string" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L56-L67
[ "def", "recognize_verify_code", "(", "image_path", ",", "broker", "=", "\"ht\"", ")", ":", "if", "broker", "==", "\"gf\"", ":", "return", "detect_gf_result", "(", "image_path", ")", "if", "broker", "in", "[", "\"yh_client\"", ",", "\"gj_client\"", "]", ":", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
detect_yh_client_result
封装了tesseract的识别,部署在阿里云上,服务端源码地址为: https://github.com/shidenggui/yh_verify_code_docker
easytrader/helpers.py
def detect_yh_client_result(image_path): """封装了tesseract的识别,部署在阿里云上,服务端源码地址为: https://github.com/shidenggui/yh_verify_code_docker""" api = "http://yh.ez.shidenggui.com:5000/yh_client" with open(image_path, "rb") as f: rep = requests.post(api, files={"image": f}) if rep.status_code != 201: ...
def detect_yh_client_result(image_path): """封装了tesseract的识别,部署在阿里云上,服务端源码地址为: https://github.com/shidenggui/yh_verify_code_docker""" api = "http://yh.ez.shidenggui.com:5000/yh_client" with open(image_path, "rb") as f: rep = requests.post(api, files={"image": f}) if rep.status_code != 201: ...
[ "封装了tesseract的识别,部署在阿里云上,服务端源码地址为:", "https", ":", "//", "github", ".", "com", "/", "shidenggui", "/", "yh_verify_code_docker" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L70-L78
[ "def", "detect_yh_client_result", "(", "image_path", ")", ":", "api", "=", "\"http://yh.ez.shidenggui.com:5000/yh_client\"", "with", "open", "(", "image_path", ",", "\"rb\"", ")", "as", "f", ":", "rep", "=", "requests", ".", "post", "(", "api", ",", "files", "...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
get_30_date
获得用于查询的默认日期, 今天的日期, 以及30天前的日期 用于查询的日期格式通常为 20160211 :return:
easytrader/helpers.py
def get_30_date(): """ 获得用于查询的默认日期, 今天的日期, 以及30天前的日期 用于查询的日期格式通常为 20160211 :return: """ now = datetime.datetime.now() end_date = now.date() start_date = end_date - datetime.timedelta(days=30) return start_date.strftime("%Y%m%d"), end_date.strftime("%Y%m%d")
def get_30_date(): """ 获得用于查询的默认日期, 今天的日期, 以及30天前的日期 用于查询的日期格式通常为 20160211 :return: """ now = datetime.datetime.now() end_date = now.date() start_date = end_date - datetime.timedelta(days=30) return start_date.strftime("%Y%m%d"), end_date.strftime("%Y%m%d")
[ "获得用于查询的默认日期", "今天的日期", "以及30天前的日期", "用于查询的日期格式通常为", "20160211", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L142-L151
[ "def", "get_30_date", "(", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "end_date", "=", "now", ".", "date", "(", ")", "start_date", "=", "end_date", "-", "datetime", ".", "timedelta", "(", "days", "=", "30", ")", "return"...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
get_today_ipo_data
查询今天可以申购的新股信息 :return: 今日可申购新股列表 apply_code申购代码 price发行价格
easytrader/helpers.py
def get_today_ipo_data(): """ 查询今天可以申购的新股信息 :return: 今日可申购新股列表 apply_code申购代码 price发行价格 """ agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0" send_headers = { "Host": "xueqiu.com", "User-Agent": agent, "Accept": "application/jso...
def get_today_ipo_data(): """ 查询今天可以申购的新股信息 :return: 今日可申购新股列表 apply_code申购代码 price发行价格 """ agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0" send_headers = { "Host": "xueqiu.com", "User-Agent": agent, "Accept": "application/jso...
[ "查询今天可以申购的新股信息", ":", "return", ":", "今日可申购新股列表", "apply_code申购代码", "price发行价格" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/helpers.py#L154-L200
[ "def", "get_today_ipo_data", "(", ")", ":", "agent", "=", "\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0\"", "send_headers", "=", "{", "\"Host\"", ":", "\"xueqiu.com\"", ",", "\"User-Agent\"", ":", "agent", ",", "\"Accept\"", ":", "\"a...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower.login
登陆接口 :param user: 用户名 :param password: 密码 :param kwargs: 其他参数 :return:
easytrader/follower.py
def login(self, user=None, password=None, **kwargs): """ 登陆接口 :param user: 用户名 :param password: 密码 :param kwargs: 其他参数 :return: """ headers = self._generate_headers() self.s.headers.update(headers) # init cookie self.s.get(self.LOG...
def login(self, user=None, password=None, **kwargs): """ 登陆接口 :param user: 用户名 :param password: 密码 :param kwargs: 其他参数 :return: """ headers = self._generate_headers() self.s.headers.update(headers) # init cookie self.s.get(self.LOG...
[ "登陆接口", ":", "param", "user", ":", "用户名", ":", "param", "password", ":", "密码", ":", "param", "kwargs", ":", "其他参数", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L39-L58
[ "def", "login", "(", "self", ",", "user", "=", "None", ",", "password", "=", "None", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "self", ".", "_generate_headers", "(", ")", "self", ".", "s", ".", "headers", ".", "update", "(", "headers", ")"...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower.follow
跟踪平台对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param strategies: 雪球组合名, 类似 ZH123450 :param total_assets: 雪球组合对应的总资产, 格式 [ 组合1对应资金, 组合2对应资金 ] 若 strategies=['ZH000001', 'ZH000002'] 设置 total_assets=[10000, 10000], 则表明每个组合对应的资产为 1w 元, 假设组合 ZH000001 加仓 价...
easytrader/follower.py
def follow( self, users, strategies, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, slippage: float = 0.0, **kwargs ): """跟踪平台对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param strategies: 雪...
def follow( self, users, strategies, track_interval=1, trade_cmd_expire_seconds=120, cmd_cache=True, slippage: float = 0.0, **kwargs ): """跟踪平台对应的模拟交易,支持多用户多策略 :param users: 支持easytrader的用户对象,支持使用 [] 指定多个用户 :param strategies: 雪...
[ "跟踪平台对应的模拟交易,支持多用户多策略" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L89-L113
[ "def", "follow", "(", "self", ",", "users", ",", "strategies", ",", "track_interval", "=", "1", ",", "trade_cmd_expire_seconds", "=", "120", ",", "cmd_cache", "=", "True", ",", "slippage", ":", "float", "=", "0.0", ",", "*", "*", "kwargs", ")", ":", "s...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower._calculate_price_by_slippage
计算考虑滑点之后的价格 :param action: 交易动作, 支持 ['buy', 'sell'] :param price: 原始交易价格 :return: 考虑滑点后的交易价格
easytrader/follower.py
def _calculate_price_by_slippage(self, action: str, price: float) -> float: """ 计算考虑滑点之后的价格 :param action: 交易动作, 支持 ['buy', 'sell'] :param price: 原始交易价格 :return: 考虑滑点后的交易价格 """ if action == "buy": return price * (1 + self.slippage) if action ==...
def _calculate_price_by_slippage(self, action: str, price: float) -> float: """ 计算考虑滑点之后的价格 :param action: 交易动作, 支持 ['buy', 'sell'] :param price: 原始交易价格 :return: 考虑滑点后的交易价格 """ if action == "buy": return price * (1 + self.slippage) if action ==...
[ "计算考虑滑点之后的价格", ":", "param", "action", ":", "交易动作,", "支持", "[", "buy", "sell", "]", ":", "param", "price", ":", "原始交易价格", ":", "return", ":", "考虑滑点后的交易价格" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L115-L126
[ "def", "_calculate_price_by_slippage", "(", "self", ",", "action", ":", "str", ",", "price", ":", "float", ")", "->", "float", ":", "if", "action", "==", "\"buy\"", ":", "return", "price", "*", "(", "1", "+", "self", ".", "slippage", ")", "if", "action...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower.track_strategy_worker
跟踪下单worker :param strategy: 策略id :param name: 策略名字 :param interval: 轮询策略的时间间隔,单位为秒
easytrader/follower.py
def track_strategy_worker(self, strategy, name, interval=10, **kwargs): """跟踪下单worker :param strategy: 策略id :param name: 策略名字 :param interval: 轮询策略的时间间隔,单位为秒""" while True: try: transactions = self.query_strategy_transaction( strate...
def track_strategy_worker(self, strategy, name, interval=10, **kwargs): """跟踪下单worker :param strategy: 策略id :param name: 策略名字 :param interval: 轮询策略的时间间隔,单位为秒""" while True: try: transactions = self.query_strategy_transaction( strate...
[ "跟踪下单worker", ":", "param", "strategy", ":", "策略id", ":", "param", "name", ":", "策略名字", ":", "param", "interval", ":", "轮询策略的时间间隔,单位为秒" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L175-L218
[ "def", "track_strategy_worker", "(", "self", ",", "strategy", ",", "name", ",", "interval", "=", "10", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "try", ":", "transactions", "=", "self", ".", "query_strategy_transaction", "(", "strategy", ","...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower._execute_trade_cmd
分发交易指令到对应的 user 并执行 :param trade_cmd: :param users: :param expire_seconds: :param entrust_prop: :param send_interval: :return:
easytrader/follower.py
def _execute_trade_cmd( self, trade_cmd, users, expire_seconds, entrust_prop, send_interval ): """分发交易指令到对应的 user 并执行 :param trade_cmd: :param users: :param expire_seconds: :param entrust_prop: :param send_interval: :return: """ for use...
def _execute_trade_cmd( self, trade_cmd, users, expire_seconds, entrust_prop, send_interval ): """分发交易指令到对应的 user 并执行 :param trade_cmd: :param users: :param expire_seconds: :param entrust_prop: :param send_interval: :return: """ for use...
[ "分发交易指令到对应的", "user", "并执行", ":", "param", "trade_cmd", ":", ":", "param", "users", ":", ":", "param", "expire_seconds", ":", ":", "param", "entrust_prop", ":", ":", "param", "send_interval", ":", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L250-L343
[ "def", "_execute_trade_cmd", "(", "self", ",", "trade_cmd", ",", "users", ",", "expire_seconds", ",", "entrust_prop", ",", "send_interval", ")", ":", "for", "user", "in", "users", ":", "# check expire", "now", "=", "datetime", ".", "datetime", ".", "now", "(...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
BaseFollower.trade_worker
:param send_interval: 交易发送间隔, 默认为0s。调大可防止卖出买入时买出单没有及时成交导致的买入金额不足
easytrader/follower.py
def trade_worker( self, users, expire_seconds=120, entrust_prop="limit", send_interval=0 ): """ :param send_interval: 交易发送间隔, 默认为0s。调大可防止卖出买入时买出单没有及时成交导致的买入金额不足 """ while True: trade_cmd = self.trade_queue.get() self._execute_trade_cmd( ...
def trade_worker( self, users, expire_seconds=120, entrust_prop="limit", send_interval=0 ): """ :param send_interval: 交易发送间隔, 默认为0s。调大可防止卖出买入时买出单没有及时成交导致的买入金额不足 """ while True: trade_cmd = self.trade_queue.get() self._execute_trade_cmd( ...
[ ":", "param", "send_interval", ":", "交易发送间隔,", "默认为0s。调大可防止卖出买入时买出单没有及时成交导致的买入金额不足" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/follower.py#L345-L356
[ "def", "trade_worker", "(", "self", ",", "users", ",", "expire_seconds", "=", "120", ",", "entrust_prop", "=", "\"limit\"", ",", "send_interval", "=", "0", ")", ":", "while", "True", ":", "trade_cmd", "=", "self", ".", "trade_queue", ".", "get", "(", ")"...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._set_cookies
设置雪球 cookies,代码来自于 https://github.com/shidenggui/easytrader/issues/269 :param cookies: 雪球 cookies :type cookies: str
easytrader/xqtrader.py
def _set_cookies(self, cookies): """设置雪球 cookies,代码来自于 https://github.com/shidenggui/easytrader/issues/269 :param cookies: 雪球 cookies :type cookies: str """ cookie_dict = helpers.parse_cookies_str(cookies) self.s.cookies.update(cookie_dict)
def _set_cookies(self, cookies): """设置雪球 cookies,代码来自于 https://github.com/shidenggui/easytrader/issues/269 :param cookies: 雪球 cookies :type cookies: str """ cookie_dict = helpers.parse_cookies_str(cookies) self.s.cookies.update(cookie_dict)
[ "设置雪球", "cookies,代码来自于", "https", ":", "//", "github", ".", "com", "/", "shidenggui", "/", "easytrader", "/", "issues", "/", "269", ":", "param", "cookies", ":", "雪球", "cookies", ":", "type", "cookies", ":", "str" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L56-L63
[ "def", "_set_cookies", "(", "self", ",", "cookies", ")", ":", "cookie_dict", "=", "helpers", ".", "parse_cookies_str", "(", "cookies", ")", "self", ".", "s", ".", "cookies", ".", "update", "(", "cookie_dict", ")" ]
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._prepare_account
转换参数到登录所需的字典格式 :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :param portfolio_code: 组合代码 :param portfolio_market: 交易市场, 可选['cn', 'us', 'hk'] 默认 'cn' :return:
easytrader/xqtrader.py
def _prepare_account(self, user="", password="", **kwargs): """ 转换参数到登录所需的字典格式 :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :param portfolio_code: 组合代码 :param portfolio_market: 交易市场, 可选['cn', 'us', 'hk'] 默认 'cn' :return:...
def _prepare_account(self, user="", password="", **kwargs): """ 转换参数到登录所需的字典格式 :param cookies: 雪球登陆需要设置 cookies, 具体见 https://smalltool.github.io/2016/08/02/cookie/ :param portfolio_code: 组合代码 :param portfolio_market: 交易市场, 可选['cn', 'us', 'hk'] 默认 'cn' :return:...
[ "转换参数到登录所需的字典格式", ":", "param", "cookies", ":", "雪球登陆需要设置", "cookies,", "具体见", "https", ":", "//", "smalltool", ".", "github", ".", "io", "/", "2016", "/", "08", "/", "02", "/", "cookie", "/", ":", "param", "portfolio_code", ":", "组合代码", ":", "param", ...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L65-L87
[ "def", "_prepare_account", "(", "self", ",", "user", "=", "\"\"", ",", "password", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "if", "\"portfolio_code\"", "not", "in", "kwargs", ":", "raise", "TypeError", "(", "\"雪球登录需要设置 portfolio_code(组合代码) 参数\")", "", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._search_stock_info
通过雪球的接口获取股票详细信息 :param code: 股票代码 000001 :return: 查询到的股票 {u'stock_id': 1000279, u'code': u'SH600325', u'name': u'华发股份', u'ind_color': u'#d9633b', u'chg': -1.09, u'ind_id': 100014, u'percent': -9.31, u'current': 10.62, u'hasexist': None, u'flag': 1, u'ind_name': u'房地产'...
easytrader/xqtrader.py
def _search_stock_info(self, code): """ 通过雪球的接口获取股票详细信息 :param code: 股票代码 000001 :return: 查询到的股票 {u'stock_id': 1000279, u'code': u'SH600325', u'name': u'华发股份', u'ind_color': u'#d9633b', u'chg': -1.09, u'ind_id': 100014, u'percent': -9.31, u'current': 10.62, ...
def _search_stock_info(self, code): """ 通过雪球的接口获取股票详细信息 :param code: 股票代码 000001 :return: 查询到的股票 {u'stock_id': 1000279, u'code': u'SH600325', u'name': u'华发股份', u'ind_color': u'#d9633b', u'chg': -1.09, u'ind_id': 100014, u'percent': -9.31, u'current': 10.62, ...
[ "通过雪球的接口获取股票详细信息", ":", "param", "code", ":", "股票代码", "000001", ":", "return", ":", "查询到的股票", "{", "u", "stock_id", ":", "1000279", "u", "code", ":", "u", "SH600325", "u", "name", ":", "u", "华发股份", "u", "ind_color", ":", "u", "#d9633b", "u", "chg", "...
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L100-L123
[ "def", "_search_stock_info", "(", "self", ",", "code", ")", ":", "data", "=", "{", "\"code\"", ":", "str", "(", "code", ")", ",", "\"size\"", ":", "\"300\"", ",", "\"key\"", ":", "\"47bce5c74f\"", ",", "\"market\"", ":", "self", ".", "account_config", "[...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._get_portfolio_info
获取组合信息 :return: 字典
easytrader/xqtrader.py
def _get_portfolio_info(self, portfolio_code): """ 获取组合信息 :return: 字典 """ url = self.config["portfolio_url"] + portfolio_code html = self._get_html(url) match_info = re.search(r"(?<=SNB.cubeInfo = ).*(?=;\n)", html) if match_info is None: raise...
def _get_portfolio_info(self, portfolio_code): """ 获取组合信息 :return: 字典 """ url = self.config["portfolio_url"] + portfolio_code html = self._get_html(url) match_info = re.search(r"(?<=SNB.cubeInfo = ).*(?=;\n)", html) if match_info is None: raise...
[ "获取组合信息", ":", "return", ":", "字典" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L125-L141
[ "def", "_get_portfolio_info", "(", "self", ",", "portfolio_code", ")", ":", "url", "=", "self", ".", "config", "[", "\"portfolio_url\"", "]", "+", "portfolio_code", "html", "=", "self", ".", "_get_html", "(", "url", ")", "match_info", "=", "re", ".", "sear...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader.get_balance
获取账户资金状况 :return:
easytrader/xqtrader.py
def get_balance(self): """ 获取账户资金状况 :return: """ portfolio_code = self.account_config.get("portfolio_code", "ch") portfolio_info = self._get_portfolio_info(portfolio_code) asset_balance = self._virtual_to_balance( float(portfolio_info["net_value"]) ...
def get_balance(self): """ 获取账户资金状况 :return: """ portfolio_code = self.account_config.get("portfolio_code", "ch") portfolio_info = self._get_portfolio_info(portfolio_code) asset_balance = self._virtual_to_balance( float(portfolio_info["net_value"]) ...
[ "获取账户资金状况", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L143-L165
[ "def", "get_balance", "(", "self", ")", ":", "portfolio_code", "=", "self", ".", "account_config", ".", "get", "(", "\"portfolio_code\"", ",", "\"ch\"", ")", "portfolio_info", "=", "self", ".", "_get_portfolio_info", "(", "portfolio_code", ")", "asset_balance", ...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._get_position
获取雪球持仓 :return:
easytrader/xqtrader.py
def _get_position(self): """ 获取雪球持仓 :return: """ portfolio_code = self.account_config["portfolio_code"] portfolio_info = self._get_portfolio_info(portfolio_code) position = portfolio_info["view_rebalancing"] # 仓位结构 stocks = position["holdings"] # 持仓股票 ...
def _get_position(self): """ 获取雪球持仓 :return: """ portfolio_code = self.account_config["portfolio_code"] portfolio_info = self._get_portfolio_info(portfolio_code) position = portfolio_info["view_rebalancing"] # 仓位结构 stocks = position["holdings"] # 持仓股票 ...
[ "获取雪球持仓", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L167-L176
[ "def", "_get_position", "(", "self", ")", ":", "portfolio_code", "=", "self", ".", "account_config", "[", "\"portfolio_code\"", "]", "portfolio_info", "=", "self", ".", "_get_portfolio_info", "(", "portfolio_code", ")", "position", "=", "portfolio_info", "[", "\"v...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader.get_position
获取持仓 :return:
easytrader/xqtrader.py
def get_position(self): """ 获取持仓 :return: """ xq_positions = self._get_position() balance = self.get_balance()[0] position_list = [] for pos in xq_positions: volume = pos["weight"] * balance["asset_balance"] / 100 position_list.appe...
def get_position(self): """ 获取持仓 :return: """ xq_positions = self._get_position() balance = self.get_balance()[0] position_list = [] for pos in xq_positions: volume = pos["weight"] * balance["asset_balance"] / 100 position_list.appe...
[ "获取持仓", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L187-L211
[ "def", "get_position", "(", "self", ")", ":", "xq_positions", "=", "self", ".", "_get_position", "(", ")", "balance", "=", "self", ".", "get_balance", "(", ")", "[", "0", "]", "position_list", "=", "[", "]", "for", "pos", "in", "xq_positions", ":", "vo...
e5ae4daeda4ea125763a95b280dd694c7f68257d
train
XueQiuTrader._get_xq_history
获取雪球调仓历史 :param instance: :param owner: :return:
easytrader/xqtrader.py
def _get_xq_history(self): """ 获取雪球调仓历史 :param instance: :param owner: :return: """ data = { "cube_symbol": str(self.account_config["portfolio_code"]), "count": 20, "page": 1, } resp = self.s.get(self.config["his...
def _get_xq_history(self): """ 获取雪球调仓历史 :param instance: :param owner: :return: """ data = { "cube_symbol": str(self.account_config["portfolio_code"]), "count": 20, "page": 1, } resp = self.s.get(self.config["his...
[ "获取雪球调仓历史", ":", "param", "instance", ":", ":", "param", "owner", ":", ":", "return", ":" ]
shidenggui/easytrader
python
https://github.com/shidenggui/easytrader/blob/e5ae4daeda4ea125763a95b280dd694c7f68257d/easytrader/xqtrader.py#L213-L227
[ "def", "_get_xq_history", "(", "self", ")", ":", "data", "=", "{", "\"cube_symbol\"", ":", "str", "(", "self", ".", "account_config", "[", "\"portfolio_code\"", "]", ")", ",", "\"count\"", ":", "20", ",", "\"page\"", ":", "1", ",", "}", "resp", "=", "s...
e5ae4daeda4ea125763a95b280dd694c7f68257d