Repository navigation
skills: serve the bundled snapshot when no skills folder is set - #8199
Conversation
Resolve returns the bundled source when DATABRICKS_SKILLS_DIR is unset and the snapshot has skills. An empty snapshot still reports no source. LocalCatalog follows Resolve. skills read prints provenance through the shared line, so the bundled copy shows no fetched time. Co-authored-by: Isaac <no-reply@databricks.com>
✅ Integration test reportCommit: cb4b064
Top 3 slowest tests (at least 2 minutes):
|
… test Co-authored-by: Isaac <no-reply@databricks.com>
|
Pushed 9d8d254 for the review findings. Added a guard test (non-empty bundled copy, preview unset: GroupSkills returns nil, WriteGroupHint writes nothing). The bundled copy's provenance line is now "Skills come from bundled copy (release X). The skills may be out of date.", with no refresh claim; real stale catalogs keep their wording. list-files now forwards file sizes for the bundled copy. The three no-source tests set an empty bundled FS, and the newBundledSource comment is corrected. |
There was a problem hiding this comment.
Automated review at 9d8d254. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR makes skills list, read, read-file, list-files and search fall back to the bundled snapshot when DATABRICKS_SKILLS_DIR is unset, and routes LocalCatalog through Resolve. The fallback logic and the folder-wins precedence look right. One thing doesn't match the description: switching skills read to the shared provenanceLine changes its stale-cache message, and the test was edited to accept the new text. A few doc comments also no longer describe what the code does.
Comments outside the changed lines
- [nit]
libs/skills/bundled_source.go: ThebundledSnapshotcomment (lines 11-12) says it is the fallback for when the release can't be reached.bundledSource.Catalog(lines 65-67) says it "is only used when the release cannot be reached", andCatalog.Stalein skills.go:73-76 says the same. After this change,Resolveserves the bundled copy wheneverDATABRICKS_SKILLS_DIRis unset, without trying any release. The new comment at list.go:84 says as much ("No refresh was tried"). Can these comments be updated to say what happens now?
| } | ||
| if catalog.Stale { | ||
| cmdio.LogString(ctx, readProvenance(catalog)) | ||
| cmdio.LogString(ctx, provenanceLine(catalog)) |
There was a problem hiding this comment.
[nice to have] skills read now uses provenanceLine, which was written for skills list. For a stale cached catalog that isn't the bundled copy (for example Label: "release cache" with a FetchedAt set), stderr now ends with "so the list may be out of date." The old text was "so the content may be out of date." That reads oddly for a command that prints one skill, and it contradicts the description's "output and errors are unchanged". TestRunReadStaleCatalogWritesProvenanceToStderr (read_test.go:135) was changed to expect the new wording. Could the caller pass the noun in, or could the shared line use neutral wording like the bundled branch's "The skills may be out of date"?
There was a problem hiding this comment.
Fixed in e0eb4bb. skills read keeps its own wording ("so the content may be out of date") for a stale cached catalog, so its old output and TestRunReadStaleCatalogWritesProvenanceToStderr are back to the original text. Only the bundled copy takes the shared neutral line, which claims no failed refresh.
| if catalog.Label == libskills.BundledLabel { | ||
| return fmt.Sprintf("Skills come from %s (release %s). The skills may be out of date.", label, catalog.Version) | ||
| } | ||
| if catalog.FetchedAt.IsZero() { |
There was a problem hiding this comment.
[nit] The bundled copy now returns at line 85. Per Catalog.FetchedAt in skills.go, it is the only source with a zero fetch time, so this FetchedAt.IsZero() branch has no real input left. The test had to switch to a made-up "cached" label to reach it. The doc comment at lines 80-81 ("A bundled copy has no fetch time, so the line leaves it out") now describes the wrong branch. Should this branch go, or should the comment name the source it is kept for?
There was a problem hiding this comment.
Removed in e0eb4bb. The bundled copy is the only source with a zero fetch time and it returns earlier, so the zero-time branch is gone, along with its made-up "cached" test. The doc comment now describes the bundled branch.
| // set. | ||
| // LocalCatalog returns the freshest catalog that needs no network call: the | ||
| // folder in DATABRICKS_SKILLS_DIR when it is set, otherwise the bundled copy. | ||
| // It returns nil when neither has skills. It follows Resolve, so the two agree |
There was a problem hiding this comment.
[nit] "It returns nil when neither has skills" isn't quite what happens. When DATABRICKS_SKILLS_DIR is set, the bundled copy is never consulted. A folder whose manifest lists no skills returns a non-nil empty catalog, not nil. Maybe: "It returns nil when no folder is set and the bundled copy has no skills."
There was a problem hiding this comment.
Fixed in e0eb4bb. The doc now reads "It returns nil when no folder is set and the bundled copy has no skills."
…int tests Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
rugpanov
left a comment
There was a problem hiding this comment.
Reviewed head c232ab1.
Risk: LOW. The skills command group is hidden, and cmd/cmd.go:87 registers it only when DATABRICKS_SKILLS_PREVIEW is set. The committed snapshot is an empty manifest, so Resolve still returns ErrNoSource in released builds. The change affects only the source choice and the stderr provenance text of the preview commands, and a revert undoes it.
Pending checks at c232ab1: Integration Tests, task test (windows, direct), task test (macos, direct). No check failed.
The change does what the description says, and it stays behind the preview gate. The inline comments are not blocking.
| if catalog.FetchedAt.IsZero() { | ||
| return fmt.Sprintf("Skills come from %s (release %s). The source could not be refreshed, so the list may be out of date.", | ||
| label, catalog.Version) | ||
| if catalog.Label == libskills.BundledLabel { |
There was a problem hiding this comment.
[nice to have] provenanceLine now selects the wording by catalog.Label, not by catalog.FetchedAt.IsZero(). The Catalog.FetchedAt doc says that a zero time means "unknown" for any source. If a later source returns a stale catalog with a zero FetchedAt and another label, skills list and skills search print fetched 0001-01-01T00:00:00Z. No source does this today, but on main the IsZero() branch and TestProvenanceLineOmitsUnknownFetchTime prevented it. readProvenance in cmd/skills/read.go:140 has the same label check. Keep the bundled wording for BundledLabel, and also keep an IsZero() branch that leaves out the fetch time. Add back a test for a zero time with another label.
There was a problem hiding this comment.
Restored an IsZero() branch in both provenanceLine and readProvenance so a non-bundled stale catalog with an unknown fetch time omits the fetch time, and added TestProvenanceLineOmitsUnknownFetchTime.
| } | ||
|
|
||
| // FileSize forwards to the snapshot, so list-files reports sizes for it too. | ||
| func (s *bundledSource) FileSize(ctx context.Context, skill, file string) (int64, error) { |
There was a problem hiding this comment.
[nice to have] No test calls the new bundledSource.FileSize, and no test runs skills list-files on the bundled copy. If the empty-snapshot guard or the size forward breaks, CI does not find it. Add a case to TestBundledSourceFromFixture that calls FileSize on a file of the fixture skill. Also cover the empty snapshot.
There was a problem hiding this comment.
Added a FileSize case to TestBundledSourceFromFixture and TestBundledSourceFileSizeEmptySnapshot for the empty snapshot guard.
| if _, err := s.Catalog(ctx); err != nil { | ||
| return 0, err | ||
| } | ||
| return s.src.(FileSizer).FileSize(ctx, skill, file) |
There was a problem hiding this comment.
[nit] s.src.(FileSizer) has no ok check. It is safe today, because newBundledSource always sets src to the *fsSource from NewFSSource. If a later change wraps src in a Source without FileSize, skills list-files -o json panics on the bundled copy. Use the , ok form and return ErrNoSize when the assertion fails, or declare the field as *fsSource.
There was a problem hiding this comment.
Switched to the ok form and return ErrNoSize when the source has no FileSize.
…tion, test bundled FileSize Co-authored-by: Isaac <no-reply@databricks.com>
Changes
skills list,read,read-file,list-filesandsearchnow serve the copy bundled in the binary whenDATABRICKS_SKILLS_DIRis not set. A folder inDATABRICKS_SKILLS_DIRstill wins. If the bundled snapshot has no skills, as in every dev build today,Resolvestill returns the same "no source" error, so output and errors are unchanged.LocalCatalog(used by help hints) followsResolve, so the two read the same source.skills readprints the bundled copy's provenance line through the sharedprovenanceLine(other catalogs keep read's own wording), so the bundled copy shows "bundled copy" and no fetched time.SetBundledFSForTestlets tests serve a non-empty snapshot without filling the embed folder.Why
A released binary has no skills to serve without a folder. This is the first working version: it serves the bundled copy before the live release, cache and fallback chain exist. Those will sit in front of the bundled copy. The feature stays behind
DATABRICKS_SKILLS_PREVIEW.Tests
LocalCatalogagrees;listandreadlabel the copy and omit the fetched time.go test ./libs/skills/... ./cmd/skills/...andgo test ./acceptance -run 'TestAccept/cmd/skills'pass with no golden changes.This pull request and its description were written by Isaac.