def algo_show(args): builtin_name = args.name[0] meta = get_registered_algo_meta(builtin_name) if meta: print(json.dumps(meta, indent=4)) else: print_error('package {} not found'.format(builtin_name))
def algo_reg(args): meta_list = read_reg_meta_list(args.meta_path) for meta in meta_list: if get_registered_algo_meta(meta['builtinName']) is not None: print_error('builtinName {} already registered'.format( meta['builtinName'])) return verify_algo_import(meta) save_algo_meta_data(meta) print_green('{} registered sucessfully!'.format(meta['builtinName']))
def algo_unreg(args): name = args.name[0] meta = get_registered_algo_meta(name) if meta is None: print_error('builtin algorithms {} not found!'.format(name)) return if meta['source'] == 'nni': print_error('{} is provided by nni, can not be unregistered!'.format(name)) return if remove_algo_meta_data(name): print_green('{} unregistered sucessfully!'.format(name)) else: print_error('Failed to unregistered {}!'.format(name))
def validate_class_args(self, class_args, algo_type, builtin_name): if not builtin_name or not class_args: return meta = get_registered_algo_meta(builtin_name, algo_type+'s') if meta and 'acceptClassArgs' in meta and meta['acceptClassArgs'] == False: raise SchemaError('classArgs is not allowed.') logging.getLogger('nni.protocol').setLevel(logging.ERROR) # we know IPC is not there, don't complain validator = create_validator_instance(algo_type+'s', builtin_name) if validator: try: validator.validate_class_args(**class_args) except Exception as e: raise SchemaError(str(e))
def algo_reg(args): meta_list = read_reg_meta_list(args.meta_path) for meta in meta_list: old = get_registered_algo_meta(meta['builtinName']) if old is None: verify_algo_import(meta) save_algo_meta_data(meta) elif old['source'] != 'nni': verify_algo_import(meta) print_green(f'Updating exist algorithm') remove_algo_meta_data(meta['builtinName']) save_algo_meta_data(meta) else: print_error(f'Cannot overwrite builtin algorithm') print_green('{} registered sucessfully!'.format(meta['builtinName']))