Skip to content
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

Fix: no_prompts flag not considered when creating plan #3600

Closed
wants to merge 2 commits into from

Conversation

lafirm
Copy link
Contributor

@lafirm lafirm commented Jan 9, 2025

When I tried to create a plan using python script with below settings, I ran into a problem because the plan method expects us to confirm whether we want to apply the plan or not which doesn't respect the no_prompts flag clearly. I believe that the no_prompts flag is used to disable any interactive prompts, so I made this change. I'd really appreciate any suggestions and feedbacks, thanks :)

plan = context.plan(
            environment=environment,
            no_prompts=True,
            auto_apply=False,
            no_gaps=True,
           )

Error:

File "/home/.local/lib/python3.11/site-packages/sqlmesh/core/analytics/__init__.py", line 110, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/sqlmesh/core/context.py", line 1136, in plan
    self.console.plan(
  File "/home/.local/lib/python3.11/site-packages/sqlmesh/core/console.py", line 695, in plan
    self._show_options_after_categorization(
  File "/home/.local/lib/python3.11/site-packages/sqlmesh/core/console.py", line 799, in _show_options_after_categorization
    if not auto_apply and self._confirm(
                          ^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/sqlmesh/core/console.py", line 334, in _confirm
    return Confirm.ask(message, console=self.console, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/rich/prompt.py", line 149, in ask
    return _prompt(default=default, stream=stream)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/rich/prompt.py", line 292, in __call__
    value = self.get_input(self.console, prompt, self.password, stream=stream)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/rich/prompt.py", line 211, in get_input
    return console.input(prompt, password=password, stream=stream)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/.local/lib/python3.11/site-packages/rich/console.py", line 2156, in input
    result = input()

@lafirm lafirm force-pushed the plan_no_auto_apply_fix branch 2 times, most recently from e24ca76 to 5f790a7 Compare January 9, 2025 11:13
@lafirm lafirm force-pushed the plan_no_auto_apply_fix branch 3 times, most recently from 0cc7a50 to dfe4ff5 Compare January 10, 2025 04:46
@lafirm lafirm force-pushed the plan_no_auto_apply_fix branch from dfe4ff5 to 6b1540c Compare January 10, 2025 14:10
@izeigerman
Copy link
Member

izeigerman commented Jan 10, 2025

@lafirmm , the plan() API should only be used if you interact with the console. If you're using it programmatically then you should use plan_builder instead:

plan = context.plan_builder(environment=environment, no_gaps=True).build()

Closing this for now, feel free to re-open with additional questions / context.

no_prompts only impacts categorization and date prompts and that's by design.

@izeigerman izeigerman closed this Jan 10, 2025
@lafirm
Copy link
Contributor Author

lafirm commented Jan 11, 2025

@lafirmm , the plan() API should only be used if you interact with the console. If you're using it programmatically then you should use plan_builder instead:

plan = context.plan_builder(environment=environment, no_gaps=True).build()

Closing this for now, feel free to re-open with additional questions / context.

no_prompts only impacts categorization and date prompts and that's by design.

@izeigerman, alright, thanks! I'll use that. apologies, I thought that the no_prompts flag should disable all the interactive prompts because of this description. Should this be corrected?

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