def test_all(arg=None): log_info_repo(arg) from time import sleep # log("os.getcwd", os.getcwd()) path = dsa2.__path__[0] log("############Check model ################################") model_list = model_get_list(folder=None, block_list=[]) log(model_list) ## Block list # root = os_package_root_path() cfg = json.load(open(path_norm(arg.config_file), mode='r'))['test_all'] block_list = cfg['model_blocked'] model_list = [t for t in model_list if t not in block_list] log("Used", model_list) path = path.replace("\\", "//") test_list = [ f"python {path}/" + t.replace(".", "//") + ".py" for t in model_list ] for cmd in test_list: log_separator() log(cmd) os.system(cmd) log_remote_push() sleep(5)
def test_cli(arg=None): log("# Testing Command Line System ") log_info_repo(arg) import dsa2, os path = dsa2.__path__[0] ### Root Path # if arg is None : # fileconfig = path_norm( f"{path}/config/cli_test_list.md" ) # else : # fileconfig = path_norm( arg.config_file ) # fileconfig = path_norm( f"{path}/../config/cli_test_list.md" ) fileconfig = path_norm(f"{path}/../README_usage_CLI.md") print("Using :", fileconfig) def is_valid_cmd(cmd): cmd = cmd.strip() if len(cmd) > 15: if cmd.startswith("ml_models ") or cmd.startswith( "ml_benchmark ") or cmd.startswith("ml_optim "): return True return False with open(fileconfig, mode="r") as f: cmd_list = f.readlines() print(cmd_list[:3]) #### Parse the CMD from the file .md and Execute for ss in cmd_list: cmd = ss.strip() if is_valid_cmd(cmd): cmd = cmd + to_logfile("cli", '+%Y-%m-%d_%H') log_separator() print(cmd, flush=True) os.system(cmd)
def test_functions(arg=None): from dsa2.util import load_function_uri path = path_norm("dataset/test_json/test_functions.json") dd = json.load(open(path))['test'] for p in dd: try: log("\n\n", "#" * 20, p) myfun = load_function_uri(p['uri']) log(myfun) w = p.get('args', []) kw = p.get('kw_args', {}) if len(kw) == 0 and len(w) == 0: log(myfun()) elif len(kw) > 0 and len(w) > 0: log(myfun(*w, **kw)) elif len(kw) > 0 and len(w) == 0: log(myfun(**kw)) elif len(kw) == 0 and len(w) > 0: log(myfun(*w)) except Exception as e: log(e, p)
def cli_load_arguments(config_file=None): #Load CLI input, load config.toml , overwrite config.toml by CLI Input import argparse from dsa2.util import load_config, path_norm config_file = "config/test_config.json" if config_file is None else config_file config_file = path_norm(config_file) # log(config_file) p = argparse.ArgumentParser() def add(*w, **kw): p.add_argument(*w, **kw) add("--do", default="test_all", help=" Action to do") add("--config_file", default=config_file, help="Params File") add("--config_mode", default="test", help="test/ prod /uat") add("--log_file", help="log.log") add("--folder", default=None, help="test") add("--name", default="ml_store", help="test") ##### model pars ##### data pars ##### compute pars ##### out pars add("--save_folder", default="ztest/", help=".") #### Env Vars : """ https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables """ # add("--repo" , default="GITHUB_REPOSITORT" , help="test/ prod /uat") # add("--sha" , default="GITHUB_SHA" , help="test/ prod /uat") # add("--ref" , default="GITHUB_REF" , help="test/ prod /uat") # add("--workflow" , default="GITHUB_WORKFLOW" , help="test/ prod /uat") # add("--event_name" , default="test" , help="test/ prod /uat") #add("--event_path" , default="test" , help="test/ prod /uat") # add("--workspace" , default="test" , help="test/ prod /uat") arg = p.parse_args() # arg = load_config(arg, arg.config_file, arg.config_mode, verbose=0) return arg
def test_dataloader(arg=None): log_info_repo(arg) # log("os.getcwd", os.getcwd()) path = dsa2.__path__[0] cfg = json_load(path_norm(arg.config_file)) log("############Check model ################################") path = path.replace("\\", "//") test_list = [ f"python {path}/dataloader.py --do test ", f"python {path}/preprocess/generic.py --do test ", ] for cmd in test_list: log_separator() log(cmd) os.system(cmd)