Skip to content

Commit 08386e6

Browse files
committed
feat(ledger): holon-jsonld-lineage on download_report_bundle
The lineage holon (the holon with its #lineage graph: the ledger lines, entries and events behind every frozen figure) had no short alias, so a caller had to pass the GraphQL enum name, and a download whose response named no file landed as .tavi.json. "holon-jsonld-lineage" now maps to HOLON_JSONLD_LINEAGE, a nameless download lands as .lineage.holon.jsonld, and the docstring lists the format. Claude-Session: https://claude.ai/code/session_015PxYaVzrbraKFeRALM7rXp
1 parent 95b8562 commit 08386e6

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎robosystems_client/clients/ledger_client.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@
786786
# ``ReportDownloadFormat`` enum names used as query variables.
787787
_DOWNLOAD_FORMAT_ALIASES = {
788788
"holon-jsonld": "HOLON_JSONLD",
789+
"holon-jsonld-lineage": "HOLON_JSONLD_LINEAGE",
789790
"xbrl-2.1": "XBRL_2_1",
790791
"tavi": "TAVI",
791792
}
@@ -3782,8 +3783,12 @@ def download_report_bundle(
37823783
format: Serialization flavor — ``"holon-jsonld"`` (default, the
37833784
dataset-form scene/boundary/projection holon, which carries
37843785
the whole report and is stamped at publish), ``"tavi"`` (the
3785-
Project Tavi compiled model), or ``"xbrl-2.1"``. The enum names ``"TAVI"`` /
3786-
``"HOLON_JSONLD"`` / ``"XBRL_2_1"`` are also accepted.
3786+
Project Tavi compiled model), ``"xbrl-2.1"``, or
3787+
``"holon-jsonld-lineage"`` (the holon with its ``#lineage`` graph:
3788+
the ledger lines, entries and events behind every frozen figure,
3789+
for this graph's own members). The enum names ``"TAVI"`` /
3790+
``"HOLON_JSONLD"`` / ``"HOLON_JSONLD_LINEAGE"`` / ``"XBRL_2_1"``
3791+
are also accepted.
37873792
to: Optional file path to write the bytes to. When set, the
37883793
returned ``ReportBundleDownload.path`` points at the
37893794
written file.
@@ -3830,6 +3835,7 @@ def download_report_bundle(
38303835
default_ext = {
38313836
"XBRL_2_1": "zip",
38323837
"HOLON_JSONLD": "holon.jsonld",
3838+
"HOLON_JSONLD_LINEAGE": "lineage.holon.jsonld",
38333839
}.get(gql_format, "tavi.json")
38343840
filename = (
38353841
_parse_filename(artifact.headers.get("content-disposition", ""))

‎tests/test_ledger_client.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3252,6 +3252,28 @@ def test_default_download_is_the_holon(self, mock_client_cls, mock_config, graph
32523252
# The bytes come from following the presigned URL.
32533253
assert mock_client.get.call_args.args[0].startswith("https://s3.example.com/")
32543254

3255+
@patch("robosystems_client.clients.ledger_client.httpx.Client")
3256+
def test_lineage_download_takes_the_short_alias(
3257+
self, mock_client_cls, mock_config, graph_id
3258+
):
3259+
"""``holon-jsonld-lineage`` names the lineage holon; with no filename from
3260+
the server it lands as ``.lineage.holon.jsonld``, never ``.tavi.json``."""
3261+
artifact = self._mock_artifact(b'{"@graph": []}', "")
3262+
artifact.headers = {}
3263+
self._patch_httpx(mock_client_cls, artifact)
3264+
with patch.object(
3265+
LedgerClient,
3266+
"_query",
3267+
return_value=self._gql_data("application/ld+json", "holon-jsonld-lineage", gen=3),
3268+
) as mock_query:
3269+
result = LedgerClient(mock_config).download_report_bundle(
3270+
graph_id, "rpt_01", format="holon-jsonld-lineage"
3271+
)
3272+
3273+
assert mock_query.call_args.args[2]["format"] == "HOLON_JSONLD_LINEAGE"
3274+
assert result.format == "holon-jsonld-lineage"
3275+
assert result.filename == "rpt_01-g3.lineage.holon.jsonld"
3276+
32553277
@patch("robosystems_client.clients.ledger_client.httpx.Client")
32563278
def test_xbrl_download_follows_presigned_url(
32573279
self, mock_client_cls, mock_config, graph_id

0 commit comments

Comments
 (0)