Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret config file/args as relative to pkg_dir #1133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions experiments/ClimaEarth/cli_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function argparse_settings()
### ClimaCoupler flags
# Simulation-identifying information
"--config_file"
help = "A yaml file used to set the configuration of the coupled model [\"config/ci_configs/amip_default.yml\" (default)]"
help = "A yaml file, relative to ClimaCoupler.jl, used to set the configuration of the\
coupled model [\"config/ci_configs/amip_default.yml\" (default)]"
arg_type = String
default = "config/ci_configs/amip_default.yml"
"--job_id"
Expand Down Expand Up @@ -84,7 +85,7 @@ function argparse_settings()
default = 480
# Restart information
"--restart_dir"
help = "Directory containing restart files"
help = "Directory containing restart files, relative to ClimaCoupler.jl [nothing (default)]"
arg_type = String
default = nothing
"--restart_t"
Expand Down Expand Up @@ -120,7 +121,8 @@ function argparse_settings()
default = false
# Output information
"--coupler_output_dir"
help = "Directory to save output files. Note that TempestRemap fails if interactive and paths are too long. [\"experiments/ClimaEarth/output\" (default)]"
help = "Directory to save output files, relative to ClimaCoupler.jl. Note that TempestRemap\
fails if interactive and paths are too long. [\"experiments/ClimaEarth/output\" (default)]"
arg_type = String
default = "experiments/ClimaEarth/output"
"--plot_diagnostics"
Expand Down
2 changes: 1 addition & 1 deletion experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ postprocessing and the conservation checks) of the simulation will be saved,
#and `dir_paths.checkpoints`, where restart files are saved.
=#

COUPLER_OUTPUT_DIR = joinpath(output_dir_root, job_id)
COUPLER_OUTPUT_DIR = joinpath(pkg_dir, output_dir_root, job_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should not be relative to pkg_dir. pkg_dir could be inside the .julia in the user's home directory. This is a hidden folder, with possibly storage quotas. It is not a great place where to save files.

dir_paths = Utilities.setup_output_dirs(output_dir = COUPLER_OUTPUT_DIR, comms_ctx = comms_ctx)
@info "Coupler output directory $(dir_paths.output)"
@info "Coupler artifacts directory $(dir_paths.artifacts)"
Expand Down
8 changes: 4 additions & 4 deletions experiments/ClimaEarth/user_io/arg_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function get_coupler_config()
parsed_args = parse_commandline(argparse_settings())

# Extract the configuration file and job ID
config_file = parsed_args["config_file"]
config_file = joinpath(pkg_dir, parsed_args["config_file"])
job_id = parsed_args["job_id"]
# Get the job ID from the config file string if not provided
job_id = isnothing(job_id) ? string(split(split(config_file, '/')[end], '.')[1]) : job_id

# Read in config dictionary from file, overriding the defaults in `parsed_args`
config_dict = merge(parsed_args, YAML.load_file(parsed_args["config_file"]))
config_dict = merge(parsed_args, YAML.load_file(config_file))
config_dict["job_id"] = job_id
return config_dict
end
Expand Down Expand Up @@ -70,7 +70,7 @@ function get_coupler_args(config_dict::Dict)
hourly_checkpoint_dt = config_dict["hourly_checkpoint_dt"]

# Restart information
restart_dir = config_dict["restart_dir"]
restart_dir = isnothing(config_dict["restart_dir"]) ? nothing : joinpath(pkg_dir, config_dict["restart_dir"])
restart_t = Int(config_dict["restart_t"])

# Diagnostics information
Expand All @@ -88,7 +88,7 @@ function get_coupler_args(config_dict::Dict)
conservation_softfail = config_dict["conservation_softfail"]

# Output information
output_dir_root = config_dict["coupler_output_dir"]
output_dir_root = joinpath(pkg_dir, config_dict["coupler_output_dir"])
plot_diagnostics = config_dict["plot_diagnostics"]

# ClimaLand-specific information
Expand Down
Loading