CLI
cli
ROMPY Command Line Interface
This module provides the command-line interface for ROMPY.
Attributes
common_options
module-attribute
common_options = [option('-v', '--verbose', count=True, help='Increase verbosity (can be used multiple times)'), option('--log-dir', envvar='ROMPY_LOG_DIR', help='Directory to save log files'), option('--show-warnings/--hide-warnings', default=False, help='Show Python warnings'), option('--ascii-only/--unicode', default=False, help='Use ASCII-only characters in output', envvar='ROMPY_ASCII_ONLY'), option('--simple-logs/--detailed-logs', default=False, help='Use simple log format without timestamps and module names', envvar='ROMPY_SIMPLE_LOGS'), option('--config-from-env', is_flag=True, help='Load configuration from ROMPY_CONFIG environment variable instead of file')]
Classes
Functions
configure_logging
configure_logging(verbosity: int = 0, log_dir: Optional[str] = None, simple_logs: bool = False, ascii_only: bool = False, show_warnings: bool = False) -> None
Configure logging based on verbosity level and other options.
This function configures the logging system using the LoggingConfig class. It sets up the log level, format, and output destinations based on the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbosity
|
int
|
Level of verbosity (0 = warning, 1 = info, 2+ = debug) |
0
|
log_dir
|
Optional[str]
|
Directory to save log files (optional) |
None
|
simple_logs
|
bool
|
Use simple log format without timestamps and module names |
False
|
ascii_only
|
bool
|
Use ASCII-only characters in output |
False
|
show_warnings
|
bool
|
Show Python warnings |
False
|
Source code in rompy/cli.py
add_common_options
load_config
load_config(config_path: str, from_env: bool = False, env_var: str = 'ROMPY_CONFIG') -> Dict[str, Any]
Load configuration from file, string, or environment variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str
|
Path to config file or raw config string |
required |
from_env
|
bool
|
If True, load from environment variable instead of config_path |
False
|
env_var
|
str
|
Environment variable name to load from when from_env=True |
'ROMPY_CONFIG'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict containing parsed configuration |
Raises:
| Type | Description |
|---|---|
UsageError
|
If config cannot be loaded or parsed |
Source code in rompy/cli.py
print_version
Callback to print version and exit.
Source code in rompy/cli.py
cli
ROMPY (Regional Ocean Modeling PYthon) - Ocean Model Configuration and Execution Tool.
ROMPY provides tools for generating, running, and processing ocean, wave, and hydrodynamic model configurations with support for multiple execution backends.
Source code in rompy/cli.py
run
run(config, backend_config, dry_run, skip_generate, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Run a model configuration using Pydantic backend configuration.
Examples:
Run with local backend configuration
rompy run config.yml --backend-config unified_local_single.yml
Run with Docker backend configuration
rompy run config.yml --backend-config unified_docker_single.yml
Run with config from environment variable
rompy run --config-from-env --backend-config unified_local_single.yml
Use pre-generated workspace (two-step workflow)
rompy generate config.yml rompy run config.yml --backend-config backend.yml --skip-generate
Source code in rompy/cli.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
pipeline
pipeline(config, run_backend, processor, cleanup_on_failure, validate_stages, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Run full model pipeline: generate → run → postprocess.
Source code in rompy/cli.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
generate
generate(config, output_dir, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Generate model input files only.
Source code in rompy/cli.py
postprocess
postprocess(config, processor, output_dir, validate_outputs, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Run postprocessing on model outputs using the specified postprocessor.
Source code in rompy/cli.py
validate
Validate model configuration.
Source code in rompy/cli.py
backends
list_backends
List available backends.
Source code in rompy/cli.py
validate_backend_config
validate_backend_config(config_file, backend_type, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Validate a backend configuration file.
Source code in rompy/cli.py
show_backend_schema
show_backend_schema(backend_type, output_format, examples, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Show JSON schema for backend configurations.
Source code in rompy/cli.py
create_backend_config
create_backend_config(backend_type, output, output_format, with_examples, verbose, log_dir, show_warnings, ascii_only, simple_logs, config_from_env)
Create a template backend configuration file.
Source code in rompy/cli.py
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | |
schema
schema(model_type: str, output: Optional[str] = None, output_format: str = 'json', verbose: int = 0, log_dir: Optional[str] = None, show_warnings: bool = False, ascii_only: bool = False, simple_logs: bool = False, config_from_env: bool = False) -> None
Show JSON schema for a rompy model.
Examples:
Show schema for ModelRun (default)
rompy schema
Show schema for a specific model type
rompy schema "rompy.model.ModelRun" rompy schema "rompy.swan.SWAN"
Save schema to a file
rompy schema --output=model_schema.json rompy schema --output=model_schema.yaml --format=yaml
Source code in rompy/cli.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 | |
legacy_main
Legacy command for backward compatibility (DEPRECATED).
Use 'rompy run' instead for new functionality.
Source code in rompy/cli.py
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 | |