from pathlib import Path
import json
import epdx.pydantic
ilcd_file = Path(__file__).parent.parent / "data" / "ilcd.json"
print("EPD as dict")
epd_dict = epdx.convert_ilcd(ilcd_file.read_text())
print(json.dumps(epd_dict, indent=2))
print("\nEPD as Pydantic model")
epd_pydantic = epdx.convert_ilcd(ilcd_file.read_text(), as_type="pydantic")
print(epd_pydantic)
print("\nEPD as string")
epd_str = epdx.convert_ilcd(ilcd_file.read_text(), as_type="str")
print(epd_str)
TypeError Traceback (most recent call last)
Cell In[4], line 12
9 print(json.dumps(epd_dict, indent=2))
11 print("\nEPD as Pydantic model")
---> 12 epd_pydantic = epdx.convert_ilcd(ilcd_file.read_text(), as_type="pydantic")
13 print(epd_pydantic)
15 print("\nEPD as string")
File ~/.cache/pypoetry/virtualenvs/epdx-test-qq20DbS5-py3.11/lib/python3.11/site-packages/epdx/__init__.py:36, in convert_ilcd(data, as_type)
34 return EPD(**json.loads(_epd))
35 else:
---> 36 raise NotImplemented("Currently only 'dict', 'str' and 'pydantic' is implemented as_type.")
TypeError: 'NotImplementedType' object is not callable
Firstly, line 36 should raise NotImplementedError(...), as now the raising raises TypeError.
Secondly, allowed values for convert_ilcd are to be str, dict and epdx.pydantic.EPD (type, type and class), not 'str', 'dict' and 'pydantic' as indicated by the documentation. You might want to update documentation to reflect the API.
The documentation at https://epdx.kongsgaard.eu/usage/usage/ is out of date. When running the sample code with epdx version 1.1.5, error arises:
Firstly, line 36 should
raise NotImplementedError(...)
, as now the raising raises TypeError.Secondly, allowed values for
convert_ilcd
are to bestr
,dict
andepdx.pydantic.EPD
(type, type and class), not'str'
,'dict'
and'pydantic'
as indicated by the documentation. You might want to update documentation to reflect the API.