fix/formation energy - #352
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
📝 WalkthroughWalkthroughThe notebook’s elemental total-energy checks now extract queries from the resolve-TE subworkflow, use renamed grouping and source context variables, and display a recycle symbol for each element. ChangesFormation energy query alignment
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@other/materials_designer/workflows/formation_energy.ipynb`:
- Around line 328-330: Update the endpoint parameter access in the notebook cell
after resolving io-te-for-an-element: read endpoint_options from
io_unit.input[0].template.content before extracting query and projection,
matching the object model used by patch_workflow_qe_input() and the workflow
tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 65c5e943-c461-4ce3-b58b-1c109e0ccf7a
📒 Files selected for processing (1)
other/materials_designer/workflows/formation_energy.ipynb
| "io_unit = resolve_te_subworkflow.get_unit_by_name(name=\"io-te-for-an-element\")\n", | ||
| "query_template = io_unit.input[0][\"endpoint_options\"][\"params\"][\"query\"]\n", | ||
| "projection_template = io_unit.input[0][\"endpoint_options\"][\"params\"][\"projection\"]\n", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 5 'io-te-for-an-element|endpoint_options|\.template\.content' \
other/materials_designer/workflows/formation_energy.ipynb \
src/py/mat3ra/notebooks_utils/workflow.py \
tests/py/unit/test_workflow_utils.py
ast-grep outline src/py/mat3ra/notebooks_utils/workflow.py --items all --type class,functionRepository: mat3ra/api-examples
Length of output: 2704
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "workflow.py outline:"
ast-grep outline src/py/mat3ra/notebooks_utils/workflow.py --items all --type class,function || true
echo
echo "relevant workflow.py sections:"
rg -n -C 8 'class .*Unit|unit\.input|template|WorkflowUnit|subworkflow|get_unit_by_name' src/py/mat3ra/notebooks_utils/workflow.py || true
echo
echo "test workflow utils relevant sections:"
sed -n '1,120p' tests/py/unit/test_workflow_utils.py
echo
echo "formation_energy relevant sections:"
sed -n '300,365p' other/materials_designer/workflows/formation_energy.ipynb | python3 -c '
import sys, json;
text=sys.stdin.read();
for line in text.splitlines():
line=line.lstrip(" ")
print(line)
'Repository: mat3ra/api-examples
Length of output: 8311
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
try:
from mat3ra.standata.workflows import WorkflowStandata
from mat3ra.wode.workflows import Workflow
apps = getattr(WorkflowStandata, "filter_by_application", None)
config = apps("formation_energy").get_by_name_first_match("formation_energy")
workflow = Workflow.create(config)
resolve_te_subworkflow = workflow.subworkflows[2]
io_unit = resolve_te_subworkflow.get_unit_by_name(name="io-te-for-an-element")
first = io_unit.input[0]
print("type:", type(first).__module__ + "." + type(first).__qualname__)
print("has __getitem__:", hasattr(first, "__getitem__"))
print("has template:", hasattr(first, "template"))
if hasattr(first, "template"):
tmpl = first.template
print("template type:", type(tmpl).__module__ + "." + type(tmpl).__qualname__)
print("template.content type:", type(tmpl.content).__name__[:200])
if isinstance(tmpl.content, dict):
print("endpoint_options present:", "endpoint_options" in tmpl.content)
print("endpoint_options:", tmpl.content.get("endpoint_options"))
else:
print("template.content[:200]:", repr(tmpl.content[:200]))
try:
first["endpoint_options"]
except Exception as exc:
print("first[key] error:", type(exc).__name__ + ":", exc)
exit(0)
except Exception as exc:
print("IMPORT/OR_ERROR:", type(exc).__name__, exc)
import traceback
traceback.print_exc()
PYRepository: mat3ra/api-examples
Length of output: 338
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "repo files mentioning WodeWorkflow/WorkflowUnit/input/template:"
rg -n -C 4 'class .*Workflow(Unit|Input|Template)|input.*template|template.*input|def get_unit_by_name|endpoint_options|wode.workflows|WorkflowStandata|format.*workflow|json\.load|yaml\.load' \
src other tests | head -n 240
echo
echo "python package candidates:"
fd -a 'workflow.*\.py$|standata.*\.py$' src/py/m* src/py | head -n 120Repository: mat3ra/api-examples
Length of output: 22941
🌐 Web query:
mat3ra wode workflows Workflow input[0].template.content
💡 Result:
In the context of the Mat3ra (formerly Exabyte) platform and the wode (Workflow Definitions) library, Workflow.input[0].template.content is not a standard, hard-coded path, but rather a representation of how input templates are structured within a workflow configuration [1][2][3]. Mat3ra workflows use a hierarchical structure: Workflows contain Subworkflows, which in turn contain Units [1][2]. Units often utilize input templates to generate simulation input files, typically using the Jinja2 templating engine [4][5]. Based on the wode schema and documentation: 1. Workflow Configuration: A workflow object is a top-level container [1]. 2. Input Templating: Input templates are defined within the configuration of a unit [1][5]. The template.content property holds the actual template string (often containing Jinja2 placeholders like {{ input.VARIABLE }}) that will be rendered with specific data to produce the final input file for a simulation engine [4][6][5]. 3. Data Access: While the path input[0].template.content may appear in specific user-defined code, it generally refers to accessing the first input object of a unit's configuration to retrieve the text template content [4][6]. For precise usage, developers typically interact with the wode library to construct these objects [3], which are then processed at build time by functions such as createWorkflows to generate the final workflow instances [2][3]. Users should refer to the official Mat3ra documentation on input templates to understand how these properties are structured and rendered during both Design-time and Runtime [4][7][5].
Citations:
- 1: https://docs.mat3ra.com/workflows/data/workflows/
- 2: https://github.com/mat3ra/wode
- 3: https://registry.npmjs.org/@mat3ra/wode
- 4: https://docs.mat3ra.com/workflow-designer/unit-editor/input-templates/
- 5: https://docs.mat3ra.com/workflows/templating/concept/
- 6: https://docs.mat3ra.com/reference/workflows/templating/examples/
- 7: https://docs.mat3ra.com/workflows/templating/exabyte-convention
🌐 Web query:
@mat3ra/wode Workflow python input template.content
💡 Result:
The @mat3ra/wode library, short for WOrkflow DEfinitions, is used for defining, creating, and manipulating modeling workflows on the Mat3ra platform [1][2][3]. While @mat3ra/wode provides the structural definitions for workflows, subworkflows, and units [1][2], the specific functionality for rendering input files—often referred to as input templates—is managed through the platform's dedicated templating engine, which utilizes Jinja2 syntax [4][5][6]. Key points regarding workflow input templates in the Mat3ra ecosystem: 1. Templating Mechanism: Templates are used to automate the generation of simulation input files by substituting placeholders with material-specific data [4][7][6]. These templates are rendered in two stages: - Design-time Rendering: Performed on the web interface (using Swig, a JavaScript template engine) to provide previews [5][6]. - Runtime Rendering: Performed on computing clusters (using Python's Jinja2 implementation) during job execution [8][6]. 2. Template Data: You can inspect the JSON representation of the data used to render these templates by accessing the Template Data section within the platform's Unit Editor interface [4][5]. 3. Python Integration: Recent updates (as of late 2025) have introduced and expanded the Python codebase within mat3ra-wode for creating and manipulating these workflows, moving beyond purely JS-based definitions [9]. 4. Syntax: Because the rendering happens in both JavaScript (design-time) and Python (runtime) environments, users are advised to avoid language-specific constructs (like list.append vs array.push) and stick to standard Jinja2 templating features to ensure cross-environment compatibility [6]. For detailed examples of how templates are structured for simulation engines (e.g., Quantum ESPRESSO), you can refer to the official Mat3ra templating examples documentation [10].
Citations:
- 1: https://github.com/mat3ra/wode
- 2: https://registry.npmjs.org/@mat3ra/wode
- 3: https://pypi.org/project/mat3ra-wode/2026.7.3.post0/
- 4: https://docs.mat3ra.com/workflow-designer/unit-editor/input-templates/
- 5: https://docs.mat3ra.com/workflow-designer/unit-editor/input-templates
- 6: https://docs.mat3ra.com/workflows/templating/concept
- 7: https://docs.mat3ra.com/workflows/templating/overview
- 8: https://docs.mat3ra.com/workflows/templating/exabyte-convention
- 9: https://www.mat3ra.com/news-and-blog-posts/release-2025-12-25
- 10: https://docs.mat3ra.com/reference/workflows/templating/examples/
Use template.content for the resolve-TE endpoint parameters.
patch_workflow_qe_input() and the workflow tests access inputs via input[0].template.content, while this cell indexes input[0] directly. Read endpoint_options from io_unit.input[0].template.content so the notebook follows the current workflow object model.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@other/materials_designer/workflows/formation_energy.ipynb` around lines 328 -
330, Update the endpoint parameter access in the notebook cell after resolving
io-te-for-an-element: read endpoint_options from
io_unit.input[0].template.content before extracting query and projection,
matching the object model used by patch_workflow_qe_input() and the workflow
tests.
Summary by CodeRabbit