gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
232 stars 49 forks source link

why can't epsg be cast to int as before? (change #188 broke my code) #200

Closed klwalker-sb closed 1 year ago

klwalker-sb commented 1 year ago

Prepare.py line 166: assert isinstance(out_epsg, int), f"out_epsg not found. {out_epsg=}"` now returns an error:

AssertionError: out_epsg not found. out_epsg='8858'

because my epsg (and thus out_epsg) is originally cast as a string. I cannot simply set it as an int initially because it is manipulated by a different code that I cannot change. The script ran fine for me with the same parameters prior to change #188 because it would cast it to an int. Why can't it continue to cast to int?

TomAugspurger commented 1 year ago

Do you have a minimal example you can share?

klwalker-sb commented 1 year ago

The issue is pretty straightforward -- if epsg is passed to prepare.prepare_items as a string (e.g. '8858'), the code breaks with the new integer check at line 166. I was passing epsg as a string due to demands of upstream code and possibly different versions of pyproj. I was just wondering why a string could not be allowed to be recast as an integer as before. No worries, though. I fixed things upstream, so you can close this if it is not helpful.

gjoseph92 commented 1 year ago

As specified in the docs, the epsg parameter was always expected to be an int. The fact that a string happened to work before was undefined behavior and not something to rely on, so I don't think this is a bug. Casting to an int yourself would be the right approach, so glad that worked for you.