Skip to content

Commit

Permalink
style: rename timing function to something meaningful
Browse files Browse the repository at this point in the history
fix: `setLevel` for root logger rather than unassigned/unused `__name__` logger
  • Loading branch information
tom-webber authored and MatMoore committed Aug 6, 2024
1 parent 212fedd commit 4eda154
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions ingestion/create_cadet_databases_source/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
get_cadet_manifest,
validate_fqn,
)
from ingestion.utils import st_time
from ingestion.utils import report_time

logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)


@config_class(CreateCadetDatabasesConfig)
class CreateCadetDatabases(Source):
source_config: CreateCadetDatabasesConfig
report: SourceReport = SourceReport()

@st_time
@report_time
def __init__(self, config: CreateCadetDatabasesConfig, ctx: PipelineContext):
super().__init__(ctx)
self.source_config = config
Expand Down Expand Up @@ -94,7 +94,7 @@ def _get_domains(self, manifest) -> set[str]:
if manifest["nodes"][node]["resource_type"] == "model"
)

@st_time
@report_time
def _get_databases_with_domains_and_display_tags(
self, manifest
) -> tuple[set[tuple[str, str]], dict]:
Expand Down
2 changes: 1 addition & 1 deletion ingestion/ingestion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ingestion.config import ENV, INSTANCE, PLATFORM

logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)


def get_cadet_manifest(manifest_s3_uri: str) -> Dict:
Expand Down
6 changes: 3 additions & 3 deletions ingestion/justice_data_source/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
)

from ingestion.ingestion_utils import list_datahub_domains
from ingestion.utils import st_time
from ingestion.utils import report_time

from .api_client import JusticeDataAPIClient
from .config import JusticeDataAPIConfig
Expand Down Expand Up @@ -73,7 +73,7 @@ def create(cls, config_dict, ctx):
config = JusticeDataAPIConfig.parse_obj(config_dict)
return cls(ctx, config)

@st_time
@report_time
def get_workunits_internal(self) -> Iterable[MetadataWorkUnit]:
all_chart_data = self.client.list_all(self.config.exclude_id_list)

Expand Down Expand Up @@ -137,7 +137,7 @@ def _make_dashboard(self, chart_urns):
dashboard_mce = MetadataChangeEvent(proposedSnapshot=dashboard_snapshot)
return dashboard_mce

@st_time
@report_time
def _make_chart(self, chart_data) -> MetadataChangeEvent:
chart_urn = builder.make_chart_urn(self.platform_name, chart_data["id"])
chart_snapshot = ChartSnapshot(
Expand Down
2 changes: 1 addition & 1 deletion ingestion/taggers/display_in_catalogue_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datahub.metadata.schema_classes import TagAssociationClass

logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)


def add_display_in_catalogue_tag(entity_urn: str) -> List[TagAssociationClass]:
Expand Down
6 changes: 3 additions & 3 deletions ingestion/transformers/assign_cadet_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
parse_database_and_table_names,
validate_fqn,
)
from ingestion.utils import st_time
from ingestion.utils import report_time

logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)


class AssignCadetDatabasesConfig(ConfigModel):
Expand Down Expand Up @@ -53,7 +53,7 @@ def transform_aspect(
) -> Optional[Aspect]:
return None

@st_time
@report_time
def handle_end_of_stream(
self,
) -> List[Union[MetadataChangeProposalWrapper, MetadataChangeProposalClass]]:
Expand Down
4 changes: 2 additions & 2 deletions ingestion/transformers/assign_cadet_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
get_cadet_manifest,
validate_fqn,
)
from ingestion.utils import st_time
from ingestion.utils import report_time


class PatternDatasetDomainSemanticsConfig(TransformerSemanticsConfigModel):
Expand Down Expand Up @@ -63,7 +63,7 @@ def create(cls, config_dict, ctx: PipelineContext) -> "AssignCadetDomains":
)
return cls(config_dict, ctx)

@st_time
@report_time
def _get_domain_mapping(self, manifest) -> PatternDatasetDomainSemanticsConfig:
"""Map regex patterns for tables to domains"""
nodes = manifest.get("nodes")
Expand Down
4 changes: 2 additions & 2 deletions ingestion/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from datetime import timedelta

logging.basicConfig()
logging.getLogger(__name__).setLevel(logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)


def st_time(func):
def report_time(func):
"""
st decorator to calculate the total time of a func
"""
Expand Down

0 comments on commit 4eda154

Please sign in to comment.