def _apply_status_filter(args, filters): status_filters = [ var.run_filter("attr", "status", status) for status in FILTERABLE if getattr(args, status, False) ] if status_filters: filters.append(var.run_filter("any", status_filters))
def _runs_filter(oprefs, run_id_prefix, status): if run_id_prefix and isinstance(run_id_prefix, six.string_types): return lambda run: run.id.startswith(run_id_prefix) return var.run_filter("all", [ var.run_filter("any", [ var.run_filter("attr", "status", status_val) for status_val in status ]), var.run_filter("any", [opref_match_filter(opref) for opref in oprefs]) ])
def _apply_status_filter(args, filters): status = getattr(args, "status", None) if not status: return if status == "stopped": # Special case, filter on any of "terminated" or "error" filters.append( var.run_filter("any", [ var.run_filter("attr", "status", "terminated"), var.run_filter("attr", "status", "error"), ])) else: filters.append(var.run_filter("attr", "status", status))
def _latest_op_run(self, opref): resolved_opref = self._fully_resolve_opref(opref) completed_op_runs = var.run_filter("all", [ var.run_filter("any", [ var.run_filter("attr", "status", "completed"), var.run_filter("attr", "status", "running"), ]), resolved_opref.is_op_run ]) runs = var.runs(sort=["-started"], filter=completed_op_runs) if runs: return runs[0] raise ResolutionError("no suitable run for %s" % self._opref_desc(resolved_opref))
def _runs_filter(args): filters = [] _apply_status_filter(args, filters) _apply_ops_filter(args, filters) _apply_labels_filter(args, filters) _apply_marked_filter(args, filters) return var.run_filter("all", filters)
def _runs_filter(args, ctx): filters = [] _apply_status_filter(args, filters) _apply_ops_filter(args, filters) _apply_labels_filter(args, filters) _apply_marked_filter(args, filters) _apply_started_filter(args, ctx, filters) _apply_sourcecode_digest_filter(args, filters) return var.run_filter("all", filters)
def _runs_filter(oprefs, run_id_prefix, status): if _is_full_run_id(run_id_prefix): return lambda run: run.id == run_id_prefix return var.run_filter( "all", [ _run_id_prefix_filter(run_id_prefix), _run_status_filter(status), _run_opref_filter(oprefs), ], )
def _runs_filter(oprefs, run_id_prefix): if run_id_prefix: return lambda run: run.id.startswith(run_id_prefix) return var.run_filter("all", [ var.run_filter("any", [ var.run_filter("attr", "status", "completed"), var.run_filter("attr", "status", "running"), var.run_filter("attr", "status", "terminated"), ]), var.run_filter("any", [opref_match_filter(opref) for opref in oprefs]) ])
def _running_runs(): running = var.runs(filter=var.run_filter("attr", "status", "running")) return [run for run in running if run.id != RUN_ID]
def _staged_runs(): return var.runs(sort=["timestamp"], filter=var.run_filter("attr", "status", "staged"))
def _run_opref_filter(oprefs): return var.run_filter("any", [opref_match_filter(opref) for opref in oprefs])
def _run_status_filter(status): return var.run_filter( "any", [var.run_filter("attr", "status", status_val) for status_val in status] )
def _blocking_runs(state): if not state.wait_for_running: return [] running = var.runs(filter=var.run_filter("attr", "status", "running")) return [run for run in running if not _is_queue_or_self(run, state)]
def _running(state): running = var.runs(filter=var.run_filter("attr", "status", "running")) return [run for run in running if run.id != state.run_id]
def _runs_filter(args): filters = [] _apply_status_filter(args, filters) _apply_model_filter(args, filters) return var.run_filter("all", filters)
def _running(state): running = var.runs(filter=var.run_filter("attr", "status", "running")) return [run for run in running if not _is_queue_or_self(run, state)]