Skip to content

Commit 767f8b5

Browse files
authored
update operators
1 parent 4a98d89 commit 767f8b5

File tree

3 files changed

+197
-1
lines changed

3 files changed

+197
-1
lines changed

docs/source/_static/dpf_operators.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/ansys/dpf/core/operators/utility/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from .remote_workflow_instantiate import remote_workflow_instantiate
5454
from .remove_unnecessary_labels import remove_unnecessary_labels
5555
from .scalars_to_field import scalars_to_field
56+
from .server_path import server_path
5657
from .set_attribute import set_attribute
5758
from .set_property import set_property
5859
from .split_in_for_each_range import split_in_for_each_range
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
"""
2+
server_path
3+
===========
4+
Autogenerated DPF operator classes.
5+
"""
6+
from warnings import warn
7+
from ansys.dpf.core.dpf_operator import Operator
8+
from ansys.dpf.core.inputs import Input, _Inputs
9+
from ansys.dpf.core.outputs import Output, _Outputs
10+
from ansys.dpf.core.operators.specification import PinSpecification, Specification
11+
12+
13+
class server_path(Operator):
14+
"""Returns the platform-specific path to a folder in the Dpf server
15+
16+
Parameters
17+
----------
18+
subpath : int, optional
19+
Subpath of the dpf server. supported values:
20+
0 (default): root of the server, 1:
21+
"dpf/bin/platform", 2:
22+
"aisol/bin/platform", 3:
23+
"dpf/plugins".
24+
25+
26+
Examples
27+
--------
28+
>>> from ansys.dpf import core as dpf
29+
30+
>>> # Instantiate operator
31+
>>> op = dpf.operators.utility.server_path()
32+
33+
>>> # Make input connections
34+
>>> my_subpath = int()
35+
>>> op.inputs.subpath.connect(my_subpath)
36+
37+
>>> # Instantiate operator and connect inputs in one line
38+
>>> op = dpf.operators.utility.server_path(
39+
... subpath=my_subpath,
40+
... )
41+
42+
>>> # Get output data
43+
>>> result_path = op.outputs.path()
44+
"""
45+
46+
def __init__(self, subpath=None, config=None, server=None):
47+
super().__init__(name="server_path", config=config, server=server)
48+
self._inputs = InputsServerPath(self)
49+
self._outputs = OutputsServerPath(self)
50+
if subpath is not None:
51+
self.inputs.subpath.connect(subpath)
52+
53+
@staticmethod
54+
def _spec():
55+
description = (
56+
"""Returns the platform-specific path to a folder in the Dpf server"""
57+
)
58+
spec = Specification(
59+
description=description,
60+
map_input_pin_spec={
61+
0: PinSpecification(
62+
name="subpath",
63+
type_names=["int32"],
64+
optional=True,
65+
document="""Subpath of the dpf server. supported values:
66+
0 (default): root of the server, 1:
67+
"dpf/bin/platform", 2:
68+
"aisol/bin/platform", 3:
69+
"dpf/plugins".""",
70+
),
71+
},
72+
map_output_pin_spec={
73+
0: PinSpecification(
74+
name="path",
75+
type_names=["string"],
76+
optional=False,
77+
document="""Path to the requested folder in the dpf
78+
server""",
79+
),
80+
},
81+
)
82+
return spec
83+
84+
@staticmethod
85+
def default_config(server=None):
86+
"""Returns the default config of the operator.
87+
88+
This config can then be changed to the user needs and be used to
89+
instantiate the operator. The Configuration allows to customize
90+
how the operation will be processed by the operator.
91+
92+
Parameters
93+
----------
94+
server : server.DPFServer, optional
95+
Server with channel connected to the remote or local instance. When
96+
``None``, attempts to use the global server.
97+
"""
98+
return Operator.default_config(name="server_path", server=server)
99+
100+
@property
101+
def inputs(self):
102+
"""Enables to connect inputs to the operator
103+
104+
Returns
105+
--------
106+
inputs : InputsServerPath
107+
"""
108+
return super().inputs
109+
110+
@property
111+
def outputs(self):
112+
"""Enables to get outputs of the operator by evaluating it
113+
114+
Returns
115+
--------
116+
outputs : OutputsServerPath
117+
"""
118+
return super().outputs
119+
120+
121+
class InputsServerPath(_Inputs):
122+
"""Intermediate class used to connect user inputs to
123+
server_path operator.
124+
125+
Examples
126+
--------
127+
>>> from ansys.dpf import core as dpf
128+
>>> op = dpf.operators.utility.server_path()
129+
>>> my_subpath = int()
130+
>>> op.inputs.subpath.connect(my_subpath)
131+
"""
132+
133+
def __init__(self, op: Operator):
134+
super().__init__(server_path._spec().inputs, op)
135+
self._subpath = Input(server_path._spec().input_pin(0), 0, op, -1)
136+
self._inputs.append(self._subpath)
137+
138+
@property
139+
def subpath(self):
140+
"""Allows to connect subpath input to the operator.
141+
142+
Subpath of the dpf server. supported values:
143+
0 (default): root of the server, 1:
144+
"dpf/bin/platform", 2:
145+
"aisol/bin/platform", 3:
146+
"dpf/plugins".
147+
148+
Parameters
149+
----------
150+
my_subpath : int
151+
152+
Examples
153+
--------
154+
>>> from ansys.dpf import core as dpf
155+
>>> op = dpf.operators.utility.server_path()
156+
>>> op.inputs.subpath.connect(my_subpath)
157+
>>> # or
158+
>>> op.inputs.subpath(my_subpath)
159+
"""
160+
return self._subpath
161+
162+
163+
class OutputsServerPath(_Outputs):
164+
"""Intermediate class used to get outputs from
165+
server_path operator.
166+
167+
Examples
168+
--------
169+
>>> from ansys.dpf import core as dpf
170+
>>> op = dpf.operators.utility.server_path()
171+
>>> # Connect inputs : op.inputs. ...
172+
>>> result_path = op.outputs.path()
173+
"""
174+
175+
def __init__(self, op: Operator):
176+
super().__init__(server_path._spec().outputs, op)
177+
self._path = Output(server_path._spec().output_pin(0), 0, op)
178+
self._outputs.append(self._path)
179+
180+
@property
181+
def path(self):
182+
"""Allows to get path output of the operator
183+
184+
Returns
185+
----------
186+
my_path : str
187+
188+
Examples
189+
--------
190+
>>> from ansys.dpf import core as dpf
191+
>>> op = dpf.operators.utility.server_path()
192+
>>> # Connect inputs : op.inputs. ...
193+
>>> result_path = op.outputs.path()
194+
""" # noqa: E501
195+
return self._path

0 commit comments

Comments
 (0)