Skip to content

Commit 78bad07

Browse files
authored
Merge pull request #344 from CABLE-LSM/342-benchcab-sub-command-for-do_meorg
2 parents b62d5ab + 874ae98 commit 78bad07

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/benchcab/benchcab.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,35 @@ def run(self, config_path: str, skip: list[str]):
453453
self.spatial_setup_work_directory(config_path)
454454
self.fluxsite_submit_job(config_path, skip)
455455
self.spatial_run_tasks(config_path)
456+
457+
def meorg_transfer(self, config_path: str):
458+
"""Endpoint for `benchcab meorg-transfer`"""
459+
460+
# Get a logger, load the config
461+
logger = self._get_logger()
462+
config = self._get_config(config_path)
463+
464+
# Check to ensure the tasks are complete
465+
logger.debug("Checking task completion")
466+
tasks = self._get_fluxsite_tasks(config)
467+
num_tasks, num_complete, num_failed, all_complete = task_summary(tasks)
468+
logger.debug(f"{num_complete}/{num_tasks} completed.")
469+
470+
# Bail out if incomplete
471+
if not all_complete:
472+
logger.error(f"{num_failed} tasks have failed, unable to transfer. Exiting.")
473+
sys.exit(1)
474+
475+
# Check if the output name is set
476+
if config.get("meorg_output_name") is None:
477+
logger.error("meorg_output_name is not defined in config, unable to transfer files.")
478+
sys.exit(1)
479+
480+
# Upload to meorg if meorg_output_name optional key is passed
481+
logger.info("Submitting job for meorg transfer")
482+
bm.do_meorg(
483+
config,
484+
upload_dir=internal.FLUXSITE_DIRS["OUTPUT"],
485+
benchcab_bin=str(self.benchcab_exe_path),
486+
benchcab_job_id=None,
487+
)

src/benchcab/cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,14 @@ def generate_parser(app: Benchcab) -> argparse.ArgumentParser:
257257
add_help=False,
258258
)
259259
parser_codecov.set_defaults(func=app.gen_codecov)
260+
261+
# subcommand: 'benchcab meorg-transfer'
262+
parser_meorg_transfer = subparsers.add_parser(
263+
"meorg-transfer",
264+
parents=[args_help, args_subcommand],
265+
help="Manually transfer model outputs to modelevaluation.org",
266+
add_help=False
267+
)
268+
parser_meorg_transfer.set_defaults(func=app.meorg_transfer)
269+
260270
return main_parser

0 commit comments

Comments
 (0)