From 2a159bf077df02692cabb22e54b6ba6a9bd43b63 Mon Sep 17 00:00:00 2001 From: Sai Kaushik Ponnekanti Date: Tue, 14 Apr 2026 22:04:18 -0700 Subject: [PATCH] feat: add get_lineage() to Python client Add MarquezClient.get_lineage(node_id, depth) method that fetches the lineage graph for a given node via GET /api/v1/lineage. The node_id format follows the existing convention: - For datasets: "dataset::" - For jobs: "job::" This was the last missing piece: users could already fetch column lineage but not the standard lineage graph from the Python client. Closes #1798 Signed-off-by: Sai Kaushik Ponnekanti --- clients/python/marquez_client/client.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/clients/python/marquez_client/client.py b/clients/python/marquez_client/client.py index 7279f28ec5..3373ffe172 100644 --- a/clients/python/marquez_client/client.py +++ b/clients/python/marquez_client/client.py @@ -343,6 +343,32 @@ def get_job_run(self, run_id): Utils.is_valid_uuid(run_id, 'run_id') return self._get(self._url('/jobs/runs/{0}', run_id)) + def get_lineage(self, node_id, depth=None): + """Fetch the lineage graph for a given node. + + Returns the lineage graph (upstream and downstream datasets and jobs) + for the specified node ID. The node ID format is: + - For datasets: "dataset::" + - For jobs: "job::" + + Args: + node_id: The node identifier to fetch lineage for. + depth: The maximum depth of the lineage graph (default: 20). + + Returns: + A dict representing the lineage graph with nodes and edges. + """ + if not node_id: + raise ValueError('node_id must not be None') + + return self._get( + self._url('/lineage'), + params={ + 'nodeId': node_id, + 'depth': depth or DEFAULT_DEPTH + } + ) + def get_column_lineage_by_dataset( self, namespace,