Пример #1
0
 def get_artifact(self) -> artifact.Artifact:
     """Gets an artifact object by parsing metadata or creating one from uri."""
     if self.metadata_file and self.output_name:
         return entrypoint_utils.get_artifact_from_output(
             self.metadata_file, self.output_name)
     else:
         # Provide an empty schema when returning a raw Artifact.
         result = artifact.Artifact(
             instance_schema=artifact.DEFAULT_ARTIFACT_SCHEMA)
         result.uri = self.uri
         return result
    def testGetArtifactFromOutput(self, mock_read):
        mock_read.return_value = _get_text_from_testdata(
            'executor_output.json')

        art = entrypoint_utils.get_artifact_from_output(file_path=os.path.join(
            'testdata', 'executor_output.json'),
                                                        output_name='output')
        self.assertIsInstance(art, ontology_artifacts.Model)
        self.assertEqual(art.uri, 'gs://root/execution/output')
        self.assertEqual(art.name, 'test-artifact')
        self.assertEqual(art.metadata['test_property'], 'test value')