Skip to content
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

Migration common toolkit #193

Merged
merged 34 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f4387f8
migration first part
gmalinve Mar 13, 2024
177dfd7
customize UI
gmalinve Mar 13, 2024
7cb469f
customize UI
gmalinve Mar 13, 2024
46b8a65
Merge branch 'main' into migration
gmalinve Mar 13, 2024
02064f4
customize UI
gmalinve Mar 13, 2024
bb880c7
post-processing ui
gmalinve Mar 14, 2024
62bf2c5
post-processing ui
gmalinve Mar 14, 2024
b67c9ed
json to toml
gmalinve Apr 3, 2024
6a31986
fixes
gmalinve Apr 3, 2024
b3cd315
fixes
gmalinve Apr 3, 2024
dde0b5f
run pre-commit and update pre-commit-config.yaml
gmalinve Apr 3, 2024
699e2b0
segmentation and skew buttons
gmalinve Apr 4, 2024
b082688
improve ui and icons
gmalinve Apr 8, 2024
446b1e8
migration
gmalinve Apr 12, 2024
9d66f82
fix tests
gmalinve Apr 14, 2024
c944dbb
fix doc
gmalinve Apr 14, 2024
d0abe2c
last thing of migration + export faces
gmalinve Apr 24, 2024
fce46d2
fix tests
gmalinve Apr 24, 2024
a000632
fix common_api.rst
gmalinve Apr 27, 2024
a991946
fix doc
gmalinve Apr 27, 2024
b719536
fix examples
gmalinve Apr 27, 2024
150cb77
fix example
gmalinve Apr 28, 2024
683f234
add images
gmalinve Apr 29, 2024
1ca8b51
WIP: test conftest fix
SMoraisAnsys Apr 29, 2024
4e6986a
update toml
gmalinve Apr 29, 2024
bf95e87
Update pyproject.toml
SMoraisAnsys May 7, 2024
e58822d
WIP: Leverage toolkits-common dependencies
SMoraisAnsys May 7, 2024
a553838
fix apply_skew_test
gmalinve May 9, 2024
6fd3f31
fix test validate
gmalinve May 9, 2024
f1e1e21
FIX: Typo in README.rst
SMoraisAnsys May 9, 2024
6f48501
improve doc
gmalinve May 10, 2024
ac14e80
update toml
gmalinve May 10, 2024
cc3e94f
clean user guide
gmalinve May 10, 2024
22f836a
update run_toolkit.py
gmalinve May 10, 2024
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
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ exclude: |
(?x)(
src/ansys/aedt/toolkits/magnet_segmentation/ui/common/frontend_ui.py |
tests/input_data/.* |
examples/input_files/.*
examples/input_files/.* |
src/ansys/aedt/toolkits/magnet_segmentation/ui/windows/.*
)

repos:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Contributing

We absolutely welcome any code contributions and we hope that this
guide will facilitate an understanding of the Magnet Segmentation Toolkit
guide will facilitate an understanding of the Magnet Segmentation ToolkitBackend
code repository. It is important to note that while the Magnet Segmentation
Toolkit software package is maintained by ANSYS and any submissions will be
ToolkitBackend software package is maintained by ANSYS and any submissions will be
reviewed thoroughly before merging, we still seek to foster a community that can
support user questions and develop new features to make this software
a useful tool for all users. As such, we welcome and encourage any
Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Magnet Segmentation Toolkit
Magnet Segmentation ToolkitBackend
===========================

|pyansys| |PythonVersion| |GH-CI| |MIT| |black|
Expand All @@ -22,7 +22,7 @@ Magnet Segmentation Toolkit

.. reuse_start

The Magnet Segmentation Toolkit is a Python wrapper for automating the segmentation
The Magnet Segmentation ToolkitBackend is a Python wrapper for automating the segmentation
and skew of interior permanent magnet (IPM) and surface permanent magnet (SPM)
motors using Ansys Electronics Desktop (AEDT). You can launch this toolkit
from the AEDT UI or launch it directly from a Python console.
Expand All @@ -31,25 +31,25 @@ Requirements
~~~~~~~~~~~~
In addition to the runtime dependencies listed in
`Getting started <https://magnet.segmentation.toolkit.docs.pyansys.com/version/stable/Getting_started.html>`_,
the Magnet Segmentation Toolkit requires AEDT 2023 R1 or later. This toolkit also supports the AEDT
the Magnet Segmentation ToolkitBackend requires AEDT 2023 R1 or later. This toolkit also supports the AEDT
Student Version for 2023 R1 or later.

