3535)
3636from ansys .geometry .core .connection .product_instance import prepare_and_start_backend
3737from 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
3939
4040try :
4141 import ansys .platform .instancemanagement as pypim
@@ -488,8 +488,9 @@ def launch_modeler_with_spaceclaim_and_pimlight(
488488 )
489489
490490
491+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
491492def launch_modeler_with_geometry_service (
492- product_version : int = None ,
493+ version : str | int | None = None ,
493494 host : str = "localhost" ,
494495 port : int = None ,
495496 enable_trace : bool = False ,
@@ -498,6 +499,7 @@ def launch_modeler_with_geometry_service(
498499 client_log_level : int = logging .INFO ,
499500 server_logs_folder : str = None ,
500501 client_log_file : str = None ,
502+ product_version : int = None , # DEPRECATED: use `version` instead
501503 ** kwargs : dict | None ,
502504) -> "Modeler" :
503505 """Start the Geometry service locally using the ``ProductInstance`` class.
@@ -509,7 +511,7 @@ def launch_modeler_with_geometry_service(
509511
510512 Parameters
511513 ----------
512- product_version: int, optional
514+ version: str | int, optional
513515 The product version to be started. Goes from v24.1 to
514516 the latest. Default is ``None``.
515517 If a specific product version is requested but not installed locally,
@@ -547,6 +549,8 @@ def launch_modeler_with_geometry_service(
547549 client_log_file : str, optional
548550 Sets the client's log file path. If nothing is defined,
549551 the client will log to the console.
552+ product_version: int, optional
553+ The product version to be started. Deprecated, use `version` instead.
550554 **kwargs : dict, default: None
551555 Placeholder to prevent errors when passing additional arguments that
552556 are not compatible with this method.
@@ -599,7 +603,7 @@ def launch_modeler_with_geometry_service(
599603
600604 return prepare_and_start_backend (
601605 BackendType .WINDOWS_SERVICE ,
602- product_version = product_version ,
606+ version = version ,
603607 host = host ,
604608 port = port ,
605609 enable_trace = enable_trace ,
@@ -609,11 +613,13 @@ def launch_modeler_with_geometry_service(
609613 client_log_level = client_log_level ,
610614 server_logs_folder = server_logs_folder ,
611615 client_log_file = client_log_file ,
616+ product_version = product_version ,
612617 )
613618
614619
620+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
615621def launch_modeler_with_discovery (
616- product_version : int = None ,
622+ version : str | int | None = None ,
617623 host : str = "localhost" ,
618624 port : int = None ,
619625 api_version : ApiVersions = ApiVersions .LATEST ,
@@ -623,6 +629,7 @@ def launch_modeler_with_discovery(
623629 server_log_level : int = 2 ,
624630 client_log_level : int = logging .INFO ,
625631 client_log_file : str = None ,
632+ product_version : int = None , # DEPRECATED: use `version` instead
626633 ** kwargs : dict | None ,
627634):
628635 """Start Ansys Discovery locally using the ``ProductInstance`` class.
@@ -634,7 +641,7 @@ def launch_modeler_with_discovery(
634641
635642 Parameters
636643 ----------
637- product_version: int, optional
644+ version: str | int, optional
638645 The product version to be started. Goes from v24.1 to
639646 the latest. Default is ``None``.
640647 If a specific product version is requested but not installed locally,
@@ -674,6 +681,8 @@ def launch_modeler_with_discovery(
674681 client_log_file : str, optional
675682 Sets the client's log file path. If nothing is defined,
676683 the client will log to the console.
684+ product_version: int, optional
685+ The product version to be started. Deprecated, use `version` instead.
677686 **kwargs : dict, default: None
678687 Placeholder to prevent errors when passing additional arguments that
679688 are not compatible with this method.
@@ -720,7 +729,7 @@ def launch_modeler_with_discovery(
720729
721730 return prepare_and_start_backend (
722731 BackendType .DISCOVERY ,
723- product_version = product_version ,
732+ version = version ,
724733 host = host ,
725734 port = port ,
726735 enable_trace = False ,
@@ -731,11 +740,13 @@ def launch_modeler_with_discovery(
731740 server_log_level = server_log_level ,
732741 client_log_level = client_log_level ,
733742 client_log_file = client_log_file ,
743+ product_version = product_version ,
734744 )
735745
736746
747+ @deprecated_argument ("product_version" , "version" , version = "0.10.8" , remove = "0.13.0" )
737748def launch_modeler_with_spaceclaim (
738- product_version : int = None ,
749+ version : str | int | None = None ,
739750 host : str = "localhost" ,
740751 port : int = None ,
741752 api_version : ApiVersions = ApiVersions .LATEST ,
@@ -745,6 +756,7 @@ def launch_modeler_with_spaceclaim(
745756 server_log_level : int = 2 ,
746757 client_log_level : int = logging .INFO ,
747758 client_log_file : str = None ,
759+ product_version : int = None , # DEPRECATED: use `version` instead
748760 ** kwargs : dict | None ,
749761):
750762 """Start Ansys SpaceClaim locally using the ``ProductInstance`` class.
@@ -756,7 +768,7 @@ def launch_modeler_with_spaceclaim(
756768
757769 Parameters
758770 ----------
759- product_version: int, optional
771+ version: str | int, optional
760772 The product version to be started. Goes from v24.1 to
761773 the latest. Default is ``None``.
762774 If a specific product version is requested but not installed locally,
@@ -796,6 +808,8 @@ def launch_modeler_with_spaceclaim(
796808 client_log_file : str, optional
797809 Sets the client's log file path. If nothing is defined,
798810 the client will log to the console.
811+ product_version: int, optional
812+ The product version to be started. Deprecated, use `version` instead.
799813 **kwargs : dict, default: None
800814 Placeholder to prevent errors when passing additional arguments that
801815 are not compatible with this method.
@@ -842,7 +856,7 @@ def launch_modeler_with_spaceclaim(
842856
843857 return prepare_and_start_backend (
844858 BackendType .SPACECLAIM ,
845- product_version = product_version ,
859+ version = version ,
846860 host = host ,
847861 port = port ,
848862 enable_trace = False ,
@@ -853,103 +867,13 @@ def launch_modeler_with_spaceclaim(
853867 server_log_level = server_log_level ,
854868 client_log_level = client_log_level ,
855869 client_log_file = client_log_file ,
870+ product_version = product_version ,
856871 )
857872
858873
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" )
951875def launch_modeler_with_core_service (
952- product_version : int = None ,
876+ version : str | int | None = None ,
953877 host : str = "localhost" ,
954878 port : int = None ,
955879 enable_trace : bool = False ,
@@ -958,6 +882,7 @@ def launch_modeler_with_core_service(
958882 client_log_level : int = logging .INFO ,
959883 server_logs_folder : str = None ,
960884 client_log_file : str = None ,
885+ product_version : int = None , # DEPRECATED: use `version` instead
961886 ** kwargs : dict | None ,
962887) -> "Modeler" :
963888 """Start the Geometry Core service locally using the ``ProductInstance`` class.
@@ -969,7 +894,7 @@ def launch_modeler_with_core_service(
969894
970895 Parameters
971896 ----------
972- product_version: int, optional
897+ version: str | int, optional
973898 The product version to be started. Goes from v25.2 to
974899 the latest. Default is ``None``.
975900 If a specific product version is requested but not installed locally,
@@ -1007,6 +932,8 @@ def launch_modeler_with_core_service(
1007932 client_log_file : str, optional
1008933 Sets the client's log file path. If nothing is defined,
1009934 the client will log to the console.
935+ product_version: int, optional
936+ The product version to be started. Deprecated, use `version` instead.
1010937 **kwargs : dict, default: None
1011938 Placeholder to prevent errors when passing additional arguments that
1012939 are not compatible with this method.
@@ -1059,7 +986,7 @@ def launch_modeler_with_core_service(
1059986
1060987 return prepare_and_start_backend (
1061988 BackendType .LINUX_SERVICE ,
1062- product_version = product_version ,
989+ version = version ,
1063990 host = host ,
1064991 port = port ,
1065992 enable_trace = enable_trace ,
@@ -1070,4 +997,97 @@ def launch_modeler_with_core_service(
1070997 server_logs_folder = server_logs_folder ,
1071998 client_log_file = client_log_file ,
1072999 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 ,
10731093 )
0 commit comments