Skip to content

Commit

Permalink
Remove config.get, use in line if/else for "rebuild_manifest". (#176)
Browse files Browse the repository at this point in the history
* Remove config.get, use in line if/else for "rebuild_manifest".

* Fix a linting error.

* One more linting error.
  • Loading branch information
drewoldag authored Jan 22, 2025
1 parent e3c94af commit 839cf98
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/fibad/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def create_results_dir(config: ConfigDict, postfix: str) -> Path:
directory.mkdir(parents=True, exist_ok=False)
return directory


def find_most_recent_results_dir(config: ConfigDict, verb: str) -> Optional[Path]:
"""Find the most recent results directory corresponding to a particular verb
This is a best effort search in the currently configured results root.
Expand Down Expand Up @@ -351,8 +352,8 @@ def find_most_recent_results_dir(config: ConfigDict, verb: str) -> Optional[Path

return best_path

def log_runtime_config(runtime_config: ConfigDict, output_path: Path, file_name: str = "runtime_config.toml"):

def log_runtime_config(runtime_config: ConfigDict, output_path: Path, file_name: str = "runtime_config.toml"):
"""Log a runtime configuration.
Parameters
Expand Down
8 changes: 5 additions & 3 deletions src/fibad/data_sets/hsc_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,13 @@ def __init__(self, config):
else:
transform = None

# Note "rebuild_manifest" is not a config, its a hack for rebuild_manifest mode
# to ensure we don't use the manifest we believe is corrupt.
rebuild_manifest = config["rebuild_manifest"] if "rebuild_manifest" in config else False # noqa: SIM401

if config["data_set"]["filter_catalog"]:
filter_catalog = Path(config["data_set"]["filter_catalog"])
elif not config.get("rebuild_manifest", False):
# Note "rebuild_manifest" is not a config, its a hack for rebuild_manifest mode
# to ensure we don't use the manifest we believe is corrupt.
elif not rebuild_manifest:
filter_catalog = Path(config["general"]["data_dir"]) / Downloader.MANIFEST_FILE_NAME
if not filter_catalog.exists():
filter_catalog = False
Expand Down
1 change: 0 additions & 1 deletion tests/fibad/test_config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os

import pytest

from fibad.config_utils import ConfigDict, ConfigManager


Expand Down

0 comments on commit 839cf98

Please sign in to comment.