File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
warehouse/oso_dagster/factories Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 11import inspect
2- import logging
32import typing as t
43from dataclasses import dataclass , field
54from graphlib import TopologicalSorter
65
6+ import structlog
77from dagster import (
88 AssetChecksDefinition ,
99 AssetsDefinition ,
2424type AssetKeyPrefixParam = dginternals .CoercibleToAssetKeyPrefix
2525type FactoryJobDefinition = JobDefinition | dginternals .UnresolvedAssetJobDefinition
2626
27- logger = logging . getLogger (__name__ )
27+ logger = structlog . get_logger (__name__ )
2828
2929
3030class 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."""
Original file line number Diff line number Diff line change 1- import functools
21import logging
32import typing as t
43from 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 ,
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments