2222
2323"""Core."""
2424
25+ from __future__ import annotations
26+
2527import logging
2628import os
27- from pathlib import Path
29+ from pathlib import Path , PurePosixPath , PureWindowsPath
2830import warnings
2931import weakref
3032
31- from ansys .dpf .core import errors , misc , server as server_module
33+ from ansys .dpf .core import AnyServerType , errors , misc , server as server_module
3234from ansys .dpf .core .check_version import server_meet_version , version_requires
3335from ansys .dpf .core .runtime_config import (
3436 RuntimeClientConfig ,
6163 CONFIGURATION = "release"
6264
6365
64- def load_library (filename , name = "" , symbol = "LoadOperators" , server = None , generate_operators = False ):
65- """Dynamically load an operators library for dpf.core.
66+ def load_library (
67+ filename : str | Path ,
68+ name : str = None ,
69+ symbol : str = "LoadOperators" ,
70+ server : AnyServerType = None ,
71+ generate_operators : bool = False ,
72+ ):
73+ """Load a DPF plugin (a binary library of operators).
6674
67- Code containing this library's operators is generated in
68- ansys. dpf. core.operators
75+ Set `generate_operators=True` to also make the operators available in the current
76+ installation of ` ansys- dpf- core`.
6977
7078 Parameters
7179 ----------
72- filename : str or os.PathLike
73- Filename of the operator library.
74-
75- name : str, optional
76- Library name. Probably optional
77-
78- server : server.DPFServer, optional
79- Server with channel connected to the remote or local instance. When
80- ``None``, attempts to use the global server.
81-
82- generate_operators : bool, optional
83- Whether operators code generation should be done or not (default is False).
80+ filename:
81+ Filename or path to the operator library.
82+ name:
83+ Name to give the plugin once loaded. Defaults to the name of the library file.
84+ symbol:
85+ The name of the entrypoint of the plugin, which is the function recording the operators.
86+ server:
87+ Server to load the plugin onto. Defaults to the global server.
88+ generate_operators:
89+ Whether to generate the Python modules for the operators of the library.
90+ This updates the ansys.dpf.core.operators package of the current installation.
8491
8592 Examples
8693 --------
@@ -385,22 +392,29 @@ def make_tmp_dir_server(self):
385392 else :
386393 return self ._api_tmp_dir .tmp_dir_get_dir ()
387394
388- def load_library (self , file_path , name = "" , symbol = "LoadOperators" , generate_operators = False ):
395+ def load_library (
396+ self ,
397+ file_path : str | Path ,
398+ name : str = None ,
399+ symbol : str = "LoadOperators" ,
400+ generate_operators : bool = False ,
401+ ):
389402 """Dynamically load an operators library for dpf.core.
390403
391404 Code containing this library's operators is generated in
392405 ansys.dpf.core.operators
393406
394407 Parameters
395408 ----------
396- file_path : str or os.PathLike
397- file_path of the operator library.
398-
399- name : str, optional
400- Library name. Probably optional
401-
402- generate_operators : bool, optional
403- Whether operators code generation should be done or not (default is False).
409+ file_path:
410+ Path to the DPF plugin file holding a library of operators.
411+ name:
412+ Name to give the plugin once loaded. Defaults to the name of the library file.
413+ symbol:
414+ The name of the entrypoint of the plugin, which is the function recording the operators.
415+ generate_operators:
416+ Whether to generate the Python modules for the operators of the library.
417+ This updates the ansys.dpf.core.operators package of the current installation.
404418
405419 Examples
406420 --------
@@ -412,7 +426,13 @@ def load_library(self, file_path, name="", symbol="LoadOperators", generate_oper
412426 >>> # base.load_library('meshOperatorsCore.dll', 'mesh_operators')
413427
414428 """
415- file_path = str (file_path )
429+ if not name :
430+ name = Path (file_path ).name
431+ file_path = str (
432+ PurePosixPath (file_path )
433+ if self .server_info ["os" ] == "posix"
434+ else PureWindowsPath (file_path )
435+ )
416436 if self ._server ().has_client ():
417437 self ._internal_obj = self ._api .data_processing_load_library_on_client (
418438 sLibraryKey = name ,
0 commit comments