sqlmesh 0.185.2.dev1__py3-none-any.whl → 0.185.2.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/__init__.py CHANGED
@@ -166,11 +166,24 @@ class CustomFormatter(logging.Formatter):
166
166
  return formatter.format(record)
167
167
 
168
168
 
169
+ def remove_excess_logs(
170
+ log_file_dir: t.Optional[t.Union[str, Path]] = None,
171
+ log_limit: int = c.DEFAULT_LOG_LIMIT,
172
+ ) -> None:
173
+ if log_limit <= 0:
174
+ return
175
+
176
+ log_file_dir = log_file_dir or c.DEFAULT_LOG_FILE_DIR
177
+ log_path_prefix = Path(log_file_dir) / LOG_FILENAME_PREFIX
178
+
179
+ for path in list(sorted(glob.glob(f"{log_path_prefix}*.log"), reverse=True))[log_limit:]:
180
+ os.remove(path)
181
+
182
+
169
183
  def configure_logging(
170
184
  force_debug: bool = False,
171
185
  write_to_stdout: bool = False,
172
186
  write_to_file: bool = True,
173
- log_limit: int = c.DEFAULT_LOG_LIMIT,
174
187
  log_file_dir: t.Optional[t.Union[str, Path]] = None,
175
188
  ignore_warnings: bool = False,
176
189
  ) -> None:
