Skip to content

Commit

Permalink
Update CLI for writing singlepoint output
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Mar 6, 2024
1 parent ef6bfe1 commit f15446f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions janus_core/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def singlepoint(
metavar="DICT",
),
] = None,
write_results: Annotated[
bool, typer.Option(help="Write out structure with results of calculations")
] = False,
write_kwargs: Annotated[
TyperDict,
typer.Option(
Expand Down Expand Up @@ -125,8 +128,10 @@ def singlepoint(
Keyword arguments to pass to ase.io.read. Default is {}.
calc_kwargs : Optional[dict[str, Any]]
Keyword arguments to pass to the selected calculator. Default is {}.
write_results : bool
True to write out structure with results of calculations. Default is False.
write_kwargs : Optional[dict[str, Any]]
Keyword arguments to pass to ase.io.write to save results. Default is {}.
Keyword arguments to pass to ase.io.write if saving results. Default is {}.
"""
read_kwargs = read_kwargs.value if read_kwargs else {}
calc_kwargs = calc_kwargs.value if calc_kwargs else {}
Expand All @@ -136,6 +141,8 @@ def singlepoint(
raise ValueError("read_kwargs must be a dictionary")
if not isinstance(calc_kwargs, dict):
raise ValueError("calc_kwargs must be a dictionary")
if not isinstance(write_kwargs, dict):
raise ValueError("write_kwargs must be a dictionary")

s_point = SinglePoint(
structure=structure,
Expand All @@ -144,7 +151,13 @@ def singlepoint(
read_kwargs=read_kwargs,
calc_kwargs=calc_kwargs,
)
print(s_point.run_single_point(properties=properties, write_kwargs=write_kwargs))
print(
s_point.run_single_point(
properties=properties,
write_results=write_results,
write_kwargs=write_kwargs,
)
)


@app.command()
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_singlepoint_write_kwargs(tmp_path):
"singlepoint",
"--structure",
DATA_PATH / "NaCl.cif",
"--write-results",
"--write-kwargs",
f"{{'filename': '{str(tmp_path / 'NaCl.xyz')}'}}",
"--property",
Expand Down

0 comments on commit f15446f

Please sign in to comment.