def test_get_statuses_watch(self, sdk_get_run_statuses): settings.CLIENT_CONFIG.watch_interval = 1 for _ in get_run_statuses(owner="owner", project="project", run_uuid=uuid.uuid4().hex, watch=True): resp = MagicMock(status="failed", status_conditions=[]) sdk_get_run_statuses.return_value = resp assert sdk_get_run_statuses.call_count == 2
def _get_run_statuses(): try: for status, conditions in get_run_statuses(owner, project_name, run_uuid, watch): if not conditions: continue Printer.print_header("Latest status:") latest_status = Printer.add_status_color({"status": status}, status_key="status") click.echo("{}\n".format(latest_status["status"])) objects = list_dicts_to_tabulate([ Printer.add_status_color(o.to_dict(), status_key="type") for o in conditions ]) if objects: Printer.print_header("Conditions:") dict_tabulate(objects, is_list_dict=True) except (ApiException, HTTPError, PolyaxonClientException) as e: handle_cli_error( e, message="Could get status for run `{}`.".format(run_uuid)) sys.exit(1)
def get_statuses(self, watch=False): for status, conditions in get_run_statuses(self.owner, self.project, self.run_uuid, watch): self.status = status yield conditions
def refresh_data(self): self._run = self.client.runs_v1.get_run(self.owner, self.project, self.run_uuid) for status, conditions in get_run_statuses(self.owner, self.project, self.run_uuid): self.status = status
def test_get_statuses(self, sdk_get_run_statuses): for _ in get_run_statuses(owner="owner", project="project", run_uuid=uuid.uuid4().hex): pass assert sdk_get_run_statuses.call_count == 1