本文整理汇总了Python中recipe.configuration.definition.recipe_definition.RecipeDefinition.get_next_jobs_to_queue方法的典型用法代码示例。如果您正苦于以下问题:Python RecipeDefinition.get_next_jobs_to_queue方法的具体用法?Python RecipeDefinition.get_next_jobs_to_queue怎么用?Python RecipeDefinition.get_next_jobs_to_queue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recipe.configuration.definition.recipe_definition.RecipeDefinition
的用法示例。
在下文中一共展示了RecipeDefinition.get_next_jobs_to_queue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_successful_job_1_completed
# 需要导入模块: from recipe.configuration.definition.recipe_definition import RecipeDefinition [as 别名]
# 或者: from recipe.configuration.definition.recipe_definition.RecipeDefinition import get_next_jobs_to_queue [as 别名]
def test_successful_job_1_completed(self, mock_store):
'''Tests calling RecipeDefinition.get_next_jobs_to_queue() successfully when job 1 has been completed.'''
definition = {
'version': '1.0',
'input_data': [{
'name': 'Recipe Input',
'type': 'file',
'media_types': ['text/plain'],
}],
'jobs': [{
'name': 'Job 1',
'job_type': {
'name': self.job_type_1.name,
'version': self.job_type_1.version,
},
'recipe_inputs': [{
'recipe_input': 'Recipe Input',
'job_input': self.input_name_1,
}]
}, {
'name': 'Job 2',
'job_type': {
'name': self.job_type_2.name,
'version': self.job_type_2.version,
},
'dependencies': [{
'name': 'Job 1',
'connections': [{
'output': self.output_name_1,
'input': self.input_name_2,
}],
}],
}],
}
recipe_definition = RecipeDefinition(definition)
recipe_definition.validate_job_interfaces()
data = {
'version': '1.0',
'input_data': [{
'name': 'Recipe Input',
'file_id': self.file_1.id,
}],
'workspace_id': 1,
}
recipe_data = RecipeData(data)
recipe_definition.validate_data(recipe_data)
png_file_ids = [98, 99, 100]
job_results = JobResults()
job_results.add_file_list_parameter(self.output_name_1, png_file_ids)
job_1 = Job.objects.select_related('job_type').get(pk=self.job_1.id)
job_1.results = job_results.get_dict()
job_1.save()
job_2 = Job.objects.select_related('job_type').get(pk=self.job_2.id)
results = recipe_definition.get_next_jobs_to_queue(recipe_data, {'Job 2': job_2}, {'Job 1': job_1})
# Make sure only Job 2 is returned and that its job data is correct
self.assertListEqual([self.job_2.id], results.keys())
self.assertDictEqual(results[self.job_2.id].get_dict(), {
'version': '1.0',
'input_data': [{
'name': self.input_name_2,
'file_ids': png_file_ids,
}],
'output_data': [{
'name': self.output_name_2,
'workspace_id': 1,
}],
})