Repository navigation
feat(datalens): -o name prints the identifier of DataLens objects too - #572
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The follow-up #569 promised:
-o namefor 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.pygets 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_IDENTIFIERwith its reason.preparewritesx-ycli-identityand the class getsAnnotated[…, Identity()], through the same path asNoDropNull.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 (connectionIdasked,idanswered), or the section has nogetat 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.
workbooks entries-list(getWorkbookEntries)entryId,workbookIdworkbookId: every line the same workbookentryIdcollections content-list(getCollectionContent)workbookId,collectionIdcollectionId, its parentworkbookIdcollectionId,workbookId,entryIdcollectionIdentryIdSo
getWorkbookEntriesis declared to return entries;getCollectionContentreturns several kinds and names none (an id alone would not say which command reads it);getRevisionsreturns revisions (revId, what--rev-idtakes).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.
tests/architecture/test_names.pyno longer excuses a class by the module it lives in: the five generated listing items still unnamed have a reason each inNO_NAME(the four items ofcollections content-list; the subject of the three access-binding listings).Choices to know about
userId, notlicenseId: no command takes a licence id;licenses-assignand--user-idstake user ids.members listis named bysub. Not verified live that a member'ssubis the idlicenses-assignaccepts (DataLens does not accept this machine's token); no example of that pipe is added to the docs.-o nameprints the operation's id, the onelakehouseoperations gettakes. The how-to says so.id(datalens.datasets.update,datalens.datasets.validate); they are named in the test and assert the error. Whether the livevalidateDatasetreply carries anid: couldn't verify.Known gap, not solved here
The results that wrap the object stay refused under
-o name, though… create -o nameis 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,ruffclean;gen_datalens_models.py --checkpasses; pre-commit hooks passed. That run was on this tree; only the squash followed it.workbooks entries-list -o nameprints two entry ids, different from each other, none is the workbook asked for;collections content-listis refused with no request sent;entries revisions-listprints therevIdof each item.getWorkbookEntriesoverride removed (the named test fails: workbook ids).Not run
Regenerated from the same saved specification as #570 (
~/.cache/ycli-research/name/dl/spec.json, sha256798680dfba3eca36573e883a1796c5fea3a524b3d4dba17245671872ef8c24cf), so the diff of the models is the marks only.🤖 Generated with Claude Code