Use ImportSchemaGen to put the curated schema to ML Metadata

Viewed 41

I am trying to generate statistics for my schema. but first I want to import the curated schema file into the ML metadata. but I keep getting an error. I have even tried using ImporterNode but it seems like it's deprecated

below is the code I am trying

user_schema_importer = tfx.components.ImportSchemaGen(
schema_file = schema_file
)

context.run(user_schema_importer, enable_cache=False)

context.show(user_schema_importer.outputs['result'])

Error:

---------------------------------------------------------------------------
AlreadyExistsError                        Traceback (most recent call last)
<ipython-input-45-ed19f846783e> in <module>
     10 
     11 # Run the component
---> 12 context.run(user_schema_importer, enable_cache=False)
     13 
     14 ### END CODE HERE ###

9 frames
/usr/local/lib/python3.7/dist-packages/ml_metadata/metadata_store/metadata_store.py in _pywrap_cc_call(self, method, request, response)
    238         self._metadata_store, request.SerializeToString())
    239     if status_code != 0:
--> 240       raise _make_exception(error_message.decode('utf-8'), status_code)
    241     response.ParseFromString(response_str)
    242 

AlreadyExistsError: Given node already exists: type_id: 18
uri: "./pipeline/ImportSchemaGen/schema/7"
custom_properties {
  key: "name"
  value {
    string_value: "schema"
  }
}
custom_properties {
  key: "producer_component"
  value {
    string_value: "ImportSchemaGen"
  }
}
}
name: "schema"
INTERNAL: Cannot create node for type_id: 18 uri: "./pipeline/ImportSchemaGen/schema/7" custom_properties { key: "name" value { string_value: "schema" } } custom_properties { key: "producer_component" value { string_value: "ImportSchemaGen" } } name: "schema"Error when executing query: UNIQUE constraint failed: Artifact.type_id, Artifact.name query:  INSERT INTO `Artifact`(    `type_id`, `uri`, `state`, `name`, `create_time_since_epoch`,    `last_update_time_since_epoch` ) VALUES(18, './pipeline/ImportSchemaGen/schema/7', NULL, 'schema', 1662549196604, 1662549196604);
0 Answers
Related