Skip to content

write_h5ed cannot write the output of io.omop.setup_obs #303

Description

@Zethson

ed.io.omop.setup_obs returns an object that ed.io.write_h5ed refuses to write, so the OMOP path has no working round trip.

Two independent causes: datetime64 columns (birth_datetime, observation_period_start_date, observation_period_end_date, plus valid_start_date/valid_end_date in var when enrich_var_with_feature_info=True), which anndata has no HDF5 writer for; and all-null object columns (location_id, provider_id, care_site_id are empty in GiBleed), which h5py rejects with TypeError: Can't implicitly convert non-string objects to strings once the datetimes are cast away.

import duckdb, ehrdata as ed

con = duckdb.connect()
ed.dt.gibleed_omop(backend_handle=con)
edata = ed.io.omop.setup_obs(backend_handle=con, observation_table="person_observation_period")
ed.io.write_h5ed(edata, "mre.h5ed")
# IORegistryError: No method registered for writing
# <class 'pandas.core.arrays.datetimes.DatetimeArray'> into <class 'h5py._hl.group.Group'>
# Error raised while writing key 'birth_datetime' of <class 'h5py._hl.group.Group'> to /obs

ehrdata 0.4.0, anndata 0.13.3.post0, h5py 3.16.0, python 3.14.7.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions