当前位置: 首页>>代码示例>>Python>>正文


Python Name.workflow方法代码示例

本文整理汇总了Python中pinball.workflow.name.Name.workflow方法的典型用法代码示例。如果您正苦于以下问题:Python Name.workflow方法的具体用法?Python Name.workflow怎么用?Python Name.workflow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pinball.workflow.name.Name的用法示例。


在下文中一共展示了Name.workflow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_job_names

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _get_job_names(self, workflow_name, instance, state):
        """Return list of job names in a given workflow instance and state.

        E.g., assume the following tokens are stored in the master:
            /workflow/some_workflow/12345/waiting/some_waiting_job
            /workflow/some_workflow/12345/waiting/some_other_waiting_job
            /workflow/some_workflow/12345/runnable/some_runnable_job

        the method called with workflow_name=some_workflow, instance=12345,
        state=waiting will return [some_waiting_job, some_other_waiting_job].
        """
        request = GroupRequest()
        name = Name()
        name.workflow = workflow_name
        name.instance = instance
        name.job_state = state
        request.namePrefix = name.get_job_state_prefix()
        request.groupSuffix = Name.DELIMITER
        response = self._client.group(request)
        job_names = []
        if response.counts:
            for job_name in response.counts.keys():
                name = Name.from_job_token_name(job_name)
                job_names.append(name.job)
        return job_names
开发者ID:Betterment,项目名称:pinball,代码行数:27,代码来源:inspector.py

示例2: _refresh_actions

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _refresh_actions(self):
        """Reload actions from the master."""
        request = QueryRequest(queries=[])
        name = Name()

        top_query = Query()
        top_query.namePrefix = name.get_signal_prefix()
        request.queries.append(top_query)

        if self._workflow:
            workflow_query = Query()
            name.workflow = self._workflow
            workflow_query.namePrefix = name.get_signal_prefix()
            request.queries.append(workflow_query)

        if self._instance:
            instance_query = Query()
            name.instance = self._instance
            instance_query.namePrefix = name.get_signal_prefix()
            request.queries.append(instance_query)

        response = self._client.query(request)
        signal_tokens = []
        for tokens in response.tokens:
            signal_tokens.extend(tokens)

        self._dedup_actions(signal_tokens)
开发者ID:Betterment,项目名称:pinball,代码行数:29,代码来源:signaller.py

示例3: _get_output_event_tokens

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _get_output_event_tokens(self, job):
        """Create output event tokens for the owned job token.

        Args:
            job: The job which output tokens should be generated.
        Returns:
            A list of event tokens corresponding to the outputs of the owned
            job token.
        """
        assert self._owned_job_token
        job_name = Name.from_job_token_name(self._owned_job_token.name)
        output_name = Name()
        output_name.workflow = job_name.workflow
        output_name.instance = job_name.instance
        output_name.input = job_name.job
        event_tokens = []
        for output in job.outputs:
            output_name.job = output
            output_name.event = get_unique_name()
            event = Event(creator=self._name)
            assert job.history
            execution_record = job.history[-1]
            event.attributes = execution_record.get_event_attributes()
            event_tokens.append(Token(name=output_name.get_event_token_name(),
                                      data=pickle.dumps(event)))
        return event_tokens
开发者ID:Betterment,项目名称:pinball,代码行数:28,代码来源:worker.py

示例4: _make_runnable

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _make_runnable(self, workflow, instance):
        """Attempt to make jobs in a given workflow instance runnable.

        Go over all waiting jobs in a given workflow instance and try to make
        them runnable.

        Args:
            workflow: The name of the workflow whose jobs should be considered.
            instance: The workflow instance whose jobs should be considered.
        Returns:
            True if there were no errors during communication with the master,
            otherwise False.
        """
        name = Name()
        name.workflow = workflow
        name.instance = instance
        name.job_state = Name.WAITING_STATE
        query = Query(namePrefix=name.get_job_state_prefix())
        # TODO(pawel): to prevent multiple workers from trying to make the
        # same job runnable at the same time, this should be a
        # QueryAndOwnRequest.  Note that the current implementation is correct,
        # just inefficient.
        request = QueryRequest(queries=[query])
        try:
            response = self._client.query(request)
        except TokenMasterException:
            LOG.exception('error sending request %s', request)
            return False
        assert len(response.tokens) == 1
        for token in response.tokens[0]:
            if not self._make_job_runnable(token):
                return False
        return True
