def get_repo(path: Optional[str] = None, experiment_name: Optional[str] = None) -> AimRepo: # Auto commit if os.getenv(AIM_AUTOMATED_EXEC_ENV_VAR): # Get Aim environment variables branch_name = os.getenv(AIM_BRANCH_ENV_VAR) commit_hash = os.getenv(AIM_COMMIT_ENV_VAR) else: commit_hash = AimRepo.generate_commit_hash() if experiment_name is not None: branch_name = experiment_name else: # FIXME: Get active experiment name from given repo # if path is specified. Currently active experiment name of # the highest repo in the hierarchy will be returned. branch_name = AimRepo.get_active_branch_if_exists() \ or AIM_DEFAULT_BRANCH_NAME if path is not None: repo = AimRepo(path) if not repo.exists(): if not repo.init(): raise ValueError('can not create repo `{}`'.format(path)) repo = AimRepo(path, branch_name, commit_hash) else: if AimRepo.get_working_repo() is None: path = os.getcwd() repo = AimRepo(path) if not repo.init(): raise ValueError('can not create repo `{}`'.format(path)) repo = AimRepo(path, branch_name, commit_hash) else: repo = AimRepo.get_working_repo(branch_name, commit_hash) return repo
def de_entry_point(ctx): repo = ctx.obj or AimRepo.get_working_repo() if repo is None: repo_init_alert() exit() ctx.obj = repo if not AimContainer.is_docker_installed(): docker_requirement_alert() exit()
def select_runs(expression: Optional[str] = None, repo_path: Optional[str] = None): if repo_path is not None: repo = AimRepo(repo_full_path=repo_path) else: repo = AimRepo.get_working_repo(mode=AimRepo.READING_MODE) if not repo: return None if expression and 'run.archived' not in expression: default_expression = 'run.archived is not True' else: default_expression = None return repo.select_runs(expression, default_expression)
def select_metrics(search_statement: str, repo_path: Optional[str] = None): if repo_path is not None: repo = AimRepo(repo_full_path=repo_path) else: repo = AimRepo.get_working_repo(mode=AimRepo.READING_MODE) if not repo: return None parser = Statement() parsed_stmt = parser.parse(search_statement.strip()) statement_select = parsed_stmt.node['select'] statement_expr = parsed_stmt.node['expression'] if 'run.archived' not in search_statement: default_expression = 'run.archived is not True' else: default_expression = None return repo.select_metrics(statement_select, statement_expr, default_expression)
def cli_entry_point(ctx, verbose): if verbose: click.echo('Verbose mode is on') # Init repo instance ctx.obj = AimRepo.get_working_repo()