Skip to content

Accept OSI directory as the loader root#226

Open
nicosuave wants to merge 2 commits into
mainfrom
fix-osi-accept-osi-dir-root
Open

Accept OSI directory as the loader root#226
nicosuave wants to merge 2 commits into
mainfrom
fix-osi-accept-osi-dir-root

Conversation

@nicosuave

Copy link
Copy Markdown
Member

Follow-up to #206: when a CLI user points sidemantic validate or load_from_directory straight at the OSI/ directory itself (the folder dbt users are told to drop released-spec OSI documents in), the JSON file sits directly at the loader root with no leading OSI/ path component. relative_parts was only ('model.json',), so the OSI-tree guard returned False, the JSON was never routed to OSIAdapter, and validation reported "No models found".

_is_under_osi_tree now also accepts an OSI-shaped JSON sitting directly in a loader root whose own directory name is OSI (case per the existing _OSI_TREE_DIR constant), in addition to the existing top-level OSI/ subtree case. The generated-artifact exclusion (target/, dbt_packages/) and the OSI-shape check are unchanged, so an archived/scratch OSI document under a non-OSI folder is still ignored.

Known limitation: this only matches when the loaded directory itself is literally named OSI; an OSI document at a differently-named root (e.g. validate . from a project root with the document at top level) is still rejected, matching dbt's <project_root>/OSI/ scope.

When sidemantic validate or load_from_directory is pointed directly at
an OSI/ directory, the JSON file sits at the loader root with no leading
OSI/ path component, so the OSI-tree guard rejected it and validation
reported no models. _is_under_osi_tree now also accepts an OSI-shaped JSON
sitting directly in a loader root that is itself named OSI (case per the
existing constant), preserving the generated-artifact exclusion and
OSI-shape check.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a07f1f00f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/loaders.py
When sidemantic loads an OSI/ directory directly, a document in a subdirectory of
it was skipped because the guard only checked the leading relative path component.
Loading the parent project accepts the same nested file (rglob + leading OSI/
check), so the two entrypoints disagreed. Treat every descendant as in the OSI
tree when the loaded directory itself is named OSI.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 454c47efb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidemantic/loaders.py
Comment on lines +508 to +509
if directory.name.casefold() == _OSI_TREE_DIR.casefold():
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve the loader root before checking for OSI

When users run the CLI from inside the OSI folder with the default path (cd project/OSI && sidemantic validate) or call load_from_directory(layer, ".") after chdiring there, directory is Path("."), whose .name is empty, so this new branch does not fire and a direct model.json is still skipped as “No models found.” Since the change is meant to accept the OSI directory itself as the loader root, check the resolved/absolute directory name rather than the raw argument.

Useful? React with 👍 / 👎.

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