tskit-dev / tszip

Gzip-like compression for tskit tree sequences
https://tszip.readthedocs.io/
MIT License
4 stars 7 forks source link

New time_units field breaks compression #54

Closed rwaples closed 2 years ago

rwaples commented 2 years ago

Great utility, but I recently ran into an error when trying to use the tszip.compress function within a Python script. It seems to occur even on super simple, just simulated tree-sequences.

The error:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/kele/anaconda3/envs/testenv/lib/python3.10/site-packages/tszip/compression.py", line 97, in compress
    compress_zarr(ts, root, variants_only=variants_only)
  File "/home/kele/anaconda3/envs/testenv/lib/python3.10/site-packages/tszip/compression.py", line 239, in compress_zarr
    ).compress(root, compressor)
  File "/home/kele/anaconda3/envs/testenv/lib/python3.10/site-packages/tszip/compression.py", line 127, in compress
    shape = self.array.shape
AttributeError: 'str' object has no attribute 'shape'

I can recreate the error via:

conda create --name testenv msprime tszip --channel conda-forge
conda activate testenv
python -c """import msprime
import tszip
ts = msprime.simulate(10, random_seed=1)
tszip.compress(ts, 'simulation.trees.tsz')"""

This env has Python 3.10.2, msprime 1.1.0, and tszip 0.2.0

Edit: I don't seem to see this problem with tszip v0.1.0

jeromekelleher commented 2 years ago

I can reproduce this.

@benjeffery - any idea what's happening here?

benjeffery commented 2 years ago

I can reproduce this.

@benjeffery - any idea what's happening here?

I've narrowed this down to upgrading tskit to 0.4.0. Looking into it.

benjeffery commented 2 years ago

Ah-ha. We added a string to the top-level of the kastore: time_units and tszip does not like this at all.

benjeffery commented 2 years ago

@rwaples We've just released version 0.2.1 which should fix this. Upgrade with pip install --upgrade tszip. Thanks again for the report.

rwaples commented 2 years ago

Thanks for the quick fix. 0.2.1 works for me!