Skip to content

fix/formation energy - #352

Merged
VsevolodX merged 1 commit into
mainfrom
fix/formation_energy
Jul 28, 2026
Merged

fix/formation energy#352
VsevolodX merged 1 commit into
mainfrom
fix/formation_energy

Conversation

@VsevolodX

@VsevolodX VsevolodX commented Jul 28, 2026

Copy link
Copy Markdown
Member
  • update: check for existing TE

Summary by CodeRabbit

  • Bug Fixes
    • Updated elemental total-energy checks to use the correct energy-resolution workflow and grouping information.
    • Corrected property-query context values for elemental total-energy sources.
    • Updated status indicators shown during per-element checks.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Formation energy query alignment

Layer / File(s) Summary
Resolve-TE query extraction and output update
other/materials_designer/workflows/formation_energy.ipynb
The notebook switches to the resolve-TE subworkflow and updated unit names, passes GROUP_FOR_MATERIAL and SOURCE_OF_TE_FOR_AN_ELEMENT into the query template, and changes the per-element output symbol.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • mat3ra/api-examples#343: Reworks the same formation-energy notebook workflow logic and elemental total-energy query handling.

Suggested reviewers: timurbazhirov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly related to the formation-energy changes in the notebook.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/formation_energy

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b6d020f and 7040c86.

📒 Files selected for processing (1)
  • other/materials_designer/workflows/formation_energy.ipynb

Comment on lines +328 to 330
"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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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,function

Repository: 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()
PY

Repository: 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 120

Repository: 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:


🌐 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:


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.

@VsevolodX
VsevolodX merged commit fd8fc52 into main Jul 28, 2026
8 checks passed
@VsevolodX
VsevolodX deleted the fix/formation_energy branch July 28, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants