Skip to content

Commit 28b1e2a

Browse files
Group CLI options (#497)
* Group janus commands * Group janus options * Add epilogue for janus CLI * Tidy janus subcommand help * Expand config help text * Group CLI subcommand options * Update MD CLI groupings * Move remove extra MD grouping * Reorder MD help * Tidy CLI help and docstrings
1 parent 07b8103 commit 28b1e2a

File tree

11 files changed

+689
-367
lines changed

11 files changed

+689
-367
lines changed

janus_core/cli/descriptors.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ReadKwargsAll,
1919
StructPath,
2020
Summary,
21+
Tracker,
2122
WriteKwargs,
2223
)
2324
from janus_core.cli.utils import yaml_converter_callback
@@ -26,43 +27,53 @@
2627

2728

2829
@app.command()
29-
@use_config(yaml_converter_callback)
30+
@use_config(yaml_converter_callback, param_help="Path to configuration file.")
3031
def descriptors(
3132
# numpydoc ignore=PR02
3233
ctx: Context,
34+
# Calculation
3335
struct: StructPath,
3436
invariants_only: Annotated[
3537
bool,
36-
Option(help="Only calculate invariant descriptors."),
38+
Option(
39+
help="Only calculate invariant descriptors.", rich_help_panel="Calculation"
40+
),
3741
] = True,
3842
calc_per_element: Annotated[
3943
bool,
40-
Option(help="Calculate mean descriptors for each element."),
44+
Option(
45+
help="Calculate mean descriptors for each element.",
46+
rich_help_panel="Calculation",
47+
),
4148
] = False,
4249
calc_per_atom: Annotated[
4350
bool,
44-
Option(help="Calculate descriptors for each atom."),
51+
Option(
52+
help="Calculate descriptors for each atom.", rich_help_panel="Calculation"
53+
),
4554
] = False,
46-
arch: Architecture = "mace_mp",
47-
device: Device = "cpu",
48-
model_path: ModelPath = None,
49-
file_prefix: FilePrefix = None,
5055
out: Annotated[
5156
Path | None,
5257
Option(
5358
help=(
5459
"Path to save structure with calculated descriptors. Default is "
5560
"inferred from name of structure file."
5661
),
62+
rich_help_panel="Calculation",
5763
),
5864
] = None,
59-
read_kwargs: ReadKwargsAll = None,
65+
# MLIP Calculator
66+
arch: Architecture = "mace_mp",
67+
device: Device = "cpu",
68+
model_path: ModelPath = None,
6069
calc_kwargs: CalcKwargs = None,
70+
# Structure I/O
71+
file_prefix: FilePrefix = None,
72+
read_kwargs: ReadKwargsAll = None,
6173
write_kwargs: WriteKwargs = None,
74+
# Logging/summary
6275
log: LogPath = None,
63-
tracker: Annotated[
64-
bool, Option(help="Whether to save carbon emissions of calculation")
65-
] = True,
76+
tracker: Tracker = True,
6677
summary: Summary = None,
6778
) -> None:
6879
"""
@@ -80,24 +91,24 @@ def descriptors(
8091
Whether to calculate mean descriptors for each element. Default is False.
8192
calc_per_atom
8293
Whether to calculate descriptors for each atom. Default is False.
94+
out
95+
Path to save structure with calculated results. Default is inferred
96+
`file_prefix`.
8397
arch
8498
MLIP architecture to use for calculations. Default is "mace_mp".
8599
device
86100
Device to run model on. Default is "cpu".
87101
model_path
88102
Path to MLIP model. Default is `None`.
103+
calc_kwargs
104+
Keyword arguments to pass to the selected calculator. Default is {}.
89105
file_prefix
90106
Prefix for output files, including directories. Default directory is
91107
./janus_results, and default filename prefix is inferred from the input
92108
stucture filename.
93-
out
94-
Path to save structure with calculated results. Default is inferred
95-
`file_prefix`.
96109
read_kwargs
97110
Keyword arguments to pass to ase.io.read. By default,
98111
read_kwargs["index"] is ":".
99-
calc_kwargs
100-
Keyword arguments to pass to the selected calculator. Default is {}.
101112
write_kwargs
102113
Keyword arguments to pass to ase.io.write when saving results. Default is {}.
103114
log

janus_core/cli/eos.py

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ReadKwargsLast,
2020
StructPath,
2121
Summary,
22+
Tracker,
2223
WriteKwargs,
2324
)
2425
from janus_core.cli.utils import yaml_converter_callback
@@ -28,51 +29,79 @@
2829

2930

3031
@app.command()
31-
@use_config(yaml_converter_callback)
32+
@use_config(yaml_converter_callback, param_help="Path to configuration file.")
3233
def eos(
3334
# numpydoc ignore=PR02
3435
ctx: Context,
36+
# Calculation
3537
struct: StructPath,
36-
min_volume: Annotated[float, Option(help="Minimum volume scale factor.")] = 0.95,
37-
max_volume: Annotated[float, Option(help="Maximum volume scale factor.")] = 1.05,
38-
n_volumes: Annotated[int, Option(help="Number of volumes.")] = 7,
38+
min_volume: Annotated[
39+
float,
40+
Option(help="Minimum volume scale factor.", rich_help_panel="Calculation"),
41+
] = 0.95,
42+
max_volume: Annotated[
43+
float,
44+
Option(help="Maximum volume scale factor.", rich_help_panel="Calculation"),
45+
] = 1.05,
46+
n_volumes: Annotated[
47+
int, Option(help="Number of volumes.", rich_help_panel="Calculation")
48+
] = 7,
3949
eos_type: Annotated[
4050
str,
4151
Option(
4252
click_type=Choice(get_args(EoSNames)),
4353
help="Type of fit for equation of state.",
54+
rich_help_panel="Calculation",
4455
),
4556
] = "birchmurnaghan",
4657
minimize: Annotated[
47-
bool, Option(help="Whether to minimize initial structure before calculations.")
58+
bool,
59+
Option(
60+
help="Whether to minimize initial structure before calculations.",
61+
rich_help_panel="Calculation",
62+
),
4863
] = True,
4964
minimize_all: Annotated[
5065
bool,
51-
Option(help="Whether to minimize all generated structures for calculations."),
66+
Option(
67+
help="Whether to minimize all generated structures for calculations.",
68+
rich_help_panel="Calculation",
69+
),
5270
] = False,
5371
fmax: Annotated[
54-
float, Option(help="Maximum force for optimization convergence.")
72+
float,
73+
Option(
74+
help="Maximum force for optimization convergence.",
75+
rich_help_panel="Calculation",
76+
),
5577
] = 0.1,
5678
minimize_kwargs: MinimizeKwargs = None,
5779
write_structures: Annotated[
5880
bool,
59-
Option(help="Whether to write out all genereated structures."),
81+
Option(
82+
help="Whether to write out all genereated structures.",
83+
rich_help_panel="Calculation",
84+
),
6085
] = False,
61-
write_kwargs: WriteKwargs = None,
6286
plot_to_file: Annotated[
6387
bool,
64-
Option(help="Whether to plot equation of state."),
88+
Option(
89+
help="Whether to plot equation of state.",
90+
rich_help_panel="Calculation",
91+
),
6592
] = False,
93+
# MLIP Calculator
6694
arch: Architecture = "mace_mp",
6795
device: Device = "cpu",
6896
model_path: ModelPath = None,
69-
read_kwargs: ReadKwargsLast = None,
7097
calc_kwargs: CalcKwargs = None,
98+
# Structure I/O
7199
file_prefix: FilePrefix = None,
100+
read_kwargs: ReadKwargsLast = None,
101+
write_kwargs: WriteKwargs = None,
102+
# Logging/summary
72103
log: LogPath = None,
73-
tracker: Annotated[
74-
bool, Option(help="Whether to save carbon emissions of calculation")
75-
] = True,
104+
tracker: Tracker = True,
76105
summary: Summary = None,
77106
) -> None:
78107
"""
@@ -103,27 +132,26 @@ def eos(
103132
Other keyword arguments to pass to geometry optimizer. Default is {}.
104133
write_structures
105134
True to write out all genereated structures. Default is False.
106-
write_kwargs
107-
Keyword arguments to pass to ase.io.write to save generated structures.
108-
Default is {}.
109135
plot_to_file
110136
Whether to save plot equation of state to svg. Default is False.
111137
arch
112-
MLIP architecture to use for geometry optimization.
113-
Default is "mace_mp".
138+
MLIP architecture to use for geometry optimization. Default is "mace_mp".
114139
device
115140
Device to run model on. Default is "cpu".
116141
model_path
117142
Path to MLIP model. Default is `None`.
118-
read_kwargs
119-
Keyword arguments to pass to ase.io.read. By default,
120-
read_kwargs["index"] is -1.
121143
calc_kwargs
122144
Keyword arguments to pass to the selected calculator. Default is {}.
123145
file_prefix
124146
Prefix for output files, including directories. Default directory is
125147
./janus_results, and default filename prefix is inferred from the input
126148
stucture filename.
149+
read_kwargs
150+
Keyword arguments to pass to ase.io.read. By default,
151+
read_kwargs["index"] is -1.
152+
write_kwargs
153+
Keyword arguments to pass to ase.io.write to save generated structures.
154+
Default is {}.
127155
log
128156
Path to write logs to. Default is inferred from `file_prefix`.
129157
tracker

0 commit comments

Comments
 (0)