Skip to content

Commit 46a28b6

Browse files
committed
Fix: Broken build
1 parent a85a8b2 commit 46a28b6

7 files changed

Lines changed: 30 additions & 25 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"agate==1.7.1",
6666
f"apache-airflow=={os.environ.get('AIRFLOW_VERSION', '2.9.1')}",
6767
"opentelemetry-proto==1.27.0", # pip was having trouble resolving this transitive dependency of airflow
68-
"beautifulsoup4",
68+
"beautifulsoup4==4.12.3",
6969
"clickhouse-connect",
7070
"cryptography",
7171
"custom-materializations",

sqlmesh/core/console.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing as t
66
import unittest
77
import uuid
8+
import logging
89

910
from hyperscript import h
1011
from rich.console import Console as RichConsole
@@ -47,6 +48,9 @@
4748
LayoutWidget = t.TypeVar("LayoutWidget", bound=t.Union[widgets.VBox, widgets.HBox])
4849

4950

51+
logger = logging.getLogger(__name__)
52+
53+
5054
SNAPSHOT_CHANGE_CATEGORY_STR = {
5155
None: "Unknown",
5256
SnapshotChangeCategory.BREAKING: "Breaking",
@@ -409,7 +413,7 @@ def log_error(self, message: str) -> None:
409413
pass
410414

411415
def log_warning(self, message: str) -> None:
412-
pass
416+
logger.warning(message)
413417

414418
def log_success(self, message: str) -> None:
415419
pass
@@ -1183,6 +1187,7 @@ def log_error(self, message: str) -> None:
11831187
self._print(f"[red]{message}[/red]")
11841188

11851189
def log_warning(self, message: str) -> None:
1190+
logger.warning(message)
11861191
if not self.ignore_warnings:
11871192
self._print(f"[yellow]{message}[/yellow]")
11881193

@@ -2311,6 +2316,7 @@ def log_error(self, message: str) -> None:
23112316
self._write(message, style="bold red")
23122317

23132318
def log_warning(self, message: str) -> None:
2319+
logger.warning(message)
23142320
if not self.ignore_warnings:
23152321
self._write(message, style="bold yellow")
23162322

sqlmesh/core/renderer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ def _optimize_query(self, query: exp.Query, all_deps: t.Set[str]) -> exp.Query:
547547
if self._validate_query:
548548
raise_config_error(warning, self._path)
549549

550-
logger.warning(warning)
551550
get_console().log_warning(warning)
552551

553552
try:
@@ -578,7 +577,6 @@ def _optimize_query(self, query: exp.Query, all_deps: t.Set[str]) -> exp.Query:
578577

579578
query = original
580579

581-
logger.warning(warning)
582580
get_console().log_warning(warning)
583581
except Exception as ex:
584582
raise_config_error(

sqlmesh/core/schema_diff.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,10 @@ def _is_coerceable_type(self, current_type: exp.DataType, new_type: exp.DataType
383383
if is_coerceable:
384384
from sqlmesh.core.console import get_console
385385

386-
warning = f"Coercing type {current_type} to {new_type} which means an alter will not be performed and therefore the resulting table structure will not match what is in the query.\nUpdate your model to cast the value to {current_type} type in order to remove this warning."
387-
logger.warning(warning)
388-
get_console().log_warning(warning)
386+
get_console().log_warning(
387+
f"Coercing type {current_type} to {new_type} which means an alter will not be performed and therefore the resulting table structure will not match what is in the query.\nUpdate your model to cast the value to {current_type} type in order to remove this warning."
388+
)
389+
389390
return is_coerceable
390391
return False
391392

sqlmesh/core/test/definition.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ def create_test(
329329
name = normalize_model_name(name, default_catalog=default_catalog, dialect=dialect)
330330
model = models.get(name)
331331
if not model:
332-
logger.warning(f"Model '{name}' was not found{' at ' + str(path) if path else ''}")
332+
from sqlmesh.core.console import get_console
333+
334+
get_console().log_warning(
335+
f"Model '{name}' was not found{' at ' + str(path) if path else ''}"
336+
)
333337
return None
334338

335339
if isinstance(model, SqlModel):

tests/core/test_model.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# ruff: noqa: F811
22
import json
3-
import logging
43
import typing as t
54
from datetime import date, datetime
65
from pathlib import Path
@@ -276,8 +275,7 @@ def test_model_validation_union_query():
276275

277276

278277
def test_model_qualification():
279-
logger = logging.getLogger("sqlmesh.core.renderer")
280-
with patch.object(logger, "warning") as mock_logger:
278+
with patch.object(get_console(), "log_warning") as mock_logger:
281279
expressions = d.parse(
282280
"""
283281
MODEL (
@@ -2677,8 +2675,7 @@ def test_update_schema():
26772675
model.update_schema(schema)
26782676
assert model.mapping_schema == {'"table_a"': {"a": "INT"}}
26792677

2680-
logger = logging.getLogger("sqlmesh.core.renderer")
2681-
with patch.object(logger, "warning") as mock_logger:
2678+
with patch.object(get_console(), "log_warning") as mock_logger:
26822679
model.render_query(needs_optimization=True)
26832680
assert mock_logger.call_args[0][0] == missing_schema_warning_msg(
26842681
'"db"."table"', ('"table_b"',)
@@ -2694,8 +2691,6 @@ def test_update_schema():
26942691

26952692

26962693
def test_missing_schema_warnings():
2697-
logger = logging.getLogger("sqlmesh.core.renderer")
2698-
26992694
full_schema = MappingSchema(
27002695
{
27012696
"a": {"x": exp.DataType.build("int")},
@@ -2710,34 +2705,36 @@ def test_missing_schema_warnings():
27102705
},
27112706
)
27122707

2708+
console = get_console()
2709+
27132710
# star, no schema, no deps
2714-
with patch.object(logger, "warning") as mock_logger:
2711+
with patch.object(console, "log_warning") as mock_logger:
27152712
model = load_sql_based_model(d.parse("MODEL (name test); SELECT * FROM (SELECT 1 a) x"))
27162713
model.render_query(needs_optimization=True)
27172714
mock_logger.assert_not_called()
27182715

27192716
# star, full schema
2720-
with patch.object(logger, "warning") as mock_logger:
2717+
with patch.object(console, "log_warning") as mock_logger:
27212718
model = load_sql_based_model(d.parse("MODEL (name test); SELECT * FROM a CROSS JOIN b"))
27222719
model.update_schema(full_schema)
27232720
model.render_query(needs_optimization=True)
27242721
mock_logger.assert_not_called()
27252722

27262723
# star, partial schema
2727-
with patch.object(logger, "warning") as mock_logger:
2724+
with patch.object(console, "log_warning") as mock_logger:
27282725
model = load_sql_based_model(d.parse("MODEL (name test); SELECT * FROM a CROSS JOIN b"))
27292726
model.update_schema(partial_schema)
27302727
model.render_query(needs_optimization=True)
27312728
assert mock_logger.call_args[0][0] == missing_schema_warning_msg('"test"', ('"b"',))
27322729

27332730
# star, no schema
2734-
with patch.object(logger, "warning") as mock_logger:
2731+
with patch.object(console, "log_warning") as mock_logger:
27352732
model = load_sql_based_model(d.parse("MODEL (name test); SELECT * FROM b JOIN a"))
27362733
model.render_query(needs_optimization=True)
27372734
assert mock_logger.call_args[0][0] == missing_schema_warning_msg('"test"', ('"a"', '"b"'))
27382735

27392736
# no star, full schema
2740-
with patch.object(logger, "warning") as mock_logger:
2737+
with patch.object(console, "log_warning") as mock_logger:
27412738
model = load_sql_based_model(
27422739
d.parse("MODEL (name test); SELECT x::INT FROM a CROSS JOIN b")
27432740
)
@@ -2746,7 +2743,7 @@ def test_missing_schema_warnings():
27462743
mock_logger.assert_not_called()
27472744

27482745
# no star, partial schema
2749-
with patch.object(logger, "warning") as mock_logger:
2746+
with patch.object(console, "log_warning") as mock_logger:
27502747
model = load_sql_based_model(
27512748
d.parse("MODEL (name test); SELECT x::INT FROM a CROSS JOIN b")
27522749
)
@@ -2755,7 +2752,7 @@ def test_missing_schema_warnings():
27552752
mock_logger.assert_not_called()
27562753

27572754
# no star, empty schema
2758-
with patch.object(logger, "warning") as mock_logger:
2755+
with patch.object(console, "log_warning") as mock_logger:
27592756
model = load_sql_based_model(
27602757
d.parse("MODEL (name test); SELECT x::INT FROM a CROSS JOIN b")
27612758
)

tests/core/test_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import logging
43
import datetime
54
import typing as t
65
from pathlib import Path
@@ -21,6 +20,7 @@
2120
ModelDefaultsConfig,
2221
)
2322
from sqlmesh.core.context import Context
23+
from sqlmesh.core.console import get_console
2424
from sqlmesh.core.dialect import parse
2525
from sqlmesh.core.engine_adapter import EngineAdapter
2626
from sqlmesh.core.macros import MacroEvaluator, macro
@@ -1771,8 +1771,7 @@ def test_unknown_model_warns(mocker: MockerFixture) -> None:
17711771
"""
17721772
)
17731773

1774-
logger = logging.getLogger("sqlmesh.core.test.definition")
1775-
with patch.object(logger, "warning") as mock_logger:
1774+
with patch.object(get_console(), "log_warning") as mock_logger:
17761775
ModelTest.create_test(
17771776
body=body,
17781777
test_name="test_unknown_model",

0 commit comments

Comments
 (0)