Skip to content

Commit a70e9a0

Browse files
committed
Update docs for nested namespace (#30)
* Update docs for nested namespace * Fix failed docs
1 parent 2ca5464 commit a70e9a0

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

.readthedocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build:
1212
- rabbitmq-server -detached
1313
- sleep 5
1414
- rabbitmq-diagnostics status
15+
- pip list
1516
- verdi presto
1617
- verdi daemon start
1718
- verdi status

docs/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- aiida-core
6+
- aiida-core~=2.6.3
77
- aiida-core.services

docs/gallery/autogen/pythonjob.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,51 @@ def generate_structures(structure: Atoms, factor_lst: list) -> dict:
279279
print(key, value)
280280

281281

282+
######################################################################
283+
# --------------------------
284+
# Nested Namespace
285+
# --------------------------
286+
#
287+
# One can also define nested namespace outputs by specifying the "ports" parameter.
288+
289+
290+
def generate_structures(structure: Atoms, factor_lst: list) -> dict:
291+
"""Scale the structure by the given factor_lst."""
292+
scaled_structures = {}
293+
volumes = {}
294+
for i in range(len(factor_lst)):
295+
atoms = structure.copy()
296+
atoms.set_cell(atoms.cell * factor_lst[i], scale_atoms=True)
297+
scaled_structures[f"s_{i}"] = atoms
298+
volumes[f"v_{i}"] = atoms.get_volume()
299+
return {
300+
"outputs": {
301+
"scaled_structures": scaled_structures,
302+
"volume": volumes,
303+
}
304+
}
305+
306+
307+
inputs = prepare_pythonjob_inputs(
308+
generate_structures,
309+
function_inputs={"structure": bulk("Al"), "factor_lst": [0.95, 1.0, 1.05]},
310+
output_ports=[
311+
{
312+
"name": "outputs",
313+
"identifier": "namespace",
314+
"ports": [
315+
{"name": "scaled_structures", "identifier": "namespace"},
316+
{"name": "volume", "identifier": "namespace"},
317+
],
318+
}
319+
],
320+
)
321+
322+
result, node = run_get_node(PythonJob, inputs=inputs)
323+
print("result: ", result["outputs"]["scaled_structures"])
324+
print("volumes: ", result["outputs"]["volume"])
325+
326+
282327
######################################################################
283328
# What if my calculation fails?
284329
# --------------------------------

docs/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
sphinx_rtd_theme==1.2.2
1+
sphinx_rtd_theme~=3.0
2+
click~=8.1.0
3+
pydantic~=2.11.0
24
sphinx-gallery
35
nbsphinx==0.9.2
46
ipython

src/aiida_pythonjob/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ def parse_outputs(
476476
for output in output_ports["ports"]:
477477
if output["name"] not in results:
478478
if output.get("required", True):
479+
logger.warning(f"Found output: {output['name']} not in results, but it is required.")
479480
return exit_codes.ERROR_MISSING_OUTPUT
480481
else:
481482
output["value"] = serialize_ports(

0 commit comments

Comments
 (0)