Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

desispec calib unit tests failing #2315

Closed
sbailey opened this issue Aug 12, 2024 · 1 comment · Fixed by #2319
Closed

desispec calib unit tests failing #2315

sbailey opened this issue Aug 12, 2024 · 1 comment · Fixed by #2319

Comments

@sbailey
Copy link
Contributor

sbailey commented Aug 12, 2024

desispec unit tests starting failing at NERSC last Friday night August 9 for reasons related to $DESI_SPECTRO_DARK and $DESI_SPECTRO_CALIB, which might be due to PRs #2313 (more FIBERSTATUS bits) or PR #2314 (readnoise per CCD row) which were merged around that time. py/desispec/test/test_io_fibermap.py fails both when run individually and when run as part of the full test suite, albeit with different failures, which is usually a symptom of one test changing an environment variable but not resetting it, which then impacts a different test.

When run individually:

pytest py/desispec/test/test_io_fibermap.py
...
====================================================== FAILURES =======================================================
________________________________________ TestIOFibermap.test_assemble_fibermap ________________________________________

self = <desispec.test.test_io_fibermap.TestIOFibermap testMethod=test_assemble_fibermap>

    @unittest.skipUnless(standard_nersc_environment, "not at NERSC")
    def test_assemble_fibermap(self):
        """Test creation of fibermaps from raw inputs"""
        for night, expid in [
            (20200219, 51039),  #- old SPS header
            (20200315, 55611),  #- new SPEC header
            ]:
            print(f'Creating fibermap for {night}/{expid}')
>           fm = assemble_fibermap(night, expid)['FIBERMAP'].data

py/desispec/test/test_io_fibermap.py:260: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
py/desispec/io/fibermap.py:1121: in assemble_fibermap
    cfinder=CalibFinder([rawheader,camheader])
py/desispec/calibfinder.py:361: in __init__
    self.find_darks_in_desi_spectro_dark(header)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <desispec.calibfinder.CalibFinder object at 0x7f62b5525030>
header = {'ACQCAM': 'GUIDE0,GUIDE2,GUIDE3,GUIDE5,GUIDE7,GUIDE8', 'ACQTIME': 15.0, 'ADC1HOME': False, 'ADC1NREV': -2.0, ...}

    def find_darks_in_desi_spectro_dark(self, header):
...
        if found:
            self.data.update({"DARK": dark_filename,
                              "BIAS": bias_filename})
        else:
            if not self.fallback_on_dark_not_found:
                log.critical(f"Didn't find matching {camera} calibration darks in $DESI_SPECTRO_DARK, quitting")
>               raise IOError(f"Didn't find matching {camera} calibration darks in $DESI_SPECTRO_DARK, quitting")
E               OSError: Didn't find matching b0 calibration darks in $DESI_SPECTRO_DARK, quitting

py/desispec/calibfinder.py:560: OSError

When run as part of the full test suite

[login23 desispec] pytest py/desispec/test/
============================= test session starts ==============================
platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0
rootdir: /global/common/software/desi/users/sjbailey/desispec
plugins: remotedata-0.4.1, anyio-4.3.0, cov-5.0.0, astropy-0.11.0, arraydiff-0.6.1, astropy-header-0.2.2, doctestplus-1.2.1, asdf-3.2.0, mock-3.14.0, hypothesis-6.100.1, filter-subpackage-0.2.0
collected 305 items                                                            

py/desispec/test/test_binscripts.py ...FF                                [  1%]    [Editorial detail: this was due GPU memory on a shared login node]
py/desispec/test/test_bitmask.py .                                       [  1%]
py/desispec/test/test_bootcalib.py x.......                              [  4%]
py/desispec/test/test_calibfinder.py .                                   [  4%]
py/desispec/test/test_ccdcalib.py .                                      [  5%]
py/desispec/test/test_coadd.py ...................                       [ 11%]
py/desispec/test/test_cosmics.py ....                                    [ 12%]
py/desispec/test/test_database.py .....                                  [ 14%]
py/desispec/test/test_emlinefit.py s.                                    [ 15%]
py/desispec/test/test_extract.py .....                                   [ 16%]
py/desispec/test/test_fiberbitmask.py .                                  [ 17%]
py/desispec/test/test_fibercrosstalk.py .                                [ 17%]
py/desispec/test/test_fiberflat.py ..........                            [ 20%]
py/desispec/test/test_flux_calibration.py ........                       [ 23%]
py/desispec/test/test_frame.py ...                                       [ 24%]
py/desispec/test/test_gpu.py ...                                         [ 25%]
py/desispec/test/test_image.py ......                                    [ 27%]
py/desispec/test/test_io.py ............................................ [ 41%]
..                                                                       [ 42%]
py/desispec/test/test_io_fibermap.py .FF....FF.                          [ 45%]
...
____________________ TestIOFibermap.test_assemble_fibermap _____________________

self = <desispec.test.test_io_fibermap.TestIOFibermap testMethod=test_assemble_fibermap>

    @unittest.skipUnless(standard_nersc_environment, "not at NERSC")
    def test_assemble_fibermap(self):
        """Test creation of fibermaps from raw inputs"""
        for night, expid in [
            (20200219, 51039),  #- old SPS header
            (20200315, 55611),  #- new SPEC header
            ]:
            print(f'Creating fibermap for {night}/{expid}')
>           fm = assemble_fibermap(night, expid)['FIBERMAP'].data

py/desispec/test/test_io_fibermap.py:260: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
py/desispec/io/fibermap.py:1121: in assemble_fibermap
    cfinder=CalibFinder([rawheader,camheader])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <desispec.calibfinder.CalibFinder object at 0x7f92f3bc33a0>
headers = [XTENSION= 'BINTABLE'           / binary table extension                         
BITPIX  =                    8 / 8-b...um updated 2020-02-20T08:26:56       
DATASUM = '3006616571'         / data unit checksum updated 2020-02-20T08:26:56 ]
yaml_file = None, fallback_on_dark_not_found = False

    def __init__(self,headers,yaml_file=None, fallback_on_dark_not_found=False) :
...
            self.directory = os.environ["DESI_SPECTRO_CALIB"]
...
        if not os.path.isdir(self.directory):
>           raise IOError("Calibration directory {} not found".format(self.directory))
E           OSError: Calibration directory /global/homes/s/sjbailey/preproc_unit_test not found

py/desispec/calibfinder.py:271: OSError

Note that it appears that something set $DESI_SPECTRO_CALIB=$HOME/preproc_unit_test which is then mucking up the calibfinder as part of the fibermap tests.

This is likely a problem in the tests triggered by the PR updates, not the underlying PR algorithms, but we should clean it up so that tests pass again.

@akremin
Copy link
Member

akremin commented Aug 12, 2024

self.calibdir = os.path.join(os.environ['HOME'], 'preproc_unit_test') is used in test_preproc.py and test_calibfinder.py, but both of those were introduced in January of 2019. I see no other reference to 'preproc_unit_test'.

Perhaps it is not that the path is set but rather something is now expected to be at that path that isn't?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants