Exercise 1-11 have good results with no errors, exercise 12 with errors, but all 12 exercises scored 0/10.
Exercise 12: Get parent artifacts
def get_parent_artifacts(store, artifact):
### START CODE HERE ###
# Get the artifact id of the input artifact
artifact_id = artifact.id
# Get events associated with the artifact id
artifact_id_events = store.get_events_by_artifact_ids(artifact_id)
# From the `artifact_id_events`, get the execution ids of OUTPUT events.
# Cast to a set to remove duplicates if any.
executions_id = set (
artifact_id_events.event.execution_id
for event in artifact_id_events
if event.type == metadata_store_pb2.Event.OUTPUT
)
# Get the events associated with the execution_id
execution_id_events = store.get_events_by_execution_ids(execution_id)
# From execution_id_events, get the artifact ids of INPUT events.
# Cast to a set to remove duplicates if any.
parent_artifact_ids = set (
event.artifact_id
for event in execution_id_events
if event.type == metadata_store_pb2.Event.INPUT
)
# Get the list of artifacts associated with the parent_artifact_ids
parent_artifact_list = store.get_artifacts_by_id(list[parent_artifact_ids])
### END CODE HERE ###
return parent_artifact_list
TypeError Traceback (most recent call last)
in
3
4 # Retrieve the parent artifacts of the instance
----> 5 parent_artifacts = get_parent_artifacts(store, artifact_instance)
6
7 # Display the results
in get_parent_artifacts(store, artifact)
7
8 # Get events associated with the artifact id
----> 9 artifact_id_events = store.get_events_by_artifact_ids(artifact_id)
10
11 # From the artifact_id_events
, get the execution ids of OUTPUT events.
/opt/conda/lib/python3.8/site-packages/ml_metadata/metadata_store/metadata_store.py in get_events_by_artifact_ids(self, artifact_ids)
1129
1130 request = metadata_store_service_pb2.GetEventsByArtifactIDsRequest()
→ 1131 for x in artifact_ids:
1132 request.artifact_ids.append(x)
1133 response = metadata_store_service_pb2.GetEventsByArtifactIDsResponse()
TypeError: ‘int’ object is not iterable