sqlmesh 0.189.3.dev10__py3-none-any.whl → 0.189.3.dev12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sqlmesh/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.189.3.dev10'
21
- __version_tuple__ = version_tuple = (0, 189, 3, 'dev10')
20
+ __version__ = version = '0.189.3.dev12'
21
+ __version_tuple__ = version_tuple = (0, 189, 3, 'dev12')
@@ -20,6 +20,7 @@ class PlanConfig(BaseConfig):
20
20
  auto_apply: Whether to automatically apply the new plan after creation.
21
21
  use_finalized_state: Whether to compare against the latest finalized environment state, or to use
22
22
  whatever state the target environment is currently in.
23
+ always_recreate_environment: Whether to always recreate the target environment from the `create_from` environment.
23
24
  """
24
25
 
25
26
  forward_only: bool = False
@@ -30,3 +31,4 @@ class PlanConfig(BaseConfig):
30
31
  no_prompts: bool = True
31
32
  auto_apply: bool = False
32
33
  use_finalized_state: bool = False
34
+ always_recreate_environment: bool = False
sqlmesh/core/context.py CHANGED
@@ -1487,6 +1487,7 @@ class GenericContext(BaseContext, t.Generic[C]):
1487
1487
  or (backfill_models is not None and not backfill_models),
1488
1488
  ensure_finalized_snapshots=self.config.plan.use_finalized_state,
1489
1489
  diff_rendered=diff_rendered,
1490
+ always_recreate_environment=self.config.plan.always_recreate_environment,
1490
1491
  )
1491
1492
  modified_model_names = {
1492
1493
  *context_diff.modified_snapshots,
@@ -2628,6 +2629,7 @@ class GenericContext(BaseContext, t.Generic[C]):
2628
2629
  force_no_diff: bool = False,
2629
2630
  ensure_finalized_snapshots: bool = False,
2630
2631
  diff_rendered: bool = False,
2632
+ always_recreate_environment: bool = False,
2631
2633
  ) -> ContextDiff:
2632
2634
  environment = Environment.sanitize_name(environment)
2633
2635
  if force_no_diff:
@@ -2645,6 +2647,7 @@ class GenericContext(BaseContext, t.Generic[C]):
2645
2647
  environment_statements=self._environment_statements,
2646
2648
  gateway_managed_virtual_layer=self.config.gateway_managed_virtual_layer,
2647
2649
  infer_python_dependencies=self.config.infer_python_dependencies,
2650
+ always_recreate_environment=always_recreate_environment,
2648
2651
  )
2649
2652
 
2650
2653
  def _destroy(self) -> None:
@@ -103,6 +103,7 @@ class ContextDiff(PydanticModel):
103
103
  environment_statements: t.Optional[t.List[EnvironmentStatements]] = [],
104
104
  gateway_managed_virtual_layer: bool = False,
105
105
  infer_python_dependencies: bool = True,
106
+ always_recreate_environment: bool = False,
106
107
  ) -> ContextDiff:
107
108
  """Create a ContextDiff object.
108
109
 
@@ -128,10 +129,12 @@ class ContextDiff(PydanticModel):
128
129
  The ContextDiff object.
