sqlmesh 0.181.2.dev6__py3-none-any.whl → 0.181.2.dev8__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.181.2.dev6'
21
- __version_tuple__ = version_tuple = (0, 181, 2, 'dev6')
20
+ __version__ = version = '0.181.2.dev8'
21
+ __version_tuple__ = version_tuple = (0, 181, 2, 'dev8')
sqlmesh/lsp/api.py ADDED
@@ -0,0 +1,61 @@
1
+ """
2
+ This module maps the LSP custom API calls to the SQLMesh web api.
3
+
4
+ Allowing the LSP to call the web api without having to know the details of the web api
5
+ and thus passing through the details of the web api to the LSP, so that both the LSP
6
+ and the web api can communicate with the same process, avoiding the need to have a
7
+ separate process for the web api.
8
+ """
9
+
10
+ import typing as t
11
+ from pydantic import field_validator
12
+ from sqlmesh.utils.pydantic import PydanticModel
13
+ from web.server.models import Model
14
+
15
+ API_FEATURE = "sqlmesh/api"
16
+
17
+
18
+ class ApiRequest(PydanticModel):
19
+ """
20
+ Request to call the SQLMesh API.
21
+ This is a generic request that can be used to call any API endpoint.
22
+ """
23
+
24
+ requestId: str
25
+ url: str
26
+ method: t.Optional[str] = "GET"
27
+ params: t.Optional[t.Dict[str, t.Any]] = None
28
+ body: t.Optional[t.Dict[str, t.Any]] = None
29
+
30
+
31
+ class ApiResponseGetModels(PydanticModel):
32
+ """
33
+ Response from the SQLMesh API for the get_models endpoint.
34
+ """
35
+
36
+ data: t.List[Model]
37
+
38
+ @field_validator("data", mode="before")
39
+ def sanitize_datetime_fields(cls, data: t.List[Model]) -> t.List[Model]:
40
+ """
41
+ Convert datetime objects to None to avoid serialization issues.
42
+ """
43
+ if isinstance(data, list):
44
+ for model in data:
45
+ if hasattr(model, "details") and model.details:
46
+ # Convert datetime fields to None to avoid serialization issues
47
+ for field in ["stamp", "start", "cron_prev", "cron_next"]:
48
+ if (
49
+ hasattr(model.details, field)
50
+ and getattr(model.details, field) is not None
51
+ ):
52
+ setattr(model.details, field, None)
53
+ return data
54
+
55
+
56
+ class ApiResponseGetLineage(PydanticModel):
57
+ """
58
+ Response from the SQLMesh API for the get_lineage endpoint.
59
+ """
60
+
61
+ data: t.Dict[str, t.List[str]]
sqlmesh/lsp/main.py CHANGED
@@ -11,12 +11,20 @@ from pygls.server import LanguageServer
11
11
  from sqlmesh._version import __version__
12
12
  from sqlmesh.core.context import Context
13
13
  from sqlmesh.core.linter.definition import AnnotatedRuleViolation
14
+ from sqlmesh.lsp.api import (
15
+ API_FEATURE,
16
+ ApiRequest,
17
+ ApiResponseGetLineage,
18
+ ApiResponseGetModels,
19
+ )
14
20
  from sqlmesh.lsp.completions import get_sql_completions
15
21
  from sqlmesh.lsp.context import LSPContext, ModelTarget
16
22
  from sqlmesh.lsp.custom import ALL_MODELS_FEATURE, AllModelsRequest, AllModelsResponse
17
23
  from sqlmesh.lsp.reference import (
18
24
  get_references,
19
25
  )
26
+ from web.server.api.endpoints.lineage import model_lineage
27
+ from web.server.api.endpoints.models import get_models
20
28
 
21
29
 
22
30
  class SQLMeshLanguageServer:
@@ -79,6 +87,23 @@ class SQLMeshLanguageServer:
79
87
  except Exception as e:
80
88
  return get_sql_completions(None, params.textDocument.uri)
81
89
 
90
+ @self.server.feature(API_FEATURE)
91
+ def api(
92
+ ls: LanguageServer, request: ApiRequest
93
+ ) -> t.Union[ApiResponseGetModels, ApiResponseGetLineage]:
94
+ ls.log_trace(f"API request: {request}")
95
+ if self.lsp_context is None:
96
+ raise RuntimeError("No context found")
97
+ if request.url == "/api/models":
98
+ response = ApiResponseGetModels(data=get_models(self.lsp_context.context))
99
+ return response
100
+ if request.url.startswith("/api/lineage"):
101
+ name = request.url.split("/")[-1]
102
+ lineage = model_lineage(name, self.lsp_context.context)
103
+ non_set_lineage = {k: v for k, v in lineage.items() if v is not None}
104
+ return ApiResponseGetLineage(data=non_set_lineage)
105
+ raise NotImplementedError(f"API request not implemented: {request.url}")
106
+
82
107
  @self.server.feature(types.TEXT_DOCUMENT_DID_OPEN)
