Skip to content

REFACTOR: Improve API and security in Desktop #5892

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 27 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8398854
REFACTOR: Improve API and security in Desktop
SMoraisAnsys Mar 10, 2025
cf91289
chore: adding changelog file 5892.miscellaneous.md [dependabot-skip]
pyansys-ci-bot Mar 10, 2025
4260757
REFACTOR: Extend API in Design
SMoraisAnsys Mar 11, 2025
57a150b
TESTS: Clean up
SMoraisAnsys Mar 11, 2025
ff85635
TESTS: Fix removed fixture decorator
SMoraisAnsys Mar 11, 2025
e075f76
TESTS: Apply code review and remove direct call
SMoraisAnsys Mar 11, 2025
d801cd8
FIX(Desktop): Add back removed properties
SMoraisAnsys Mar 11, 2025
b066757
TESTS: Clean up
SMoraisAnsys Mar 11, 2025
10ca258
FIX: init desktop from design
SMoraisAnsys Mar 11, 2025
cd8aef5
REFACTOR: Extend subprocess checking
SMoraisAnsys Mar 14, 2025
5bb2b04
REFACTOR: add checking for subprocess calls
SMoraisAnsys Mar 17, 2025
2af0b1e
Merge branch 'main' into refact/desktop-to-deprecate-and-improve-sec
SMoraisAnsys Mar 17, 2025
5e2e7a7
REFACTOR: Simply reading
SMoraisAnsys Mar 17, 2025
5372bde
Merge branch 'main' into refact/desktop-to-deprecate-and-improve-sec
SMoraisAnsys Mar 26, 2025
5d8ddd0
REFACTOR: Continue refactoring
SMoraisAnsys Mar 26, 2025
96e1d94
DOCS: Add warning on method usage
SMoraisAnsys Mar 27, 2025
859b38d
Merge branch 'main' into refact/desktop-to-deprecate-and-improve-sec
SMoraisAnsys Mar 27, 2025
a600663
DOCS: Fix vale issues
SMoraisAnsys Mar 27, 2025
e4736c6
TESTS: Fix import issue
SMoraisAnsys Mar 27, 2025
f0663a7
DOCS: Fix vale issues
SMoraisAnsys Mar 27, 2025
5b9c5d7
FIX: Codacy issues
SMoraisAnsys Mar 27, 2025
ffbaf5d
TESTS: Extend testing coverage
SMoraisAnsys Mar 28, 2025
e990bbf
Apply suggestions from code review
SMoraisAnsys Mar 28, 2025
9d1f4dd
Merge branch 'main' into refact/desktop-to-deprecate-and-improve-sec
SMoraisAnsys Mar 28, 2025
731a007
Update doc/source/User_guide/index.rst
SMoraisAnsys Apr 1, 2025
e97b470
Merge branch 'main' into refact/desktop-to-deprecate-and-improve-sec
Samuelopez-ansys Apr 1, 2025
2f98223
DOCS: Fix typo
SMoraisAnsys Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/5892.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve API and security in Desktop
38 changes: 22 additions & 16 deletions src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from ansys.aedt.core.application.design_solutions import solutions_defaults
from ansys.aedt.core.application.variables import DataSet
from ansys.aedt.core.application.variables import VariableManager
from ansys.aedt.core.desktop import _init_desktop_from_design
from ansys.aedt.core.desktop import Desktop
from ansys.aedt.core.desktop import exception_to_desktop
from ansys.aedt.core.generic.constants import AEDT_UNITS
from ansys.aedt.core.generic.constants import unit_system
Expand Down Expand Up @@ -196,7 +196,7 @@
self._design_datasets: List = []
self.close_on_exit: bool = close_on_exit
self._desktop_class = None
self._desktop_class = _init_desktop_from_design(
self._desktop_class = self.__init_desktop_from_design(

Check warning on line 199 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L199

Added line #L199 was not covered by tests
version,
non_graphical,
new_desktop,
Expand Down Expand Up @@ -4233,6 +4233,12 @@
self.odesign.EditNotes(text)
return True

@classmethod
def __init_desktop_from_design(cls, *args, **kwargs):
"""Internal instantiation of the ``Desktop`` class."""
Desktop._invoked_from_design = True
return Desktop(*args, **kwargs)

Check warning on line 4240 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L4239-L4240

Added lines #L4239 - L4240 were not covered by tests


class DesignSettings:
"""Get design settings for the current AEDT app.
Expand All @@ -4246,20 +4252,6 @@
self._app: Any = app
self.manipulate_inputs: Optional[DesignSettingsManipulation] = None

@property
def design_settings(self) -> Optional[Any]:
"""Design settings."""
try:
return self._app.odesign.GetChildObject("Design Settings")
except GrpcApiError: # pragma: no cover
self._app.logger.error("Failed to retrieve design settings.")
return None

@property
def available_properties(self) -> List[str]:
"""Available properties names for the current design."""
return [prop for prop in self.design_settings.GetPropNames() if not prop.endswith("/Choices")]

def __repr__(self) -> str:
lines = ["{"]
for prop in self.available_properties:
Expand Down Expand Up @@ -4294,6 +4286,20 @@
def __contains__(self, item: str) -> bool:
return item in self.available_properties

@property
def design_settings(self) -> Optional[Any]:
"""Design settings."""
try:
return self._app.odesign.GetChildObject("Design Settings")

Check warning on line 4293 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L4292-L4293

Added lines #L4292 - L4293 were not covered by tests
except GrpcApiError: # pragma: no cover
self._app.logger.error("Failed to retrieve design settings.")
return None

@property
def available_properties(self) -> List[str]:
"""Available properties names for the current design."""
return [prop for prop in self.design_settings.GetPropNames() if not prop.endswith("/Choices")]

Check warning on line 4301 in src/ansys/aedt/core/application/design.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/application/design.py#L4301

Added line #L4301 was not covered by tests


class DesignSettingsManipulation:
@abstractmethod
Expand Down
Loading
Loading