AuScope / seismo-loader

MIT License
1 stars 0 forks source link

Issues with Pydantic not being able to serialize obspy objects #38

Closed bmotevalli closed 2 weeks ago

bmotevalli commented 3 weeks ago

The SeismoLoaderSettings is a pydantic model. A couple of its properties such as catalogs and inventories are obspy objects. This seems not to be serializable. We serialize SeismoLoaderSettings to cache requests and avoid re-requesting the same thing. See below for example:

@st.cache_data
def get_event_data(settings_json_str: str):

    settings = SeismoLoaderSettings.model_validate_json(settings_json_str)
    return get_events(settings)

where the input settings_json_str is the serialized form of SeismoLoaderSettings. (Note that streamlit cannot directly cache a complex object such as pydantic. That is why we try to pass the serialized obj.)

bmotevalli commented 2 weeks ago

Resolved.