本文整理汇总了Python中pinball.workflow.name.Name.from_instance_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Name.from_instance_prefix方法的具体用法?Python Name.from_instance_prefix怎么用?Python Name.from_instance_prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pinball.workflow.name.Name
的用法示例。
在下文中一共展示了Name.from_instance_prefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_instances_using_cache
# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import from_instance_prefix [as 别名]
def _get_instances_using_cache(self, workflow):
"""Get workflow instances, preferably from the cache.
As a side effect, archived instances that do not exist in the cache
will be added to the cache.
Args:
workflow: The name of the workflow whose instances we are
interested in.
Returns:
List of instances for the given workflow.
"""
name = Name(workflow=workflow)
workflow_prefix = name.get_workflow_prefix()
workflow_token_names = self._store.read_token_names(
name_prefix=workflow_prefix)
instances_prefixes = DataBuilder._get_instance_prefixes(
workflow_token_names)
result = []
for prefix in instances_prefixes:
name = Name.from_instance_prefix(prefix)
assert name.workflow and name.instance, (
'Expected instance prefix, found %s' % prefix)
result.append(self.get_instance(name.workflow, name.instance))
return result
示例2: get_workflow_instances
# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import from_instance_prefix [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
示例3: _get_workflows_using_cache
# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import from_instance_prefix [as 别名]
def _get_workflows_using_cache(self):
"""Get workflows, preferably fetching instances from the cache.
As a side effect, archived instances that do not exist in the cache
will be added to the cache.
Returns:
List of workflows data.
"""
instances_token_names = self._store.read_token_names(
name_prefix=Name.WORKFLOW_PREFIX)
instances_prefixes = DataBuilder._get_instance_prefixes(
instances_token_names)
instances = []
for prefix in instances_prefixes:
name = Name.from_instance_prefix(prefix)
assert name.workflow and name.instance, (
'Expected instance prefix, found %s' % prefix)
instances.append(self.get_instance(name.workflow, name.instance))
return self._workflows_data_from_instances_data(instances)
示例4: test_instance_prefix
# 需要导入模块: from pinball.workflow.name import Name [as 别名]
# 或者: from pinball.workflow.name.Name import from_instance_prefix [as 别名]
def test_instance_prefix(self):
PREFIX = "/workflow/some_workflow/some_instance/"
name = Name.from_instance_prefix(PREFIX)
self.assertEqual("some_workflow", name.workflow)
self.assertEqual("some_instance", name.instance)
self.assertEqual(PREFIX, name.get_instance_prefix())