cli
#
Utilities for defining CLIs
Modules:
-
femto
–A comprehensive toolkit for predicting free energies
Functions:
-
generate_slurm_cli_options
–A helper function to generate the default set of options to add to a CLI
-
add_options
–Apply a list of options / arguments to a function
-
validate_mutually_exclusive_groups
–Checks whether the user tried to specify options from two mutually exclusive
-
configure_logging
–Set up basic logging for the CLI, silencing any overly verbose modules (e.g.
Attributes:
-
DEFAULT_MAIN_OPTIONS
–The default set of click options to expose on the main command groups.
DEFAULT_MAIN_OPTIONS
module-attribute
#
DEFAULT_MAIN_OPTIONS = [
option(
"-v",
"--verbose",
"log_level",
help="Log debug messages",
flag_value=DEBUG,
),
option(
"-s",
"--silent",
"log_level",
help="Log only warning messages",
flag_value=WARNING,
),
]
The default set of click options to expose on the main command groups.
generate_slurm_cli_options
#
A helper function to generate the default set of options to add to a CLI function that will submit SLURM jobs.
Parameters:
-
job_name
(str | None
) –The default job name to use.
-
required
(bool
, default:False
) –Whether options without defaults should be required or not.
Returns A list of click options.
Source code in femto/fe/utils/cli.py
add_options
#
Apply a list of options / arguments to a function
Source code in femto/fe/utils/cli.py
validate_mutually_exclusive_groups
#
validate_mutually_exclusive_groups(
context: Context,
group_1_titles: list[str] | str,
group_2_titles: list[str] | str,
optional_fields: set[str] | None = None,
) -> tuple[bool, bool]
Checks whether the user tried to specify options from two mutually exclusive sets of option groups.
Parameters:
-
context
(Context
) –The click context.
-
group_1_titles
(list[str] | str
) –The titles of the first groups.
-
group_2_titles
(list[str] | str
) –The titles of the second groups.
-
optional_fields
(set[str] | None
, default:None
) –A set of fields that are optional and do not have default values.
Returns:
-
tuple[bool, bool]
–Whether the user specified options from group 1 and group 2, respectively.
Source code in femto/fe/utils/cli.py
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 321 322 323 324 325 326 327 328 329 |
|
configure_logging
#
Set up basic logging for the CLI, silencing any overly verbose modules (e.g. parmed).
Parameters:
-
log_level
(int | None
) –The log level to use.