Skip to content

feat(datalens): -o name prints the identifier of DataLens objects too - #572

Merged
bim-ba merged 1 commit into
mainfrom
feat/datalens-identifiers
Oct 10, 2026
Merged

bim-ba merged 1 commit into
mainfrom
feat/datalens-identifiers

Conversation

@bim-ba

@bim-ba bim-ba commented Oct 10, 2026

Copy link
Copy Markdown
Owner

The follow-up #569 promised: -o name for DataLens. Its models are generated from the specification, so the mark that names an object is put there by the generator, not by hand.

What it does

  • scripts/gen_datalens_models.py gets one table, _IDENTIFIERS: for each section of the specification, the key of a reply that says which object it is (what the command that reads the object takes). A section with no such object stands in _NO_IDENTIFIER with its reason. prepare writes x-ycli-identity and the class gets Annotated[…, Identity()], through the same path as NoDropNull.
  • Only a row of a reply is marked: the reply itself, or an item of a list in it. What lies deeper (the fields of a dataset) is read by no command and has no mark.
  • An error for a reply that leaves the identifier out now ends "The request was sent: a command that changes something has changed it", for every command: a script that sees exit code 1 after a write must not conclude the write did not happen.

Why a table and not a rule

The specification names the identifier by itself in 9 sections of 34 (the required argument of the section's get… operation that its reply repeats). Elsewhere the reply wraps the object, names the key otherwise than the request does (connectionId asked, id answered), or the section has no get at all (Embeds, RestCatalogs, Licensing, Navigation). So a declaration is needed; the derivation is not added as a second mechanism.

Why three operations are declared apart (_RETURNS_ANOTHER_KIND)

Under the section's key alone, three listing items would have been named WRONGLY: they are objects of another kind that carry the section's key as a reference to their parent.

Listing Item Keys it has The section's key gives Right
workbooks entries-list (getWorkbookEntries) an entry entryId, workbookId workbookId: every line the same workbook entryId
collections content-list (getCollectionContent) a workbook workbookId, collectionId collectionId, its parent workbookId
same an entry collectionId, workbookId, entryId collectionId entryId

So getWorkbookEntries is declared to return entries; getCollectionContent returns several kinds and names none (an id alone would not say which command reads it); getRevisions returns revisions (revId, what --rev-id takes).

The generator stops on

A section in neither table or in both; a declared section, or a declared operation, the specification no longer has; a key (of a section or of an operation) that no row it is declared for has; a schema two keys would name. Each has a test. One more test holds the two tables equal to the sections of the committed snapshot, both ways. When the rule was restricted to rows, the generator itself stopped on five sections whose replies wrap the object; they moved to _NO_IDENTIFIER.

Numbers

Marks in the generated models: 131 under "every schema reached from the section", 71 once restricted to rows; the commands that print names are the same in both.

Print names Refused
Listing commands, all services (105) 93 (was 71) 12 (was 34)
Commands that answer with one object (378) 217 (was 165) 161 (was 213)
DataLens listings (27) 23 4
DataLens single-object commands (108) 52 56

tests/architecture/test_names.py no longer excuses a class by the module it lives in: the five generated listing items still unnamed have a reason each in NO_NAME (the four items of collections content-list; the subject of the three access-binding listings).

Choices to know about

  • Licensing is named by userId, not licenseId: no command takes a licence id; licenses-assign and --user-ids take user ids.
  • members list is named by sub. Not verified live that a member's sub is the id licenses-assign accepts (DataLens does not accept this machine's token); no example of that pipe is added to the docs.
  • A DataLens command that starts a long operation (cloud environments, Spark and Trino clusters, REST catalogs) answers with the operation, so -o name prints the operation's id, the one lakehouseoperations get takes. The how-to says so.
  • Two contract cases have a canned reply with no id (datalens.datasets.update, datalens.datasets.validate); they are named in the test and assert the error. Whether the live validateDataset reply carries an id: couldn't verify.

Known gap, not solved here

The results that wrap the object stay refused under -o name, though … create -o name is the main use (#498): dashboards, reports, charts editor, charts wizard, charts ql, sqlqueries — get, create, update; htmlpages create / update; connections get (its union includes the kind the specification does not know); entrylocks create. A mark that reaches into a wrapper is its own question.

Checked

  • uv run pytest: 7020 passed, 5 skipped, coverage 100% (lines and branches); lint-imports, ty, ruff clean; gen_datalens_models.py --check passes; pre-commit hooks passed. That run was on this tree; only the squash followed it.
  • The named test: workbooks entries-list -o name prints two entry ids, different from each other, none is the workbook asked for; collections content-list is refused with no request sent; entries revisions-list prints the revId of each item.
  • Seen failing on its defect, then restored: a section without its line (the generator stops, the snapshot test fails); an override with a key no row has (the generator stops); the getWorkbookEntries override removed (the named test fails: workbook ids).

Not run

  • No live DataLens call.
  • The e2e scenarios.

Regenerated from the same saved specification as #570 (~/.cache/ycli-research/name/dl/spec.json, sha256 798680dfba3eca36573e883a1796c5fea3a524b3d4dba17245671872ef8c24cf), so the diff of the models is the marks only.

🤖 Generated with Claude Code

The models generated from the DataLens specification now mark the field that names the object. The generator reads it from one table, a key for each section of the specification (`_IDENTIFIERS`, or `_NO_IDENTIFIER` with the reason), and from the operations whose reply holds objects of another kind than their section (`_RETURNS_ANOTHER_KIND`). Only a row of a reply is marked: the reply itself or an item of a list in it.

The generator stops on a section in neither table, a declared key no row has, an operation the specification no longer has, and a schema two keys would name.

A reply that leaves the identifier out now says that the request was sent, so a script does not take a failed naming for a change that did not happen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
yandex-e2e — 85f1944e Deployed Oct 10, 2026 by bim-ba via live (all) #706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant