Exemplo n.º 1
0
 def get_workflow(self, request):
     with self._app.app_context():
         project, party = self.check_auth_info(request.auth_info)
         workflow = Workflow.query.filter_by(name=request.workflow_name,
                                             project_id=project.id).first()
         assert workflow is not None
         config = workflow.get_config()
         self._filter_workflow(config, [
             common_pb2.Variable.PEER_READABLE,
             common_pb2.Variable.PEER_WRITABLE
         ])
         # job details
         jobs = [
             service_pb2.JobDetail(name=job.name,
                                   state=job.get_state_for_front())
             for job in workflow.get_jobs()
         ]
         # fork info
         forked_from = ''
         if workflow.forked_from:
             forked_from = Workflow.query.get(workflow.forked_from).name
         return service_pb2.GetWorkflowResponse(
             name=request.workflow_name,
             status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS),
             config=config,
             jobs=jobs,
             state=workflow.state.value,
             target_state=workflow.target_state.value,
             transaction_state=workflow.transaction_state.value,
             forkable=workflow.forkable,
             forked_from=forked_from,
             reuse_job_names=workflow.get_reuse_job_names(),
             peer_reuse_job_names=workflow.get_peer_reuse_job_names(),
             fork_proposal_config=workflow.get_fork_proposal_config())
Exemplo n.º 2
0
 def get_workflow(self, request, context):
     with self._app.app_context():
         project, party = self.check_auth_info(request.auth_info, context)
         workflow = Workflow.query.filter_by(name=request.workflow_name,
                                             project_id=project.id).first()
         assert workflow is not None, 'Workflow not found'
         config = workflow.get_config()
         config = self._filter_workflow(config, [
             common_pb2.Variable.PEER_READABLE,
             common_pb2.Variable.PEER_WRITABLE
         ])
         # job details
         jobs = [
             service_pb2.JobDetail(
                 name=job.name,
                 state=job.get_state_for_frontend(),
                 pods=json.dumps(
                     job.get_pods_for_frontend(include_private_info=False)))
             for job in workflow.get_jobs()
         ]
         # fork info
         forked_from = ''
         if workflow.forked_from:
             forked_from = Workflow.query.get(workflow.forked_from).name
         return service_pb2.GetWorkflowResponse(
             name=request.workflow_name,
             status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS),
             config=config,
             jobs=jobs,
             state=workflow.state.value,
             target_state=workflow.target_state.value,
             transaction_state=workflow.transaction_state.value,
             forkable=workflow.forkable,
             forked_from=forked_from,
             create_job_flags=workflow.get_create_job_flags(),
             peer_create_job_flags=workflow.get_peer_create_job_flags(),
             fork_proposal_config=workflow.get_fork_proposal_config(),
             uuid=workflow.uuid,
             metric_is_public=workflow.metric_is_public)