129
130
  """
130
131
  environment = environment.lower()
131
- env = state_reader.get_environment(environment)
132
-
132
+ existing_env = state_reader.get_environment(environment)
133
133
  create_from_env_exists = False
134
- if env is None or env.expired:
134
+
135
+ recreate_environment = always_recreate_environment and not environment == create_from
136
+
137
+ if existing_env is None or existing_env.expired or recreate_environment:
135
138
  env = state_reader.get_environment(create_from.lower())
136
139
 
137
140
  if not env and create_from != c.PROD:
@@ -143,6 +146,7 @@ class ContextDiff(PydanticModel):
143
146
  create_from_env_exists = env is not None
144
147
  previously_promoted_snapshot_ids = set()
145
148
  else:
149
+ env = existing_env
146
150
  is_new_environment = False
147
151
  previously_promoted_snapshot_ids = {s.snapshot_id for s in env.promoted_snapshots}
148
152
 
@@ -220,6 +224,11 @@ class ContextDiff(PydanticModel):
220
224
 
221
225
  previous_environment_statements = state_reader.get_environment_statements(environment)
222
226
 
227
+ if existing_env and always_recreate_environment:
228
+ previous_plan_id: t.Optional[str] = existing_env.plan_id
229
+ else:
230
+ previous_plan_id = env.plan_id if env and not is_new_environment else None
231
+
223
232
  return ContextDiff(
224
233
  environment=environment,
225
234
  is_new_environment=is_new_environment,
@@ -232,7 +241,7 @@ class ContextDiff(PydanticModel):
232
241
  modified_snapshots=modified_snapshots,
233
242
  snapshots=merged_snapshots,
234
243
  new_snapshots=new_snapshots,
235
- previous_plan_id=env.plan_id if env and not is_new_environment else None,
244
+ previous_plan_id=previous_plan_id,
236
245
  previously_promoted_snapshot_ids=previously_promoted_snapshot_ids,
237
246
  previous_finalized_snapshots=env.previous_finalized_snapshots if env else None,
238
247
  previous_requirements=env.requirements if env else {},
sqlmesh/lsp/custom.py CHANGED
@@ -99,3 +99,22 @@ class SupportedMethodsResponse(PydanticModel):
99
99
  """
100
100
 
101
101
  methods: t.List[CustomMethod]
102
+
103
+
104
+ FORMAT_PROJECT_FEATURE = "sqlmesh/format_project"
105
+
106
+
107
+ class FormatProjectRequest(PydanticModel):
108
+ """
109
+ Request to format all models in the current project.
110
+ """
111
+
112
+ pass
113
+
114
+
115
+ class FormatProjectResponse(PydanticModel):
116
+ """
117
+ Response to format project request.
118
+ """
119
+
120
+ pass
sqlmesh/lsp/main.py CHANGED
@@ -30,6 +30,7 @@ from sqlmesh.lsp.custom import (
30
30
  ALL_MODELS_FOR_RENDER_FEATURE,
31
31
  RENDER_MODEL_FEATURE,
32
32
  SUPPORTED_METHODS_FEATURE,
33
+ FORMAT_PROJECT_FEATURE,
33
34
  AllModelsRequest,
34
35
  AllModelsResponse,
35
36
  AllModelsForRenderRequest,
@@ -38,6 +39,8 @@ from sqlmesh.lsp.custom import (
38
39
  RenderModelResponse,
39
40
  SupportedMethodsRequest,
40
41
  SupportedMethodsResponse,
42
+ FormatProjectRequest,
43
+ FormatProjectResponse,
41
44
  CustomMethod,
42
45
  )
43
46
  from sqlmesh.lsp.hints import get_hints
@@ -52,6 +55,7 @@ SUPPORTED_CUSTOM_METHODS = [
52
55
  ALL_MODELS_FOR_RENDER_FEATURE,
53
56
  API_FEATURE,
54
57
  SUPPORTED_METHODS_FEATURE,
58
+ FORMAT_PROJECT_FEATURE,
55
59
  ]
56
60
 
57
61
 
@@ -175,6 +179,25 @@ class SQLMeshLanguageServer:
175
179
  ]
176
180
  )
177
181
 
182
+ @self.server.feature(FORMAT_PROJECT_FEATURE)
183
+ def format_project(
184
+ ls: LanguageServer, params: FormatProjectRequest
185
+ ) -> FormatProjectResponse:
186
+ """Format all models in the current project."""
187
+ try:
188
+ if self.lsp_context is None:
189
+ current_path = Path.cwd()
190
+ self._ensure_context_in_folder(current_path)
191
+ if self.lsp_context is None:
192
+ raise RuntimeError("No context found")
193
+
194
+ # Call the format method on the context
195
+ self.lsp_context.context.format()
196
+ return FormatProjectResponse()
197
+ except Exception as e:
198
+ ls.log_trace(f"Error formatting project: {e}")
199
+ return FormatProjectResponse()
200
+
178
201
  @self.server.feature(API_FEATURE)
