Skip to content

Commit

Permalink
Use file handlers for params
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow committed Nov 28, 2024
1 parent 7782751 commit 5389b8e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion data/eda/add_dvc_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import yaml

params = yaml.safe_load(open("params.yaml"))
with open("params.yaml") as file:
params = yaml.safe_load(file)

year = "2024"
states = params["input"]["state"]
Expand Down
3 changes: 2 additions & 1 deletion data/src/calculate_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from utils.constants import DOCKER_INTERNAL_PATH
from utils.utils import format_time, get_md5_hash

params = yaml.safe_load(open(DOCKER_INTERNAL_PATH / "params.yaml"))
with open(DOCKER_INTERNAL_PATH / "params.yaml") as file:
params = yaml.safe_load(file)
os.environ["AWS_PROFILE"] = params["s3"]["profile"]
with open(DOCKER_INTERNAL_PATH / "valhalla.json", "r") as f:
valhalla_data = json.load(f)
Expand Down
3 changes: 2 additions & 1 deletion data/src/create_public_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def create_public_files(
year: Year of the data.
geography: Census geography of the data. See params.yaml for list.
"""
params = yaml.safe_load(open("params.yaml"))
with open("params.yaml") as file:
params = yaml.safe_load(file)
states = params["input"]["state"]
con = create_duckdb_connection()
logger.info("Successfully connected to DuckDB")
Expand Down
3 changes: 2 additions & 1 deletion data/src/create_public_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

logger = create_logger(__name__)

params = yaml.safe_load(open("params.yaml"))
with open("params.yaml") as file:
params = yaml.safe_load(file)
session = boto3.Session(profile_name=params["s3"]["profile"])
s3 = session.client("s3", endpoint_url=params["s3"]["endpoint"])

Expand Down
3 changes: 2 additions & 1 deletion data/src/split_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from utils.constants import DOCKER_INTERNAL_PATH
from utils.utils import split_file_to_str

params = yaml.safe_load(open(DOCKER_INTERNAL_PATH / "params.yaml"))
with open(DOCKER_INTERNAL_PATH / "params.yaml") as file:
params = yaml.safe_load(file)


def split_origin(
Expand Down

0 comments on commit 5389b8e

Please sign in to comment.