Example #1
0
    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
        ]
Example #2
0
    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