Documentation and issues
~~~~~~~~~~~~~~~~~~~~~~~~
Documentation for the latest stable release of the Magnet Segmentation Toolkit is hosted at
`Magnet Segmentation Toolkit documentation <https://magnet.segmentation.toolkit.docs.pyansys.com/version/stable/index.html>`_.
Documentation for the latest stable release of the Magnet Segmentation ToolkitBackend is hosted at
`Magnet Segmentation ToolkitBackend documentation <https://magnet.segmentation.toolkit.docs.pyansys.com/version/stable/index.html>`_.

In the upper right corner of the documentation's title bar, there is an option for switching from
viewing the documentation for the latest stable release to viewing the documentation for the
development version or previously released versions.

On the `Magnet Segmentation Toolkit Issues <https://github.com/ansys/magnet-segmentation-toolkit/issues>`_
On the `Magnet Segmentation ToolkitBackend Issues <https://github.com/ansys/magnet-segmentation-toolkit/issues>`_
page, you can create issues to report bugs and request new features. On the `Discussions <https://discuss.ansys.com/>`_
page on the Ansys Developer portal, you can post questions, share ideas, and get community feedback.

License
~~~~~~~
The Magnet Segmentation Toolkit is licensed under the MIT license.
The Magnet Segmentation ToolkitBackend is licensed under the MIT license.

This toolkit makes no commercial claim over Ansys whatsoever. The use of this toolkit
requires a legally licensed copy of AEDT. For more information, see the
Expand Down
10 changes: 5 additions & 5 deletions doc/source/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ in the *PyAnsys developer's guide*. Ensure that you are thoroughly familiar
with this guide before attempting to contribute to PyAEDT or its toolkits.

The following contribution information is specific to the Magnet Segmentation
Toolkit.
ToolkitBackend.

Clone the repository
--------------------
To clone and install the latest version of the Magnet Segmentation Toolkit in
To clone and install the latest version of the Magnet Segmentation ToolkitBackend in
development mode, run these commands:

.. code::
Expand All @@ -23,20 +23,20 @@ development mode, run these commands:

Post issues
-----------
Use the `Magnet Segmentation Toolkit Issues <https://github.com/ansys/magnet-segmentation-toolkit/issues>`_ page
Use the `Magnet Segmentation ToolkitBackend Issues <https://github.com/ansys/magnet-segmentation-toolkit/issues>`_ page
to create issues to report bugs and request new features.

View documentation
-------------------
Documentation for the latest stable release is hosted at `Magnet Segmentation Toolkit documentation <https://magnet.segmentation.toolkit.docs.pyansys.com/version/stable/>`_.
Documentation for the latest stable release is hosted at `Magnet Segmentation ToolkitBackend documentation <https://magnet.segmentation.toolkit.docs.pyansys.com/version/stable/>`_.

In the upper right corner of the documentation's title bar, there is an option for switching from viewing
the documentation for the latest stable release to viewing the documentation for the development version
or previously released versions.

Adhere to code style
--------------------
The Magnet Segmentation Toolkit is compliant with `PyAnsys code style
The Magnet Segmentation ToolkitBackend is compliant with `PyAnsys code style
<https://dev.docs.pyansys.com/coding-style/index.html>`_. It uses the tool
`pre-commit <https://pre-commit.com/>`_ to check the code style.

Expand Down
38 changes: 20 additions & 18 deletions doc/source/Getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Getting started
===============

To run the Magnet Segmentation Toolkit, you must have a licensed copy of AEDT installed.
To run the Magnet Segmentation ToolkitBackend, you must have a licensed copy of AEDT installed.
You have multiple options for installing and launching this toolkit:

- You can install the toolkit directly in AEDT via an installation script and then launch it
Expand All @@ -17,21 +17,21 @@ You have multiple options for installing and launching this toolkit:
How to install directly in AEDT and launch as a wizard
------------------------------------------------------

You can install the Magnet Segmentation Toolkit directly in AEDT using the base
You can install the Magnet Segmentation ToolkitBackend directly in AEDT using the base
interpreter from the AEDT installation.

