Skip to content

Commit

Permalink
refactor: use fromisoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Nov 15, 2024
1 parent a84af00 commit e6823c4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/teamster/libraries/alchemer/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def _sensor(context: SensorEvaluationContext, alchemer: AlchemerResource):
context.log.info(msg=survey_obj["title"])

survey_id = survey_obj["id"]
modified_on = datetime.strptime(
survey_obj["modified_on"], "%Y-%m-%d HH:mm:ss"
)
modified_on = datetime.fromisoformat(survey_obj["modified_on"])

survey_cursor_timestamp = cursor.get(survey_id)

Expand Down
4 changes: 2 additions & 2 deletions src/teamster/libraries/amplify/dibels/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def build_amplify_dds_report_asset(
def _asset(context: AssetExecutionContext, dds: DibelsDataSystemResource):
partition_key = _check.inst(obj=context.partition_key, ttype=MultiPartitionKey)

date_partition_key = datetime.strptime(
partition_key.keys_by_dimension["date"], "%Y-%m-%d"
date_partition_key = datetime.fromisoformat(
partition_key.keys_by_dimension["date"]
)

if report == "DataFarming":
Expand Down
8 changes: 4 additions & 4 deletions src/teamster/libraries/deanslist/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _asset(context: AssetExecutionContext, deanslist: DeansListResource):
partition_key = _check.inst(obj=context.partition_key, ttype=MultiPartitionKey)

date_partition_def = partitions_def.get_partitions_def_for_dimension("date")
date_partition_key = datetime.strptime(
partition_key.keys_by_dimension["date"], "%Y-%m-%d"
date_partition_key = datetime.fromisoformat(
partition_key.keys_by_dimension["date"]
)

date_partition_key_fy = FiscalYear(datetime=date_partition_key, start_month=7)
Expand Down Expand Up @@ -166,8 +166,8 @@ def build_deanslist_paginated_multi_partition_asset(
def _asset(context: AssetExecutionContext, deanslist: DeansListResource):
partition_key = _check.inst(obj=context.partition_key, ttype=MultiPartitionKey)

date_partition_key = datetime.strptime(
partition_key.keys_by_dimension["date"], "%Y-%m-%d"
date_partition_key = datetime.fromisoformat(
partition_key.keys_by_dimension["date"]
)

date_partition_key_fy = FiscalYear(datetime=date_partition_key, start_month=7)
Expand Down
2 changes: 1 addition & 1 deletion src/teamster/libraries/schoolmint/grow/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _asset(context: AssetExecutionContext, schoolmint_grow: SchoolMintGrowResour
archived_key = partition_key.keys_by_dimension["archived"]
last_modified_key = partition_key.keys_by_dimension["last_modified"]

last_modified_datetime = datetime.strptime(last_modified_key, "%Y-%m-%d")
last_modified_datetime = datetime.fromisoformat(last_modified_key)

last_modified_end = last_modified_datetime.replace(
hour=23, minute=59, second=59, microsecond=999999
Expand Down
2 changes: 1 addition & 1 deletion src/teamster/libraries/titan/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def build_titan_sftp_asset(
current_fiscal_year: FiscalYear,
):
start_fy = FiscalYear(
datetime=datetime.strptime(partition_start_date, "%Y-%m-%d"), start_month=7
datetime=datetime.fromisoformat(partition_start_date), start_month=7
)

partition_keys = [
Expand Down
2 changes: 1 addition & 1 deletion src/teamster/libraries/zendesk/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def build_ticket_metrics_archive(code_location, timezone, avro_schema):
def _asset(context: AssetExecutionContext, zendesk: ZendeskResource):
partition_key = _check.not_none(value=context.partition_key)

partition_key_datetime = datetime.strptime(partition_key, "")
partition_key_datetime = datetime.fromisoformat(partition_key)

data_filepath = pathlib.Path("env/ticket_metrics_archive/data.avro")
schema = parse_schema(schema=avro_schema)
Expand Down

0 comments on commit e6823c4

Please sign in to comment.