Skip to content

chore/SOF 7921 1#149

Merged
VsevolodX merged 33 commits into
mainfrom
chore/SOF-7921-1
Jun 5, 2026
Merged

chore/SOF 7921 1#149
VsevolodX merged 33 commits into
mainfrom
chore/SOF-7921-1

Conversation

@VsevolodX

Copy link
Copy Markdown
Member
  • update: adjust {} -> []
  • update: tests:
  • update: tests
  • update: restructure unit context
  • update: model serialization
  • chore: mode
  • update: unit has no context
  • update: possible type
  • update: execution to have context
  • update: adjsut convergence
  • update: use context item
  • chore: cleanup
  • update: execution unit test
  • update: check for execution unit
  • chore: simplify
  • update: context to match NBs
  • update: validate context item
  • update: use standata for tests
  • update: context shape in tests
  • update: preserve yield data

@property
def unit_context(self) -> Dict[str, Any]:
return self._points_grid_context(
yielded = self._points_grid_context(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's update _points_grid_context instead?

Comment thread src/py/mat3ra/wode/units/execution.py Outdated
from .execution_unit_input import ExecutionUnitInput
from .unit import Unit

Context = List[ContextItemSchema]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just take from schema?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's an alias for ease of reading. Also if we eventually create Context class -- it is already used as such

Comment thread src/py/mat3ra/wode/units/execution.py Outdated
if isinstance(item, dict):
return item.get("name")
name = getattr(item, "name", None)
return str(name) if name is not None else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't be none and should always just be item.get("name")

Comment thread src/py/mat3ra/wode/units/execution.py Outdated
def _coerce_context(cls, value: Any) -> Any:
if value is None:
return []
return value

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should not be needed

Comment thread src/py/mat3ra/wode/units/execution.py Outdated
def get_context_item(self, name: str) -> Optional[Dict[str, Any]]:
for item in self.context:
if self._context_item_name(item) == name:
return item if isinstance(item, dict) else item.model_dump()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is a dict

Comment thread src/py/mat3ra/wode/units/execution.py Outdated
else:
self.context.append(item)

def get_context(self, name: str, default: Any = None) -> Any:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

get_context_item_by_name

default should be {} if not present

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it is {} by default. by in Py we get "argument value is mutable", so we need to do the if None -> {} thing

Comment thread tests/py/test_workflow.py Outdated
yield unit


def _assert_subworkflow_models_have_functional(workflow_payload, expected_functional):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be tested in mode, not here

Comment thread tests/py/test_workflow.py Outdated
assert model.get("functional") == expected_functional


def _assert_execution_unit_context_is_webapp_shaped(unit):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't make sense - mention of webapp??

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll remove. This came from a file checkout.

from mat3ra.ade.context.context_provider import ContextProvider as AdeContextProvider


class ContextProvider(AdeContextProvider):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TODO: remove context provider from Ade

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add todo pls

context=unit_for_convergence.context
).get_reciprocal_vector_ratios()
kgrid_item = unit_for_convergence.get_context_item("kgrid")
provider_context = {"kgrid": kgrid_item["data"]} if kgrid_item else None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should be unit_for_convergence.get_context_item_by_name("kgrid")

).get_reciprocal_vector_ratios()
kgrid_item = unit_for_convergence.get_context_item("kgrid")
provider_context = {"kgrid": kgrid_item["data"]} if kgrid_item else None
reciprocal_vector_ratios = PointsGridDataProvider().get_reciprocal_vector_ratios(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be just PointsGridDataProvider(**provider_context)

provider_context = {"kgrid": kgrid_item["data"]} if kgrid_item else None
reciprocal_vector_ratios = PointsGridDataProvider().get_reciprocal_vector_ratios(
context=provider_context,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

get_reciprocal_vector_ratios()

pattern, f"{parameter_name} = {scope_reference}", input_name=input_name
)
execution_unit.add_context({parameter_name: parameter_initial})
execution_unit.add_context({"name": parameter_name, "data": parameter_initial})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@k0stik - Will it work like this? The context would have {"name": "N_k", ...}, will the substitution work for the template based on the variable name?

Comment thread tests/py/fixtures/__init__.py Outdated
WORKFLOW_STANDATA = WorkflowStandata()


def execution_unit_config(application: str, workflow_name: str, unit_name: str) -> Dict[str, Any]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

get_execution_unit_config_by_application_workflow_unit

Comment thread tests/py/test_workflow.py Outdated
assert wf.hash == expected_hash


def test_workflow_to_dict_is_json_serializable_after_model_assignment():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove

self, dimensions: List[str], reciprocal_vector_ratios: Optional[List[float]] = None
) -> Dict[str, Any]:
return PointsGridDataProvider().yield_data_with_overrides(
provider = PointsGridDataProvider(isEdited=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does it need to be True here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We replace dimensions with Jinja vars, so it means that we edit it by definition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'll address all of this when removing CP from Ade and syncing py with JS

@VsevolodX VsevolodX merged commit 15ee179 into main Jun 5, 2026
9 checks passed
@VsevolodX VsevolodX deleted the chore/SOF-7921-1 branch June 5, 2026 05:25
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