Skip to content

Commit

Permalink
fix rogue caching of (see #2138)
Browse files Browse the repository at this point in the history
  • Loading branch information
moustakas committed Jan 3, 2024
1 parent ced20c2 commit 5a9fbe5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions py/desispec/test/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,19 @@ def tearDownClass(cls):
for testfile in [cls.testfile, cls.testyfile, cls.testbrfile, cls.testlog]:
if os.path.exists(testfile):
os.remove(testfile)

for e in cls.origEnv:
if cls.origEnv[e] is None:
del os.environ[e]
else:
os.environ[e] = cls.origEnv[e]

if os.path.exists(cls.testDir):
if os.path.isdir(cls.testDir):
rmtree(cls.testDir)

# reset the readonly cache
from ..io import meta
meta._desi_root_readonly = None

def test_write_bintable(self):
"""Test writing binary tables to FITS.
"""
Expand Down Expand Up @@ -969,7 +972,8 @@ def test_desi_root_readonly(self):
meta._desi_root_readonly = None

#- Case 1: $DESI_ROOT_READONLY is set and exists -> use it
os.environ['DESI_ROOT_READONLY'] = tempfile.mkdtemp()
tmpdir = tempfile.mkdtemp()
os.environ['DESI_ROOT_READONLY'] = tmpdir
blat = meta.get_desi_root_readonly()
self.assertEqual(blat, os.environ['DESI_ROOT_READONLY'])

Expand Down
12 changes: 8 additions & 4 deletions py/desispec/test/test_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

class TestPhoto(unittest.TestCase):

def setUp(self):
@classmethod
def setUpClass(self):
from astropy.table import Table

# for testing gather_targetphot and gather_tractorphot

# sv3-dark (secondary), sv1-bright (primary), main-dark (secondary), main-dark (primary, south), main-dark (primary, north), sv3-bright (TOO)
input_cat = Table()
input_cat['TARGETID'] = [929413348720641, 39627061832191195, 2253225356951552, 39627565329026280, 39633086782113662, 43977491483722156]
Expand Down Expand Up @@ -54,6 +54,10 @@ def setUp(self):
tractorphot['LS_ID'] = np.array([10995128657712508, 10995128743167117, 10995128743105186]).astype(np.int64)
self.tractorphot_dr10 = tractorphot

@classmethod
def tearDownClass(self):
pass

@unittest.skipUnless('NERSC_HOST' in os.environ, "not at NERSC")
def test_gather_targetdirs(self):
"""Test that we get the correct targeting directories given a tile."""
Expand Down Expand Up @@ -101,4 +105,4 @@ def test_gather_tractorphot_dr10(self):
legacysurveydir = os.path.join(desi_root, 'external', 'legacysurvey', 'dr10')
tractorphot = gather_tractorphot(self.input_cat_dr10, legacysurveydir=legacysurveydir)
for col in self.tractorphot_dr10.colnames:
self.assertTrue(np.all(tractorphot[col] == self.tractorphot_dr10[col]))
self.assertTrue(np.all(tractorphot[col] == self.tractorphot_dr10[col]))

0 comments on commit 5a9fbe5

Please sign in to comment.