@@ -192,20 +205,18 @@ def configure_logging(
192
205
 
193
206
  log_file_dir = log_file_dir or c.DEFAULT_LOG_FILE_DIR
194
207
  log_path_prefix = Path(log_file_dir) / LOG_FILENAME_PREFIX
208
+
195
209
  if write_to_file:
196
210
  os.makedirs(str(log_file_dir), exist_ok=True)
197
211
  filename = f"{log_path_prefix}{datetime.now().strftime('%Y_%m_%d_%H_%M_%S')}.log"
198
212
  file_handler = logging.FileHandler(filename, mode="w", encoding="utf-8")
213
+
199
214
  # the log files should always log at least info so that users will always have
200
215
  # minimal info for debugging even if they specify "ignore_warnings"
201
216
  file_handler.setLevel(level)
202
217
  file_handler.setFormatter(logging.Formatter(LOG_FORMAT))
203
218
  logger.addHandler(file_handler)
204
219
 
205
- if log_limit > 0:
206
- for path in list(sorted(glob.glob(f"{log_path_prefix}*.log"), reverse=True))[log_limit:]:
207
- os.remove(path)
208
-
209
220
  if debug:
210
221
  import faulthandler
211
222
 
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.185.2.dev1'
21
- __version_tuple__ = version_tuple = (0, 185, 2, 'dev1')
20
+ __version__ = version = '0.185.2.dev3'
21
+ __version_tuple__ = version_tuple = (0, 185, 2, 'dev3')
sqlmesh/cli/main.py CHANGED
@@ -7,7 +7,7 @@ import typing as t
7
7
 
8
8
  import click
9
9
 
10
- from sqlmesh import configure_logging
10
+ from sqlmesh import configure_logging, remove_excess_logs
11
11
  from sqlmesh.cli import error_handler
12
12
  from sqlmesh.cli import options as opt
13
13
  from sqlmesh.cli.example_project import ProjectTemplate, init_example_project
@@ -100,17 +100,19 @@ def cli(
100
100
  if ctx.invoked_subcommand in SKIP_LOAD_COMMANDS:
101
101
  load = False
102
102
 
103
- configs = load_configs(config, Context.CONFIG_TYPE, paths)
104
- log_limit = list(configs.values())[0].log_limit
105
103
  configure_logging(
106
104
  debug,
107
105
  log_to_stdout,
108
- log_limit=log_limit,
109
106
  log_file_dir=log_file_dir,
110
107
  ignore_warnings=ignore_warnings,
111
108
  )
112
109
  configure_console(ignore_warnings=ignore_warnings)
113
110
 
111
+ configs = load_configs(config, Context.CONFIG_TYPE, paths)
112
+ log_limit = list(configs.values())[0].log_limit
113
+
114
+ remove_excess_logs(log_file_dir, log_limit)
115
+
114
116
  try:
115
117
  context = Context(
116
118
  paths=paths,
@@ -26,7 +26,7 @@ from sqlmesh.core.config.common import (
26
26
  )
27
27
  from sqlmesh.core.engine_adapter.shared import CatalogSupport
28
28
  from sqlmesh.core.engine_adapter import EngineAdapter
29
- from sqlmesh.utils import str_to_bool
29
+ from sqlmesh.utils import debug_mode_enabled, str_to_bool
30
30
  from sqlmesh.utils.errors import ConfigError
31
31
  from sqlmesh.utils.pydantic import (
32
32
  ValidationInfo,
@@ -67,8 +67,16 @@ def _get_engine_import_validator(
67
67
  try:
68
68
  importlib.import_module(import_name)
69
69
  except ImportError:
70
+ if debug_mode_enabled():
71
+ raise
72
+
73
+ logger.exception("Failed to import the engine library")
74
+
70
75
  raise ConfigError(
71
- f"Failed to import the '{engine_type}' engine library. Please run `pip install \"sqlmesh[{extra_name}]\"`."
76
+ f"Failed to import the '{engine_type}' engine library. This may be due to a missing "
77
+ "or incompatible installation. Please ensure the required dependency is installed by "
78
+ f'running: `pip install "sqlmesh[{extra_name}]"`. For more details, check the logs '
79
+ "in the 'logs/' folder, or rerun the command with the '--debug' flag."
72
80
  )
73
81
 
74
82
  return data
sqlmesh/core/context.py CHANGED
@@ -35,7 +35,6 @@ from __future__ import annotations
35
35
 
36
36
  import abc
37
37
  import collections
38
- from itertools import chain
39
38
  import logging
40
39
  import sys
41
40
  import time
@@ -44,6 +43,7 @@ import typing as t
44
43
  import unittest.result
45
44
  from functools import cached_property
46
45
  from io import StringIO
46
+ from itertools import chain
47
47
  from pathlib import Path
48
48
  from shutil import rmtree
49
49
  from types import MappingProxyType
sqlmesh/magics.py CHANGED
@@ -129,18 +129,23 @@ class SQLMeshMagics(Magics):
129
129
  @line_magic
130
130
  def context(self, line: str) -> None:
131
131
  """Sets the context in the user namespace."""
132
- from sqlmesh import configure_logging
132
+ from sqlmesh import configure_logging, remove_excess_logs
133
133
 
134
134
  args = parse_argstring(self.context, line)
135
- configs = load_configs(args.config, Context.CONFIG_TYPE, args.paths)
136
- log_limit = list(configs.values())[0].log_limit
135
+ log_file_dir = args.log_file_dir
136
+
137
137
  configure_logging(
138
138
  args.debug,
139
- log_limit=log_limit,
140
- log_file_dir=args.log_file_dir,
139
+ log_file_dir=log_file_dir,
141
140
  ignore_warnings=args.ignore_warnings,
142
141
  )
143
142
  configure_console(ignore_warnings=args.ignore_warnings)
143
+
144
+ configs = load_configs(args.config, Context.CONFIG_TYPE, args.paths)
145
+ log_limit = list(configs.values())[0].log_limit
146
+
147
+ remove_excess_logs(log_file_dir, log_limit)
148
+
144
149
  try:
145
150
  context = Context(paths=args.paths, config=configs, gateway=args.gateway)
146
151
  self._shell.user_ns["context"] = context
@@ -148,6 +153,7 @@ class SQLMeshMagics(Magics):
148
153
  if args.debug:
149
154
  logger.exception("Failed to initialize SQLMesh context")
150
155
  raise
156
+
151
157
  context.console.log_success(f"SQLMesh project context set to: {', '.join(args.paths)}")
152
158
 
153
159
  @magic_arguments()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.185.2.dev1
3
+ Version: 0.185.2.dev3
4
4
  Summary: Next-generation data transformation framework
5
5
  Author-email: "TobikoData Inc." <engineering@tobikodata.com>
6
6
  License: Apache License
@@ -1,19 +1,19 @@
1
- sqlmesh/__init__.py,sha256=DRovDXI-9D9xeYDP7t8Fq7mI31S2btlN-LHPOK3y7PA,7240
2
- sqlmesh/_version.py,sha256=52EqeiC27hoqsLTJzcoy8g4qsYv7ecK5qXPKrDOahV4,528
3
- sqlmesh/magics.py,sha256=aeOyTdeNnyGzGtJXECDAbqJ8OAplrV4UAYl0I2hhtig,39670
1
+ sqlmesh/__init__.py,sha256=69xw6bTmi4cW90M-sl3g6wLDgxVcLHcKg1q8GS3lqyA,7466
2
+ sqlmesh/_version.py,sha256=uLFP2tRRpi1dQNf1Yk25gnRf1m1Utjm7b8oG398Bhlg,528
3
+ sqlmesh/magics.py,sha256=JHorAZNtezf123jmTyNSoUC9yHmv-08hMP205PJmmIo,39750
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  sqlmesh/cicd/bot.py,sha256=2zlbn-DXkqQzr3lA0__IGU4XaIfXBXBKLWXNI2DRJX8,759
7
7
  sqlmesh/cicd/config.py,sha256=mpgkisSBBovlNrNZir2unT8Wes6b38RW2UsU_o4e8vY,109
8
8
  sqlmesh/cli/__init__.py,sha256=MAXAyO7isbyM-PaSdFjkJNcjn32WjOl0XzxT5gvp_vo,1690
9
9
  sqlmesh/cli/example_project.py,sha256=QAFQbw_kzqn30GLTthqsuWXbFDBpX8W6RsCgQ-jx65M,9308
10
- sqlmesh/cli/main.py,sha256=WNwiqXjbnlfr3ky159IXIMZWd1V4SNx1cZHjNSAyd9Q,32269
10
+ sqlmesh/cli/main.py,sha256=dt92CJPuMzUZvBYqXMh-tkUCaLfj2Z5RC2COa98_9Co,32310
11
11
  sqlmesh/cli/options.py,sha256=aC_L5WnMScKzMU55BD1Y-8R-QzqCkPSYrlCI-payHRA,1333
12
12
  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=ZAaGLOWBJGBxPzLV7KZZ9akPExgD5m5AboCM8O0Q0nY,150944
15
15
  sqlmesh/core/constants.py,sha256=oqt6zjepUhQoWlgapKn_HpG7Pu9mrFwepdX5caNfJUI,2499
16
- sqlmesh/core/context.py,sha256=1EFWFHQyTuKKpEasguZJmVZNth5IZCjdqSLgwDfeEgU,115024
16
+ sqlmesh/core/context.py,sha256=uv-RQTajXhrltbzOEbalDY6NKIJWCUhmiww8YTgFxW0,115024
17
17
  sqlmesh/core/context_diff.py,sha256=s9toP17d4tJfOpFH91LcjGK2CM64PVuB0MPkeFgF4hQ,20415
18
18
  sqlmesh/core/dialect.py,sha256=fPTV517IOS0nWMxYznNNQnXkQkFFrPOSKe8ghsQ0o8A,49759
19
19
  sqlmesh/core/environment.py,sha256=0TTQf4C4LXwf37fm-dfYv1qyG7vtZfQI5rizgm5g0j0,11442
@@ -41,7 +41,7 @@ sqlmesh/core/config/__init__.py,sha256=b4gFb04tpeZpowqJD-7h3U3TLgxrpQhZahVEAo6VW
41
41
  sqlmesh/core/config/base.py,sha256=t8NQmsgQoZSc-k0dlDiCb8t1jj0AMYdGZ-6se9q_Pks,4898
42
42
  sqlmesh/core/config/categorizer.py,sha256=6vzUoNLjR6GOEb_2mYVz2TwmMv2BfldgHX2u-Le5HZs,1975
43
43
  sqlmesh/core/config/common.py,sha256=-o_HoRFtR4u84frg_TLno7z7vS9II6ASiOayb59MKHo,2806
44
- sqlmesh/core/config/connection.py,sha256=2xEBZFjaHgdTiSj0MjDIfCPnOoe5dT4gRQ2RYm0bQ80,73499
44
+ sqlmesh/core/config/connection.py,sha256=scyhg-gq0czu7-2y9n1tBKnLfM0jT51QaYR_hFCeQU8,73917
45
45
  sqlmesh/core/config/feature_flag.py,sha256=JRcD31OG_t2cYc24meKbHDGB0iVID0P07V2oOeB_mgA,203
46
46
  sqlmesh/core/config/format.py,sha256=6CXFbvnor56xbldKE-Vrm9k_ABRoY4v6vgIb3mCihiQ,1355
47
47
  sqlmesh/core/config/gateway.py,sha256=tYngyqwd_4Qr9lhcv2hlvLvb_2pgYYtKu6hdGsTr-4I,1931
@@ -268,7 +268,7 @@ sqlmesh/utils/pydantic.py,sha256=dywc9i-diWLA3vB-X_28I8NX3BPoSWAjcaP31zkzr0k,111
268
268
  sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
269
269
  sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
270
270
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
271
- sqlmesh-0.185.2.dev1.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
271
+ sqlmesh-0.185.2.dev3.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
272
272
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
273
273
  web/client/dist/index.html,sha256=xQIU9G6dbuTnmbHZ61bSYbh0gYz9A2lb4BRwLlXL94Y,5472
274
274
  web/client/dist/assets/Audits-Dcl7Y5yf.js,sha256=D2CfXzrdXFdD_-7c51tBJCKNwUY9yGeIpDEaRae7V8I,1041
@@ -386,8 +386,8 @@ web/server/api/endpoints/models.py,sha256=ud-lRwriyI_OYg9tZchrBgeiXELiRTLNEodraf
386
386
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
387
387
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
388
388
  web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
389
- sqlmesh-0.185.2.dev1.dist-info/METADATA,sha256=DvXLT-n3ppnATFnrE_bS33bownhatjJjbEv4umTeOaA,25523
390
- sqlmesh-0.185.2.dev1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
391
- sqlmesh-0.185.2.dev1.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
392
- sqlmesh-0.185.2.dev1.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
393
- sqlmesh-0.185.2.dev1.dist-info/RECORD,,
389
+ sqlmesh-0.185.2.dev3.dist-info/METADATA,sha256=b4oaKUqD5EDyY0Zd7HOmof1EV0TS6tsT-e3X9T26X0w,25523
390
+ sqlmesh-0.185.2.dev3.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
391
+ sqlmesh-0.185.2.dev3.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
392
+ sqlmesh-0.185.2.dev3.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
393
+ sqlmesh-0.185.2.dev3.dist-info/RECORD,,