Skip to content

Commit e4422cb

Browse files
authored
Feat: improve blueprint loading performance (#4030)
1 parent 7040c74 commit e4422cb

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

sqlmesh/core/model/decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def models(
9797
) -> t.List[Model]:
9898
return create_models_from_blueprints(
9999
gateway=self.kwargs.get("gateway"),
100-
blueprints=self.kwargs.get("blueprints"),
100+
blueprints=self.kwargs.pop("blueprints", None),
101101
get_variables=get_variables,
102102
loader=self.model,
103103
path=path,

sqlmesh/core/model/definition.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,8 @@ def load_sql_based_models(
19351935
if prop.name == "gateway":
19361936
gateway = prop.args["value"]
19371937
elif prop.name == "blueprints":
1938-
blueprints = prop.args["value"]
1938+
# We pop the `blueprints` here to avoid walking large lists when rendering the meta
1939+
blueprints = prop.pop().args["value"]
19391940

19401941
if isinstance(blueprints, d.MacroFunc):
19411942
rendered_blueprints = render_expression(
@@ -2362,9 +2363,6 @@ def _create_model(
23622363
variables: t.Optional[t.Dict[str, t.Any]] = None,
23632364
**kwargs: t.Any,
23642365
) -> Model:
2365-
# blueprints are not really part of the model meta, so we pop it off here before validation kicks in
2366-
kwargs.pop("blueprints", None)
2367-
23682366
_validate_model_fields(klass, {"name", *kwargs} - {"grain", "table_properties"}, path)
23692367

23702368
for prop in PROPERTIES:

0 commit comments

Comments
 (0)