Skip to content

Commit 198f149

Browse files
authored
release licenses (#623)
1 parent 30c44c9 commit 198f149

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

ansys/dpf/core/core.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,23 @@ def initialize_with_context(self, context):
468468
context.context_type.value, context.xml_path
469469
)
470470

471+
@version_requires("6.0")
472+
def release_dpf(self):
473+
"""Clears the available Operators and Releases licenses when necessary.
474+
475+
Notes
476+
-----
477+
Available with server's version starting at 6.0 (Ansys 2023R2).
478+
"""
479+
if self._server().has_client():
480+
error = self._api.data_processing_release_on_client(
481+
self._server().client, 1
482+
)
483+
else:
484+
error = self._api.data_processing_release(
485+
1
486+
)
487+
471488
def get_runtime_client_config(self):
472489
if self._server().has_client():
473490
data_tree_tmp = (

ansys/dpf/core/server_types.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,30 @@ def config(self):
445445
def shutdown(self):
446446
pass
447447

448+
def release(self):
449+
"""Clears the available Operators and Releases licenses when necessary.
450+
451+
Notes
452+
-----
453+
Available with server's version starting at 6.0 (Ansys 2023R2).
454+
"""
455+
self._base_service.release_dpf()
456+
457+
def apply_context(self, context):
458+
"""Defines the settings that will be used to load DPF's plugins.
459+
A DPF xml file can be used to list the plugins and set up variables.
460+
461+
Parameters
462+
----------
463+
context : ServerContext
464+
The context allows to choose which capabilities are available server side.
465+
466+
Notes
467+
-----
468+
Available with server's version starting at 6.0 (Ansys 2023R2).
469+
"""
470+
self._base_service.apply_context(context)
471+
448472
def check_version(self, required_version, msg=None):
449473
"""Check if the server version matches with a required version.
450474

tests/test_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,17 @@ def test_apply_context_remote(remote_config_server_type, set_context_back_to_pre
504504
dpf.core.Operator("core::field::high_pass")
505505

506506

507+
@pytest.mark.order("last")
508+
@pytest.mark.skipif(running_docker or not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
509+
reason="AWP ROOT is not set with Docker")
510+
@conftest.raises_for_servers_version_under("6.0")
511+
def test_release_dpf(server_type):
512+
op = dpf.core.Operator("expansion::modal_superposition", server=server_type)
513+
server_type.release()
514+
515+
with pytest.raises((KeyError, dpf.core.errors.DPFServerException)):
516+
dpf.core.Operator("expansion::modal_superposition", server=server_type)
517+
518+
507519
if __name__ == "__main__":
508520
test_load_api_with_awp_root()

0 commit comments

Comments
 (0)