Skip to content

User-defined Output Folder#238

Draft
elenya-grant wants to merge 8 commits intoNatLabRockies:developfrom
elenya-grant:output_dir
Draft

User-defined Output Folder#238
elenya-grant wants to merge 8 commits intoNatLabRockies:developfrom
elenya-grant:output_dir

Conversation

@elenya-grant
Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant commented Mar 23, 2026

User-defined Output Folder

Before, the outputs of a Hercules simulation were written to Path.cwd()/"outputs". This PR introduces the flexibility to define an output folder and output filenames. If one is not input, the default behavior is the same as before. This PR also enables the user to specify more logging options.

This impacts the output .h5 file location and the logger file location. The introduces some new inputs to the Hercules input file:

output_dir: "outputs"
logging:
  logger_name: "hercules"
  log_file: "log_hercules.log"
  console_output: True
  console_prefix: "HERCULES"
  log_level: "INFO"
  use_outputs_dir: True
  outputs_dir: "outputs"

TO-DO

  • add more tests?
  • finish updating PR description
  • update documentation (?)
  • clean-up (removed commented out code, etc)

Requested Feedback from Reviewers/Questions

  1. What are additional test cases that I should add in for the tests?
  2. What documentation should be updated?
  3. Should I update any examples?
  4. I think the function prepare_output_directory should either be called in HerculesModel.__init__() so that it can use the output dir specified in the input dictionary. Thoughts? If so - I think that another user-input parameter in the input dictionary should dictate whether that's called or not, like below:
if h_dict.get("remove_existing_output_dir", False):
   prepare_output_dictory(Path(output_dir))

Or - remove the function all together and put the shutil.rmtree(output_dir) logic in HerculesModel.__init__()

Files that were modified

  • examples/hercules_input_example.yaml
  • hercules/hercules_model.py
    • HerculesModel.__init__()
      • updating logic for initializing the HDF5 output configuration
      • updated logic for getting/specifying output folder
      • updated inputs when calling self._setup_logging()
    • HerculesModel._setup_logging(): updated to take in (optional) other user-specified logger inputs
  • hercules/utilities.py
    • setup_logging()
  • hercules/plant_components/component_base.py
    • ComponentBase.__init__()
      • updated logic for getting/specifying output folder for logger
      • updated inputs when calling self._setup_logging()
    • ComponentBase._setup_logging(): updated to take in (optional) other user-specified logger inputs for the component
  • tests/hercules_model_test.py: updated some strings to Path objects.
    • test_specified_outputs_dir(): new test for user-specified output dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant