Skip to content

Commit

Permalink
Implement parse_last_datajob_run_date method in EntityParser and remo…
Browse files Browse the repository at this point in the history
…ve duplicate method from DatasetParser
  • Loading branch information
murdo-moj committed Dec 30, 2024
1 parent 35c33ed commit cfe5ca9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/datahub-client/data_platform_catalogue/client/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,18 @@ def parse_metadata_last_ingested(self, entity: dict[str, Any]) -> datetime | Non
return None
return timestamp

def parse_last_datajob_run_date(self, response: dict[str, Any]) -> datetime | None:
"""
Look for the last job that produced/consumed the dataset and return the time it ran.
"""
list_of_runs: list = response.get("runs", {}).get("runs", [])
if not list_of_runs:
updated = None
if list_of_runs:
updated = list_of_runs[0].get("created", {}).get("time", {})

return updated


class DatasetParser(EntityParser):
def __init__(self):
Expand Down Expand Up @@ -593,18 +605,6 @@ def parse_to_entity_object(self, response: dict, urn: str) -> Table:
platform=EntityRef(display_name=platform_name, urn=platform_name),
)

def parse_last_datajob_run_date(self, response: dict[str, Any]) -> datetime | None:
"""
Look for the last job that produced/consumed the dataset and return the time it ran.
"""
list_of_runs: list = response.get("runs", {}).get("runs", [])
if not list_of_runs:
updated = None
if list_of_runs:
updated = list_of_runs[0].get("created", {}).get("time", {})

return updated


class TableParser(DatasetParser):
def __init__(self):
Expand Down

0 comments on commit cfe5ca9

Please sign in to comment.