-
Notifications
You must be signed in to change notification settings - Fork 56
refactor: session #2566
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
Merged
Merged
refactor: session #2566
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
caca29d
Refactor: session
prmukherj 6d16a2b
Refactoring.
prmukherj d9dac12
Make error_state private.
prmukherj a8d7b12
Fix bug.
prmukherj c377422
Correct docstrings.
prmukherj 4e202a1
Merge branch 'main' into maint/refactor_session
prmukherj d63a504
Merge branch 'main' into maint/refactor_session
prmukherj cd05dbe
root -> settings
prmukherj aa762b6
Update stability check.
prmukherj 23cb60b
Renaming and restructuring.
prmukherj 65176fa
Update tests.
prmukherj 6279239
Add test.
prmukherj 06a17bd
Doc update.
prmukherj d91e29d
include is_active check.
prmukherj 90e0d5b
Ignore Stability check.
prmukherj 1ea3907
Fix tests.
prmukherj 1d1cc5a
Updated field data test.
prmukherj abb6dce
Update dir.
prmukherj fda10b8
Update src/ansys/fluent/core/session.py
prmukherj e43ea16
Update src/ansys/fluent/core/session.py
prmukherj 8543348
Update src/ansys/fluent/core/session_solver.py
prmukherj 6e1ac7c
Update src/ansys/fluent/core/session.py
prmukherj da65719
Update src/ansys/fluent/core/solver/flobject.py
prmukherj 48b7d67
Update docstrings.
prmukherj 63b542a
Merge branch 'main' into maint/refactor_session
prmukherj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,7 @@ def __init__( | |
| def _build_from_fluent_connection(self, fluent_connection): | ||
| self._tui_service = self.datamodel_service_tui | ||
| self._se_service = self.datamodel_service_se | ||
| self._settings_service = self.settings_service | ||
| self._settings_service = self._settings_service | ||
|
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. @prmukherj This line looks redundant |
||
| self._tui = None | ||
| self._workflow = None | ||
| self._system_coupling = None | ||
|
|
@@ -103,49 +103,58 @@ def _build_from_fluent_connection(self, fluent_connection): | |
| self._solution_variable_service = service_creator("svar").create( | ||
| fluent_connection._channel, fluent_connection._metadata | ||
| ) | ||
| self.solution_variable_info = SolutionVariableInfo( | ||
| self.fields.solution_variable_info = SolutionVariableInfo( | ||
| self._solution_variable_service | ||
| ) | ||
| self._reduction_service = self.fluent_connection.create_grpc_service( | ||
| ReductionService, self.error_state | ||
| ReductionService, self._error_state | ||
| ) | ||
| if FluentVersion(self._version) >= FluentVersion.v241: | ||
| self.reduction = service_creator("reduction").create( | ||
| self.fields.reduction = service_creator("reduction").create( | ||
| self._reduction_service, self | ||
| ) | ||
| else: | ||
| self.reduction = reduction_old | ||
| self.fields.reduction = reduction_old | ||
| self._settings_api_root = None | ||
| self.fields.solution_variable_data = self._solution_variable_data() | ||
|
|
||
| def build_from_fluent_connection(self, fluent_connection): | ||
| """Build a solver session object from fluent_connection object.""" | ||
| super(Solver, self).build_from_fluent_connection(fluent_connection) | ||
| self._build_from_fluent_connection(fluent_connection) | ||
|
|
||
| @property | ||
| def solution_variable_data(self) -> SolutionVariableData: | ||
| def _solution_variable_data(self) -> SolutionVariableData: | ||
| """Return the SolutionVariableData handle.""" | ||
| return service_creator("svar_data").create( | ||
| self._solution_variable_service, self.solution_variable_info | ||
| self._solution_variable_service, self.fields.solution_variable_info | ||
prmukherj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| @property | ||
| def svar_data(self): | ||
| """Return the SolutionVariableData handle.""" | ||
| """``SolutionVariableData`` handle.""" | ||
| warnings.warn( | ||
| "svar_data is deprecated, use solution_variable_data instead", | ||
| "svar_data is deprecated. Use fields.solution_variable_data instead.", | ||
| DeprecationWarning, | ||
| ) | ||
| return self.solution_variable_data | ||
| return self.fields.solution_variable_data | ||
|
|
||
| @property | ||
| def svar_info(self): | ||
| """Return the SolutionVariableInfo handle.""" | ||
| """``SolutionVariableInfo`` handle.""" | ||
| warnings.warn( | ||
| "svar_info is deprecated, use solution_variable_info instead", | ||
| "svar_info is deprecated. Use fields.solution_variable_info instead.", | ||
| DeprecationWarning, | ||
| ) | ||
| return self.solution_variable_info | ||
| return self.fields.solution_variable_info | ||
|
|
||
| @property | ||
| def reduction(self): | ||
| """``Reduction`` handle.""" | ||
| warnings.warn( | ||
| "reduction is deprecated. Use fields.reduction instead.", | ||
| DeprecationWarning, | ||
| ) | ||
| return self.fields.reduction | ||
|
|
||
| @property | ||
| def _version(self): | ||
|
|
@@ -192,7 +201,7 @@ def workflow(self): | |
| return self._workflow | ||
|
|
||
| @property | ||
| def _root(self): | ||
| def settings(self): | ||
| """Root settings object.""" | ||
| if self._settings_root is None: | ||
| self._settings_root = flobject.get_root( | ||
|
|
@@ -223,10 +232,10 @@ def _sync_from_future(self, fut: Future): | |
| fut_session = fut.result() | ||
| except Exception as ex: | ||
| raise RuntimeError("Unable to read mesh") from ex | ||
| state = self._root.get_state() | ||
| state = self.settings.get_state() | ||
| self.build_from_fluent_connection(fut_session.fluent_connection) | ||
| # TODO temporary fix till set_state at settings root is fixed | ||
| _set_state_safe(self._root, state) | ||
| _set_state_safe(self.settings, state) | ||
|
|
||
| def read_case_lightweight(self, file_name: str): | ||
| """Read a case file using light IO mode. | ||
|
|
@@ -247,29 +256,33 @@ def read_case_lightweight(self, file_name: str): | |
|
|
||
| def get_state(self) -> StateT: | ||
| """Get the state of the object.""" | ||
| return self._root.get_state() | ||
| return self.settings.get_state() | ||
|
|
||
| def set_state(self, state: Optional[StateT] = None, **kwargs): | ||
| """Set the state of the object.""" | ||
| self._root.set_state(state, **kwargs) | ||
| self.settings.set_state(state, **kwargs) | ||
|
|
||
| def __call__(self): | ||
| return self.get_state() | ||
|
|
||
| def _populate_settings_api_root(self): | ||
| if not self._settings_api_root: | ||
| self._settings_api_root = _import_settings_root(self._root) | ||
| self._settings_api_root = _import_settings_root(self.settings) | ||
|
|
||
| def __getattr__(self, attr): | ||
| self._populate_settings_api_root() | ||
| return getattr(self._settings_api_root, attr) | ||
|
|
||
| def __dir__(self): | ||
| self._populate_settings_api_root() | ||
| return sorted( | ||
| set( | ||
| list(self.__dict__.keys()) | ||
| + dir(type(self)) | ||
| + dir(self._settings_api_root) | ||
| ) | ||
| ) | ||
| dir_list = set( | ||
| list(self.__dict__.keys()) + dir(type(self)) + dir(self._settings_api_root) | ||
| ) - { | ||
| "svar_data", | ||
| "svar_info", | ||
| "reduction", | ||
| "field_data", | ||
| "field_info", | ||
| "field_data_streaming", | ||
| } | ||
| return sorted(dir_list) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.