-
Notifications
You must be signed in to change notification settings - Fork 4
Description
I'm routinely looking up paths for SDSS-5 data and SDSS-4 data.
I use a dictionary to lookup instances of SDSSPath(...) so that I don't have to create a SDSSPath object every time I evaluate a path. It looks something like this:
_sdss_path_instances = {}
def path(release, filetype, **kwargs):
try:
p = _sdss_path_instances[release]
except:
p = _sdss_path_instances[release] = SDSSPath(release)
finally:
return p.full(filetype, **kwargs)But I am encountering very weird behaviour, which I can only conclude must be because of either a strange state issue, or because sdss_access is changing environment variables behind the scenes.
Here is a minimum reproducible example:
import os
from sdss_access import SDSSPath
# create a DR17 instance
p = SDSSPath("dr17")
kwds = {'obj': '2M07591936+1734091', 'apred': 'dr17', 'field': '204+22', 'apstar': 'stars', 'prefix': 'ap', 'reduction': '2M07591936+1734091', 'telescope': 'apo25m'}
# This part works fine.
original_path = p.full("apStar", **kwds)
print(os.path.exists(original_path), original_path)
# Now let's evaluate a SDSS 5 path, but **we are using a different instance**
fake_path = SDSSPath("sdss5").full("mwmVisit", v_astra="0.2.6", cat_id=1, run2d="v6_0_9", apred="1.0")
# Now let's use the original instance to evaluate a DR17 path.
check_path = p.full("apStar", **kwds)
print(os.path.exists(check_path), check_path)Here is the output:
True /uufs/chpc.utah.edu/common/home/sdss50/dr17/apogee/spectro/redux/dr17/stars/apo25m/204+22/apStar-dr17-2M07591936+1734091.fits
False /uufs/chpc.utah.edu/common/home/sdss50/sdsswork/mwm/apogee/spectro/redux/dr17/stars/apo25m/204+22/apStar-dr17-2M07591936+1734091.fits
Is this the intended behaviour?
I assumed each instance would evaluate paths for that particular release, and that evaluating one path on a different instance would not impact existing instances. Note that this happens even if the second SDSSPath(...) is created in a totally unrelated scope, which makes me think there is some state sharing within sdss_access, or environment variables being changed.