Skip to content

Feat(cicd_bot): Allow forward-only plans based on branch suffix#4953

Merged
erindru merged 3 commits intomainfrom
erin/cicd-forward-only
Jul 14, 2025
Merged

Feat(cicd_bot): Allow forward-only plans based on branch suffix#4953
erindru merged 3 commits intomainfrom
erin/cicd-forward-only

Conversation

@erindru
Copy link
Collaborator

@erindru erindru commented Jul 11, 2025

Prior to this, there was no way to trigger the CICD bot to perform a --forward-only plan.

This PR:

  • Adds a new bot property, forward_only_branch_suffix which defaults to -forward-only. This means that any PR's where the git branch ends in -forward-only, eg erin/update-sales-model-forward-only will have the --forward-only flag added to the PR environment and prod deployment plans
  • Adds a tip to the comment the bot creates against the PR on how to restate historical data

The PR Environment Synced step looks like (notice the (Forward Only) indicators and forward_only=True in the plan flags):
Screenshot From 2025-07-11 12-21-59

The bot comment on the PR after prod deployment looks like:
Screenshot From 2025-07-11 13-26-32

@plaflamme
Copy link
Contributor

FWIW: a more general solution would be to allow more sophisticated commands. For example, we have customized our CI to allow things like:

/categorize non-breaking

Which categorizes all changes as non-breaking. Similarly for breaking and forward-only. Ideally, we'd allow specifying this on a per-model basis, perhaps using some kind of form or just something like /catgorize non-breaking model-a, model-b, but that seems rather tedious... Perhaps the bot could submit a comment as a form with tickboxes and then the user can do /plan to trigger a new plan with the categorization taken from the form, e.g.:

model-a

  • breaking
  • non-breaking
  • forward-only

In practice though, we've found that applying the same categorization on all changes typically works fine...

@erindru erindru force-pushed the erin/cicd-forward-only branch from 22cae4b to 4cd4d14 Compare July 11, 2025 01:44
@erindru
Copy link
Collaborator Author

erindru commented Jul 11, 2025

Thanks @plaflamme , we did discuss a more generic solution for specifying plan flags internally but ultimately decided to not go down that path just yet.

Regarding categorization in particular, we noticed that most people are using auto categorization so we currently have no plans to provide an interface for manual categorization via the bot.

"> [!TIP]\n"
"> In order to see this forward-only plan retroactively apply to historical intervals on the production model, run the below for date ranges in scope:\n"
"> \n"
f"> `$ sqlmesh plan --restate-model {example_model_name} --start YYYY-MM-dd --end YYYY-MM-DD`\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"> `$ sqlmesh plan --restate-model {example_model_name} --start YYYY-MM-dd --end YYYY-MM-DD`\n"
f"> `$ sqlmesh plan --restate-model {example_model_name} --start YYYY-MM-DD --end YYYY-MM-DD`\n"

quick nit

"""> [!TIP]
> In order to see this forward-only plan retroactively apply to historical intervals on the production model, run the below for date ranges in scope:
>
> `$ sqlmesh plan --restate-model sushi.customer_revenue_by_day --start YYYY-MM-dd --end YYYY-MM-DD`"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
> `$ sqlmesh plan --restate-model sushi.customer_revenue_by_day --start YYYY-MM-dd --end YYYY-MM-DD`"""
> `$ sqlmesh plan --restate-model sushi.customer_revenue_by_day --start YYYY-MM-DD --end YYYY-MM-DD`"""

same nit

@erindru erindru force-pushed the erin/cicd-forward-only branch from 4cd4d14 to b8433e9 Compare July 13, 2025 20:36
Copy link
Contributor

@themisvaltinos themisvaltinos left a comment

Choose a reason for hiding this comment

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

looks good to me, just a small nit typo in the alias

pr_min_intervals: t.Optional[int] = None
prod_branch_names_: t.Optional[str] = Field(default=None, alias="prod_branch_name")
forward_only_branch_suffix_: t.Optional[str] = Field(
default=None, alias="foward_only_branch_suffix"
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a typo in the alias foward instead of forward in case this affects the config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, thanks for spotting. The real question is why didn't a test fail 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, test contains same typo 🤦

@erindru erindru force-pushed the erin/cicd-forward-only branch from 3366622 to e9d0a2d Compare July 14, 2025 21:27
@erindru erindru force-pushed the erin/cicd-forward-only branch from e9d0a2d to 549036c Compare July 14, 2025 21:46
@erindru erindru merged commit 5dfdeca into main Jul 14, 2025
27 checks passed
@erindru erindru deleted the erin/cicd-forward-only branch July 14, 2025 22:08
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.

4 participants