Repository navigation
fix(cli): let plan --restate-model run without local model files
#6219
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,9 @@ | |
| LOCAL_ONLY_COMMANDS = ("format",) | ||
| # Commands that are local-only when they're passed --local. | ||
| OPTIONAL_LOCAL_COMMANDS = ("lint", "test") | ||
| # Flags that, when passed to `plan`, make the command restatement-only and allow | ||
| # running without local model definitions, since restatements operate against state. | ||
| _RESTATE_ONLY_PLAN_FLAGS = ("--restate-model", "-r") | ||
|
|
||
|
|
||
| class _SQLMeshGroup(click.Group): | ||
|
|
@@ -151,6 +154,13 @@ def cli( | |
| if ctx.invoked_subcommand == "lint": | ||
| load = False | ||
|
|
||
| # `plan --restate-model` works entirely against state, so missing local model | ||
| # files shouldn't block it (parity with `run`). | ||
| if ctx.invoked_subcommand == "plan" and any( | ||
| arg in _RESTATE_ONLY_PLAN_FLAGS for arg in ctx.meta["subcommand_args"] | ||
| ): | ||
| load = False | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve backfill selection when disabling local loading. For deployed example models,
|
||
|
|
||
| configs = load_configs(config, Context.CONFIG_TYPE, paths, dotenv_path=dotenv) | ||
| log_limit = list(configs.values())[0].log_limit | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1771,7 +1771,17 @@ def plan_builder( | |
|
|
||
| expanded_restate_models = None | ||
| if restate_models is not None: | ||
| expanded_restate_models = model_selector.expand_model_selections(restate_models) | ||
| # Restatements operate entirely against state, so the selector must be | ||
| # able to find models that exist only in the target environment (for | ||
| # example when local model files are absent). | ||
| env_models_for_restate = model_selector._load_env_models( | ||
| environment, | ||
| fallback_env_name=create_from or c.PROD, | ||
| ensure_finalized_snapshots=self.config.plan.use_finalized_state, | ||
| ) | ||
| expanded_restate_models = model_selector.expand_model_selections( | ||
| restate_models, models={**env_models_for_restate, **self._models} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build the selector DAG from the environment models too. For deployed models
|
||
| ) | ||
|
|
||
| if (restate_models is not None and not expanded_restate_models) or ( | ||
| backfill_models is not None and not backfill_models and not selected_deletion_fqns | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recognize attached restatement option values.
With no local models,
plan --restate-model=sqlmesh_example.full_modelstill reaches the “doesn't seem to have any models” error. Click 8.1.8 preserves this token in the group arguments, so exact membership does not recognize it. The supported-rNAMEform has the same problem. Recognize attached values or inspect parsed option values. (raw.githubusercontent.com)