ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
69 stars 25 forks source link

Improve error and docstring for unsupported 'abstract_field_support' from 'material_support_provider' #969

Open greschd opened 1 year ago

greschd commented 1 year ago

EDIT: This is not really a bug, but the error message + docs could be improved. See discussion below.

Before submitting the issue

Description of the bug

When directly accessing the .outputs.abstract_field_support() of a material_support_provider, the following exception is raised:

Traceback (most recent call last):
  File "D:\ANSYSDev\dpf_playground\repro.py", line 9, in <module>
    op.outputs.abstract_field_support()
  File "D:\ANSYSDev\dpf_playground\.venv2\lib\site-packages\ansys\dpf\core\outputs.py", line 58, in __call__
    return self.get_data()
  File "D:\ANSYSDev\dpf_playground\.venv2\lib\site-packages\ansys\dpf\core\outputs.py", line 55, in get_data
    return self._operator.get_output(self._pin, type_output)
  File "D:\ANSYSDev\dpf_playground\.venv2\lib\site-packages\ansys\dpf\core\dpf_operator.py", line 446, in get_output
    output_type = _write_output_type_to_type(output_type)
  File "D:\ANSYSDev\dpf_playground\.venv2\lib\site-packages\ansys\dpf\core\dpf_operator.py", line 814, in _write_output_type_to_type
    output_type = types[output_type]
  File "C:\Program Files\Python310\lib\enum.py", line 440, in __getitem__
    return cls._member_map_[name]
KeyError: 'abstract_field_support'

When instead passing the material_support_provider as input to other operators, things appear to work as expected, see https://composites.dpf.docs.pyansys.com/version/stable/examples/gallery_examples/dpf_composite_failure_workflow.html#set-up-providers

Steps To Reproduce

Which Operating System causes the issue?

Windows

Which DPF/Ansys version are you using?

DPF Server 2024R1 daily.

Which Python version causes the issue?

3.10

Installed packages

ansys-dpf-core==0.8.1 ansys-dpf-gate==0.3.1 ansys-dpf-gatebin==0.3.1 ansys-grpc-dpf==0.7.1 cachetools==5.3.1 certifi==2023.5.7 charset-normalizer==3.1.0 colorama==0.4.6 google-api-core==2.11.0 google-api-python-client==2.88.0 google-auth==2.19.0 google-auth-httplib2==0.1.0 googleapis-common-protos==1.59.0 grpcio==1.54.2 httplib2==0.22.0 idna==3.4 importlib-metadata==6.6.0 numpy==1.24.3 packaging==23.1 protobuf==4.23.2 psutil==5.9.5 pyasn1==0.5.0 pyasn1-modules==0.3.0 pyparsing==3.0.9 requests==2.31.0 rsa==4.9 six==1.16.0 tqdm==4.65.0 uritemplate==4.1.1 urllib3==1.26.16 zipp==3.15.0

janvonrickenbach commented 1 year ago

You get this error because the MaterialSupport is not available in python. It would be nice if the error message could be improved.

greschd commented 1 year ago

Thanks for the explanation @janvonrickenbach. Additionally, I think the generated doc-string should take into account when data is unavailable. This is why I originally expected this to work:

>>> # Get output data
>>> result_abstract_field_support = op.outputs.abstract_field_support()

From https://dpf.docs.pyansys.com/version/stable/api/ansys.dpf.core.operators.metadata.material_support_provider.html#material-support-provider