Skip to content

Commit

Permalink
setting necessary filesystem changes from settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
dhensle committed Oct 1, 2024
1 parent ecb00b5 commit 6a531a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 12 additions & 0 deletions activitysim/core/configuration/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ def _parse_arg(name, x):

return self

def parse_settings(self, settings):
def _parse_setting(name, x):
v = getattr(settings, x, None)
if v is not None:
setattr(self, name, v)

_parse_setting("cache_dir", "cache_dir")
_parse_setting("sharrow_cache_dir", "sharrow_cache_dir")
_parse_setting("profile_dir", "profile_dir")
_parse_setting("pipeline_file_name", "pipeline_file_name")
return

def get_working_subdir(self, subdir) -> Path:
if self.working_dir:
return self.working_dir.joinpath(subdir)
Expand Down
9 changes: 3 additions & 6 deletions activitysim/core/workflow/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,15 +478,12 @@ def load_settings(self) -> State:
include_stack=False,
)

# the settings can redefine the cache directories.
cache_dir = raw_settings.pop("cache_dir", None)
if cache_dir:
if self.filesystem.cache_dir != cache_dir:
logger.warning(f"settings file changes cache_dir to {cache_dir}")
self.filesystem.cache_dir = cache_dir
settings_class = self.__class__.settings.member_type
self.settings: Settings = settings_class.model_validate(raw_settings)

# need to parse any filesystem settings set in the settings file itself
self.filesystem.parse_settings(self.settings)

extra_settings = set(self.settings.__dict__) - set(settings_class.__fields__)

if extra_settings:
Expand Down

0 comments on commit 6a531a7

Please sign in to comment.