|
19 | 19 | class SQLMeshRunConfig(dg.Config): |
20 | 20 | # Set this to True to restate the selected models |
21 | 21 | restate_models: list[str] | None = None |
22 | | - |
| 22 | + |
23 | 23 | # Set this to True to dynamically identify models to restate based on entity_category tags |
24 | 24 | restate_by_entity_category: bool = False |
25 | 25 | # List of entity categories to restate (e.g., ["project", "collection"]) |
@@ -79,30 +79,34 @@ async def sqlmesh_project( |
79 | 79 | trino: TrinoResource, |
80 | 80 | config: SQLMeshRunConfig, |
81 | 81 | ): |
82 | | - |
83 | 82 | restate_models = config.restate_models[:] if config.restate_models else [] |
84 | | - |
85 | | - # Ensure that both trino and the mcs are available |
| 83 | + |
86 | 84 | async with multiple_async_contexts( |
87 | 85 | trino=trino.ensure_available(log_override=context.log), |
88 | 86 | ): |
89 | 87 | # If restate_by_entity_category is True, dynamically identify models based on entity categories |
90 | 88 | if config.restate_by_entity_category: |
91 | 89 | # Ensure we have entity categories to filter by |
92 | 90 | if not config.restate_entity_categories: |
93 | | - context.log.info("restate_by_entity_category is True but no entity categories specified. Using both 'project' and 'collection'.") |
| 91 | + context.log.info( |
| 92 | + "restate_by_entity_category is True but no entity categories specified. Using both 'project' and 'collection'." |
| 93 | + ) |
94 | 94 | entity_categories = ["project", "collection"] |
95 | 95 | else: |
96 | 96 | entity_categories = config.restate_entity_categories |
97 | | - context.log.info(f"Filtering models by entity categories: {entity_categories}") |
| 97 | + context.log.info( |
| 98 | + f"Filtering models by entity categories: {entity_categories}" |
| 99 | + ) |
98 | 100 |
|
99 | 101 | for category in entity_categories: |
100 | 102 | restate_models.append(f"tag:entity_category={category}") |
101 | 103 |
|
102 | 104 | plan_options: PlanOptions = {"skip_tests": config.skip_tests} |
103 | 105 | if config.allow_destructive_models: |
104 | | - plan_options["allow_destructive_models"] = config.allow_destructive_models |
105 | | - |
| 106 | + plan_options["allow_destructive_models"] = ( |
| 107 | + config.allow_destructive_models |
| 108 | + ) |
| 109 | + |
106 | 110 | # If we specify a dev_environment, we will first plan it for safety |
107 | 111 | if dev_environment: |
108 | 112 | context.log.info("Planning dev environment") |
@@ -130,7 +134,7 @@ async def sqlmesh_project( |
130 | 134 | yield result |
131 | 135 |
|
132 | 136 | all_assets_selection = AssetSelection.assets(sqlmesh_project) |
133 | | - |
| 137 | + |
134 | 138 | return AssetFactoryResponse( |
135 | 139 | assets=[sqlmesh_project], |
136 | 140 | jobs=[ |
|
0 commit comments