sqlmesh 0.200.1.dev2__py3-none-any.whl → 0.200.1.dev3__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 +2 -2
- sqlmesh/core/loader.py +17 -10
- sqlmesh/core/model/common.py +6 -3
- sqlmesh/core/model/definition.py +4 -1
- sqlmesh/lsp/context.py +0 -12
- sqlmesh/lsp/errors.py +51 -0
- sqlmesh/lsp/main.py +70 -46
- sqlmesh/utils/errors.py +9 -4
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/METADATA +1 -1
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/RECORD +14 -13
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/WHEEL +0 -0
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.200.1.dev2.dist-info → sqlmesh-0.200.1.dev3.dist-info}/top_level.txt +0 -0
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.200.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 200, 1, '
|
|
20
|
+
__version__ = version = '0.200.1.dev3'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 200, 1, 'dev3')
|
sqlmesh/core/loader.py
CHANGED
|
@@ -349,7 +349,7 @@ class Loader(abc.ABC):
|
|
|
349
349
|
for row in YAML().load(file.read())
|
|
350
350
|
]
|
|
351
351
|
except Exception as ex:
|
|
352
|
-
raise ConfigError(self._failed_to_load_model_error(path, ex))
|
|
352
|
+
raise ConfigError(self._failed_to_load_model_error(path, ex), path)
|
|
353
353
|
|
|
354
354
|
for path in paths_to_load:
|
|
355
355
|
self._track_file(path)
|
|
@@ -363,7 +363,8 @@ class Loader(abc.ABC):
|
|
|
363
363
|
raise ConfigError(
|
|
364
364
|
self._failed_to_load_model_error(
|
|
365
365
|
path, f"Duplicate external model name: '{model.name}'."
|
|
366
|
-
)
|
|
366
|
+
),
|
|
367
|
+
path,
|
|
367
368
|
)
|
|
368
369
|
models[model.fqn] = model
|
|
369
370
|
|
|
@@ -375,7 +376,8 @@ class Loader(abc.ABC):
|
|
|
375
376
|
raise ConfigError(
|
|
376
377
|
self._failed_to_load_model_error(
|
|
377
378
|
path, f"Duplicate external model name: '{model.name}'."
|
|
378
|
-
)
|
|
379
|
+
),
|
|
380
|
+
path,
|
|
379
381
|
)
|
|
380
382
|
models.update({model.fqn: model})
|
|
381
383
|
|
|
@@ -402,13 +404,15 @@ class Loader(abc.ABC):
|
|
|
402
404
|
args = [k.strip() for k in line.split("==")]
|
|
403
405
|
if len(args) != 2:
|
|
404
406
|
raise ConfigError(
|
|
405
|
-
f"Invalid lock file entry '{line.strip()}'. Only 'dep==ver' is supported"
|
|
407
|
+
f"Invalid lock file entry '{line.strip()}'. Only 'dep==ver' is supported",
|
|
408
|
+
requirements_path,
|
|
406
409
|
)
|
|
407
410
|
dep, ver = args
|
|
408
411
|
other_ver = requirements.get(dep, ver)
|
|
409
412
|
if ver != other_ver:
|
|
410
413
|
raise ConfigError(
|
|
411
|
-
f"Conflicting requirement {dep}: {ver} != {other_ver}. Fix your {c.REQUIREMENTS} file."
|
|
414
|
+
f"Conflicting requirement {dep}: {ver} != {other_ver}. Fix your {c.REQUIREMENTS} file.",
|
|
415
|
+
requirements_path,
|
|
412
416
|
)
|
|
413
417
|
requirements[dep] = ver
|
|
414
418
|
|
|
@@ -619,13 +623,14 @@ class SqlMeshLoader(Loader):
|
|
|
619
623
|
raise ConfigError(
|
|
620
624
|
self._failed_to_load_model_error(
|
|
621
625
|
path, f"Duplicate SQL model name: '{model.name}'."
|
|
622
|
-
)
|
|
626
|
+
),
|
|
627
|
+
path,
|
|
623
628
|
)
|
|
624
629
|
elif model.enabled:
|
|
625
630
|
model._path = path
|
|
626
631
|
models[model.fqn] = model
|
|
627
632
|
except Exception as ex:
|
|
628
|
-
raise ConfigError(self._failed_to_load_model_error(path, ex))
|
|
633
|
+
raise ConfigError(self._failed_to_load_model_error(path, ex), path)
|
|
629
634
|
|
|
630
635
|
return models
|
|
631
636
|
|
|
@@ -678,7 +683,7 @@ class SqlMeshLoader(Loader):
|
|
|
678
683
|
if model.enabled:
|
|
679
684
|
models[model.fqn] = model
|
|
680
685
|
except Exception as ex:
|
|
681
|
-
raise ConfigError(self._failed_to_load_model_error(path, ex))
|
|
686
|
+
raise ConfigError(self._failed_to_load_model_error(path, ex), path)
|
|
682
687
|
|
|
683
688
|
finally:
|
|
684
689
|
model_registry._dialect = None
|
|
@@ -782,7 +787,9 @@ class SqlMeshLoader(Loader):
|
|
|
782
787
|
metric = load_metric_ddl(expression, path=path, dialect=dialect)
|
|
783
788
|
metrics[metric.name] = metric
|
|
784
789
|
except SqlglotError as ex:
|
|
785
|
-
raise ConfigError(
|
|
790
|
+
raise ConfigError(
|
|
791
|
+
f"Failed to parse metric definitions at '{path}': {ex}.", path
|
|
792
|
+
)
|
|
786
793
|
|
|
787
794
|
return metrics
|
|
788
795
|
|
|
@@ -1005,7 +1012,7 @@ class MigratedDbtProjectLoader(SqlMeshLoader):
|
|
|
1005
1012
|
package=package,
|
|
1006
1013
|
)
|
|
1007
1014
|
except Exception as e:
|
|
1008
|
-
raise ConfigError(f"Failed to load macro file:
|
|
1015
|
+
raise ConfigError(f"Failed to load macro file: {e}", path)
|
|
1009
1016
|
|
|
1010
1017
|
self._macros_max_mtime = macros_max_mtime
|
|
1011
1018
|
|
sqlmesh/core/model/common.py
CHANGED
|
@@ -41,7 +41,7 @@ def make_python_env(
|
|
|
41
41
|
macros: MacroRegistry,
|
|
42
42
|
variables: t.Optional[t.Dict[str, t.Any]] = None,
|
|
43
43
|
used_variables: t.Optional[t.Set[str]] = None,
|
|
44
|
-
path: t.Optional[
|
|
44
|
+
path: t.Optional[Path] = None,
|
|
45
45
|
python_env: t.Optional[t.Dict[str, Executable]] = None,
|
|
46
46
|
strict_resolution: bool = True,
|
|
47
47
|
blueprint_variables: t.Optional[t.Dict[str, t.Any]] = None,
|
|
@@ -265,12 +265,14 @@ def validate_extra_and_required_fields(
|
|
|
265
265
|
klass: t.Type[PydanticModel],
|
|
266
266
|
provided_fields: t.Set[str],
|
|
267
267
|
entity_name: str,
|
|
268
|
+
path: t.Optional[Path] = None,
|
|
268
269
|
) -> None:
|
|
269
270
|
missing_required_fields = klass.missing_required_fields(provided_fields)
|
|
270
271
|
if missing_required_fields:
|
|
271
272
|
field_names = "'" + "', '".join(missing_required_fields) + "'"
|
|
272
273
|
raise_config_error(
|
|
273
|
-
f"Please add required field{'s' if len(missing_required_fields) > 1 else ''} {field_names} to the {entity_name}."
|
|
274
|
+
f"Please add required field{'s' if len(missing_required_fields) > 1 else ''} {field_names} to the {entity_name}.",
|
|
275
|
+
path,
|
|
274
276
|
)
|
|
275
277
|
|
|
276
278
|
extra_fields = klass.extra_fields(provided_fields)
|
|
@@ -293,7 +295,8 @@ def validate_extra_and_required_fields(
|
|
|
293
295
|
similar_msg = "\n\n " + "\n ".join(similar) if similar else ""
|
|
294
296
|
|
|
295
297
|
raise_config_error(
|
|
296
|
-
f"Invalid field name{'s' if len(extra_fields) > 1 else ''} present in the {entity_name}: {extra_field_names}{similar_msg}"
|
|
298
|
+
f"Invalid field name{'s' if len(extra_fields) > 1 else ''} present in the {entity_name}: {extra_field_names}{similar_msg}",
|
|
299
|
+
path,
|
|
297
300
|
)
|
|
298
301
|
|
|
299
302
|
|
sqlmesh/core/model/definition.py
CHANGED
|
@@ -2434,7 +2434,10 @@ def _create_model(
|
|
|
2434
2434
|
**kwargs: t.Any,
|
|
2435
2435
|
) -> Model:
|
|
2436
2436
|
validate_extra_and_required_fields(
|
|
2437
|
-
klass,
|
|
2437
|
+
klass,
|
|
2438
|
+
{"name", *kwargs} - {"grain", "table_properties"},
|
|
2439
|
+
"MODEL block",
|
|
2440
|
+
path,
|
|
2438
2441
|
)
|
|
2439
2442
|
|
|
2440
2443
|
for prop in PROPERTIES:
|
sqlmesh/lsp/context.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
import uuid
|
|
4
3
|
from sqlmesh.core.context import Context
|
|
5
4
|
import typing as t
|
|
6
5
|
|
|
@@ -35,14 +34,8 @@ class LSPContext:
|
|
|
35
34
|
map: t.Dict[Path, t.Union[ModelTarget, AuditTarget]]
|
|
36
35
|
_render_cache: t.Dict[Path, t.List[RenderModelEntry]]
|
|
37
36
|
_lint_cache: t.Dict[Path, t.List[AnnotatedRuleViolation]]
|
|
38
|
-
_version_id: str
|
|
39
|
-
"""
|
|
40
|
-
This is a version ID for the context. It is used to track changes to the context. It can be used to
|
|
41
|
-
return a version number to the LSP client.
|
|
42
|
-
"""
|
|
43
37
|
|
|
44
38
|
def __init__(self, context: Context) -> None:
|
|
45
|
-
self._version_id = str(uuid.uuid4())
|
|
46
39
|
self.context = context
|
|
47
40
|
self._render_cache = {}
|
|
48
41
|
self._lint_cache = {}
|
|
@@ -70,11 +63,6 @@ class LSPContext:
|
|
|
70
63
|
**audit_map,
|
|
71
64
|
}
|
|
72
65
|
|
|
73
|
-
@property
|
|
74
|
-
def version_id(self) -> str:
|
|
75
|
-
"""Get the version ID for the context."""
|
|
76
|
-
return self._version_id
|
|
77
|
-
|
|
78
66
|
def render_model(self, uri: URI) -> t.List[RenderModelEntry]:
|
|
79
67
|
"""Get rendered models for a file, using cache when available.
|
|
80
68
|
|
sqlmesh/lsp/errors.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from lsprotocol.types import Diagnostic, DiagnosticSeverity, Range, Position
|
|
2
|
+
|
|
3
|
+
from sqlmesh.lsp.uri import URI
|
|
4
|
+
from sqlmesh.utils.errors import (
|
|
5
|
+
ConfigError,
|
|
6
|
+
)
|
|
7
|
+
import typing as t
|
|
8
|
+
|
|
9
|
+
ContextFailedError = t.Union[str, ConfigError, Exception]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def context_error_to_diagnostic(
|
|
13
|
+
error: t.Union[Exception, ContextFailedError],
|
|
14
|
+
uri_filter: t.Optional[URI] = None,
|
|
15
|
+
) -> t.Tuple[t.Optional[t.Tuple[str, Diagnostic]], ContextFailedError]:
|
|
16
|
+
"""
|
|
17
|
+
Convert an error to a diagnostic message.
|
|
18
|
+
If the error is a ConfigError, it will be converted to a diagnostic message.
|
|
19
|
+
|
|
20
|
+
uri_filter is used to filter diagnostics by URI. If present, only diagnostics
|
|
21
|
+
with a matching URI will be returned.
|
|
22
|
+
"""
|
|
23
|
+
if isinstance(error, ConfigError):
|
|
24
|
+
return config_error_to_diagnostic(error), error
|
|
25
|
+
return None, str(error)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def config_error_to_diagnostic(
|
|
29
|
+
error: ConfigError,
|
|
30
|
+
uri_filter: t.Optional[URI] = None,
|
|
31
|
+
) -> t.Optional[t.Tuple[str, Diagnostic]]:
|
|
32
|
+
if error.location is None:
|
|
33
|
+
return None
|
|
34
|
+
uri = URI.from_path(error.location).value
|
|
35
|
+
if uri_filter and uri != uri_filter.value:
|
|
36
|
+
return None
|
|
37
|
+
return uri, Diagnostic(
|
|
38
|
+
range=Range(
|
|
39
|
+
start=Position(
|
|
40
|
+
line=0,
|
|
41
|
+
character=0,
|
|
42
|
+
),
|
|
43
|
+
end=Position(
|
|
44
|
+
line=0,
|
|
45
|
+
character=0,
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
message=str(error),
|
|
49
|
+
severity=DiagnosticSeverity.Error,
|
|
50
|
+
source="SQLMesh",
|
|
51
|
+
)
|
sqlmesh/lsp/main.py
CHANGED
|
@@ -6,6 +6,7 @@ import logging
|
|
|
6
6
|
import typing as t
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
import urllib.parse
|
|
9
|
+
import uuid
|
|
9
10
|
|
|
10
11
|
from lsprotocol import types
|
|
11
12
|
from lsprotocol.types import (
|
|
@@ -46,6 +47,7 @@ from sqlmesh.lsp.custom import (
|
|
|
46
47
|
FormatProjectResponse,
|
|
47
48
|
CustomMethod,
|
|
48
49
|
)
|
|
50
|
+
from sqlmesh.lsp.errors import ContextFailedError, context_error_to_diagnostic
|
|
49
51
|
from sqlmesh.lsp.hints import get_hints
|
|
50
52
|
from sqlmesh.lsp.reference import (
|
|
51
53
|
LSPCteReference,
|
|
@@ -56,17 +58,18 @@ from sqlmesh.lsp.reference import (
|
|
|
56
58
|
)
|
|
57
59
|
from sqlmesh.lsp.rename import prepare_rename, rename_symbol, get_document_highlights
|
|
58
60
|
from sqlmesh.lsp.uri import URI
|
|
61
|
+
from sqlmesh.utils.errors import ConfigError
|
|
59
62
|
from web.server.api.endpoints.lineage import column_lineage, model_lineage
|
|
60
63
|
from web.server.api.endpoints.models import get_models
|
|
61
64
|
from typing import Union
|
|
62
|
-
from dataclasses import dataclass
|
|
65
|
+
from dataclasses import dataclass, field
|
|
63
66
|
|
|
64
67
|
|
|
65
68
|
@dataclass
|
|
66
69
|
class NoContext:
|
|
67
70
|
"""State when no context has been attempted to load."""
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
version_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
@dataclass
|
|
@@ -74,14 +77,16 @@ class ContextLoaded:
|
|
|
74
77
|
"""State when context has been successfully loaded."""
|
|
75
78
|
|
|
76
79
|
lsp_context: LSPContext
|
|
80
|
+
version_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
77
81
|
|
|
78
82
|
|
|
79
83
|
@dataclass
|
|
80
84
|
class ContextFailed:
|
|
81
85
|
"""State when context failed to load with an error message."""
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
error: ContextFailedError
|
|
84
88
|
context: t.Optional[Context] = None
|
|
89
|
+
version_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
85
90
|
|
|
86
91
|
|
|
87
92
|
ContextState = Union[NoContext, ContextLoaded, ContextFailed]
|
|
@@ -110,7 +115,7 @@ class SQLMeshLanguageServer:
|
|
|
110
115
|
self._supported_custom_methods: t.Dict[
|
|
111
116
|
str,
|
|
112
117
|
t.Callable[
|
|
113
|
-
# mypy unable to
|
|
118
|
+
# mypy unable to recognize the base class
|
|
114
119
|
[LanguageServer, t.Any],
|
|
115
120
|
t.Any,
|
|
116
121
|
],
|
|
@@ -223,9 +228,8 @@ class SQLMeshLanguageServer:
|
|
|
223
228
|
) -> None:
|
|
224
229
|
"""Helper method to reload context and publish diagnostics."""
|
|
225
230
|
if isinstance(self.context_state, NoContext):
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if isinstance(self.context_state, ContextFailed):
|
|
231
|
+
pass
|
|
232
|
+
elif isinstance(self.context_state, ContextFailed):
|
|
229
233
|
if self.context_state.context:
|
|
230
234
|
try:
|
|
231
235
|
self.context_state.context.load()
|
|
@@ -235,14 +239,17 @@ class SQLMeshLanguageServer:
|
|
|
235
239
|
)
|
|
236
240
|
except Exception as e:
|
|
237
241
|
ls.log_trace(f"Error loading context: {e}")
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
context = (
|
|
243
|
+
self.context_state.context
|
|
244
|
+
if hasattr(self.context_state, "context")
|
|
245
|
+
else None
|
|
242
246
|
)
|
|
243
|
-
|
|
247
|
+
self.context_state = ContextFailed(error=e, context=context)
|
|
244
248
|
else:
|
|
245
|
-
# If there's no context, try to create one from scratch
|
|
249
|
+
# If there's no context, reset to NoContext and try to create one from scratch
|
|
250
|
+
ls.log_trace("No partial context available, attempting fresh creation")
|
|
251
|
+
self.context_state = NoContext()
|
|
252
|
+
self.has_raised_loading_error = False # Reset error flag to show new errors
|
|
246
253
|
try:
|
|
247
254
|
self._ensure_context_for_document(uri)
|
|
248
255
|
# If successful, context_state will be ContextLoaded
|
|
@@ -253,43 +260,42 @@ class SQLMeshLanguageServer:
|
|
|
253
260
|
)
|
|
254
261
|
except Exception as e:
|
|
255
262
|
ls.log_trace(f"Still cannot load context: {e}")
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return
|
|
263
|
+
# The error will be stored in context_state by _ensure_context_for_document
|
|
264
|
+
else:
|
|
265
|
+
# Reload the context if it was successfully loaded
|
|
266
|
+
try:
|
|
267
|
+
context = self.context_state.lsp_context.context
|
|
268
|
+
context.load()
|
|
269
|
+
# Create new LSPContext which will have fresh, empty caches
|
|
270
|
+
self.context_state = ContextLoaded(lsp_context=LSPContext(context))
|
|
271
|
+
except Exception as e:
|
|
272
|
+
ls.log_trace(f"Error loading context: {e}")
|
|
273
|
+
self.context_state = ContextFailed(
|
|
274
|
+
error=e, context=self.context_state.lsp_context.context
|
|
275
|
+
)
|
|
270
276
|
|
|
271
277
|
# Send a workspace diagnostic refresh request to the client. This is used to notify the client that the diagnostics have changed.
|
|
272
278
|
ls.lsp.send_request(
|
|
273
279
|
types.WORKSPACE_DIAGNOSTIC_REFRESH,
|
|
274
280
|
WorkspaceDiagnosticRefreshRequest(
|
|
275
|
-
id=self.context_state.
|
|
281
|
+
id=self.context_state.version_id,
|
|
276
282
|
),
|
|
277
283
|
)
|
|
278
|
-
|
|
279
284
|
ls.lsp.send_request(
|
|
280
285
|
types.WORKSPACE_INLAY_HINT_REFRESH,
|
|
281
286
|
WorkspaceInlayHintRefreshRequest(
|
|
282
|
-
id=self.context_state.
|
|
287
|
+
id=self.context_state.version_id,
|
|
283
288
|
),
|
|
284
289
|
)
|
|
285
290
|
|
|
286
291
|
# Only publish diagnostics if client doesn't support pull diagnostics
|
|
287
292
|
if not self.client_supports_pull_diagnostics:
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
if hasattr(self.context_state, "lsp_context"):
|
|
294
|
+
diagnostics = self.context_state.lsp_context.lint_model(uri)
|
|
295
|
+
ls.publish_diagnostics(
|
|
296
|
+
document_uri,
|
|
297
|
+
LSPContext.diagnostics_to_lsp_diagnostics(diagnostics),
|
|
298
|
+
)
|
|
293
299
|
|
|
294
300
|
def _register_features(self) -> None:
|
|
295
301
|
"""Register LSP features on the internal LanguageServer instance."""
|
|
@@ -650,9 +656,21 @@ class SQLMeshLanguageServer:
|
|
|
650
656
|
return types.WorkspaceDiagnosticReport(items=items)
|
|
651
657
|
|
|
652
658
|
except Exception as e:
|
|
653
|
-
ls.log_trace(
|
|
654
|
-
|
|
655
|
-
|
|
659
|
+
ls.log_trace(f"Error getting workspace diagnostics: {e}")
|
|
660
|
+
error_diagnostic, error = context_error_to_diagnostic(e)
|
|
661
|
+
if error_diagnostic:
|
|
662
|
+
uri_value, unpacked_diagnostic = error_diagnostic
|
|
663
|
+
return types.WorkspaceDiagnosticReport(
|
|
664
|
+
items=[
|
|
665
|
+
types.WorkspaceFullDocumentDiagnosticReport(
|
|
666
|
+
kind=types.DocumentDiagnosticReportKind.Full,
|
|
667
|
+
result_id=self.context_state.version_id, # No versioning, always fresh
|
|
668
|
+
uri=uri_value,
|
|
669
|
+
items=[unpacked_diagnostic],
|
|
670
|
+
)
|
|
671
|
+
]
|
|
672
|
+
)
|
|
673
|
+
|
|
656
674
|
return types.WorkspaceDiagnosticReport(items=[])
|
|
657
675
|
|
|
658
676
|
@self.server.feature(types.TEXT_DOCUMENT_CODE_ACTION)
|
|
@@ -759,17 +777,23 @@ class SQLMeshLanguageServer:
|
|
|
759
777
|
context = self._context_get_or_load(uri)
|
|
760
778
|
diagnostics = context.lint_model(uri)
|
|
761
779
|
return LSPContext.diagnostics_to_lsp_diagnostics(diagnostics), 0
|
|
762
|
-
except
|
|
780
|
+
except ConfigError as config_error:
|
|
781
|
+
diagnostic, error = context_error_to_diagnostic(config_error, uri_filter=uri)
|
|
782
|
+
if diagnostic:
|
|
783
|
+
return [diagnostic[1]], 0
|
|
763
784
|
return [], 0
|
|
764
785
|
|
|
765
786
|
def _context_get_or_load(self, document_uri: t.Optional[URI] = None) -> LSPContext:
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
787
|
+
state = self.context_state
|
|
788
|
+
if isinstance(state, ContextFailed):
|
|
789
|
+
if isinstance(state.error, str):
|
|
790
|
+
raise Exception(state.error)
|
|
791
|
+
raise state.error
|
|
792
|
+
if isinstance(state, NoContext):
|
|
769
793
|
self._ensure_context_for_document(document_uri)
|
|
770
|
-
if
|
|
771
|
-
|
|
772
|
-
|
|
794
|
+
if isinstance(state, ContextLoaded):
|
|
795
|
+
return state.lsp_context
|
|
796
|
+
raise RuntimeError("Context failed to load")
|
|
773
797
|
|
|
774
798
|
def _ensure_context_for_document(
|
|
775
799
|
self,
|
|
@@ -866,7 +890,7 @@ class SQLMeshLanguageServer:
|
|
|
866
890
|
context = self.context_state.lsp_context.context
|
|
867
891
|
elif isinstance(self.context_state, ContextFailed) and self.context_state.context:
|
|
868
892
|
context = self.context_state.context
|
|
869
|
-
self.context_state = ContextFailed(
|
|
893
|
+
self.context_state = ContextFailed(error=e, context=context)
|
|
870
894
|
return None
|
|
871
895
|
|
|
872
896
|
@staticmethod
|
sqlmesh/utils/errors.py
CHANGED
|
@@ -24,7 +24,12 @@ class SQLMeshError(Exception):
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class ConfigError(SQLMeshError):
|
|
27
|
-
|
|
27
|
+
location: t.Optional[Path] = None
|
|
28
|
+
|
|
29
|
+
def __init__(self, message: str | Exception, location: t.Optional[Path] = None) -> None:
|
|
30
|
+
super().__init__(message)
|
|
31
|
+
if location:
|
|
32
|
+
self.location = Path(location) if isinstance(location, str) else location
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
class MissingDependencyError(SQLMeshError):
|
|
@@ -188,12 +193,12 @@ class SignalEvalError(SQLMeshError):
|
|
|
188
193
|
|
|
189
194
|
def raise_config_error(
|
|
190
195
|
msg: str,
|
|
191
|
-
location: t.Optional[
|
|
196
|
+
location: t.Optional[Path] = None,
|
|
192
197
|
error_type: t.Type[ConfigError] = ConfigError,
|
|
193
198
|
) -> None:
|
|
194
199
|
if location:
|
|
195
|
-
raise error_type(f"{msg} at '{location}'")
|
|
196
|
-
raise error_type(msg)
|
|
200
|
+
raise error_type(f"{msg} at '{location}'", location)
|
|
201
|
+
raise error_type(msg, location=location)
|
|
197
202
|
|
|
198
203
|
|
|
199
204
|
def raise_for_status(response: Response) -> None:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=ti3p-yTvANYdTMyL-eBx5C3XG4FXWxuHnwBnMUijRKg,528
|
|
3
3
|
sqlmesh/magics.py,sha256=bEzYqXHcM0P3CjyUZ1O9arlmXAdLAhoglKbQ29fD9AE,41842
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -18,7 +18,7 @@ sqlmesh/core/context_diff.py,sha256=CeUmMBJzN__98YohrtAiIYPIZI9mrGBk6bVADWBLUw8,
|
|
|
18
18
|
sqlmesh/core/dialect.py,sha256=1ykYwb9WZn_nCaX08PcQ0BJh2Pihv9SPvoMNjpMeCfs,50158
|
|
19
19
|
sqlmesh/core/environment.py,sha256=7DbJX0r5nZRU3LhcgIxbSV-JosQYDjAt3V5Wc2Fpns8,13005
|
|
20
20
|
sqlmesh/core/lineage.py,sha256=zjB0Zfamo2Fja2r5SSZPMbrEKTXr1WjozZPVqvxdybI,3143
|
|
21
|
-
sqlmesh/core/loader.py,sha256=
|
|
21
|
+
sqlmesh/core/loader.py,sha256=JSozxPrvnnJL7vVA93UkRDRF0bkCBkv4QxUFW0sPwE8,40818
|
|
22
22
|
sqlmesh/core/macros.py,sha256=3M3lChT2X5APuHyEprEbFfCXL31ab_2k3KkgPLKx6xE,60652
|
|
23
23
|
sqlmesh/core/node.py,sha256=3ChBz1PIMJhp-jzed_GLBrtmEF2v_BVDEM5WNe0ssPk,14658
|
|
24
24
|
sqlmesh/core/notification_target.py,sha256=PPGoDrgbRKxr27vJEu03XqNTQLYTw0ZF_b0yAapxGeI,16158
|
|
@@ -86,9 +86,9 @@ sqlmesh/core/metric/definition.py,sha256=Yd5aVgsZCDPJ43aGP7WqtzZOuuSUtB8uJGVA6Jw
|
|
|
86
86
|
sqlmesh/core/metric/rewriter.py,sha256=GiSTHfn2kinqCfNPYgZPRk93JFLzVaaejHtHDQ0yXZI,7326
|
|
87
87
|
sqlmesh/core/model/__init__.py,sha256=C8GRZ53xuXEA9hQv3BQS9pNNyd9rZ06R_B96UYGhDu4,1644
|
|
88
88
|
sqlmesh/core/model/cache.py,sha256=csun0RJguHzKX6-qITcOs4fVP4f8_Ts8qiUVV4sHY6Q,7869
|
|
89
|
-
sqlmesh/core/model/common.py,sha256=
|
|
89
|
+
sqlmesh/core/model/common.py,sha256=2kXT6DhDAOR59x3EVYrhyoU4QxKv_ScG0zzp98wU8m0,17897
|
|
90
90
|
sqlmesh/core/model/decorator.py,sha256=wUUg5t0K559tV9Pqt6FE2EWXt5TPGb4wF2Yg4B4hX4w,9251
|
|
91
|
-
sqlmesh/core/model/definition.py,sha256=
|
|
91
|
+
sqlmesh/core/model/definition.py,sha256=PvE6EYZrPFQHZgSw7kn-V85qpwBf07TOGMnjdz03CE0,112811
|
|
92
92
|
sqlmesh/core/model/kind.py,sha256=8Dp8yiTiXltboZWrB2FJ-LQ3zx4Fv_5Tj0KdUIPwCHI,36358
|
|
93
93
|
sqlmesh/core/model/meta.py,sha256=D9InI9M2-IXeb34vkXNQSLALL8xVXjZ_LXwI-Tqxm7I,21197
|
|
94
94
|
sqlmesh/core/model/schema.py,sha256=_HMYfzK9wWXh7_CQDIIGnuQUD4aiX3o5D2cRp2sERzc,3387
|
|
@@ -165,12 +165,13 @@ sqlmesh/integrations/github/cicd/config.py,sha256=Gwc0Gj9gj3CSvr8g1LMVK0rK8g05BU
|
|
|
165
165
|
sqlmesh/integrations/github/cicd/controller.py,sha256=xLItdmgjYAkN8e3oBuaaOOC51Vg_69UO8U4ITK1Az-s,52811
|
|
166
166
|
sqlmesh/lsp/api.py,sha256=_lA_buSPZFIoLJuINbS53LbNOOaHp3orb0uFTE3aCqI,2328
|
|
167
167
|
sqlmesh/lsp/completions.py,sha256=Nt1XpFL_-QAIRM8BBBC6Ia6YG0hMZriiNJra7nGfD4Q,6676
|
|
168
|
-
sqlmesh/lsp/context.py,sha256=
|
|
168
|
+
sqlmesh/lsp/context.py,sha256=szHCrmKAjg4wDRnSbjRU158wSGx9HBRnNswSNw9N0Qc,12439
|
|
169
169
|
sqlmesh/lsp/custom.py,sha256=IJ70li8d5RbOFDrjHfsI2UNOiOp-WB22lrgpdJ7lVSg,2942
|
|
170
170
|
sqlmesh/lsp/description.py,sha256=PjguwyVw5YeYSgT0JMhkf5U1Jry-sDPLvQ2caIR9JPQ,856
|
|
171
|
+
sqlmesh/lsp/errors.py,sha256=3NMim_5J00Eypz7t8b7XbkBfy8gIsRkeq-VcjD4COtc,1489
|
|
171
172
|
sqlmesh/lsp/helpers.py,sha256=EFc1u3-b7kSv5-tNwmKUDxId72RCLDBnN2lLTgRSzzQ,1020
|
|
172
173
|
sqlmesh/lsp/hints.py,sha256=j-blccBUil94yRoDjWfkSM0HqMmsKD6hP2TaWdWWVk4,3734
|
|
173
|
-
sqlmesh/lsp/main.py,sha256=
|
|
174
|
+
sqlmesh/lsp/main.py,sha256=82VNH0d6T6OZlGM8U-q5B39UV6gTaaHUwhddWzRcseA,39770
|
|
174
175
|
sqlmesh/lsp/reference.py,sha256=CjIXCJ5qM5mHyKRyM1brKyvpK9oQfLI0LiNKHfjJuVw,32257
|
|
175
176
|
sqlmesh/lsp/rename.py,sha256=399v1vyVRHHxvbCHVcuS4Pl8K2N-Z60JdZ6e1znOI4s,4397
|
|
176
177
|
sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
|
|
@@ -271,7 +272,7 @@ sqlmesh/utils/conversions.py,sha256=Ul8u6TzlKzFz_lVrUzFSzmJBKHUXOYe2e-xmkMXV084,
|
|
|
271
272
|
sqlmesh/utils/cron.py,sha256=eGwn4iUeiRoQzwcd9eS2TZkut8nR4yWud77N7xQ9CQ0,1829
|
|
272
273
|
sqlmesh/utils/dag.py,sha256=L_jwKf81wCySmt1TFs4vEKsrIHSOPTBhptlmv1bsSSg,7025
|
|
273
274
|
sqlmesh/utils/date.py,sha256=uS0Kii4hFJeTXqXtM39sDCzvFhTAoPk_NPg51T1YYeo,16218
|
|
274
|
-
sqlmesh/utils/errors.py,sha256=
|
|
275
|
+
sqlmesh/utils/errors.py,sha256=8FE33Eo3KN3Y4s5EZM5t92jZi9BAVGzkr3QCGlrLeDk,5679
|
|
275
276
|
sqlmesh/utils/git.py,sha256=v1MD4Zwn52UBn_tTfoKn8SAPJVGC6SEFrJ4WEJFbgF0,1868
|
|
276
277
|
sqlmesh/utils/hashing.py,sha256=4Bi0NvRctBHzg58btNxXwSNgcvj8doIVVvOjJ40mHBg,512
|
|
277
278
|
sqlmesh/utils/jinja.py,sha256=zulSPIICdFOjN__xkAiMpxbCS7S0--xAFK9d8VG0KvU,27844
|
|
@@ -283,7 +284,7 @@ sqlmesh/utils/pydantic.py,sha256=o_NsXbIpDqNpUA1Uc5xF0ZzoXQYYB0DfHwdRxBwXPNk,120
|
|
|
283
284
|
sqlmesh/utils/rich.py,sha256=BpB47G0-JcU41LkGkeGKroexj4NOV5fox4-GOIXPgIc,3545
|
|
284
285
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
285
286
|
sqlmesh/utils/yaml.py,sha256=hvo5lmybYLcIx4p6CQwufS8X4MbwS60lEBnCmYJCXmU,2336
|
|
286
|
-
sqlmesh-0.200.1.
|
|
287
|
+
sqlmesh-0.200.1.dev3.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
287
288
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
288
289
|
web/client/dist/index.html,sha256=DAv6ABGogw4xRLb0T_92WP_S7XWyqVhwBgGKWtuQwU4,5472
|
|
289
290
|
web/client/dist/assets/Audits-BuHAmFO8.js,sha256=zbYUF6WdUGMbnMm01GMNPb7xAJwj-o5wMdL56vPo2qE,1041
|
|
@@ -401,8 +402,8 @@ web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWf
|
|
|
401
402
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
402
403
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
403
404
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
404
|
-
sqlmesh-0.200.1.
|
|
405
|
-
sqlmesh-0.200.1.
|
|
406
|
-
sqlmesh-0.200.1.
|
|
407
|
-
sqlmesh-0.200.1.
|
|
408
|
-
sqlmesh-0.200.1.
|
|
405
|
+
sqlmesh-0.200.1.dev3.dist-info/METADATA,sha256=OiskmfyuGAP41tYm5lvENPjA7qFE4oMQ3Uo86RdFiX0,26657
|
|
406
|
+
sqlmesh-0.200.1.dev3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
407
|
+
sqlmesh-0.200.1.dev3.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
408
|
+
sqlmesh-0.200.1.dev3.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
409
|
+
sqlmesh-0.200.1.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|