Ejemplo n.º 1
0
    def testGetLatestArtifact(self):
        with metadata.Metadata(connection_config=self._connection_config) as m:
            contexts = m.register_pipeline_contexts_if_not_exists(
                self._pipeline_info)
            artifact_one = standard_artifacts.Examples()
            artifact_one.uri = 'uri_one'
            m.publish_artifacts([artifact_one])
            artifact_two = standard_artifacts.Examples()
            artifact_two.uri = 'uri_two'
            m.publish_artifacts([artifact_two])
            m.publish_artifacts([artifact_one, artifact_two])
            m.register_execution(input_artifacts={
                'a': [artifact_one, artifact_two],
            },
                                 exec_properties={},
                                 pipeline_info=self._pipeline_info,
                                 component_info=self._component_info,
                                 contexts=contexts)

            resolver = latest_artifacts_resolver.LatestArtifactsResolver()
            resolve_result = resolver.resolve(
                pipeline_info=self._pipeline_info,
                metadata_handler=m,
                source_channels={
                    'input': types.Channel(type=artifact_one.type)
                })

            self.assertTrue(resolve_result.has_complete_result)
            self.assertEqual([
                artifact.uri
                for artifact in resolve_result.per_key_resolve_result['input']
            ], ['uri_two'])
            self.assertTrue(resolve_result.per_key_resolve_state['input'])
    def testGetLatestArtifact(self):
        contexts = self._metadata.register_pipeline_contexts_if_not_exists(
            self._pipeline_info)
        artifact_one = standard_artifacts.Examples()
        artifact_one.uri = 'uri_one'
        self._metadata.publish_artifacts([artifact_one])
        artifact_two = standard_artifacts.Examples()
        artifact_two.uri = 'uri_two'
        self._metadata.register_execution(exec_properties={},
                                          pipeline_info=self._pipeline_info,
                                          component_info=self._component_info,
                                          contexts=contexts)
        self._metadata.publish_execution(
            component_info=self._component_info,
            output_artifacts={'key': [artifact_one, artifact_two]})
        expected_artifact = max(artifact_one, artifact_two, key=lambda a: a.id)

        resolver = latest_artifacts_resolver.LatestArtifactsResolver()
        resolve_result = resolver.resolve(
            pipeline_info=self._pipeline_info,
            metadata_handler=self._metadata,
            source_channels={
                'input':
                types.Channel(
                    type=artifact_one.type,
                    producer_component_id=self._component_info.component_id,
                    output_key='key')
            })

        self.assertTrue(resolve_result.has_complete_result)
        self.assertEqual([
            artifact.uri
            for artifact in resolve_result.per_key_resolve_result['input']
        ], [expected_artifact.uri])
        self.assertTrue(resolve_result.per_key_resolve_state['input'])
    def testGetLatestArtifact_IrMode(self):
        artifact_one = standard_artifacts.Examples()
        artifact_one.uri = 'uri_one'
        artifact_one.id = 1
        artifact_two = standard_artifacts.Examples()
        artifact_two.uri = 'uri_two'
        artifact_one.id = 2

        expected_artifact = max(artifact_one, artifact_two, key=lambda a: a.id)

        resolver = latest_artifacts_resolver.LatestArtifactsResolver()
        result = resolver.resolve_artifacts(
            self._store, {'input': [artifact_two, artifact_one]})
        self.assertIsNotNone(result)
        self.assertEqual([a.uri for a in result['input']],
                         [expected_artifact.uri])
Ejemplo n.º 4
0
    def testArtifact(self):
        with metadata.Metadata(connection_config=self._connection_config) as m:
            # Publish multiple artifacts.
            artifact_one = standard_artifacts.Examples()
            artifact_one.uri = 'uri_one'
            m.publish_artifacts([artifact_one])
            artifact_two = standard_artifacts.Examples()
            artifact_two.uri = 'uri_two'
            m.publish_artifacts([artifact_two])

            resolver = latest_artifacts_resolver.LatestArtifactsResolver()
            resolve_result = resolver.resolve(
                m, {'input': types.Channel(type=artifact_one.type)})

            self.assertTrue(resolve_result.has_complete_result)
            self.assertEqual([
                artifact.uri
                for artifact in resolve_result.per_key_resolve_result['input']
            ], ['uri_two'])
            self.assertTrue(resolve_result.per_key_resolve_state['input'])