83
108
  def did_open(ls: LanguageServer, params: types.DidOpenTextDocumentParams) -> None:
84
109
  context = self._context_get_or_load(params.text_document.uri)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.181.2.dev6
3
+ Version: 0.181.2.dev8
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=DRovDXI-9D9xeYDP7t8Fq7mI31S2btlN-LHPOK3y7PA,7240
2
- sqlmesh/_version.py,sha256=p79rnFkPmoBd1N3yklVHNWykPQlii1xVrig6eA6dw0A,528
2
+ sqlmesh/_version.py,sha256=m-E-GGmR7GxW8S19G7ZHHmWmKoUBoqjIUDAYPE33SYI,528
3
3
  sqlmesh/magics.py,sha256=9oY1Uz8uwsuTtPRg9HTYDxnGiJ7-OVRCpmCgAhbKHUU,39431
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -155,10 +155,11 @@ sqlmesh/integrations/github/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
155
155
  sqlmesh/integrations/github/cicd/command.py,sha256=a48qtSeRM7RD3IeydJwHLAZBHRbmFdA7uHh7Yhe5a74,11301
156
156
  sqlmesh/integrations/github/cicd/config.py,sha256=qEy0mRfPYJw1pm68UK0v1_4kZBj5QodnpIsOZ8JjZro,1838
157
157
  sqlmesh/integrations/github/cicd/controller.py,sha256=AiEMsRW4WSVxXP_7oQSIdzBzmYPxfYDgYeOYRk9sfJA,41388
158
+ sqlmesh/lsp/api.py,sha256=Ls7BjrPSovvOu6VU_eFR0_nHcbsQl020eJvGbdWi7s8,1957
158
159
  sqlmesh/lsp/completions.py,sha256=ScW0H9couhfW6QckEX2djVYTClRPXpT2Hdcg1qLfUUY,3479
159
160
  sqlmesh/lsp/context.py,sha256=vUpbWYjKYuwDvU3zkzhAgw9An-TeVYe_5KTk-ec_UwM,1569
160
161
  sqlmesh/lsp/custom.py,sha256=GvNAiW7imPI8xmIx3qLWN5FljGPHFJKh0N5b6aZnwRo,489
161
- sqlmesh/lsp/main.py,sha256=HBbJMtWF98yZiTHspdx0hfyGnsMTh2WSirgYvvOwRs4,15204
162
+ sqlmesh/lsp/main.py,sha256=AHVkfOvmDh3NqgfGF41uAnlxUDZdFyx5HEpGgCA_F1o,16346
162
163
  sqlmesh/lsp/reference.py,sha256=3vmLpEDbsJ740DfaOc2_ESZnXsUxWLS4lUunoO9km9s,8121
163
164
  sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
165
  sqlmesh/migrations/v0001_init.py,sha256=h8FwMYJj9_O8yGpk12guaSaGwX5A3we2GiKeHrXi15o,2048
@@ -265,7 +266,7 @@ sqlmesh/utils/pandas.py,sha256=j_tYhuPcWpzuPceZZ6IhdTVbmxYyGJW7l4FHr4bQqjM,1824
265
266
  sqlmesh/utils/pydantic.py,sha256=ioaAzYF42PutEJRyAS11-AHguiCG3yWI6VRcTVa2G-g,10470
266
267
  sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
267
268
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
268
- sqlmesh-0.181.2.dev6.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
269
+ sqlmesh-0.181.2.dev8.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
269
270
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
270
271
  web/client/dist/index.html,sha256=cQRIlDgkl6OgeWuHI9hM8bJhKUE9-Ji2NpQa2hlgNM8,5472
271
272
  web/client/dist/assets/Audits-4U9LnWyN.js,sha256=reXu-sKJ76kiaAZIGkCPvgO68Km9tj1PN_9mx6X6WAY,997
@@ -382,8 +383,8 @@ web/server/api/endpoints/models.py,sha256=SzS5bshzdXyM6hb948sZ_3k-xhpGCHkxkb7pHz
382
383
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
383
384
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
384
385
  web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
385
- sqlmesh-0.181.2.dev6.dist-info/METADATA,sha256=bI0uNmasldAm6flVXhB2sfE3UVMgapV0MkDAiV7FRsU,25307
386
- sqlmesh-0.181.2.dev6.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
387
- sqlmesh-0.181.2.dev6.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
388
- sqlmesh-0.181.2.dev6.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
389
- sqlmesh-0.181.2.dev6.dist-info/RECORD,,
386
+ sqlmesh-0.181.2.dev8.dist-info/METADATA,sha256=oXV47yFT5VeGOg2gTitD8hp1TmJRiAIsPKFaQ3U_wc0,25307
387
+ sqlmesh-0.181.2.dev8.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
388
+ sqlmesh-0.181.2.dev8.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
389
+ sqlmesh-0.181.2.dev8.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
390
+ sqlmesh-0.181.2.dev8.dist-info/RECORD,,