def cli_representation(self): return ArgoWorkflow.ArgoWorkflowCliModel( name=self.name, started_at=format_timestamp_for_cli(self.started_at) if self.started_at else '', finished_at=format_timestamp_for_cli(self.finished_at) if self.finished_at else '', submitter=self.namespace, phase=self.phase if self.phase else QUEUED_PHASE)
def cli_representation(self): return self.UserCliModel( name=self.name, created=format_timestamp_for_cli(self.creation_timestamp), running_jobs=self.running_jobs_count, queued_jobs=self.queued_jobs_count, date_of_last_submitted_job=format_timestamp_for_cli( self.date_of_last_submitted_job) if self.date_of_last_submitted_job is not None else None)
def uninitialized_experiment_cli_representation(experiment: Experiment): return UninitializedExperimentCliModel(name=experiment.name, parameters_spec=' '.join(experiment.parameters_spec), metrics='', start_date='', end_date='', duration='', creation_timestamp=format_timestamp_for_cli(experiment.creation_timestamp), submitter=experiment.namespace, status=experiment.state.value, template_name=experiment.template_name, template_version=experiment.template_version)
def test_format_timestamp_for_cli(mocker): tzlocal_mock = mocker.patch("dateutil.tz.tzlocal") tzlocal_mock.return_value = datetime.timezone(datetime.timedelta(hours=1)) cli_timestamp = format_timestamp_for_cli("2018-10-11T20:30:30Z") assert cli_timestamp == "2018-10-11 09:30:30 PM"
def cli_representation(self): return Experiment.ExperimentCliModel( name=self.name, parameters_spec=' '.join(self.parameters_spec), creation_timestamp=format_timestamp_for_cli( self.creation_timestamp), submitter=self.namespace, status=self.state.value, template_name=self.template_name)
def cli_representation(self): return Run.RunCliModel( name=self.name, parameters=textwrap.fill( ' '.join(self.parameters), width=30, drop_whitespace=False) if self.parameters else "", metrics='\n'.join( textwrap.fill(f'{key}: {value}', width=30) for key, value in self.metrics.items()) if self.metrics else "", submission_date=format_timestamp_for_cli(self.creation_timestamp) if self.creation_timestamp else "", submitter=self.namespace if self.namespace else "", status=self.state.value if self.state else "", template_name=self.template_name, start_date=format_timestamp_for_cli(self.start_timestamp) if self.start_timestamp else "", end_date=format_timestamp_for_cli(self.end_timestamp) if self.end_timestamp else "")
def container_status_to_msg(state) -> str: if not state: return Texts.CONTAINER_NOT_CREATED_MSG if state.running is not None: return Texts.CONTAINER_RUNNING_MSG + format_timestamp_for_cli(str(state.running.started_at)) if state.terminated is not None: msg = Texts.CONTAINER_TERMINATED_MSG + str(state.terminated.reason) msg += Texts.REASON + wrap_text(str(state.terminated.message), width=CONTAINER_DETAILS_MAX_WIDTH) \ if state.terminated.message else '' return msg if state.waiting is not None: return Texts.CONTAINER_WAITING_MSG + str(state.waiting.reason)