Skip to content

Commit

Permalink
Config changes (#476)
Browse files Browse the repository at this point in the history
* database path updates

* Update config getters to return Paths where needed

* Update lint.yml

* Update lint.yml

---------

Co-authored-by: GundulaW <gundulawinter@gmail.com>
  • Loading branch information
LuukBlom and GundulaW authored Jul 2, 2024
1 parent c57f80b commit 8ac79a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
pip install ruff
pip install ruff==0.4.8 # Make sure these are the same as the versions in pyproject.toml
# Include `--format=github` to enable automatic inline annotations.
- name: Run Ruff
run: ruff check . --fix
Expand All @@ -25,7 +25,7 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
pip install black
pip install black==24.1.1 # Make sure these are the same as the versions in pyproject.toml
- name: Check black version
run: black --version
- name: Run black
Expand Down
13 changes: 3 additions & 10 deletions flood_adapt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ def get_database_root() -> Union[Path, None]:
The path to the root of the database if the DATABASE_ROOT environment variable is set,
None otherwise.
"""
try:
if os.environ.get("DATABASE_ROOT", None):
return Path(os.environ["DATABASE_ROOT"])
except KeyError:
return None


def get_system_folder() -> Union[Path, None]:
Expand All @@ -138,10 +136,8 @@ def get_system_folder() -> Union[Path, None]:
Path or None
The system folder path if the SYSTEM_FOLDER environment variable is set, otherwise None.
"""
try:
if os.environ.get("SYSTEM_FOLDER", None):
return Path(os.environ["SYSTEM_FOLDER"])
except KeyError:
return None


def get_database_name() -> Union[str, None]:
Expand All @@ -153,10 +149,7 @@ def get_database_name() -> Union[str, None]:
str or None
The database name if the DATABASE_NAME environment variable is set, otherwise None.
"""
try:
return Path(os.environ["DATABASE_NAME"])
except KeyError:
return None
return os.environ.get("DATABASE_NAME", None)


def parse_config(config_path: Path, overwrite: bool = True) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion flood_adapt/dbs_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
self.database_name = database_name

# Set the paths
self.base_path = Path(database_path / database_name)
self.base_path = Path(database_path) / database_name
self.input_path = self.base_path / "input"
self.static_path = self.base_path / "static"
self.output_path = self.base_path / "output"
Expand Down

0 comments on commit 8ac79a2

Please sign in to comment.