Skip to content

Commit 034ab1b

Browse files
committed
pdate tutorial steps 8-10 to the redesigned httk-workflow CLI and templates
1 parent 0f49404 commit 034ab1b

4 files changed

Lines changed: 93 additions & 70 deletions

File tree

docs/tutorial/08-prepare-vasp.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
# Prepare a VASP calculation
22

3-
```{admonition} Status
4-
:class: caution
3+
In v1 this was a Python call (`prepare_single_run`) followed by running
4+
`vasp` by hand. In v2 the packaged VASP runners do both halves: preparation
5+
derives every input you do not supply, and the workflow manager runs the
6+
calculation.
57

6-
V2 has dependency-free VASP work-directory preparation, but not yet the v1
7-
one-call path from `UnitcellStructure` to a complete run directory. In particular,
8-
*httk-io* reads POSCAR but does not write it. Supply `Run/POSCAR` and
9-
`Run/INCAR`, then prepare the remaining inputs explicitly.
8+
```console
9+
httk project init --name tutorial
10+
httk workflow job new --template vasp-static --from POSCAR --tag example
11+
httk workflow workspace settings set vasp.command vasp_std
12+
httk workflow workspace settings set vasp.pseudo_library /path/to/potpaw_PBE
13+
httk workflow run
1014
```
1115

12-
```python
13-
from httk.workflow.vasp import VaspPreparationOptions, prepare_vasp_inputs
16+
`job new` scaffolds and submits one job from the packaged `vasp-static`
17+
template (`vasp-relax` and `vasp-relax-static` work the same way), staging the
18+
structure as the `files/POSCAR` the runner reads. No INCAR, KPOINTS, or POTCAR
19+
needs to be written: the runner's `prepare` step derives the k-point grid,
20+
assembles the POTCAR from the pseudopotential library, and fills in `MAGMOM`
21+
and `NBANDS`, with any explicit `--input incar_tags=...` winning over derived
22+
values. `run` executes the manager until nothing is ready, driving the job
23+
through prepare, run, and collect; the results and logs end up in the payload
24+
directory the `job new` command printed.
1425

15-
choices = prepare_vasp_inputs(
16-
VaspPreparationOptions(
17-
pseudopotential_library="/path/to/potpaw_PBE",
18-
kpoint_density=40,
19-
),
20-
directory="Run",
21-
)
22-
print(choices)
23-
```
26+
Both `vasp.*` settings are stored on the workspace, so they are set once, not
27+
per job; a real `HTTK_VASP_COMMAND` environment variable remains a deployment
28+
override and wins over the workspace setting.
2429

25-
This normalizes POSCAR handedness, assembles POTCAR, writes KPOINTS, and updates
26-
INCAR with recorded choices. Execution is separately available through
27-
`run_vasp` or the native workflow runner API.
30+
```{admonition} Status
31+
:class: caution
32+
33+
The starting structure must already be a VASP structure file: *httk-io* reads
34+
POSCAR but does not yet write it, so there is no route yet from a loaded
35+
`UnitcellStructure` (steps 1–7) to a POSCAR on disk.
36+
```
2837

29-
See the workflow runner helpers in the versioned *httk-workflow* documentation
30-
listed by the {doc}`module directory <../modules>`.
38+
See the quickstart and the packaged VASP runner guide in the versioned
39+
*httk-workflow* documentation listed by the {doc}`module directory <../modules>`.

docs/tutorial/09-create-batch.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
# Generate a batch of jobs
22

3-
V2 replaces implicit task directories with explicit immutable job payloads.
4-
This small example creates and submits one payload per name:
3+
Point `job new` at a *directory* and every `POSCAR*` or `*.vasp` file in it
4+
becomes one job, each tagged after its file. The runner is published once for
5+
the whole set:
6+
7+
```console
8+
httk workflow job new --template vasp-relax --from structures/ \
9+
--input kpoint_density=30.0 --placement batch
10+
```
11+
12+
In Python the same thing streams, which is how a batch of any size is built —
13+
neither side of the loop is ever materialized, and each job costs one payload
14+
directory and one state marker:
515

616
```python
717
from pathlib import Path
818

