35
35
)
36
36
from ansys .geometry .core .connection .product_instance import prepare_and_start_backend
37
37
from ansys .geometry .core .logger import LOG
38
- from ansys .geometry .core .misc .checks import check_type
38
+ from ansys .geometry .core .misc .checks import check_type , deprecated_argument
39
39
40
40
try :
41
41
import ansys .platform .instancemanagement as pypim
@@ -488,8 +488,9 @@ def launch_modeler_with_spaceclaim_and_pimlight(
488
488
)
489
489
490
490
491
+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
491
492
def launch_modeler_with_geometry_service (
492
- product_version : int = None ,
493
+ version : str | int | None = None ,
493
494
host : str = "localhost" ,
494
495
port : int = None ,
495
496
enable_trace : bool = False ,
@@ -498,6 +499,7 @@ def launch_modeler_with_geometry_service(
498
499
client_log_level : int = logging .INFO ,
499
500
server_logs_folder : str = None ,
500
501
client_log_file : str = None ,
502
+ product_version : int = None , # DEPRECATED: use `version` instead
501
503
** kwargs : dict | None ,
502
504
) -> "Modeler" :
503
505
"""Start the Geometry service locally using the ``ProductInstance`` class.
@@ -509,7 +511,7 @@ def launch_modeler_with_geometry_service(
509
511
510
512
Parameters
511
513
----------
512
- product_version: int, optional
514
+ version: str | int, optional
513
515
The product version to be started. Goes from v24.1 to
514
516
the latest. Default is ``None``.
515
517
If a specific product version is requested but not installed locally,
@@ -547,6 +549,8 @@ def launch_modeler_with_geometry_service(
547
549
client_log_file : str, optional
548
550
Sets the client's log file path. If nothing is defined,
549
551
the client will log to the console.
552
+ product_version: int, optional
553
+ The product version to be started. Deprecated, use `version` instead.
550
554
**kwargs : dict, default: None
551
555
Placeholder to prevent errors when passing additional arguments that
552
556
are not compatible with this method.
@@ -599,7 +603,7 @@ def launch_modeler_with_geometry_service(
599
603
600
604
return prepare_and_start_backend (
601
605
BackendType .WINDOWS_SERVICE ,
602
- product_version = product_version ,
606
+ version = version ,
603
607
host = host ,
604
608
port = port ,
605
609
enable_trace = enable_trace ,
@@ -609,11 +613,13 @@ def launch_modeler_with_geometry_service(
609
613
client_log_level = client_log_level ,
610
614
server_logs_folder = server_logs_folder ,
611
615
client_log_file = client_log_file ,
616
+ product_version = product_version ,
612
617
)
613
618
614
619
620
+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
615
621
def launch_modeler_with_discovery (
616
- product_version : int = None ,
622
+ version : str | int | None = None ,
617
623
host : str = "localhost" ,
618
624
port : int = None ,
619
625
api_version : ApiVersions = ApiVersions .LATEST ,
@@ -623,6 +629,7 @@ def launch_modeler_with_discovery(
623
629
server_log_level : int = 2 ,
624
630
client_log_level : int = logging .INFO ,
625
631
client_log_file : str = None ,
632
+ product_version : int = None , # DEPRECATED: use `version` instead
626
633
** kwargs : dict | None ,
627
634
):
628
635
"""Start Ansys Discovery locally using the ``ProductInstance`` class.
@@ -634,7 +641,7 @@ def launch_modeler_with_discovery(
634
641
635
642
Parameters
636
643
----------
637
- product_version: int, optional
644
+ version: str | int, optional
638
645
The product version to be started. Goes from v24.1 to
639
646
the latest. Default is ``None``.
640
647
If a specific product version is requested but not installed locally,
@@ -674,6 +681,8 @@ def launch_modeler_with_discovery(
674
681
client_log_file : str, optional
675
682
Sets the client's log file path. If nothing is defined,
676
683
the client will log to the console.
684
+ product_version: int, optional
685
+ The product version to be started. Deprecated, use `version` instead.
677
686
**kwargs : dict, default: None
678
687
Placeholder to prevent errors when passing additional arguments that
679
688
are not compatible with this method.
@@ -720,7 +729,7 @@ def launch_modeler_with_discovery(
720
729
721
730
return prepare_and_start_backend (
722
731
BackendType .DISCOVERY ,
723
- product_version = product_version ,
732
+ version = version ,
724
733
host = host ,
725
734
port = port ,
726
735
enable_trace = False ,
@@ -731,11 +740,13 @@ def launch_modeler_with_discovery(
731
740
server_log_level = server_log_level ,
732
741
client_log_level = client_log_level ,
733
742
client_log_file = client_log_file ,
743
+ product_version = product_version ,
734
744
)
735
745
736
746
747
+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
737
748
def launch_modeler_with_spaceclaim (
738
- product_version : int = None ,
749
+ version : str | int | None = None ,
739
750
host : str = "localhost" ,
740
751
port : int = None ,
741
752
api_version : ApiVersions = ApiVersions .LATEST ,
@@ -745,6 +756,7 @@ def launch_modeler_with_spaceclaim(
745
756
server_log_level : int = 2 ,
746
757
client_log_level : int = logging .INFO ,
747
758
client_log_file : str = None ,
759
+ product_version : int = None , # DEPRECATED: use `version` instead
748
760
** kwargs : dict | None ,
749
761
):
750
762
"""Start Ansys SpaceClaim locally using the ``ProductInstance`` class.
@@ -756,7 +768,7 @@ def launch_modeler_with_spaceclaim(
756
768
757
769
Parameters
758
770
----------
759
- product_version: int, optional
771
+ version: str | int, optional
760
772
The product version to be started. Goes from v24.1 to
761
773
the latest. Default is ``None``.
762
774
If a specific product version is requested but not installed locally,
@@ -796,6 +808,8 @@ def launch_modeler_with_spaceclaim(
796
808
client_log_file : str, optional
797
809
Sets the client's log file path. If nothing is defined,
798
810
the client will log to the console.
811
+ product_version: int, optional
812
+ The product version to be started. Deprecated, use `version` instead.
799
813
**kwargs : dict, default: None
800
814
Placeholder to prevent errors when passing additional arguments that
801
815
are not compatible with this method.
@@ -842,7 +856,7 @@ def launch_modeler_with_spaceclaim(
842
856
843
857
return prepare_and_start_backend (
844
858
BackendType .SPACECLAIM ,
845
- product_version = product_version ,
859
+ version = version ,
846
860
host = host ,
847
861
port = port ,
848
862
enable_trace = False ,
@@ -853,103 +867,13 @@ def launch_modeler_with_spaceclaim(
853
867
server_log_level = server_log_level ,
854
868
client_log_level = client_log_level ,
855
869
client_log_file = client_log_file ,
870
+ product_version = product_version ,
856
871
)
857
872
858
873
859
- def _launch_pim_instance (
860
- is_pim_light : bool ,
861
- product_name : str ,
862
- product_platform : str | None = None ,
863
- product_version : str | None = None ,
864
- client_log_level : int = logging .INFO ,
865
- client_log_file : str | None = None ,
866
- ):
867
- """
868
- Start `PyPIM <https://github.com/ansys/pypim>`_ using the PIM API.
869
-
870
- When calling this method, you must ensure that you are in an
871
- environment where PyPIM is configured. You can use the
872
- :func:`pypim.is_configured <ansys.platform.instancemanagement.is_configured>`
873
- method to check if it is configured.
874
-
875
- Parameters
876
- ----------
877
- is_pim_light : bool
878
- Whether PIM Light is being used. For example, whether PIM is
879
- running on a local machine.
880
- product_name : str
881
- Name of the service to run.
882
- product_platform : str, default: None
883
- Platform on which the service will run. **Specific for Ansys Lab**.
884
- This parameter is used to specify the operating system on which the
885
- Geometry service will run. The possible values are:
886
-
887
- * ``"windows"``: The Geometry service runs on a Windows machine.
888
- * ``"linux"``: The Geometry service runs on a Linux machine.
889
-
890
- product_version : str, default: None
891
- Version of the service to run.
892
- client_log_level : int, default: logging.INFO
893
- Log level for the client. The default is ``logging.INFO``.
894
- client_log_file : str, default: None
895
- Path to the log file for the client. The default is ``None``,
896
- in which case the client logs to the console.
897
-
898
- Returns
899
- -------
900
- ansys.geometry.core.modeler.Modeler
901
- Instance of the Geometry service.
902
- """
903
- from ansys .geometry .core .modeler import Modeler
904
-
905
- check_type (product_version , (type (None ), str ))
906
-
907
- if not _HAS_PIM : # pragma: no cover
908
- raise ModuleNotFoundError (
909
- "The package 'ansys-platform-instancemanagement' is required to use this function."
910
- )
911
-
912
- # Platform is used mostly for Ansys Lab purposes. If product_version is defined, use it.
913
- # Higher priority is given to product_version.
914
- if product_platform : # pragma: no cover
915
- if product_version :
916
- LOG .warning (
917
- "The 'product_platform' parameter is not used when 'product_version' is defined."
918
- )
919
- else :
920
- product_version = product_platform
921
-
922
- # If PIM Light is being used and PyPIM configuration is not defined... use defaults.
923
- if is_pim_light and not os .environ .get ("ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" , None ):
924
- os .environ ["ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" ] = pygeom_defaults .DEFAULT_PIM_CONFIG
925
- pop_out = True
926
- else :
927
- pop_out = False
928
-
929
- # Perform PyPIM connection
930
- pim = pypim .connect ()
931
- instance = pim .create_instance (product_name = product_name , product_version = product_version )
932
- instance .wait_for_ready ()
933
- channel = instance .build_grpc_channel (
934
- options = [
935
- ("grpc.max_receive_message_length" , pygeom_defaults .MAX_MESSAGE_LENGTH ),
936
- ]
937
- )
938
-
939
- # If the default PyPIM configuration was used... remove
940
- if pop_out :
941
- os .environ .pop ("ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" )
942
-
943
- return Modeler (
944
- channel = channel ,
945
- remote_instance = instance ,
946
- logging_level = client_log_level ,
947
- logging_file = client_log_file ,
948
- )
949
-
950
-
874
+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
951
875
def launch_modeler_with_core_service (
952
- product_version : int = None ,
876
+ version : str | int | None = None ,
953
877
host : str = "localhost" ,
954
878
port : int = None ,
955
879
enable_trace : bool = False ,
@@ -958,6 +882,7 @@ def launch_modeler_with_core_service(
958
882
client_log_level : int = logging .INFO ,
959
883
server_logs_folder : str = None ,
960
884
client_log_file : str = None ,
885
+ product_version : int = None , # DEPRECATED: use `version` instead
961
886
** kwargs : dict | None ,
962
887
) -> "Modeler" :
963
888
"""Start the Geometry Core service locally using the ``ProductInstance`` class.
@@ -969,7 +894,7 @@ def launch_modeler_with_core_service(
969
894
970
895
Parameters
971
896
----------
972
- product_version: int, optional
897
+ version: str | int, optional
973
898
The product version to be started. Goes from v25.2 to
974
899
the latest. Default is ``None``.
975
900
If a specific product version is requested but not installed locally,
@@ -1007,6 +932,8 @@ def launch_modeler_with_core_service(
1007
932
client_log_file : str, optional
1008
933
Sets the client's log file path. If nothing is defined,
1009
934
the client will log to the console.
935
+ product_version: int, optional
936
+ The product version to be started. Deprecated, use `version` instead.
1010
937
**kwargs : dict, default: None
1011
938
Placeholder to prevent errors when passing additional arguments that
1012
939
are not compatible with this method.
@@ -1059,7 +986,7 @@ def launch_modeler_with_core_service(
1059
986
1060
987
return prepare_and_start_backend (
1061
988
BackendType .LINUX_SERVICE ,
1062
- product_version = product_version ,
989
+ version = version ,
1063
990
host = host ,
1064
991
port = port ,
1065
992
enable_trace = enable_trace ,
@@ -1070,4 +997,97 @@ def launch_modeler_with_core_service(
1070
997
server_logs_folder = server_logs_folder ,
1071
998
client_log_file = client_log_file ,
1072
999
specific_minimum_version = 252 ,
1000
+ product_version = product_version ,
1001
+ )
1002
+
1003
+
1004
+ def _launch_pim_instance (
1005
+ is_pim_light : bool ,
1006
+ product_name : str ,
1007
+ product_platform : str | None = None ,
1008
+ product_version : str | None = None ,
1009
+ client_log_level : int = logging .INFO ,
1010
+ client_log_file : str | None = None ,
1011
+ ):
1012
+ """
1013
+ Start `PyPIM <https://github.com/ansys/pypim>`_ using the PIM API.
1014
+
1015
+ When calling this method, you must ensure that you are in an
1016
+ environment where PyPIM is configured. You can use the
1017
+ :func:`pypim.is_configured <ansys.platform.instancemanagement.is_configured>`
1018
+ method to check if it is configured.
1019
+
1020
+ Parameters
1021
+ ----------
1022
+ is_pim_light : bool
1023
+ Whether PIM Light is being used. For example, whether PIM is
1024
+ running on a local machine.
1025
+ product_name : str
1026
+ Name of the service to run.
1027
+ product_platform : str, default: None
1028
+ Platform on which the service will run. **Specific for Ansys Lab**.
1029
+ This parameter is used to specify the operating system on which the
1030
+ Geometry service will run. The possible values are:
1031
+
1032
+ * ``"windows"``: The Geometry service runs on a Windows machine.
1033
+ * ``"linux"``: The Geometry service runs on a Linux machine.
1034
+
1035
+ product_version : str, default: None
1036
+ Version of the service to run.
1037
+ client_log_level : int, default: logging.INFO
1038
+ Log level for the client. The default is ``logging.INFO``.
1039
+ client_log_file : str, default: None
1040
+ Path to the log file for the client. The default is ``None``,
1041
+ in which case the client logs to the console.
1042
+
1043
+ Returns
1044
+ -------
1045
+ ansys.geometry.core.modeler.Modeler
1046
+ Instance of the Geometry service.
1047
+ """
1048
+ from ansys .geometry .core .modeler import Modeler
1049
+
1050
+ check_type (product_version , (type (None ), str ))
1051
+
1052
+ if not _HAS_PIM : # pragma: no cover
1053
+ raise ModuleNotFoundError (
1054
+ "The package 'ansys-platform-instancemanagement' is required to use this function."
1055
+ )
1056
+
1057
+ # Platform is used mostly for Ansys Lab purposes. If product_version is defined, use it.
1058
+ # Higher priority is given to product_version.
1059
+ if product_platform : # pragma: no cover
1060
+ if product_version :
1061
+ LOG .warning (
1062
+ "The 'product_platform' parameter is not used when 'product_version' is defined."
1063
+ )
1064
+ else :
1065
+ product_version = product_platform
1066
+
1067
+ # If PIM Light is being used and PyPIM configuration is not defined... use defaults.
1068
+ if is_pim_light and not os .environ .get ("ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" , None ):
1069
+ os .environ ["ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" ] = pygeom_defaults .DEFAULT_PIM_CONFIG
1070
+ pop_out = True
1071
+ else :
1072
+ pop_out = False
1073
+
1074
+ # Perform PyPIM connection
1075
+ pim = pypim .connect ()
1076
+ instance = pim .create_instance (product_name = product_name , product_version = product_version )
1077
+ instance .wait_for_ready ()
1078
+ channel = instance .build_grpc_channel (
1079
+ options = [
1080
+ ("grpc.max_receive_message_length" , pygeom_defaults .MAX_MESSAGE_LENGTH ),
1081
+ ]
1082
+ )
1083
+
1084
+ # If the default PyPIM configuration was used... remove
1085
+ if pop_out :
1086
+ os .environ .pop ("ANSYS_PLATFORM_INSTANCEMANAGEMENT_CONFIG" )
1087
+
1088
+ return Modeler (
1089
+ channel = channel ,
1090
+ remote_instance = instance ,
1091
+ logging_level = client_log_level ,
1092
+ logging_file = client_log_file ,
1073
1093
)
0 commit comments