Skip to content

Commit

Permalink
Fixed metadata sheet processing year input data type
Browse files Browse the repository at this point in the history
* Standardise year to string value internally
  • Loading branch information
victorskl committed Sep 13, 2024
1 parent 0530e02 commit c4063fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def handler(event, context):
logger.info("Start processing update from google tracking sheet")
logger.info(f'event: {libjson.dumps(event)}')

year = event.get('year', datetime.date.today().year)
year: str = str(event.get('year', datetime.date.today().year))
if isinstance(year, list):
raise ValueError("Year cannot be an array")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,16 @@ def persist_lab_metadata(df: pd.DataFrame, sheet_year: str):
}


def download_tracking_sheet(year: int) -> pd.DataFrame:
def download_tracking_sheet(year: str) -> pd.DataFrame:
"""
Download the full original metadata from Google tracking sheet
"""
sheet_id = libssm.get_secret(SSM_NAME_TRACKING_SHEET_ID)
account_info = libssm.get_secret(SSM_NAME_GDRIVE_ACCOUNT)

frames = []
year_str = str(year)
logger.info(f"Downloading {year_str} sheet")
sheet_df = libgdrive.download_sheet(account_info, sheet_id, year_str)
logger.info(f"Downloading {year} sheet")
sheet_df = libgdrive.download_sheet(account_info, sheet_id, year)
sheet_df = sanitize_lab_metadata_df(sheet_df)

frames.append(sheet_df)
Expand Down

0 comments on commit c4063fb

Please sign in to comment.