Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limited error handling in import_materials_from_file #5215

Closed
2 tasks done
isaacwaldron opened this issue Sep 26, 2024 · 1 comment · Fixed by #5217
Closed
2 tasks done

Limited error handling in import_materials_from_file #5215

isaacwaldron opened this issue Sep 26, 2024 · 1 comment · Fixed by #5217
Labels
bug Something isn't working

Comments

@isaacwaldron
Copy link
Collaborator

Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

Description of the bug

Loading a JSON file for materials that fails to load due to some missing data generates just an error by the catch-all error handler, e.g.:

PyAEDT ERROR: **************************************************************
PyAEDT ERROR:   File "<frozen runpy>", line 198, in _run_module_as_main
PyAEDT ERROR:   File "<frozen runpy>", line 88, in _run_code
PyAEDT ERROR:   File "C:\git\Ansys\ic-setup-toolkit\venv\Scripts\pytest.exe\__main__.py", line 7, in <module>
PyAEDT ERROR:     sys.exit(console_main())
PyAEDT ERROR:   File "c:\git\Ansys\materials-avalanche\tests\test_apps.py", line 113, in test_json2amat_bad_json
PyAEDT ERROR:     assert json2amat_main(args) == 1
PyAEDT ERROR:   File "C:\git\Ansys\materials-avalanche\src\materials_avalanche\json2amat.py", line 70, in main
PyAEDT ERROR:     if not hfss.materials.import_materials_from_file(input_path.as_posix()):
PyAEDT ERROR: 'red' on import_materials_from_file
PyAEDT ERROR: Method arguments:
PyAEDT ERROR:     input_file = C:/git/Ansys/materials-avalanche/testdata/variations/process_materials_missing_rgb.json
PyAEDT ERROR: **************************************************************

While we can use this to find the actual problem, it would be nice to avoid the catch-all error handler and have a pointer at least to the material being parsed to narrow the search scope.

Steps To Reproduce

  1. Take any valid materials JSON with "appearance data" and remove the RGB color values (keys "red,", "green," "blue")
  2. Pass above file into import_materials_from_file

Which Operating System are you using?

Windows

Which Python version are you using?

3.10

Installed packages

annotated-types==0.7.0
ansys-pythonnet==3.1.0rc3
asttokens==2.4.1
attrs==24.2.0
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
clr-loader==0.2.6
colorama==0.4.6
contourpy==1.3.0
coverage==7.6.1
cycler==0.12.1
decorator==5.1.1
defusedxml==0.7.1
et-xmlfile==1.1.0
exceptiongroup==1.2.2
execnet==2.1.1
executing==2.1.0
fiona==1.10.1
fonttools==4.54.1
fpdf2==2.7.9
geopandas==0.14.4
idna==3.10
imageio==2.35.1
iniconfig==2.0.0
ipython==8.27.0
jedi==0.19.1
joblib==1.4.2
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.7
markdown-it-py==3.0.0
matplotlib==3.9.2
matplotlib-inline==0.1.7
mdurl==0.1.2
meshio==5.3.5
mock==5.1.0
networkx==3.3
numpy==1.26.4
openpyxl==3.1.5
osmnx==1.9.4
packaging==24.1
pandas==2.2.3
parso==0.8.4
pillow==10.4.0
platformdirs==4.3.6
pluggy==1.5.0
plumbum==1.8.3
pooch==1.8.2
prompt_toolkit==3.0.48
psutil==6.0.0
pure_eval==0.2.3
-e git+https://github.com/ansys/pyaedt@44045940c750e23e6e409f28f972cfe865525263#egg=pyaedt
pycparser==2.22
pydantic==2.8.2
pydantic_core==2.20.1
pyedb==0.27.0
Pygments==2.18.0
pyparsing==3.1.4
pyproj==3.6.1
pytest==8.3.3
pytest-cov==5.0.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytomlpp==1.0.13
pytz==2024.2
pyvista==0.44.1
pywin32==306
PyYAML==6.0.2
referencing==0.35.1
requests==2.32.3
rich==13.8.1
rpds-py==0.20.0
rpyc==6.0.1
Rtree==1.3.0
scikit-learn==1.5.2
scikit-rf==1.3.0
scipy==1.14.1
scooby==0.10.0
shapely==2.0.6
six==1.16.0
SRTM.py==0.3.7
stack-data==0.6.3
threadpoolctl==3.5.0
toml==0.10.2
tomli==2.0.1
traitlets==5.14.3
typing_extensions==4.12.2
tzdata==2024.2
urllib3==2.2.3
utm==0.7.0
vtk==9.3.1
wcwidth==0.2.13
@SMoraisAnsys
Copy link
Collaborator

@isaacwaldron As mentionned in #5217, this catch all exception behavior can be deactivated through the settings. See enable_error_handler in https://aedt.docs.pyansys.com/version/stable/User_guide/settings.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants