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 28, 2024
1 parent 8d6696f commit 86d5031
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,14 +88,15 @@ 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()

# Select the correct timestep for each component model based on which are available
parse_component_dts!(config_dict)
# Add extra diagnostics if specified
add_extra_diagnostics!(config_dict)

(;
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 @@ -6,29 +6,21 @@ A dictionary is constructed from the input configuration file and returned.
# 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 @@ -46,6 +38,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 @@ -94,6 +87,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 86d5031

Please sign in to comment.