def list_branches(self): """Print listing of branches for default project in tabular format.""" branches = self.api.list_branches(self.api.get_default_project()) rows = list() rows.append(['Identifier', 'Name', 'Created at', 'Last modified']) for branch in branches: rows.append([ branch.identifier, branch.name, ts(branch.created_at), ts(branch.last_modified_at) ]) print() self.output(rows) print('\n' + str(len(branches)) + ' branch(es)\n') return True
def list_projects(self): """Print listing of active projects in tabular format.""" projects = self.api.list_projects() rows = list() rows.append(['Identifier', 'Name', 'Created at', 'Last modified']) for project in projects: rows.append([ project.identifier, project.name, ts(project.created_at), ts(project.last_modified_at) ]) print() self.output(rows) print('\n' + str(len(projects)) + ' project(s)\n') return True
def show_notebook(self, workflow_id=None): """List all modules for a given workflow. If the workflow identifier is not given the branch head is used as the workflow. """ workflow = self.api.get_workflow( project_id=self.api.get_default_project(), branch_id=self.api.get_default_branch(), workflow_id=workflow_id) if workflow.is_empty: print('Notebook is empty') return True print('Workflow ' + workflow.identifier + ' (created at ' + ts(workflow.created_at) + ')') for i in range(len(workflow.modules)): module = workflow.modules[i] cell_id = '[' + str(i + 1) + '] ' indent = ' ' * len(cell_id) print('\n' + cell_id + '(' + module.state.upper() + ') ' + module.identifier) timestamps = 'Created @ ' + ts(module.timestamp.created_at) if not module.timestamp.started_at is None: timestamps += ', Started @ ' + ts(module.timestamp.started_at) if not module.timestamp.finished_at is None: timestamps += ', Finished @ ' + ts( module.timestamp.finished_at) print(indent + timestamps) print(indent + '--') for line in module.external_form.split('\n'): print(indent + line) if len(module.outputs) > 0: print(indent + '--') for line in module.outputs: if '\n' in line: sublines = line.split('\n') for l in sublines: print(indent + l) else: print(indent + line) if len(module.datasets) > 0: print(indent + '--') print(indent + 'Datasets: ' + ', '.join(module.datasets)) if len(module.charts) > 0: print(indent + 'Charts: ' + ', '.join(list(module.charts.keys()))) print('.') return True
def list_workflows(self): """Print listing of workflows in the history of the default branch in tabular format. """ branch = self.api.get_branch(project_id=self.api.get_default_project(), branch_id=self.api.get_default_branch()) rows = list() rows.append(['Identifier', 'Action', 'Command', 'Created at']) for workflow in branch.workflows: rows.append([ workflow.identifier, workflow.action.upper(), workflow.command, ts(workflow.created_at) ]) print() self.output(rows) print('\n' + str(len(branch.workflows)) + ' workflow(s)\n') return True