Repository navigation
feat(semantic): rebuild second-generation models on pull and write them as files - #557
Conversation
7d4071b to
5b0b86d
Compare
5b0b86d to
c262da8
Compare
merr1988
left a comment
There was a problem hiding this comment.
Thanks Fei, the reader mirrors the writer closely, the round-trip test is a great safety net, and the per-type re-read answers my question from #556. Approving, with one question and a small optional note inline.
[Question] metrics_exclude comes back as '*' when it lists every metric (kc_converter.ts L271)
Since push expands '*' and never stores it, pull can't tell '*' from a list that happens to name every metric. Writing '*' back changes meaning on the next edit: after a pull, adding a metric silently excludes it from that profile, though the author's list didn't. Writing the sorted list only changes notation for someone who wrote '*', and never excludes more than they asked. Was '*' the agreed choice?
| }; | ||
| if (sidecar) { | ||
| return fileName === `${model}.overview.md` || | ||
| fileName.startsWith(`${model}/`) ? |
There was a problem hiding this comment.
[Optional] pulledFileTarget accepts any .overview.md under <model>/, while push reads only <model>.overview.md and <model>/{entities,metrics,relationships}/*.overview.md. Matching that set would keep pull from writing a sidecar push then ignores.
There was a problem hiding this comment.
Done in c025863: with sidecars on, pull now accepts only <model>.overview.md and <model>/{entities,metrics,relationships}/<name>.overview.md, the paths push reads, and skips any other sidecar name with the usual warning.
|
Thanks Miguel. This follows Dmitry's design in the 10/21 mapping exactly: pull derives the notation instead of storing it, and writes |
…em as files With KC_V2_ASPECTS on, pull rebuilds a model whose semantic-model aspect has specVersion from the second-generation types. Every value push stores there comes back. Each relationship comes from its own entry, and pull reads no entry link. Each metric's stored entity comes back as entity:, declared or derived. A field an entity only rebinds comes back from its sql-expressions records, since the schema lists declared fields only. Pull writes the model file, and for a Google-flavor model one file per named profile; a vanilla model keeps its profiles in its GOOGLE block. It writes an overview sidecar for each entry whose overview holds content, contentType or links. Content that opens with a --- line gets an empty frontmatter, so the next push reads it unchanged. A local profile file or sidecar the pull did not write draws a warning, and --force-remove deletes it. A read that returns 100 aspects is repeated once per aspect type. Pull names the schema-join link type in KC_TYPE_PROJECT, as push does, so a pull with KC_V2_ASPECTS off finds those links when KC_TYPE_PROJECT is set. Otherwise a pull with KC_V2_ASPECTS off is unchanged. Every rule here was settled by Fei Xu with Dmitry Lychagin, the author of the mapping.
c262da8 to
c025863
Compare
With
KC_V2_ASPECTSon, pull rebuilds a model pushed with the second-generation types from its entries. It writes the model back as its model file, its profile files and its overview sidecars.The mapping rules here were settled by Fei Xu with Dmitry Lychagin, the author of the mapping.
What changed
semantic-modelaspect hasspecVersiontakes the new reader.ai_contextwith custom members, and third-party blocks. Each named profile gets its sources, keys, field expressions, excluded fields and relationship columns from the entries. Itsmetrics_excludeis'*'when it excludes every metric, and otherwise a list sorted by name.entity:.schemalists only the fields it declares. A field the entity only rebinds comes back from itssql-expressionsrecords.GOOGLEblock. A rewritten profile file keeps theactions:it binds locally, since the catalog stores no profile's actions.<entry-id>.overview.mdfor each entry whose overview holds content, a content type or links. Content whose first line is---gets an empty frontmatter, so the next push reads the same content.--force-removedeletes it.KC_TYPE_PROJECTto the catalog reads. A flag-off pull now looks up relationship links in that project, where push writes them. Otherwise a flag-off pull is unchanged.What now fails
entry '<id>' holds 100 or more <type> aspects, and Knowledge Catalog returns at most 100 in one read, so pull cannot read them all; pull abortedNew warning:
local overview sidecar <path> is not in the catalog; delete it, or pull with --force-remove to delete it.What to look at closely
readEntityV2andwithRebindingsin kc_converter.ts, which rebuild the fields an entity declares and the ones it only rebinds.readModelV2fills each named profile from the entity, relationship and metric entries.pullSemanticModelin commands.ts and the file writer it calls, which writes the rebuilt files and sidecars and finds the stale ones.GOOGLEblocks, pulls each from entries listed in reverse, writes the files, loads them and pushes again. It expects the same entries, links, and BigQuery and Spanner DDL.