From 1ce76055f5e81bf7ac8eefc776d24292cee3d82b Mon Sep 17 00:00:00 2001 From: KaifAhmad1 Date: Wed, 26 Aug 2026 19:33:00 +0530 Subject: [PATCH] docs(cookbook): record relationship endpoints explicitly in metadata track_relationship() has no dedicated subject/object fields, so the Step 2 example only stored relationship_id + type, leaving readers unable to reconstruct which two entities the relationship connects. Encode subject_entity_id/object_entity_id in metadata by convention, and note the lack of dedicated fields in the prose. --- cookbook/introduction/22_Provenance_Tracking.ipynb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cookbook/introduction/22_Provenance_Tracking.ipynb b/cookbook/introduction/22_Provenance_Tracking.ipynb index 7df9ab1d..de54ddf1 100644 --- a/cookbook/introduction/22_Provenance_Tracking.ipynb +++ b/cookbook/introduction/22_Provenance_Tracking.ipynb @@ -91,7 +91,9 @@ "source": [ "## Step 2: Track the Relationship Between Facts\n", "\n", - "Facts rarely stand alone. The claim about biomass increase is *about* the marine reserve — that relationship is a first-class provenance-tracked object too." + "Facts rarely stand alone. The claim about biomass increase is *about* the marine reserve — that relationship is a first-class provenance-tracked object too.\n", + "\n", + "`track_relationship()` has no dedicated subject/object fields, so by convention we record which two entities it connects inside `metadata`." ] }, { @@ -103,10 +105,16 @@ "rel = prov.track_relationship(\n", " relationship_id=\"rel_biomass_about_reserve\",\n", " source=\"DOI:10.1371/journal.pone.0023601\",\n", - " metadata={\"type\": \"measured_at\"},\n", + " metadata={\n", + " \"type\": \"measured_at\",\n", + " # No dedicated endpoint fields on track_relationship() yet -- record\n", + " # which entities this relationship connects here by convention.\n", + " \"subject_entity_id\": \"claim_biomass_increase\",\n", + " \"object_entity_id\": \"marine_reserve_1\",\n", + " },\n", ")\n", "\n", - "print(\"Relationship tracked:\", rel.entity_id)" + "print(\"Relationship tracked:\", rel.entity_id, \"|\", rel.metadata[\"subject_entity_id\"], \"->\", rel.metadata[\"object_entity_id\"])" ] }, {