def Run(self, args): """Runs the command. Args: args: The arguments that were provided to this command invocation. Returns: A Job message. """ job = job_utils.GetJobForArgs(self.context, args) # Extract the basic display information for the job dataflow_messages = self.context[commands.DATAFLOW_MESSAGES_MODULE_KEY] shown_job = job_display.DisplayInfo(job, dataflow_messages) # TODO(user): "Prettify" the environment, etc, since it includes # JSON as a string in some of the fields. if args.environment: shown_job.environment = job.environment if args.steps: shown_job.steps = [ self._PrettyStep(step) for step in step_json.ExtractSteps(job) ] return shown_job
def Run(self, args): """Runs the command. Args: args: The arguments that were provided to this command invocation. Returns: A Job message. """ job_ref = job_utils.ExtractJobRef(args) job = apis.Jobs.Get( job_id=job_ref.jobId, project_id=job_ref.projectId, region_id=job_ref.location, view=apis.Jobs.GET_REQUEST.ViewValueValuesEnum.JOB_VIEW_ALL) # Extract the basic display information for the job shown_job = job_display.DisplayInfo(job) if args.environment: shown_job.environment = job.environment if args.steps: shown_job.steps = [ self._PrettyStep(step) for step in step_json.ExtractSteps(job) ] return shown_job
def Run(self, args): """Runs the command. Args: args: The arguments that were provided to this command invocation. Returns: A Job message. """ job_ref = job_utils.ExtractJobRef(args.job) job = apis.Jobs.Get( job_id=job_ref.jobId, project_id=job_ref.projectId, view=apis.Jobs.GET_REQUEST.ViewValueValuesEnum.JOB_VIEW_ALL) # Extract the basic display information for the job shown_job = job_display.DisplayInfo(job) # TODO(b/36057351): "Prettify" the environment, etc, since it includes # JSON as a string in some of the fields. if args.environment: shown_job.environment = job.environment if args.steps: shown_job.steps = [ self._PrettyStep(step) for step in step_json.ExtractSteps(job) ] return shown_job
def Run(self, args): """Runs the command. Args: args: All the arguments that were provided to this command invocation. Returns: An iterator over Job messages. """ job_refs = job_utils.ExtractJobRefs(self.context, args) filter_pred = _JobFilter(self.context, args) if job_refs and not filter_pred.AlwaysTrue(): raise calliope_exceptions.ToolException( 'Cannot specify both job IDs and job filters.') jobs = [] if job_refs: view = job_utils.JOB_VIEW_SUMMARY jobs = [job_utils.GetJob(self.context, job_ref, view=view) for job_ref in job_refs] else: project_id = properties.VALUES.core.project.Get(required=True) jobs = self._JobSummariesForProject(project_id, filter_pred) dataflow_messages = self.context[commands.DATAFLOW_MESSAGES_MODULE_KEY] return [job_display.DisplayInfo(job, dataflow_messages) for job in jobs]
def Run(self, args): """Runs the command. Args: args: All the arguments that were provided to this command invocation. Returns: An iterator over Job messages. """ filter_pred = _JobFilter(args) project_id = properties.VALUES.core.project.Get(required=True) jobs = self._JobSummariesForProject(project_id, args, filter_pred) return [job_display.DisplayInfo(job) for job in jobs]
def Run(self, args): """Runs the command. Args: args: All the arguments that were provided to this command invocation. Returns: An iterator over Job messages. """ if args.filter: filter_expr = resource_filter.Compile(args.filter) filter_pred = lambda x: filter_expr.Evaluate(x) and _JobFilter(args )(x) else: filter_pred = _JobFilter(args) project_id = properties.VALUES.core.project.Get(required=True) jobs = self._JobSummariesForProject(project_id, args, filter_pred) return [job_display.DisplayInfo(job) for job in jobs]
def EvalFilter(x): return (filter_expr.Evaluate(job_display.DisplayInfo(x)) and _JobFilter(args)(x))