Specifying Filepaths in H2I#
You can specify filepaths in H2I in several ways. The find_file() method used in H2I searches for files in this order:
With respect to a specified root folder
With respect to the current working directory (cwd)
With respect to the H2Integrate package root. This folder includes subdirectories of
examples,resource_files,docsandh2integrate.As an absolute filepath
Main Input Files#
The main input files to H2Integrate (plant_config, tech_config and driver_config) are defined in a top-level config file. In many examples, these files live in the same folder as the python run script.
The main input files are searched for in H2I in the following order (with examples):
Relative to the folder containing the top-level config file, e.g.:
plant_config: "plant_config.yaml" technology_config: "tech_config.yaml" driver_config: "driver_config.yaml"
Relative to the current working directory (suppose our cwd is
examples/14_wind_hydrogen_dispatch):plant_config: "inputs/plant_config.yaml" technology_config: "inputs/tech_config.yaml" driver_config: "inputs/driver_config.yaml"
Relative to the H2Integrate root directory:
plant_config: "examples/01_onshore_steel_mn/plant_config.yaml" technology_config: "examples/01_onshore_steel_mn/tech_config.yaml" driver_config: "examples/01_onshore_steel_mn/driver_config.yaml"
As an absolute filepath:
plant_config: "/Users/myname/H2Integrate/examples/01_onshore_steel_mn/plant_config.yaml" technology_config: "/Users/myname/H2Integrate/examples/01_onshore_steel_mn/tech_config.yaml" driver_config: "/Users/myname/H2Integrate/examples/01_onshore_steel_mn/driver_config.yaml"
Note: If none of the search methods find a single matching file (search methods find multiple files with matching names or no files with a matching name), H2I will raise an error. A filepath is only returned if exactly one matching file is found for a given search method.
Recommendations#
Change your current working directory to the folder containing your input files. This is how most examples are setup.
cd examples/01_onshore_steel_mn python run_onshore_steel_mn.py
Specify full filepaths instead of relative filepaths.
Use unique filenames if specifying filepaths relative to the H2Integrate package root.
Check the filepaths are correct:
model = H2IntegrateModel(Path.cwd()/"01_onshore_steel_mn.yaml") print(f"Driver config file: {model.driver_config_path}") print(f"Tech config file: {model.tech_config_path}") print(f"Plant config file: {model.plant_config_path}")