9-
from httk.workflow import Workspace
10-
from httk.workflow.runtime_builders import JobSpec, prepare_job_payload
11-
12-
workspace = Workspace.initialize("Runs")
13-
14-
for name in ("CaTiO3", "TiO2", "CaO"):
15-
payload = Path("payloads") / name
16-
payload.mkdir(parents=True)
17-
runner = payload / "run.sh"
18-
runner.write_text("#!/bin/sh\nexec vasp_std\n", encoding="utf-8")
19-
runner.chmod(0o755)
20-
21-
prepare_job_payload(
22-
payload,
23-
JobSpec(
24-
name=name,
25-
workflow="presentation.vasp-static",
26-
runner_path="run.sh",
27-
claim_pool="vasp",
28-
),
29-
)
30-
workspace.submit(payload, f"batch/{name}")
19+
from httk.workflow import Workspace, new_jobs
20+
from httk.workflow.registry import default_workspace
21+
from httk.workflow.scaffold import structure_tag
22+
23+
workspace = Workspace(default_workspace().path)
24+
items = (
25+
{"files": {"POSCAR": path}, "tag": structure_tag(path)}
26+
for path in sorted(Path("structures").glob("POSCAR.*"))
27+
)
28+
for job in new_jobs(workspace, "vasp-relax", items, inputs={"kpoint_density": 30.0}):
29+
print(job.job_key)
30+
```
31+
32+
```{admonition} Status
33+
:class: caution
34+
35+
v1 fed a database search directly into batch creation
36+
(`create_batch_task(..., {"structure": struct})`). The v2 equivalent —
37+
streaming the structures found in step 7 into `new_jobs` — waits on the
38+
POSCAR writer noted in step 8; today the batch starts from structure files
39+
on disk.
3140
```
3241

33-
A real payload also carries immutable POSCAR, INCAR, and other inputs. The
34-
runner should publish a structured success, failure, retry, or next-step
35-
outcome; see the *httk-workflow* native APIs in the versioned documentation
36-
listed by the {doc}`module directory <../modules>`.
42+
See the quickstart and the workflow CLI guide in the versioned *httk-workflow*
43+
documentation listed by the {doc}`module directory <../modules>`.

docs/tutorial/10-run-remotely.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
# Send and run a batch remotely
22

3-
Remote setup and transfer remain command-line operations, now under the
4-
`httk workflow` command tree. The maintained adapters are explicit,
5-
versioned bundles.
3+
A *remote* is one machine the project can reach, named like a `git remote`; a
4+
workspace on it is addressed `REMOTE:NAME`. Setting up a cluster is a one-time
5+
sequence:
66

77
```console
8-
httk workflow project init . --name tutorial --default-queue default
9-
httk workflow remote add kappa --template ssh-slurm --non-interactive
10-
httk workflow remote configure kappa:default \
11-
--set workspace=/remote/path/to/Runs
12-
httk workflow remote install kappa:default
8+
httk workflow remote add kappa --template ssh-slurm
9+
httk workflow remote configure kappa \
10+
--set host=kappa.example.org --set username=rar \
11+
--set workspace_root=/scratch/rar/httk
12+
httk workflow remote install kappa
13+
httk workflow workspace init kappa:runs
14+
httk workflow workspace settings set kappa:runs vasp.command "srun -n 32 vasp_std"
15+
```
16+
17+
After that, each batch is send, run, watch — and one command to bring the
18+
finished jobs home:
1319

14-
httk workflow workspace init local-runs --remote local --path Runs \
15-
--extension detached-transfer-v1
16-
httk workflow workspace init kappa-runs --remote kappa:default \
17-
--path /remote/path/to/Runs --extension detached-transfer-v1
18-
httk workflow transfer local-runs kappa-runs --job JOB_UUID
19-
httk workflow manager run kappa-runs --workers 8
20-
httk workflow workspace status kappa-runs
20+
```console
21+
httk workflow transfer default kappa:runs --placement batch
22+
httk workflow run kappa:runs --workers 8
23+
httk workflow workspace status kappa:runs
24+
httk workflow transfer kappa:runs default
2125
```
2226

23-
Both named workspaces must already exist with the `detached-transfer-v1`
24-
extension. Transfers preserve the job UUID, seal and validate payload digests,
25-
and retire the source only after acknowledgement.
27+
`transfer` detaches the selected jobs from the local default workspace, pushes
28+
each sealed bundle, validates its digest, and retires the source only after
29+
acknowledgement, so a job never exists in two runnable places. `run` on a
30+
remote workspace submits managers through the remote's scheduler over its
31+
adapter. The reverse `transfer` pulls home whatever has finished; a local
32+
`httk workflow harvest` then reads the results (next step).
2633

27-
See the project and workflow CLI guide in the versioned *httk-workflow*
34+
See the task manager and workflow CLI guides in the versioned *httk-workflow*
2835
documentation listed by the {doc}`module directory <../modules>`.

docs/tutorial/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ python -m pip install httk2 "httk-data[db]" ase
3131
| 6 | Store structure data in SQLite | Available through representation-specific Records | `httk-data` |
3232
| 7 | Search the local database | Available | `httk-data` |
3333
| 8 | Prepare a VASP calculation | Partial: workdir preparation, no structure writer | `httk-workflow` |
34-
| 9 | Generate a batch | Available as explicit job payloads | `httk-workflow` |
34+
| 9 | Generate a batch | Available through job templates; database-fed batches need the POSCAR writer | `httk-workflow` |
3535
| 10 | Send and run remotely | Available through remote adapters | `httk-workflow` |
3636
| 11 | Read results into the database | Available as explicit extraction + record storage | `httk-workflow` + `httk-data` |
3737
| 12 | Draw a phase diagram | Available | `httk-analyse` |

0 commit comments

Comments
 (0)