Skip to content

Commit

Permalink
add config_file, job_id defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Nov 26, 2024
1 parent 570dbbf commit 1e40048
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 39 deletions.
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ steps:

# AMIP EXPERIMENTS

# Test default behavior with no config file or job ID provided
- label: "AMIP: default"
key: "amip_default"
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl"
artifact_paths: "experiments/ClimaEarth/output/amip_default/artifacts/*"
agents:
slurm_mem: 20GB

- label: "AMIP target: albedo from function"
key: "target_amip_albedo_function"
command: "julia --color=yes --project=experiments/ClimaEarth/ experiments/ClimaEarth/run_amip.jl --config_file $CONFIG_PATH/amip_albedo_function.yml --job_id target_amip_albedo_function"
Expand Down
19 changes: 0 additions & 19 deletions config/ci_configs/interactive_debug.yml

This file was deleted.

5 changes: 3 additions & 2 deletions experiments/ClimaEarth/cli_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ function argparse_settings()
### ClimaCoupler flags
# Simulation-identifying information
"--config_file"
help = "[REQUIRED] A yaml file used to set the configuration of the coupled model"
help = "A yaml file 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"
help = "[REQUIRED] A unique identifier for this run"
help = "A unique identifier for this run, defaults to the config file name"
arg_type = String
default = nothing
"--print_config_dict"
Expand Down
3 changes: 2 additions & 1 deletion experiments/ClimaEarth/run_amip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ We can additionally pass the configuration dictionary to the component model ini

include("cli_options.jl")
include("user_io/arg_parsing.jl")
config_dict, job_id = get_coupler_config()
config_dict = get_coupler_config()
(;
job_id,
mode_name,
random_seed,
FT,
Expand Down
28 changes: 11 additions & 17 deletions experiments/ClimaEarth/user_io/arg_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,21 @@ is returned along with the job ID.
# Returns
- `config_dict`: A dictionary mapping configuration keys to the specified settings
- `job_id`: A unique identifier for the job
"""
function get_coupler_config()
## coupler simulation default configuration
# Read in command line arguments
parsed_args = parse_commandline(argparse_settings())

## modify parsed args for fast testing from REPL #hide
if isinteractive()
parsed_args["config_file"] =
isnothing(parsed_args["config_file"]) ? joinpath(pkg_dir, "config/ci_configs/interactive_debug.yml") :
parsed_args["config_file"]
parsed_args["job_id"] = "interactive_debug"
end

## the unique job id should be passed in via the command line
# Extract the configuration file and job ID
config_file = parsed_args["config_file"]
job_id = parsed_args["job_id"]
@assert !isnothing(job_id) "job_id must be passed in via the command line"

## read in config dictionary from file, overriding the coupler defaults in `parsed_args`
config_dict = YAML.load_file(parsed_args["config_file"])
config_dict = merge(parsed_args, config_dict)
# 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

return config_dict, 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["job_id"] = job_id
return config_dict
end

"""
Expand All @@ -47,6 +39,7 @@ This function may modify the input dictionary to remove unnecessary keys.
function get_coupler_args!(config_dict::Dict)
# Simulation-identifying information; Print `config_dict` if requested
config_dict["print_config_dict"] && @info(config_dict)
job_id = config_dict["job_id"]
mode_name = config_dict["mode_name"]

# Computational simulation setup information
Expand Down Expand Up @@ -108,6 +101,7 @@ function get_coupler_args!(config_dict::Dict)
use_land_diagnostics = config_dict["use_land_diagnostics"]

return (;
job_id,
mode_name,
random_seed,
FT,
Expand Down

0 comments on commit 1e40048

Please sign in to comment.