Skip to content

Commit 05c565c

Browse files
authored
Fix specification.config_specification on empty spec (#2107)
* Querying Specification.config_specification on an empty spec now returns an empty ConfigSpecification instead of throwing. * Add test
1 parent 020ac7d commit 05c565c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/ansys/dpf/core/operator_specification.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ def config_specification(self) -> ConfigSpecification:
460460
"""
461461
if self._config_specification is None:
462462
self._config_specification = ConfigSpecification()
463+
if self._internal_obj is not None:
463464
num_options = self._api.operator_specification_get_num_config_options(self)
464465
for i in range(num_options):
465466
option_name = self._api.operator_specification_get_config_name(self, i)

tests/test_operator.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,16 @@ def test_generated_operator_config_specification_simple(server_type):
13281328
assert "id" in conf_spec["work_by_index"].document
13291329

13301330

1331+
def test_empty_specification(server_type):
1332+
op = dpf.core.dpf_operator.Operator("chunk_fc", server=server_type)
1333+
spec = op.specification
1334+
_ = spec.config_specification
1335+
_ = spec.properties
1336+
_ = spec.description
1337+
_ = spec.inputs
1338+
_ = spec.outputs
1339+
1340+
13311341
def test_operator_exception():
13321342
ds = dpf.core.DataSources(r"dummy/file.rst")
13331343
op = ops.result.displacement(data_sources=ds)

0 commit comments

Comments
 (0)