diff --git a/.github/workflows/ironpython.yml b/.github/workflows/ironpython.yml index 7bda69df44c..1f5a4bf3c1b 100644 --- a/.github/workflows/ironpython.yml +++ b/.github/workflows/ironpython.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v2 - name: 'Run Unit Tests in Ironpython' - timeout-minutes: 40 + timeout-minutes: 45 run: | $process = start-process 'cmd' -ArgumentList '/c .\_unittest_ironpython\run_unittests_batchmode.cmd' -PassThru diff --git a/.github/workflows/ironpython_linux.yml b/.github/workflows/ironpython_linux.yml index 683d4c6f728..9c686a4e6ed 100644 --- a/.github/workflows/ironpython_linux.yml +++ b/.github/workflows/ironpython_linux.yml @@ -31,7 +31,7 @@ jobs: run: | export DISPLAY="127.0.0.1:1" chmod 777 _unittest_ironpython/run_unittests_batchmode_linux.cmd - timeout -k 2400s 2400s ./_unittest_ironpython/run_unittests_batchmode_linux.cmd + timeout -k 3600s 3600s ./_unittest_ironpython/run_unittests_batchmode_linux.cmd if [ $? -eq 124 ] ; then echo "ERROR: Timeout while waiting for the file _unittest_ironpython/tests_succeeded.log." exit 1 diff --git a/_unittest/conftest.py b/_unittest/conftest.py index 7862dc70866..e7fd3f83dd7 100644 --- a/_unittest/conftest.py +++ b/_unittest/conftest.py @@ -68,7 +68,7 @@ with open(local_config_file) as f: config = json.load(f) else: - default_version = "2022.1" + default_version = "2022.2" if inside_desktop and "oDesktop" in dir(sys.modules["__main__"]): default_version = sys.modules["__main__"].oDesktop.GetVersion()[0:6] config = { diff --git a/_unittest/test_00_grpc.py b/_unittest/test_00_grpc.py index 492257b8abc..8d16a036e39 100644 --- a/_unittest/test_00_grpc.py +++ b/_unittest/test_00_grpc.py @@ -13,7 +13,7 @@ test_project_name = "Coax_HFSS" -if not is_ironpython and config["desktopVersion"] >= "2022.2": +if not is_ironpython and config["desktopVersion"] >= "2023.1": class TestClass(BasisTest, object): def setup_class(self): @@ -21,6 +21,7 @@ def setup_class(self): def teardown_class(self): settings.use_grpc_api = config["use_grpc"] + settings.non_graphical = config["NonGraphical"] def test_00_destkop(self): d = Desktop(specified_version="2022.2", new_desktop_session=True) @@ -33,7 +34,7 @@ def test_01_destkop_existing(self): d.release_desktop(False, False) def test_02_destkop_new(self): - d = Desktop(specified_version="2022.2", new_desktop_session=True) + d = Desktop(specified_version="2022.2", new_desktop_session=True, non_graphical=True) assert d.port in grpc_active_sessions() d.release_desktop(False, False) diff --git a/_unittest/test_02_2D_modeler.py b/_unittest/test_02_2D_modeler.py index c45ffe16a69..b1fd94d404b 100644 --- a/_unittest/test_02_2D_modeler.py +++ b/_unittest/test_02_2D_modeler.py @@ -3,7 +3,6 @@ import os from _unittest.conftest import BasisTest -from _unittest.conftest import config from pyaedt.generic.general_methods import is_ironpython from pyaedt.generic.general_methods import isclose from pyaedt.maxwell import Maxwell2d @@ -129,7 +128,7 @@ def test_08_create_regular_polygon(self): assert pg2.material_name == "copper" assert isclose(pg2.faces[0].area, 5.196152422706631) - @pytest.mark.skipif(config["NonGraphical"] or is_ironpython, reason="Not running in ironpython") + @pytest.mark.skipif(is_ironpython, reason="Not running in ironpython") def test_09_plot(self): self.aedtapp.modeler.create_regular_polygon([0, 0, 0], [0, 0, 2]) self.aedtapp.modeler.create_regular_polygon( diff --git a/_unittest/test_12_PostProcessing.py b/_unittest/test_12_PostProcessing.py index 1fb7fe6d336..3787e74e352 100644 --- a/_unittest/test_12_PostProcessing.py +++ b/_unittest/test_12_PostProcessing.py @@ -416,18 +416,18 @@ def test_09d_create_monitor(self): # pragma: no cover assert new_report.add_cartesian_y_marker("-55") @pytest.mark.skipif( - config["NonGraphical"], reason="Skipped because it cannot run on build machine in non-graphical mode" + config["desktopVersion"] < "2022.2", + reason="Skipped because it cannot run on build machine in non-graphical mode", ) def test_09e_add_line_from_point(self): # pragma: no cover - assert self.aedtapp.post.create_report("dB(S(1,1))") new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") + assert new_report.create() assert new_report.add_limit_line_from_points([3, 5, 5, 3], [-50, -50, -60, -60], "GHz") @pytest.mark.skipif( config["desktopVersion"] < "2022.2", reason="Not working in non-graphical mode in version earlier than 2022.2." ) def test_09f_add_line_from_equation(self): - assert self.aedtapp.post.create_report("dB(S(1,1))") new_report = self.aedtapp.post.reports_by_category.modal_solution("dB(S(1,1))") assert new_report.create() assert new_report.add_limit_line_from_equation(start_x=1, stop_x=20, step=0.5, units="GHz") @@ -862,13 +862,13 @@ def test_66_spectral_from_json(self): local_path = os.path.dirname(os.path.realpath(__file__)) self.circuit_test.analyze_setup("Transient") assert self.circuit_test.post.create_report_from_configuration( - os.path.join(local_path, "example_models", "report_json", "Spectral_Report_simple.json"), + os.path.join(local_path, "example_models", "report_json", "Spectral_Report_Simple.json"), solution_name="Transient", ) def test_67_sweep_from_json(self): local_path = os.path.dirname(os.path.realpath(__file__)) - dict_vals = json_to_dict(os.path.join(local_path, "example_models", "report_json", "Modal_Report_simple.json")) + dict_vals = json_to_dict(os.path.join(local_path, "example_models", "report_json", "Modal_Report_Simple.json")) assert self.aedtapp.post.create_report_from_configuration(input_dict=dict_vals) @pytest.mark.skipif( diff --git a/_unittest/test_20_HFSS.py b/_unittest/test_20_HFSS.py index 2f04dcc7628..082f7e0c4c9 100644 --- a/_unittest/test_20_HFSS.py +++ b/_unittest/test_20_HFSS.py @@ -949,10 +949,11 @@ def test_50_set_differential_pair(self): hfss2.close_project() @pytest.mark.skipif( - config["desktopVersion"] < "2022.2", reason="Not working in non-graphical in version lower than 2022.2" + is_ironpython or config["desktopVersion"] < "2022.2", + reason="Not working in non-graphical in version lower than 2022.2", ) def test_51_array(self): - self.aedtapp.insert_design("Array_simple") + self.aedtapp.insert_design("Array_simple", "Modal") from pyaedt.generic.DataHandlers import json_to_dict dict_in = json_to_dict(os.path.join(local_path, "example_models", "array_simple.json")) diff --git a/_unittest/test_26_emit.py b/_unittest/test_26_emit.py index 038a5c96b06..55230d0b572 100644 --- a/_unittest/test_26_emit.py +++ b/_unittest/test_26_emit.py @@ -1,6 +1,7 @@ # Import required modules from _unittest.conftest import BasisTest from _unittest.conftest import config +from _unittest.conftest import is_ironpython from pyaedt import Emit from pyaedt.modeler.PrimitivesEmit import EmitComponent from pyaedt.modeler.PrimitivesEmit import EmitComponents @@ -27,7 +28,9 @@ def test_objects(self): assert self.aedtapp.modeler assert self.aedtapp.oanalysis is None - @pytest.mark.skipif(config["NonGraphical"], reason="Not functional in non-graphical mode") + @pytest.mark.skipif( + config["desktopVersion"] <= "2022.1" or is_ironpython, reason="Skipped on versions lower than 2021.2" + ) def test_create_components(self): radio = self.aedtapp.modeler.components.create_component("New Radio", "TestRadio") assert radio.name == "TestRadio" @@ -36,8 +39,9 @@ def test_create_components(self): assert antenna.name == "TestAntenna" assert isinstance(antenna, EmitComponent) - @pytest.mark.skipif(config["NonGraphical"], reason="Not functional in non-graphical mode") - @pytest.mark.skipif(config["desktopVersion"] < "2021.2", reason="Skipped on versions lower than 2021.2") + @pytest.mark.skipif( + config["desktopVersion"] <= "2022.1" or is_ironpython, reason="Skipped on versions lower than 2021.2" + ) def test_connect_components(self): radio = self.aedtapp.modeler.components.create_component("New Radio") antenna = self.aedtapp.modeler.components.create_component("Antenna") @@ -54,7 +58,9 @@ def test_connect_components(self): assert connected_comp is None assert connected_port is None - @pytest.mark.skipif(config["NonGraphical"], reason="Not functional in non-graphical mode") + @pytest.mark.skipif( + config["desktopVersion"] <= "2022.1" or is_ironpython, reason="Skipped on versions lower than 2021.2" + ) def test_radio_component(self): radio = self.aedtapp.modeler.components.create_component("New Radio") # default radio has 1 Tx channel and 1 Rx channel @@ -67,8 +73,9 @@ def test_radio_component(self): band.enabled = False assert not band.enabled - @pytest.mark.skipif(config["NonGraphical"], reason="Not functional in non-graphical mode") - @pytest.mark.skipif(config["desktopVersion"] < "2021.2", reason="Skipped on versions lower than 2021.2") + @pytest.mark.skipif( + config["desktopVersion"] <= "2022.1" or is_ironpython, reason="Skipped on versions lower than 2021.2" + ) def test_couplings(self): self.aedtapp = BasisTest.add_app(self, project_name="Cell Phone RFI Desense", application=Emit) links = self.aedtapp.couplings.linkable_design_names diff --git a/_unittest/test_41_3dlayout_modeler.py b/_unittest/test_41_3dlayout_modeler.py index 18e19dd53f4..a03a6e81a1c 100644 --- a/_unittest/test_41_3dlayout_modeler.py +++ b/_unittest/test_41_3dlayout_modeler.py @@ -481,6 +481,7 @@ def test_36_import_gds(self): assert self.aedtapp.import_gds(gds_file, aedb_path=aedb_file, control_file=control_file) assert self.aedtapp.import_gds(gds_file, aedb_path=aedb_file, control_file=control_file) + @pytest.mark.skipif(os.name == "posix", reason="Failing on linux") def test_37_import_gerber(self): gerber_file = os.path.join(local_path, "example_models", "cad", "Gerber", "gerber1.zip") control_file = os.path.join(local_path, "example_models", "cad", "Gerber", "gerber1.xml") @@ -501,7 +502,6 @@ def test_39_import_ipc(self): @pytest.mark.skipif(config["desktopVersion"] < "2022.2", reason="Not working on AEDT 22R1") def test_40_test_flex(self): assert self.flex.enable_rigid_flex() - assert not self.flex.enable_rigid_flex() pass @pytest.mark.skipif(os.name == "posix", reason="Bug on linux") diff --git a/_unittest_ironpython/run_unittests.py b/_unittest_ironpython/run_unittests.py index da1bb2bad23..e98dfaaa5a3 100644 --- a/_unittest_ironpython/run_unittests.py +++ b/_unittest_ironpython/run_unittests.py @@ -19,7 +19,7 @@ if os.name != "posix": ansysem_install_dir = os.environ.get("ANSYSEM_INSTALL_DIR", "") if not ansysem_install_dir: - ansysem_install_dir = os.environ["ANSYSEM_ROOT221"] + ansysem_install_dir = os.environ["ANSYSEM_ROOT222"] sys.path.append(os.path.join(ansysem_install_dir, "PythonFiles", "DesktopPlugin")) path_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..") sys.path.append(path_dir) diff --git a/_unittest_ironpython/run_unittests_batchmode.cmd b/_unittest_ironpython/run_unittests_batchmode.cmd index 293eac7f39a..e86d21b303a 100644 --- a/_unittest_ironpython/run_unittests_batchmode.cmd +++ b/_unittest_ironpython/run_unittests_batchmode.cmd @@ -2,4 +2,4 @@ set ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1 set ANSYSEM_FEATURE_SF159726_SCRIPTOBJECT_ENABLE=1 set RUN_UNITTESTS_ARGS=%* set ANSYSEM_INSTALL_DIR=%ANSYSEM_ROOT221% -"%ANSYSEM_ROOT221%\ansysedt.exe" -ng -RunScriptAndExit "_unittest_ironpython\run_unittests.py" \ No newline at end of file +"%ANSYSEM_ROOT222%\ansysedt.exe" -ng -RunScriptAndExit "_unittest_ironpython\run_unittests.py" \ No newline at end of file diff --git a/_unittest_ironpython/run_unittests_batchmode_linux.cmd b/_unittest_ironpython/run_unittests_batchmode_linux.cmd index 1da14a6d8c2..a215deea27c 100644 --- a/_unittest_ironpython/run_unittests_batchmode_linux.cmd +++ b/_unittest_ironpython/run_unittests_batchmode_linux.cmd @@ -1,3 +1,3 @@ cd /apps/actions-runner/_work/pyaedt/pyaedt -/apps/AnsysEM/v221/Linux64/ansysedt -features=SF159726_SCRIPTOBJECT,SF6694_NON_GRAPHICAL_COMMAND_EXECUTION -RunScriptAndExit _unittest_ironpython/run_unittests.py +/apps/AnsysEM/v222/Linux64/ansysedt -features=SF159726_SCRIPTOBJECT,SF6694_NON_GRAPHICAL_COMMAND_EXECUTION -RunScriptAndExit _unittest_ironpython/run_unittests.py echo "INFO: Finished" \ No newline at end of file diff --git a/pyaedt/application/Design.py b/pyaedt/application/Design.py index 8de0c4ece05..9f37dd7efff 100644 --- a/pyaedt/application/Design.py +++ b/pyaedt/application/Design.py @@ -3281,7 +3281,7 @@ def get_evaluated_value(self, variable_name, units=None): else: var_obj = self.get_oo_object(app, "Variables/{}".format(variable_name)) if var_obj: - if is_ironpython: # pragma: no cover + if is_ironpython or settings.use_grpc_api: # pragma: no cover val = var_obj.Get_SIValue() else: val = var_obj.Get_SIValue diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index bbb2ed537a7..a1f6ee89b1d 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -170,18 +170,17 @@ def release_desktop(close_projects=True, close_desktop=True): for project in projects: desktop.CloseProject(project) pid = _main.oDesktop.GetProcessID() - if _com != "pythonnet_v3": - if settings.aedt_version >= "2022.2" and settings.use_grpc_api: - import ScriptEnv - - ScriptEnv.Release() - elif not inside_desktop: - i = 0 - scopeID = 5 - while i <= scopeID: - _main.COMUtil.ReleaseCOMObjectScope(_main.COMUtil.PInvokeProxyAPI, i) - i += 1 - _delete_objects() + if settings.aedt_version >= "2022.2" and settings.use_grpc_api and not is_ironpython: + import ScriptEnv + + ScriptEnv.Release() + elif not inside_desktop: + i = 0 + scopeID = 5 + while i <= scopeID: + _main.COMUtil.ReleaseCOMObjectScope(_main.COMUtil.PInvokeProxyAPI, i) + i += 1 + _delete_objects() if close_desktop: try: @@ -640,7 +639,7 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve launch_msg = "AEDT installation Path {}".format(base_path) self.logger.info(launch_msg) - self.logger.info("Launching AEDT with PyDesktopPlugin.") + self.logger.info("Launching AEDT with GRPC Plugin.") if ( not self.port and not new_aedt_session @@ -693,7 +692,7 @@ def _init_cpython_new(self, non_graphical, new_aedt_session, version, student_ve self.logger.info("{} Started with process ID {}.".format(version, _proc)) else: - self.logger.warning("PyDesktopPlugin is not supported in AEDT versions older than 2022.2.") + self.logger.warning("GRPC Plugin is not supported in AEDT versions older than 2022.2.") def _set_logger_file(self): # Set up the log file in the AEDT project directory diff --git a/pyaedt/hfss3dlayout.py b/pyaedt/hfss3dlayout.py index fc6314195a6..23e637bfc62 100644 --- a/pyaedt/hfss3dlayout.py +++ b/pyaedt/hfss3dlayout.py @@ -1570,7 +1570,10 @@ def enable_rigid_flex(self): ------- bool `True` if bend is enabled `False` if bend is disabled. + In Non-graphical it returns always True due to bug in native API. """ if settings.aedt_version >= "2022.2": self.modeler.oeditor.ProcessBentModelCmd() + if settings.non_graphical: + return True return True if self.variable_manager["BendModel"].expression == "1" else False diff --git a/pyaedt/modeler/Object3d.py b/pyaedt/modeler/Object3d.py index d05394574ff..fa19134389b 100644 --- a/pyaedt/modeler/Object3d.py +++ b/pyaedt/modeler/Object3d.py @@ -3492,12 +3492,17 @@ def angle(self): @angle.setter def angle(self, angle=None): """Set the part angle.""" - if not angle: - angle = str(self._angle) + "°" + if not settings.use_grpc_api: + if not angle: + angle = str(self._angle) + "°" + else: + angle = _dim_arg(angle, "°") + vMaterial = ["NAME:Component Angle", "Value:=", angle] + self.change_property(vMaterial) else: - angle = _dim_arg(angle, "°") - vMaterial = ["NAME:Component Angle", "Value:=", angle] - self.change_property(vMaterial) + self._circuit_components._app.logger.error( + "Grpc doesn't support angle settings because special characters are not supported." + ) @property def mirror(self): diff --git a/pyaedt/modeler/PrimitivesNexxim.py b/pyaedt/modeler/PrimitivesNexxim.py index 88cbed06e75..42090e1dfd3 100644 --- a/pyaedt/modeler/PrimitivesNexxim.py +++ b/pyaedt/modeler/PrimitivesNexxim.py @@ -82,7 +82,7 @@ def components_catalog(self): return self._components_catalog @pyaedt_function_handler() - def create_subcircuit(self, location=None, angle=0, name=None, nested_subcircuit_id=None): + def create_subcircuit(self, location=None, angle=None, name=None, nested_subcircuit_id=None): """Add a new Circuit subcircuit to the design. Parameters @@ -90,7 +90,7 @@ def create_subcircuit(self, location=None, angle=0, name=None, nested_subcircuit location : list of float, optional Position on the X axis and Y axis. angle : float, optional - Angle rotation in degrees. The default is ``0``. + Angle rotation in degrees. The default is ``None``. name : str, optional Name of the design. The default is ``None``, in which case a unique name is generated.