Skip to content

Commit

Permalink
Adjust DAGs for handling pathlib objects in XCOMs
Browse files Browse the repository at this point in the history
  • Loading branch information
jermnelson committed May 15, 2024
1 parent 2e34333 commit bc59b08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions libsys_airflow/dags/vendor/data_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@
def setup():
context = get_current_context()
params = context["params"]
params["download_path"] = download_path(
dag_run_download_path = download_path(
params["vendor_uuid"], params["vendor_interface_uuid"]
)
params["environment"] = os.getenv('HONEYBADGER_ENVIRONMENT', 'development')

logger.info(f"Params are {params}")
dag_run_download_path.mkdir(exist_ok=True)

# XCOM cannot serialize pathlib Path object
params["download_path"] = str(dag_run_download_path)

os.makedirs(params["download_path"], exist_ok=True)
logger.info(f"Params are {params}")

return params

Expand Down
4 changes: 3 additions & 1 deletion libsys_airflow/dags/vendor/default_data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def setup():
params["archive_regex"] = processing_options.get("archive_regex")

logger.info(f"Params are {params}")
assert os.path.exists(os.path.join(params["download_path"], params["filename"]))
assert (params["download_path"] / params["filename"]).exists()
# XCOM cannot serialize pathlib Paths
params["download_path"] = str(params["download_path"])

return params

Expand Down

0 comments on commit bc59b08

Please sign in to comment.