Skip to content

Commit a279f81

Browse files
authored
Merge branch 'main' into feat/add-testsuites-to-createtestcase-api
2 parents fde4655 + 7f4cf82 commit a279f81

115 files changed

Lines changed: 5070 additions & 1161 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/py-cli-e2e-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,18 @@ jobs:
283283

284284
- name: Generate report
285285
run: |
286+
# Copy coverage artifacts into ingestion/ so paths resolve relative to it
286287
for folder in artifacts/coverage-*; do
287-
cp -rT $folder/ . ;
288+
cp -rT $folder/ ingestion/ ;
288289
done
289-
mkdir ingestion/junit
290+
mkdir -p ingestion/junit
290291
for folder in artifacts/tests-*; do
291292
cp -rT $folder/ ingestion/junit ;
292293
done
293294
source env/bin/activate
294-
coverage combine --rcfile=ingestion/pyproject.toml --keep -a .coverage*
295-
coverage xml --rcfile=ingestion/pyproject.toml --data-file=.coverage -o ingestion/coverage.xml
296-
sed -e "s/$(python -c "import site; import os; from pathlib import Path; print(os.path.relpath(site.getsitepackages()[0], str(Path.cwd())).replace('/','\/'))")/src/g" ingestion/coverage.xml >> ingestion/ci-coverage.xml
297-
sed -i 's/src\/metadata/\/github\/workspace\/ingestion\/src\/metadata/g' ingestion/ci-coverage.xml
295+
cd ingestion
296+
coverage combine --rcfile=pyproject.toml --keep -a .coverage*
297+
coverage xml --rcfile=pyproject.toml --data-file=.coverage
298298
shell: bash
299299

300300
- name: Push Results to Sonar

ingestion/src/metadata/ingestion/api/step.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from metadata.ingestion.api.models import Either, Entity, StackTraceError
2424
from metadata.ingestion.api.status import Status
2525
from metadata.ingestion.ometa.ometa_api import OpenMetadata
26-
from metadata.utils.logger import ingestion_logger
26+
from metadata.utils.logger import StatusWarningHandler, ingestion_logger
2727
from metadata.utils.operation_metrics import OperationMetricsState
2828
from metadata.utils.progress_tracker import ProgressTrackerState
2929

@@ -45,6 +45,24 @@ class Step(ABC, Closeable):
4545

4646
def __init__(self):
4747
self.status = Status()
48+
self._warning_handler = StatusWarningHandler(self.status)
49+
50+
def _activate_handler(self) -> None:
51+
"""Attach the warning handler to the ingestion logger.
52+
53+
Called at the start of each run() so that warnings emitted
54+
during step execution are captured in the step's Status.
55+
Must be paired with _deactivate_handler in a finally block.
56+
"""
57+
ingestion_logger().addHandler(self._warning_handler)
58+
59+
def _deactivate_handler(self) -> None:
60+
"""Remove the warning handler from the ingestion logger.
61+
62+
Called in the finally block of run() to ensure the handler
63+
does not leak across step boundaries.
64+
"""
65+
ingestion_logger().removeHandler(self._warning_handler)
4866

4967
@classmethod
5068
@abstractmethod
@@ -128,6 +146,7 @@ def run(self, record: Entity) -> Optional[Entity]:
128146
"""
129147
Run the step and handle the status and exceptions
130148
"""
149+
self._activate_handler()
131150
try:
132151
result: Either = self._run(record)
133152
if result:
@@ -162,6 +181,8 @@ def run(self, record: Entity) -> Optional[Entity]:
162181
name="Unhandled", error=error, stackTrace=traceback.format_exc()
163182
)
164183
)
184+
finally:
185+
self._deactivate_handler()
165186

166187
return None
167188

@@ -186,6 +207,7 @@ def run(self, record: Entity) -> None:
186207
"""
187208
Run the step and handle the status and exceptions.
188209
"""
210+
self._activate_handler()
189211
try:
190212
for result in self._run(record):
191213
if result.left is not None:
@@ -217,6 +239,8 @@ def run(self, record: Entity) -> None:
217239
name="Unhandled", error=error, stackTrace=traceback.format_exc()
218240
)
219241
)
242+
finally:
243+
self._deactivate_handler()
220244

221245

222246
class IterStep(Step, ABC):
@@ -233,6 +257,7 @@ def run(self) -> Iterable[Optional[Entity]]:
233257
Note that we are overwriting the default run implementation
234258
in order to create a generator with `yield`.
235259
"""
260+
self._activate_handler()
236261
try:
237262
for result in self._iter():
238263
if result.left is not None:
@@ -266,6 +291,8 @@ def run(self) -> Iterable[Optional[Entity]]:
266291
name="Unhandled", error=error, stackTrace=traceback.format_exc()
267292
)
268293
)
294+
finally:
295+
self._deactivate_handler()
269296

270297

271298
class BulkStep(Step, ABC):

ingestion/src/metadata/ingestion/api/steps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,15 @@ class BulkSink(BulkStep, ABC):
9494
@property
9595
def name(self) -> str:
9696
return "BulkSink"
97+
98+
def run(self) -> None:
99+
"""Wrap the abstract run() with the warning handler lifecycle.
100+
101+
BulkStep.run() is abstract and overridden directly by
102+
concrete subclasses, so the handler must be scoped here.
103+
"""
104+
self._activate_handler()
105+
try:
106+
super().run()
107+
finally:
108+
self._deactivate_handler()

ingestion/src/metadata/ingestion/ometa/ometa_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ def update_file_name(create: Type[C], file_name: str) -> str:
429429
"""
430430
Update the filename for services and schemas
431431
"""
432+
explicit_file_name_map = {
433+
"CreateTableProfileRequest": "table",
434+
"CreateTestCaseResult": "basic",
435+
}
436+
if create.__name__ in explicit_file_name_map:
437+
return explicit_file_name_map[create.__name__]
438+
432439
if "service" in create.__name__.lower():
433440
return file_name.replace("service", "Service")
434441

ingestion/src/metadata/ingestion/source/database/azuresql/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
logger = ingestion_logger()
4545

46-
ischema_names = update_mssql_ischema_names(ischema_names)
46+
update_mssql_ischema_names(ischema_names)
4747

4848
MSDialect.get_table_comment = get_table_comment
4949
MSDialect.get_view_definition = get_view_definition

0 commit comments

Comments
 (0)