-
Notifications
You must be signed in to change notification settings - Fork 0
chore/SOF 7921 1 #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore/SOF 7921 1 #149
Changes from all commits
dd5c3c3
d1cbc39
a1af9db
13ff5eb
876aab1
a11e694
9ac6a90
c84862e
5b714e9
872bc1d
f131678
5409a7e
9c36a36
06646aa
97d4899
aab26fe
c3d2cb2
5993c0c
8a17b42
dd0f48e
066c546
f232508
3e871d3
7ccf85a
f5d946b
3475895
a59b743
eb41454
e5c2a74
84c4137
98e10eb
305e5bf
035f2c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from typing import Any, Dict | ||
|
|
||
| from mat3ra.ade.context.context_provider import ContextProvider as AdeContextProvider | ||
|
|
||
| # TODO: Remove context provider from Ade -- sync with JS implementation fully | ||
| class ContextProvider(AdeContextProvider): | ||
| def get_context_item_data(self) -> Dict[str, Any]: | ||
| return { | ||
| "name": self.name_str, | ||
| "isEdited": self.is_edited, | ||
| "data": self.get_data(), | ||
| "extraData": self.extra_data or {}, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,12 @@ class UniformKGridConvergence(ConvergenceParameter): | |
| def _points_grid_context( | ||
| self, dimensions: List[str], reciprocal_vector_ratios: Optional[List[float]] = None | ||
| ) -> Dict[str, Any]: | ||
| return PointsGridDataProvider().yield_data_with_overrides( | ||
| provider = PointsGridDataProvider(isEdited=True) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it need to be True here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| provider.data = provider.build_data( | ||
| dimensions=dimensions, | ||
| reciprocal_vector_ratios=reciprocal_vector_ratios, | ||
| is_using_jinja_variables=True, | ||
| ) | ||
| return provider.get_context_item_data() | ||
|
|
||
| @property | ||
| def increment(self) -> str: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
|
|
||
| from mat3ra.esse.models.workflow.subworkflow.convergence.enum_options import ConvergenceParameterNameEnum | ||
| from mat3ra.utils.extra.jinja import JINJA_EXPRESSION_PATTERN, NUMERIC_VALUE_PATTERN, wrap_text_in_raw_block | ||
|
|
||
| from .convergence.factory import create_convergence_parameter | ||
| from ..context.providers import PointsGridDataProvider | ||
| from ..units import Unit | ||
|
|
@@ -67,15 +66,6 @@ def _find_unit_for_convergence(self, result: str): | |
| return unit | ||
| return None | ||
|
|
||
| @staticmethod | ||
| def _merge_convergence_context(unit_context: Dict[str, Any], convergence_context: Dict[str, Any]) -> Dict[str, Any]: | ||
| merged_context = dict(unit_context) | ||
| merged_kgrid_context = dict(unit_context.get("kgrid") or {}) | ||
| merged_kgrid_context.update(convergence_context.get("kgrid") or {}) | ||
| merged_context.update(convergence_context) | ||
| if merged_kgrid_context: | ||
| merged_context["kgrid"] = merged_kgrid_context | ||
| return merged_context | ||
|
|
||
| def _build_convergence_units( | ||
| self, | ||
|
|
@@ -153,6 +143,17 @@ def _build_convergence_units( | |
| host.add_unit(next_step) | ||
| host.add_unit(exit_unit) | ||
|
|
||
| param_init.next = prev_result_init.flowchartId | ||
| prev_result_init.next = iter_init.flowchartId | ||
| iter_init.next = execution_unit_flowchart_id | ||
|
|
||
| execution_unit = host.get_unit(execution_unit_flowchart_id) | ||
| if execution_unit is not None: | ||
| execution_unit.next = store_result.flowchartId | ||
|
|
||
| store_result.next = condition_unit.flowchartId | ||
| store_prev_result.next = next_iter.flowchartId | ||
| next_iter.next = next_step.flowchartId | ||
| next_step.next = execution_unit_flowchart_id | ||
|
|
||
| def add_convergence( | ||
|
|
@@ -185,9 +186,12 @@ def add_convergence( | |
| ) | ||
| and reciprocal_vector_ratios is None | ||
| ): | ||
| reciprocal_vector_ratios = PointsGridDataProvider( | ||
| context=unit_for_convergence.context | ||
| ).get_reciprocal_vector_ratios() | ||
| kgrid_item = unit_for_convergence.get_context_item("kgrid") | ||
| provider = PointsGridDataProvider( | ||
| data=kgrid_item.get("data"), | ||
| is_edited=kgrid_item.get("isEdited"), | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get_reciprocal_vector_ratios() |
||
| reciprocal_vector_ratios = provider.get_reciprocal_vector_ratios() | ||
| if reciprocal_vector_ratios is None: | ||
| raise ValueError("Non-uniform k-grid convergence requires reciprocal_vector_ratios to be provided.") | ||
|
|
||
|
|
@@ -198,11 +202,7 @@ def add_convergence( | |
| reciprocal_vector_ratios=reciprocal_vector_ratios, | ||
| ) | ||
|
|
||
| merged_context = self._merge_convergence_context( | ||
| unit_for_convergence.context, | ||
| parameter.unit_context, | ||
| ) | ||
| unit_for_convergence.set_context(merged_context) | ||
| unit_for_convergence.add_context(parameter.unit_context) | ||
|
|
||
| self._build_convergence_units( | ||
| parameter_name=parameter.name, | ||
|
|
@@ -266,7 +266,6 @@ def add_template_parameter_convergence( | |
| execution_unit.replace_in_input_content( | ||
| pattern, f"{parameter_name} = {scope_reference}", input_name=input_name | ||
| ) | ||
| execution_unit.add_context({parameter_name: parameter_initial}) | ||
|
|
||
| self._build_convergence_units( | ||
| parameter_name=parameter_name, | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add todo pls