#. From `Install from a Python file <https://aedt.docs.pyansys.com/version/stable//Getting_started/Installation.html#install-from-a-python-file>`_
in the PyAEDT documentation, download the ``PyAEDTInstallerFromDesktop.py`` file and then run this Python script.

#. If this is the first toolkit being installed in AEDT, restart AEDT to update its **Tools** menu.

#. In AEDT, select **Tools > Toolkit > PyAEDT > Console** to load the PyAEDT console:
#. In AEDT, select **Tools > ToolkitBackend > PyAEDT > Console** to load the PyAEDT console:

.. image:: ./_static/console.png
:width: 800
:alt: PyAEDT console in AEDT

#. In the PyAEDT console, run these commands to add the Magnet Segmentation Toolkit as a wizard (toolkit UI)
#. In the PyAEDT console, run these commands to add the Magnet Segmentation ToolkitBackend as a wizard (toolkit UI)
in AEDT:

.. code:: python
Expand All @@ -41,23 +41,23 @@ interpreter from the AEDT installation.

#. Close the PyAEDT console.

#. In AEDT, select **Tools > Toolkit > Update Menu** to update the **Toolkit** menu.
#. In AEDT, select **Tools > ToolkitBackend > Update Menu** to update the **ToolkitBackend** menu.

#. Select **Tools > Toolkit > PersonalLib > TemplateToolkit > Run PyAEDT Toolkit Script** to open the
Magnet Segmentation Toolkit Wizard in AEDT:
#. Select **Tools > ToolkitBackend > PersonalLib > TemplateToolkit > Run PyAEDT ToolkitBackend Script** to open the
Magnet Segmentation ToolkitBackend Wizard in AEDT:

.. image:: ./_static/design_connected.png
:width: 800
:alt: UI opened from AEDT, design tab

The wizard is connected directly to the AEDT session. For wizard usage information, see :doc:`Toolkit/ui`.
The wizard is connected directly to the AEDT session. For wizard usage information, see :doc:`ToolkitBackend/ui`.

.. _install_toolkit_console_ui:

How to install from the AEDT console and launch as a wizard
-----------------------------------------------------------

You can install the Magnet Segmentation Toolkit in a specific Python environment from the
You can install the Magnet Segmentation ToolkitBackend in a specific Python environment from the
AEDT console.

- If you have an existing virtual environment, skip step 1.
Expand Down Expand Up @@ -85,20 +85,20 @@ AEDT console.

python -m pip install git+https://github.com/ansys/magnet-segmentation-toolkit.git

#. Launch the Magnet Segmentation Toolkit Wizard:
#. Launch the Magnet Segmentation ToolkitBackend Wizard:

.. code:: bash

python .venv\Lib\site-packages\ansys\aedt\toolkits\magnet_segmentation\run_toolkit.py

For wizard usage information, see :doc:`Toolkit/ui`.
For wizard usage information, see :doc:`ToolkitBackend/ui`.

.. _install_toolkit_console_api:

How to install from a Python console and use the toolkit's APIs
---------------------------------------------------------------

You can install the Magnet Segmentation Toolkit in a specific Python environment from a Python
You can install the Magnet Segmentation ToolkitBackend in a specific Python environment from a Python
console and then use this toolkit's APIs.

.. note::
Expand All @@ -123,19 +123,19 @@ console and then use this toolkit's APIs.
import os

# Import backend services
from ansys.aedt.toolkits.magnet_segmentation.backend.api import Toolkit
from ansys.aedt.toolkits.magnet_segmentation.backend.api import ToolkitBackend

# Backend object
toolkit = Toolkit()
toolkit = ToolkitBackend()

# Get service properties
properties = toolkit.get_properties()

# Define properties

properties["active_project"] = active_project
properties["active_design"] = {"Maxwell3d": active_design}
properties["designs_by_project_name"] = {active_project: [{"Maxwell3d": active_design}]}
properties["active_design"] = active_design
properties["design_list"] = {active_project: [active_design]}
properties["is_skewed"] = False
properties["motor_type"] = "IPM"
properties["rotor_material"] = "M250-35A_20C"
Expand All @@ -149,8 +149,10 @@ console and then use this toolkit's APIs.
# Set service properties
toolkit.set_properties(properties)

# Launch AEDT
# Launch AEDT, open project and connect to Maxwell3d design
toolkit.launch_aedt()
toolkit.open_project(aedt_file)
toolkit.connect_design("Maxwell3D")