179
202
  def api(ls: LanguageServer, request: ApiRequest) -> t.Dict[str, t.Any]:
180
203
  ls.log_trace(f"API request: {request}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.189.3.dev10
3
+ Version: 0.189.3.dev12
4
4
  Summary: Next-generation data transformation framework
5
5
  Author-email: "TobikoData Inc." <engineering@tobikodata.com>
6
6
  License: Apache License
@@ -1,5 +1,5 @@
1
1
  sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
2
- sqlmesh/_version.py,sha256=FJkjszzzHetna4ZyMF5hpNdbQOzIbMjc_E5XAYytY2I,530
2
+ sqlmesh/_version.py,sha256=P3wEdhgoz6BF2ozBjdqSJX_la0iQ4tTkdPCZEUdTQ74,530
3
3
  sqlmesh/magics.py,sha256=gjzoxREb1XT8Yho_PQMlMqhhkLq_sEfBM8S3PTgxvWE,40337
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -13,8 +13,8 @@ sqlmesh/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  sqlmesh/core/_typing.py,sha256=e1f7xO2aZCy38M_3VoDy-XI3shyd99-IFctgIFSgXWM,497
14
14
  sqlmesh/core/console.py,sha256=x7qWETjHgu8ZpMtfW8V3bGKByT4nZXDjgtO6xmvAb-I,151143
15
15
  sqlmesh/core/constants.py,sha256=oqt6zjepUhQoWlgapKn_HpG7Pu9mrFwepdX5caNfJUI,2499
16
- sqlmesh/core/context.py,sha256=u05rMOVPd8LvpTRrs6W5IiyT7cdjtHDIXBGqIthwFRI,117732
17
- sqlmesh/core/context_diff.py,sha256=I7luvY2za30E5ynVaFPaEQQEmNViJpWAmW48PGSyDCU,21135
16
+ sqlmesh/core/context.py,sha256=kWKYcmcdZBQI2bE3bVcsZDCQvO68Kty6uSvIfL2nnC0,117938
17
+ sqlmesh/core/context_diff.py,sha256=TCzM8egBE35DskpouOB-GQM2Qf5iUHWbRgiB5yZ6tzg,21552
18
18
  sqlmesh/core/dialect.py,sha256=93cXYVuNoZ9CvJNTVn2Yz7WDOdHINwVXflbn0eZ-p14,49764
19
19
  sqlmesh/core/environment.py,sha256=bNj-JCG_l13dwrp--YPIuGNsuWLTMLcFA5sY8IazVK8,12917
20
20
  sqlmesh/core/lineage.py,sha256=zjB0Zfamo2Fja2r5SSZPMbrEKTXr1WjozZPVqvxdybI,3143
@@ -51,7 +51,7 @@ sqlmesh/core/config/loader.py,sha256=Jcxp5Y6fCqg_BFQ03h9XVWhEQKESy5e2pomjvxh2Qa8
51
51
  sqlmesh/core/config/migration.py,sha256=3lZIlmIcQH3_hIEm3Y3jFtvpw0YXzRzAnk4OdiklO6M,408
52
52
  sqlmesh/core/config/model.py,sha256=GIz9kAfKD2NEXNzCZCQ17-CK2OtqN6WgeG1fvibcChM,3650
53
53
  sqlmesh/core/config/naming.py,sha256=KVGaxUgswoQajXR_cHFJvgkmEFcU1V182GkOH1SJxuE,326
54
- sqlmesh/core/config/plan.py,sha256=Sql_bdO2H_vVrIYosf8rWOTRVoMURciX7mEcbMNFFdg,1389
54
+ sqlmesh/core/config/plan.py,sha256=wJEDfocMcKSMN0-5gVojjIcmJZ0376LJU3tkGMTm-Zc,1558
55
55
  sqlmesh/core/config/root.py,sha256=Ytu5Evj4vtqouEIqQ4LkhZLc354P8qpOwrXkunTS6Tg,14907
56
56
  sqlmesh/core/config/run.py,sha256=rIK0QnN_vArrwps2TXGVEbvao2AnGZgzXo7EliJa42E,852
57
57
  sqlmesh/core/config/scheduler.py,sha256=k3BVMpy5ZrC05ZlyE3vec8ZGfTjUjWyfsKZtYgflbyA,7029
@@ -161,10 +161,10 @@ sqlmesh/integrations/github/cicd/controller.py,sha256=IgUWK9orYSMiElO3GaL6Ja-osF
161
161
  sqlmesh/lsp/api.py,sha256=LJdECSaEZoPbu_Xl4KscVG-WLt7_g4dY-zKGO68dH14,2162
162
162
  sqlmesh/lsp/completions.py,sha256=Y6zNKNne91tzRm5vRk82JmhIpo7dIBUoK8GGQesGlT8,5746
163
163
  sqlmesh/lsp/context.py,sha256=36bUTiMSyfX91bri_F1aivDvSllq0rKidIM_RGAtirs,6253
164
- sqlmesh/lsp/custom.py,sha256=0kiztcI_UyttXcIsDQ4tUzeaTtp-Yb-5A0ZzrkLLvB8,1880
164
+ sqlmesh/lsp/custom.py,sha256=f6-s5gJop6YjTmX7jfwTIqjYvinhMpv_T9v0H7g4DuM,2172
165
165
  sqlmesh/lsp/description.py,sha256=4QIGC9ix8IzmWF6DVUNhY4m1Crk3sNQA6hZ1RbyqU78,827
166
166
  sqlmesh/lsp/hints.py,sha256=j-blccBUil94yRoDjWfkSM0HqMmsKD6hP2TaWdWWVk4,3734
167
- sqlmesh/lsp/main.py,sha256=FckdvGADwFwvWT3XxyfDOdKqxfujeTZVUg4MbCVbOaU,34355
167
+ sqlmesh/lsp/main.py,sha256=mi8N7qKybd1aDUhPAinwYXNSxSeZ6Eh3Gop8-_Zopuw,35279
168
168
  sqlmesh/lsp/reference.py,sha256=dyeacD_MHATGRIrl8Ax86nDK9EC_dh3TaaVNAepPce0,17902
169
169
  sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
170
170
  sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -274,7 +274,7 @@ sqlmesh/utils/pydantic.py,sha256=I898jAFqa3qU6lG2uPpRebVFncOUo8ZrLWM_R3K3DHU,116
274
274
  sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
275
275
  sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
276
276
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
277
- sqlmesh-0.189.3.dev10.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
277
+ sqlmesh-0.189.3.dev12.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
278
278
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
279
279
  web/client/dist/index.html,sha256=OVPMTMsqC8zy0qnBcMb7PpVcqTHdIJoCmJLYh7gC1Xs,5472
280
280
  web/client/dist/assets/Audits-Bvr7M5Cg.js,sha256=GrigkyEVYbM5zy0PAjOXdqmVV0kL-STP5gFQmx35vhw,1041
@@ -392,8 +392,8 @@ web/server/api/endpoints/models.py,sha256=ud-lRwriyI_OYg9tZchrBgeiXELiRTLNEodraf
392
392
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
393
393
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
394
394
  web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
395
- sqlmesh-0.189.3.dev10.dist-info/METADATA,sha256=mSDVrBL2E-PnKrywO202qaVHlpWWlboL0su3vhnl8f8,26541
396
- sqlmesh-0.189.3.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
397
- sqlmesh-0.189.3.dev10.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
398
- sqlmesh-0.189.3.dev10.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
399
- sqlmesh-0.189.3.dev10.dist-info/RECORD,,
395
+ sqlmesh-0.189.3.dev12.dist-info/METADATA,sha256=6MTTCr5Zgjo9PUbtUCib-NgyTR1MFs0EuFF7X3LluXk,26541
396
+ sqlmesh-0.189.3.dev12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
397
+ sqlmesh-0.189.3.dev12.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
398
+ sqlmesh-0.189.3.dev12.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
399
+ sqlmesh-0.189.3.dev12.dist-info/RECORD,,