def testResolveArtifactFailIncompleteResult(self): with metadata.Metadata(connection_config=self.connection_config) as m: driver = resolver._ResolverDriver(metadata_handler=m) driver.pre_execution( component_info=self.component_info, pipeline_info=self.pipeline_info, driver_args=self.driver_args, input_dict=self.source_channels, output_dict=self.source_channels.copy(), exec_properties={ resolver.RESOLVER_STRATEGY_CLASS: latest_artifact_strategy.LatestArtifactStrategy, resolver.RESOLVER_CONFIG: {} })
def testResolveArtifactSuccess(self): existing_artifact = standard_artifacts.Examples() existing_artifact.uri = 'my/uri' with metadata.Metadata(connection_config=self.connection_config) as m: contexts = m.register_pipeline_contexts_if_not_exists( self.pipeline_info) m.publish_artifacts([existing_artifact]) m.register_execution(exec_properties={}, pipeline_info=self.pipeline_info, component_info=self.component_info, contexts=contexts) m.publish_execution(component_info=self.component_info, output_artifacts={'key': [existing_artifact]}) driver = resolver._ResolverDriver(metadata_handler=m) output_dict = self.source_channels.copy() execution_result = driver.pre_execution( component_info=self.component_info, pipeline_info=self.pipeline_info, driver_args=self.driver_args, input_dict=self.source_channels, output_dict=output_dict, exec_properties={ resolver.RESOLVER_STRATEGY_CLASS: latest_artifact_strategy.LatestArtifactStrategy, resolver.RESOLVER_CONFIG: { 'desired_num_of_artifacts': 1 } }) self.assertTrue(execution_result.use_cached_results) self.assertEmpty(execution_result.input_dict) self.assertDictEqual( execution_result.exec_properties, { resolver.RESOLVER_STRATEGY_CLASS: latest_artifact_strategy.LatestArtifactStrategy, resolver.RESOLVER_CONFIG: { 'desired_num_of_artifacts': 1 } }) self.assertEqual( execution_result.output_dict[self.source_channel_key][0].uri, existing_artifact.uri) # TODO(b/148828122): Remove this after b/148828122 resolved. self.assertEqual(output_dict[self.source_channel_key].get()[0].uri, existing_artifact.uri)