Skip to content

Commit 9667057

Browse files
committed
allow to read env vars for qe_exec or use number_cores from the toml
1 parent 1f22f47 commit 9667057

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

python/solid_dmft/dft_managers/qe_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def run(number_cores, qe_file_ext, qe_exec, mpi_profile, mpi_exe_param, seedname
106106
qe_exec_path += '/'
107107
qe_select = {"path": qe_exec_path}
108108
else:
109+
assert "path" in qe_exec, "If dft_exec is not a string it must at least specify the path key"
109110
unknown_keys = set(qe_exec.keys()) - valid_exec_keys
110111
if unknown_keys:
111112
raise ValueError(f"Unknown keys in dft_exec: {unknown_keys}. Valid keys: {valid_exec_keys}")
@@ -138,7 +139,10 @@ def run(number_cores, qe_file_ext, qe_exec, mpi_profile, mpi_exe_param, seedname
138139
elif qe_file_ext in ['win']:
139140
qe_exec += qe_select.get("win", "wannier90.x")
140141

141-
qe_exec = qe_exec.format(number_cores=number_cores)
142+
try:
143+
qe_exec = qe_exec.format(**{**os.environ, "number_cores": number_cores})
144+
except KeyError as e:
145+
raise ValueError(f"Unknown placeholder {e} in dft_exec. Available: 'number_cores' and environment variables.") from None
142146

143147
arguments = mpi_helpers.get_mpi_arguments(mpi_profile, mpi_exe, number_cores, qe_exec, hostfile)
144148
_start_with_piping(mpi_exe, arguments, qe_file_ext, env_vars, seedname)

0 commit comments

Comments
 (0)