tensorflow / metadata

Utilities for passing TensorFlow-related metadata between tools
Apache License 2.0
106 stars 49 forks source link

Error when running any Tensorflow Extended Component twice #38

Closed JPXKQX closed 2 years ago

JPXKQX commented 2 years ago

Version Info: Python: 3.9.12 TensorFlow: 2.9.1 TensorFlow Extended (TFX): 1.9.0 TensorFlow Data Validation: 1.9.0 TensorFlow ML Metadata: 1.9.0

Trace Error:

I have reproduced the error with the following installation: AlreadyExistsError Traceback (most recent call last) /tmp/ipykernel_400871/1925612415.py in <cell line: 7>() 5 ) 6 ----> 7 context.run(statistics_gen) ......

~/miniconda3/envs/reportTFbug/lib/python3.9/site-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: 16 uri: "/PATH/TO/PROJECT/pipeline/StatisticsGen/statistics/5" custom_properties { key: "name" value { string_value: "statistics" } } custom_properties { key: "producer_component" value { string_value: "StatisticsGen" } } name: "statistics" INTERNAL: Cannot create node for type_id: 16 uri: "/PATH/TO/PROJECT/pipeline/StatisticsGen/statistics/5" custom_properties { key: "name" value { string_value: "statistics" } } custom_properties { key: "producer_component" value { string_value: "StatisticsGen" } } name: "statistics"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(16, '/PATH/TO/PROJECT/pipeline/StatisticsGen/statistics/5', NULL, 'statistics', 1658136178744, 1658136178744);

This error can be reproduced easily by creating and python environment with the latest version of tfx, as follows,

conda create -n env-tf-error python==3.9
conda activate env-tf-error
pip install tfx jupyter

and running the following notebook reportTFbug.pdf

with this sample data.csv from Iris dataset.

More info about the error: Looking at the metadata.sqlite inside the pipeline, the table Artifacts when the workflow fails is id type_id uri state name create_time_since_epoch last_update_time_since_epoch
1 14 /PATH/TO/PROJECT/pipeline/CsvExampleGen/examples/1 2 1658136824003 1658136824928
2 16 /PATH/TO/PROJECT/pipeline/StatisticsGen/statistics/2 2 statistics 1658136824970 1658136827866
3 18 /PATH/TO/PROJECT/pipeline/SchemaGen/schema/3 2 schema 1658136827901 1658136827916
4 18 /PATH/TO/PROJECT/pipeline/updated_schema.pbtxt 1658136828010 1658136828041

The code fails when trying to insert a new row,

INSERT INTO Artifact( type_id, uri, state, name, create_time_since_epoch, last_update_time_since_epoch ) VALUES(16, '/home/mario/PycharmProjects/reportTFbug/pipeline/StatisticsGen/statistics/5', NULL, 'statistics', 1658137654606, 1658137654606);

This error occurs also with the previous 1.8.0 and 1.7.0 versions but not for 1.3.0.

JPXKQX commented 2 years ago

The bug comes from tfx, and a solution is proposed in here