Skip to content

Commit 6815c56

Browse files
authored
fix(oso_dagster): hotfix asset loading due to incorrect annotations (#4671)
1 parent a6ed5b3 commit 6815c56

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

warehouse/oso_dagster/factories/common.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import inspect
2-
import logging
32
import typing as t
43
from dataclasses import dataclass, field
54
from graphlib import TopologicalSorter
65

6+
import structlog
77
from dagster import (
88
AssetChecksDefinition,
99
AssetsDefinition,
@@ -24,7 +24,7 @@
2424
type AssetKeyPrefixParam = dginternals.CoercibleToAssetKeyPrefix
2525
type FactoryJobDefinition = JobDefinition | dginternals.UnresolvedAssetJobDefinition
2626

27-
logger = logging.getLogger(__name__)
27+
logger = structlog.get_logger(__name__)
2828

2929

3030
class GenericGCSAsset:
@@ -216,6 +216,12 @@ def run[T](
216216
annotations = f.__annotations__.copy()
217217
annotations.update(additional_annotations)
218218

219+
logger.debug(
220+
f"running function {f.__name__} with annotations",
221+
func_name=f.__name__,
222+
annotations=annotations,
223+
)
224+
219225
resolved_resources: t.Dict[str, t.Any] = {}
220226
if ResourcesContext.resources_keyword_name in annotations:
221227
# If the function has a resources argument, we will pass the
@@ -308,6 +314,12 @@ def name(self) -> str:
308314
"""Get the name of the asset factory."""
309315
return self._f.__name__
310316

317+
@property
318+
def caller_filename(self) -> str:
319+
if self._caller is None:
320+
return "<unknown>"
321+
return self._caller.filename
322+
311323
@property
312324
def module(self) -> str:
313325
"""Get the module of the asset factory."""

warehouse/oso_dagster/factories/dlt.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import functools
21
import logging
32
import typing as t
43
from uuid import uuid4
@@ -90,7 +89,6 @@ def _decorator(
9089
asset_name = name or f.__name__
9190

9291
@early_resources_asset_factory(caller_depth=2)
93-
@functools.wraps(f)
9492
def _factory(
9593
dlt_staging_destination: Destination,
9694
dlt_warehouse_destination: Destination,

warehouse/oso_dagster/factories/loader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def load_all_assets_from_package(
6161

6262
for module_info in pkgutil.walk_packages(package_path, package.__name__ + "."):
6363
module_name = module_info.name
64-
with time_context(logger, f"loading module {module_name}"):
64+
with time_context(
65+
logger, f"loading module {module_name}", module_name=module_name
66+
):
6567
module = importlib.import_module(module_name)
6668
modules.append(module)
6769
factories = load_assets_factories_from_modules(modules, early_resources_dag)
@@ -75,6 +77,7 @@ def load_all_assets_from_package(
7577
with time_context(
7678
logger,
7779
f"generating assets for '{early_factory.name}'",
80+
caller_filename=early_factory.caller_filename,
7881
loading_from_module=early_factory.module,
7982
):
8083
resp = early_factory(resources, dependencies=resolved_deps)

0 commit comments

Comments
 (0)