pastas / pastastore

:spaghetti: :convenience_store: Tools for managing timeseries and Pastas models

Home Page:https://pastastore.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON can't handle datetime.datetime in pastastore metadata

martinvonk opened this issue · comments

datetime in a dictionary can't be saved when writing the pastastore to a zip file. You get the following error: TypeError: Object of type datetime is not JSON serializable and the .zip file becomes empty.

This could be solved by checking if there are datetime.datetime formats in the metadata when adding a stress/oseries. pandas.to_datetime() should work or just convert to a string.

I think we should add a method similar to pastastore.util.validate_names() that runs through the dtypes of dictionary values and checks whether Pastas supports writing those to JSON.

I believe I added support for storing datetime.datetime entries in metadata in pastas/pastas@99ca82e.

@martinvonk, could you check if this is fixed now?

Note that the datetime entry will be converted to pastas.Timestamp on load.

Yes this is fixed now. Thanks for the heads up. I'll close the issue.