开发者ID:Betterment,项目名称:pinball,代码行数:35,代码来源:worker.py

示例5: _post_signal_tokens

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _post_signal_tokens(self):
        """Add some signal tokens to the master."""
        request = ModifyRequest(updates=[])

        signal = Signal(action=Signal.EXIT)
        name = Name(signal='exit')
        signal_token = Token(name=name.get_signal_token_name())
        signal_token.data = pickle.dumps(signal)
        request.updates.append(signal_token)

        signal = Signal(action=Signal.DRAIN)
        name.signal = 'drain'
        name.workflow = 'some_workflow'
        signal_token = Token(name=name.get_signal_token_name())
        signal_token.data = pickle.dumps(signal)
        request.updates.append(signal_token)

        name.instance = '123'
        signal_token = Token(name=name.get_signal_token_name())
        signal_token.data = pickle.dumps(signal)
        request.updates.append(signal_token)

        signal = Signal(action=Signal.ABORT)
        name.signal = 'abort'
        signal_token = Token(name=name.get_signal_token_name())
        signal_token.data = pickle.dumps(signal)
        request.updates.append(signal_token)

        client = self._factory.get_client()
        client.modify(request)
开发者ID:Betterment,项目名称:pinball,代码行数:32,代码来源:signaller_test.py

示例6: get_workflow_instances

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
 def get_workflow_instances(self, workflow_name):
     """Return list of instances of a given workflow."""
     request = GroupRequest()
     name = Name()
     name.workflow = workflow_name
     request.namePrefix = name.get_workflow_prefix()
     request.groupSuffix = Name.DELIMITER
     response = self._client.group(request)
     instance_names = []
     if response.counts:
         for prefix in response.counts.keys():
             name = Name.from_instance_prefix(prefix)
             if name.instance:
                 instance_names.append(name.instance)
     return instance_names
开发者ID:Betterment,项目名称:pinball,代码行数:17,代码来源:inspector.py

示例7: get_event_names

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
 def get_event_names(self, workflow_name, instance, job, input_name):
     """Return names of events under a workflow instance, job, and input."""
     request = GroupRequest()
     name = Name()
     name.workflow = workflow_name
     name.instance = instance
     name.job = job
     name.input = input_name
     request.namePrefix = name.get_input_prefix()
     request.groupSuffix = Name.DELIMITER
     response = self._client.group(request)
     events = []
     if response.counts:
         for event in response.counts.keys():
             name = Name.from_event_token_name(event)
             events.append(name.event)
     return events
开发者ID:Betterment,项目名称:pinball,代码行数:19,代码来源:inspector.py

示例8: _make_job_runnable

# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import workflow [as 别名]
    def _make_job_runnable(self, job_token):
        """Attempt to make a job runnable.

        Query event tokens in job inputs.  If a combination of triggering
        events exist, remove those events and make the job runnable.
        Otherwise, do nothing.

        Args:
            job_token: The job token to make runnable.
        Returns:
            True if there were no errors during communication with the master,
            otherwise False.
        """
        job = pickle.loads(job_token.data)
        name = Name.from_job_token_name(job_token.name)
        request = QueryRequest(queries=[])
        # TODO(pawel): handle jobs with no dependencies
        assert job.inputs
        for input_name in job.inputs:
            prefix = Name()
            prefix.workflow = name.workflow
            prefix.instance = name.instance
            prefix.job = name.job
            prefix.input = input_name
            query = Query()
            query.namePrefix = prefix.get_input_prefix()
            query.maxTokens = 1
            request.queries.append(query)
        try:
            response = self._client.query(request)
        except TokenMasterException:
            # TODO(pawel): add a retry count and fail if a limit is reached.
            LOG.exception('error sending request %s', request)
            return False
        triggering_events = Worker._get_triggering_events(response.tokens)
        if triggering_events:
            return self._move_job_token_to_runnable(job_token,
                                                    triggering_events)
        return True
开发者ID:Betterment,项目名称:pinball,代码行数:41,代码来源:worker.py


注:本文中的pinball.workflow.name.Name.workflow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。