def _run_duration(run): started = run.get("started") if run.status == "running": return util.format_duration(started) stopped = run.get("stopped") if stopped: return util.format_duration(started, stopped) return ""
def format_run(run, index=None): status = run.status operation = format_op_desc(run) marked = bool(run.get("marked")) started = run.get("started") stopped = run.get("stopped") return { "_run": run, "id": run.id, "short_id": run.short_id, "index": _format_run_index(run, index), "short_index": _format_run_index(run), "model": run.opref.model_name, "op_name": run.opref.op_name, "operation": operation, "operation_with_marked": _op_with_marked(operation, marked), "pkg": run.opref.pkg_name, "status": status, "status_with_remote": _status_with_remote(status, run.remote), "marked": _format_val(marked), "label": _format_label(run.get("label") or ""), "pid": run.pid or "", "started": util.format_timestamp(started), "stopped": util.format_timestamp(stopped), "duration": util.format_duration(started, stopped), "run_dir": util.format_dir(run.path), "command": _format_command(run.get("cmd", "")), "exit_status": _format_exit_status(run) }
def format_run(run, index=None): status = run.status started = run.get("started") stopped = run.get("stopped") return { "_run": run, "command": _format_command(run.get("cmd", "")), "duration": util.format_duration(started, stopped), "exit_status": _format_exit_status(run), "from": format_pkg_name(run), "id": run.id, "index": _format_run_index(run, index), "label": run.get("label") or "", "marked": format_attr(bool(run.get("marked"))), "model": run.opref.model_name, "op_name": run.opref.op_name, "operation": format_operation(run), "pid": run.pid or "", "pkg_name": run.opref.pkg_name, "run_dir": util.format_dir(run.path), "short_id": run.short_id, "short_index": _format_run_index(run), "sourcecode_digest": run.get("sourcecode_digest", ""), "vcs_commit": run.get("vcs_commit", ""), "started": util.format_timestamp(started), "status": status, "status_with_remote": _status_with_remote(status, run.remote), "stopped": util.format_timestamp(stopped), }
def _run_attr(run, name, fmt): if name == "run": return RunIndex(run, fmt) elif name in ("operation", ): return fmt[name] elif name in ("started", "stopped"): return _datetime(run.get(name)) elif name in ("label", ): return run.get(name, "") elif name == "time": return util.format_duration(run.get("started"), run.get("stopped")) else: return getattr(run, name)
def _format_time(started, stopped): if started and stopped: return util.format_duration(started, stopped) return ""
def _duration(status, started, stopped): if status == "running": return util.format_duration(started) elif stopped: return util.format_duration(started, stopped) return None
def _run_time(run): formatted_time = util.format_duration(run.get("started"), run.get("stopped")) return pd.to_timedelta(formatted_time)