From aa188b26c0384b62bca9a18201d3fc569d56e708 Mon Sep 17 00:00:00 2001 From: Julia Sloan Date: Mon, 25 Nov 2024 12:01:16 -0800 Subject: [PATCH] add config_file, job_id defaults --- .buildkite/pipeline.yml | 8 ++++++ config/ci_configs/interactive_debug.yml | 19 ------------- experiments/ClimaEarth/cli_options.jl | 5 ++-- experiments/ClimaEarth/run_amip.jl | 3 +- experiments/ClimaEarth/user_io/arg_parsing.jl | 28 ++++++++----------- 5 files changed, 24 insertions(+), 39 deletions(-) delete mode 100644 config/ci_configs/interactive_debug.yml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 59a4c7c7cd..13f667fc5b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -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" diff --git a/config/ci_configs/interactive_debug.yml b/config/ci_configs/interactive_debug.yml deleted file mode 100644 index 460823a040..0000000000 --- a/config/ci_configs/interactive_debug.yml +++ /dev/null @@ -1,19 +0,0 @@ -apply_limiter: false -coupler_output_dir: "experiments/ClimaEarth/output" -dt: "200secs" -dt_cpl: "200secs" -dt_save_to_sol: "10days" -energy_check: true -evolving_ocean: true -h_elem: 4 -land_albedo_type: "function" -mode_name: "slabplanet" -moist: "equil" -mono_surface: true -precip_model: "0M" -rad: "gray" -start_date: "20100101" -surface_setup: "PrescribedSurface" -t_end: "20days" -turb_flux_partition: "CombinedStateFluxesMOST" -vert_diff: "true" diff --git a/experiments/ClimaEarth/cli_options.jl b/experiments/ClimaEarth/cli_options.jl index a6c329ef18..1c3f0e6647 100644 --- a/experiments/ClimaEarth/cli_options.jl +++ b/experiments/ClimaEarth/cli_options.jl @@ -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" diff --git a/experiments/ClimaEarth/run_amip.jl b/experiments/ClimaEarth/run_amip.jl index 6f43872344..3dd7857eb0 100644 --- a/experiments/ClimaEarth/run_amip.jl +++ b/experiments/ClimaEarth/run_amip.jl @@ -88,7 +88,7 @@ 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) @@ -96,6 +96,7 @@ parse_component_dts!(config_dict) add_extra_diagnostics!(config_dict) (; + job_id, mode_name, random_seed, FT, diff --git a/experiments/ClimaEarth/user_io/arg_parsing.jl b/experiments/ClimaEarth/user_io/arg_parsing.jl index a4d21cb209..09aceabce0 100644 --- a/experiments/ClimaEarth/user_io/arg_parsing.jl +++ b/experiments/ClimaEarth/user_io/arg_parsing.jl @@ -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 """ @@ -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 @@ -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,