Skip to content

Commit 43cba7c

Browse files
committed
feat(server): Add ServerContext.xml_path setter to allow setting the xml_path for a "dpf.AvailableServerContexts.custom_defined" context.
1 parent 78cb13a commit 43cba7c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/ansys/dpf/core/server_context.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
ANSYS_DPF_SERVER_CONTEXT=ENTRY and ANSYS_DPF_SERVER_CONTEXT=PREMIUM can be used.
3636
"""
3737

38+
from __future__ import annotations
39+
3840
from enum import Enum
3941
import os
4042
import warnings
@@ -264,6 +266,29 @@ def xml_path(self):
264266
"""
265267
return self._xml_path
266268

269+
@xml_path.setter
270+
def xml_path(self, xml_path: str | os.PathLike):
271+
r"""Set the path to the xml file defining default plugins to load at server start.
272+
273+
Parameters
274+
----------
275+
xml_path:
276+
Path to the XML file to use at server start. Useful to target a custom XML file.
277+
278+
Examples
279+
--------
280+
Create a ServerContext targeting a custom XML file.
281+
282+
>>> import ansys.dpf.core as dpf
283+
>>> # Create a custom server context
284+
>>> custom_server_context = dpf.AvailableServerContexts.custom_defined
285+
>>> # Set the XML path
286+
>>> custom_server_context.xml_path = r'\path\to\file'
287+
>>> # Start a DPF server using this context
288+
>>> # server = dpf.start_local_server(context=custom_server_context)
289+
"""
290+
self._xml_path = str(xml_path)
291+
267292
def __str__(self):
268293
"""Return string representation of the ServerContext instance."""
269294
return (

0 commit comments

Comments
 (0)