Skip to content

chore: make _path optional and more representative #4303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

benfdking
Copy link
Contributor

@benfdking benfdking commented May 2, 2025

At the moment, the path type is slightly confusing. Models can exist without a Path. Rather than mark the _path property as None we call Path() which is equivalent to calling Path(".") which is not particularly indicative it just returns your path to cwd. Optional is a much better representation.

@benfdking benfdking marked this pull request as draft May 2, 2025 16:45
@benfdking benfdking force-pushed the rough_making_model_node_optional branch from 4b06000 to 7caa5fa Compare May 15, 2025 10:45
@benfdking benfdking marked this pull request as ready for review May 15, 2025 10:45
@benfdking benfdking changed the title NOT READY: chore: make _path optional chore: make _path optional and thus more representative May 15, 2025
@benfdking benfdking force-pushed the rough_making_model_node_optional branch from 7caa5fa to ac68e4c Compare June 4, 2025 10:45
@benfdking benfdking force-pushed the rough_making_model_node_optional branch from aab1108 to b7be02d Compare June 11, 2025 19:33
@benfdking benfdking changed the title chore: make _path optional and thus more representative chore: make _path optional and more representative Jun 12, 2025
@benfdking benfdking force-pushed the rough_making_model_node_optional branch from b7be02d to f25a7ee Compare June 17, 2025 11:23
@benfdking benfdking force-pushed the rough_making_model_node_optional branch 2 times, most recently from 99d0f86 to 7055cb5 Compare July 4, 2025 17:26
- more correctly represent path being optional
@benfdking benfdking force-pushed the rough_making_model_node_optional branch from 7055cb5 to 98b2d25 Compare July 4, 2025 17:26
@@ -2171,6 +2173,8 @@ def load_sql_based_model(
# The name of the model will be inferred from its path relative to `models/`, if it's not explicitly specified
name = meta_fields.pop("name", "")
if not name and infer_names:
if path is None:
raise ValueError("Model must have a name", path)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is the path included, given that it's None. the string message should be enough

@@ -207,6 +207,8 @@ def _convert_models(

if model.kind.is_seed:
# this will produce the original seed file, eg "items.csv"
if model._path is None:
raise ValueError(f"Unhandled model path: {model._path}")
Copy link
Contributor

Choose a reason for hiding this comment

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

again in these I'm confused about the inclusion of model._path in the error message when it's none

return models.Model(
name=model.name,
fqn=model.fqn,
path=str(model._path.absolute().relative_to(context.path).as_posix()),
full_path=str(model._path.absolute().as_posix()),
path=str(path.absolute().relative_to(context.path).as_posix()) if path else None,
Copy link
Contributor

Choose a reason for hiding this comment

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

in line 125 you check for none and raise so here there is no need for a check as the path should exist

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.

3 participants