Skip to content

Commit 5eaf6ce

Browse files
committed
refactor(iceberg): add cache for is_profiling_enabled
1 parent 80eb46e commit 5eaf6ce

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

metadata-ingestion/src/datahub/ingestion/source/iceberg/iceberg_common.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pydantic import Field, validator
77
from pyiceberg.catalog import Catalog, load_catalog
88
from sortedcontainers import SortedList
9-
9+
from functools import lru_cache
1010
from datahub.configuration.common import AllowDenyPattern, ConfigModel
1111
from datahub.configuration.source_common import DatasetSourceConfigMixin
1212
from datahub.ingestion.source.state.stale_entity_removal_handler import (
@@ -85,10 +85,6 @@ class IcebergSourceConfig(StatefulIngestionConfigBase, DatasetSourceConfigMixin)
8585
processing_threads: int = Field(
8686
default=1, description="How many threads will be processing tables"
8787
)
88-
def __init__(self):
89-
self.profiling_enabled = self.profiling.enabled and is_profiling_enabled(
90-
self.profiling.operation_config
91-
)
9288

9389
@validator("catalog", pre=True, always=True)
9490
def handle_deprecated_catalog_format(cls, value):
@@ -128,9 +124,12 @@ def validate_catalog_size(cls, value):
128124
)
129125

130126
return value
131-
127+
128+
@lru_cache()
132129
def is_profiling_enabled(self) -> bool:
133-
return self.profiling_enabled
130+
return self.profiling.enabled and is_profiling_enabled(
131+
self.profiling.operation_config
132+
)
134133

135134
def get_catalog(self) -> Catalog:
136135
"""Returns the Iceberg catalog instance as configured by the `catalog` dictionary.

0 commit comments

Comments
 (0)