# Wait for the toolkit thread to be idle and ready to accept a new task
toolkit.wait_to_be_idle()
Expand All @@ -164,4 +166,4 @@ console and then use this toolkit's APIs.
# Release AEDT
service.release_aedt()

For descriptions of the APIs available for the Magnet Segmentation Toolkit, see :doc:`Toolkit/index`.
For descriptions of the APIs available for the Magnet Segmentation ToolkitBackend, see :doc:`ToolkitBackend/index`.
27 changes: 18 additions & 9 deletions doc/source/Toolkit/api.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Toolkit API
ToolkitBackend API

Check warning on line 1 in doc/source/Toolkit/api.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/Toolkit/api.rst#L1

[Google.Headings] 'ToolkitBackend API' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'ToolkitBackend API' should use sentence-style capitalization.", "location": {"path": "doc/source/Toolkit/api.rst", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
===========
The Toolkit API contains the ``Toolkit`` class, which provides methods for
The ToolkitBackend API contains the ``ToolkitBackend`` class, which provides methods for
controlling the toolkit workflow. In addition to methods for creating an AEDT
session or connecting to an existing AEDT session, this API provides methods for
automating the segmentation and skew of a 3D motor.
Expand All @@ -17,28 +17,37 @@
.. autosummary::
:toctree: _autosummary

Toolkit
ToolkitBackend

This code shows how to use the ``Toolkit`` class:
This code shows how to use the ``ToolkitBackend`` class:

.. code:: python

# Import required modules and backend
from ansys.aedt.toolkits.magnet_segmentation.backend.api import Toolkit
from ansys.aedt.toolkits.magnet_segmentation.backend.api import ToolkitBackend

# Initialize generic service
toolkit = Toolkit()
toolkit = ToolkitBackend()

# Get the default properties loaded from JSON file
properties = toolkit.get_properties()

# Set properties
new_properties = {"aedt_version": "2023.2"}
aedt_file = os.path.join(common_temp_dir, "input_data", f"{PROJECT_NAME}.aedt")
new_properties = {
"aedt_version": "2024.1",
"non_graphical": True,
"active_project": aedt_file,
"active_design": DESIGN_NAME,
"design_list": {PROJECT_NAME: [DESIGN_NAME]},
"use_grpc": config["use_grpc"],
}
toolkit.set_properties(new_properties)
properties = toolkit.get_properties()

# Launch AEDT
# Launch AEDT and open project
msg = toolkit.launch_aedt()
toolkit.open_project(aedt_file)
toolkit.connect_design("Maxwell3D")

# Wait for the toolkit thread to be idle
toolkit.wait_to_be_idle()
Expand Down
43 changes: 0 additions & 43 deletions doc/source/Toolkit/common_api.rst

This file was deleted.

11 changes: 3 additions & 8 deletions doc/source/Toolkit/index.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.. _toolkit_API_ref:

=============
API reference

Check warning on line 4 in doc/source/Toolkit/index.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/Toolkit/index.rst#L4

[Google.Headings] 'API reference' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'API reference' should use sentence-style capitalization.", "location": {"path": "doc/source/Toolkit/index.rst", "range": {"start": {"line": 4, "column": 1}}}, "severity": "WARNING"}
=============

This section provides descriptions of the two APIs available for the Magnet
Segmentation Toolkit:
This section provides descriptions of the available API for the Magnet
Segmentation ToolkitBackend:

- **Toolkit API**: Contains the ``Toolkit`` class, which provides methods for
- **ToolkitBackend API**: Contains the ``ToolkitBackend`` class, which provides methods for
controlling the toolkit workflow. In addition to methods for creating an AEDT
session or connecting to an existing AEDT session, this API provides methods
for automating the segmentation and skew of a 3D motor.
Expand All @@ -19,12 +19,7 @@
- For segmentation, ``SymmetryFactor`` and ``HalfAxial`` design settings must be defined.
- For skew, ``Shaft`` must be the name of the shaft.

- **AEDT Common Toolkit API**: Contains the ``AEDTCommonToolkit`` class, which provides basic
functions for controlling AEDT that are shared between the backend and frontend.
These functions are the same for all AEDT toolkits.

.. toctree::
:maxdepth: 2

api
common_api
Loading
Loading