Giter VIP home page Giter VIP logo

crds's Introduction

CRDS

CRDS is a package used for working with astronomical reference files for the HST and JWST telescopes. CRDS is useful for performing various operations on reference files or reference file assignment rules. CRDS is used to assign, check, and compare reference files and rules, and also to predict those datasets which should potentially be reprocessed due to changes in reference files or assignment rules. CRDS has versioned rules which define the assignment of references for each type and instrument configuration. CRDS has web sites corresponding to each project (http://hst-crds.stsci.edu or https://jwst-crds.stsci.edu/) which record information about reference files and provide related services.

CRDS development is occuring at:

Project's github page.

CRDS is also available for installation as part of stenv:

stenv.

Basic CRDS Installation

For many roles, CRDS is automatically installed as a dependency of the calibration software. This default installation supports running calibrations but not more advanced CRDS activities like submitting files or development.

You can test for an existing installation of CRDS like this:

$ crds list --status
CRDS Version = '7.4.0, b7.4.0, daf308e24c8dd37e70c89012e464058861417245'
CRDS_MODE = 'auto'
CRDS_PATH = 'undefined'
CRDS_SERVER_URL = 'undefined'
Cache Locking = 'enabled, multiprocessing'
Effective Context = 'jwst_0541.pmap'
Last Synced = '2019-08-26 07:30:09.254136'
Python Executable = '/Users/homer/miniconda3/envs/crds-env/bin/python'
Python Version = '3.7.4.final.0'
Readonly Cache = False

This output indicates CRDS is installed and configured for processing onsite using a pre-built cache of CRDS rules and references at /grp/crds/cache.

File Submission Installation

For performing the file submission role, CRDS includes additional dependencies and can be trickier to install.

Addding CRDS to an Existing Environment

You can install/upgrade CRDS and it's dependencies in your current environment like this:

git clone https://github.com/spacetelescope/crds.git
cd crds
./crds_setup_crds

It is recommended that you only do this in an environment dedicated to file submissions. This may be suitable for e.g. installing/upgrading CRDS in an active redcatconda environment.

Full Environment Install

Sometimes it's expedient to install an entirely new environment including a baseline conda, CRDS, and all of it's dependencies. To start from scratch, you can:

git clone https://github.com/spacetelescope/crds.git
cd crds
./crds_setup_all

# open a new terminal window
conda activate crds-env

To customize a bit more, crds_setup_all and crds_setup_env support parameters which can be used to specify OS, shell, and install location. Substitute the below to specify Linux, c-shell, and a non-default install location:

./crds_setup_all   Linux  csh   $HOME/miniconda_crds

Advanced Install

Below are the current sub-tasks used conceptually for a full featured CRDS install. These can serve as an alternative to cloning the CRDS repo and running the install script(s). If you already have a python environment supporting pip,

1. Installing Conda / Astroconda

Alternate / definitive installation instructions for installing a baseline conda can be found here:

https://spacetelescope.github.io/training-library/computer_setup.html#installing-conda

2. Create crds-env Environment

The CRDS software and basic conda dependencies should be installed in an isolated conda environment:

conda create -n crds-env
conda activate crds-env

You can substitute the environment name of your choice, e.g. redcatconda vs. crds-env.

3. Add JWST CAL S/W and Dependencies

Installing the JWST CAL S/W will also automatically install many dendencies of a numerical computing environment:

pip install --upgrade numpy
pip install --upgrade git+https://github.com/spacetelescope/jwst

Note that these commands also install the latest version of CRDS from pip which may not be current enough for ongoing reference file testing and troubleshooting.

4. Install CRDS and Dependencies

This sequence first removes the CRDS installed automatically as part of installing the jwst package and then installs the latest available CRDS from github with advanced dependencies not needed for basic operation:

pip uninstall --yes crds
pip install --upgrade  git+https://github.com/spacetelescope/crds.git#egg=crds["submission","test"]

A more full featured CRDS install is:

pip install --upgrade  git+https://github.com/spacetelescope/crds.git#egg=crds["submission","dev","test","docs"]

5. Install Fitsverify

Since it is a C-based package fitsverify is not available using pip but is available via conda on the astroconda channel:

conda config --add channels http://ssb.stsci.edu/astroconda
conda install --yes fitsverify

As part of an end-user setup installation of fitsverify is optional, CRDS certify will run without it after issuing a warning, the CRDS server will run fitsverify as part of its checks unless/until we stop using it altogether.

User's Guide

More documentation about CRDS is available here:

https://jwst-crds.stsci.edu/static/users_guide/index.html

crds's People

Contributors

alphasentaurii avatar bernie-simon avatar braingram avatar ddkauffman avatar eslavich avatar hbrown-st avatar jaytmiller avatar jbdoggett avatar jdavies-st avatar jhunkeler avatar nden avatar paulhuwe avatar pllim avatar rendinam avatar sean-lockwood avatar stsci-hack avatar stscieisenhamer avatar stscirij avatar zacharyburnett avatar zanecodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crds's Issues

Update the help

Tyler Desjardins mentions that we should consider moving emails from help[at]stsci.edu to point to the web portal where possible and appropriate. For HST (or any non-JWST), it is https://hsthelp.stsci.edu . For JWST, it is https://jwsthelp.stsci.edu . Please update info in setup.py, setup.cfg, documentation, etc as appropriate.

Please close this issue if it is irrelevant to your repository. This is an automated issue. If this is opened in error, please let pllim know!

xref spacetelescope/hstcal#317

random arguments error in is_writable

With version 7.1.5 and a fresh conda-dev install, I'm getting the following error. However, the error is random; sometimes all works fine.

$ pytest -rsx jwst/pipeline/tests/test_calwebb_spec2.py --runslow
============================================================================= test session starts ==============================================================================
platform darwin -- Python 3.5.3, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /Users/eisenham/Documents/ssbdev/jwst, inifile: setup.cfg
collected 7 items

jwst/pipeline/tests/test_calwebb_spec2.py F......

=================================================================================== FAILURES ===================================================================================
________________________________________________________________________________ test_full_run _________________________________________________________________________________

mk_tmp_dirs = ('/var/folders/z7/hcykr_n546s_5033t9rj5d200000zj/T/tmp7v6fc68_', '/var/folders/z7/hcykr_n546s_5033t9rj5d200000zj/T/tmp2ptvz896', '/var/folders/z7/hcykr_n546s_5033t9rj5d200000zj/T/tmpvlklnq_r')

    def test_full_run(mk_tmp_dirs):
        """Make a full run with the default configuraiton"""
        tmp_current_path, tmp_data_path, tmp_config_path = mk_tmp_dirs
        exppath = path.join(DATAPATH, EXPFILE)

        args = [
            path.join(SCRIPT_DATA_PATH, 'calwebb_spec2.cfg'),
            exppath
        ]
>       Step.from_cmdline(args)

/Users/eisenham/Documents/ssbdev/jwst/jwst/pipeline/tests/test_calwebb_spec2.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py:143: in from_cmdline
    return cmdline.step_from_cmdline(args)
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/cmdline.py:320: in step_from_cmdline
    step.run(*positional)
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py:361: in run
    result = self.process(*args)
/Users/eisenham/Documents/ssbdev/jwst/jwst/pipeline/calwebb_spec2.py:89: in process
    asn.filename
/Users/eisenham/Documents/ssbdev/jwst/jwst/pipeline/calwebb_spec2.py:148: in process_exposure_product
    input = self.assign_wcs(input)
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py:361: in run
    result = self.process(*args)
/Users/eisenham/Documents/ssbdev/jwst/jwst/assign_wcs/assign_wcs_step.py:58: in process
    reffile = self.get_reference_file(input_model, reftype)
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py:633: in get_reference_file
    input_file, reference_file_type)
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/crds_client.py:150: in get_reference_file
    return list(get_multiple_reference_paths(input_file, [reference_file_type]).items())[0][1]
/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/crds_client.py:103: in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/crds_cache_locking.py:107: in get_cache_lock
    if not utils.is_writable(lockpath):
/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/utils.py:580: in is_writable
    return no_exist and len(os.path.dirname(filepath)) and is_writable(os.path.dirname(filepath))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

filepath = '/tmp', no_exist = True

    def is_writable(filepath, no_exist=True):
        """Interpret the mode bits of `filepath` in terms of the current user and it's groups,
        returning True if any of user, group, or other have write permission on the path.

        If `filepath` doesn't exist,  return `no_exist` if the directory is writable.
        """
        if not os.path.exists(filepath):   # If file doesn't exist,  make sure directory is writable.
            return no_exist and len(os.path.dirname(filepath)) and is_writable(os.path.dirname(filepath))
        stats = os.stat(filepath)
        return bool((stats.st_mode & stat.S_IWUSR) and (stats.st_uid == os.geteuid()) or
>                   (stats.st_mode & stat.S_IWGRP) and (stats.st_gid in os.getgroups()) or
                    (stats.st_mode & stat.S_IWOTH))
E       OSError: [Errno 22] Invalid argument

/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/utils.py:583: OSError
----------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------
----------------------------------------------------------------------
ERROR RUNNING STEP 'Spec2Pipeline':
    [Errno 22] Invalid argument
Traceback (most recent call last):
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/cmdline.py", line 320, in step_from_cmdline
    step.run(*positional)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/pipeline/calwebb_spec2.py", line 89, in process
    asn.filename
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/pipeline/calwebb_spec2.py", line 148, in process_exposure_product
    input = self.assign_wcs(input)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/assign_wcs/assign_wcs_step.py", line 58, in process
    reffile = self.get_reference_file(input_model, reftype)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/step.py", line 633, in get_reference_file
    input_file, reference_file_type)
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/crds_client.py", line 150, in get_reference_file
    return list(get_multiple_reference_paths(input_file, [reference_file_type]).items())[0][1]
  File "/Users/eisenham/Documents/ssbdev/jwst/jwst/stpipe/crds_client.py", line 103, in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
  File "/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/crds_cache_locking.py", line 107, in get_cache_lock
    if not utils.is_writable(lockpath):
  File "/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/utils.py", line 580, in is_writable
    return no_exist and len(os.path.dirname(filepath)) and is_writable(os.path.dirname(filepath))
  File "/Users/eisenham/anaconda3/envs/spec2/lib/python3.5/site-packages/crds/core/utils.py", line 583, in is_writable
    (stats.st_mode & stat.S_IWGRP) and (stats.st_gid in os.getgroups()) or
OSError: [Errno 22] Invalid argument

----------------------------------------------------------------------
----------------------------------------------------------------------------- Captured stderr call -----------------------------------------------------------------------------
2017-07-26 14:35:07,133 - stpipe.Spec2Pipeline - INFO - Spec2Pipeline instance created.
2017-07-26 14:35:07,134 - stpipe.Spec2Pipeline.imprint_subtract - INFO - ImprintStep instance created.
2017-07-26 14:35:07,135 - stpipe.Spec2Pipeline.fringe - INFO - FringeStep instance created.
2017-07-26 14:35:07,136 - stpipe.Spec2Pipeline.extract_2d - INFO - Extract2dStep instance created.
2017-07-26 14:35:07,136 - stpipe.Spec2Pipeline.extract_1d - INFO - Extract1dStep instance created.
2017-07-26 14:35:07,137 - stpipe.Spec2Pipeline.photom - INFO - PhotomStep instance created.
2017-07-26 14:35:07,139 - stpipe.Spec2Pipeline.cube_build - INFO - CubeBuildStep instance created.
2017-07-26 14:35:07,140 - stpipe.Spec2Pipeline.flat_field - INFO - FlatFieldStep instance created.
2017-07-26 14:35:07,140 - stpipe.Spec2Pipeline.srctype - INFO - SourceTypeStep instance created.
2017-07-26 14:35:07,141 - stpipe.Spec2Pipeline.bkg_subtract - INFO - BackgroundStep instance created.
2017-07-26 14:35:07,142 - stpipe.Spec2Pipeline.assign_wcs - INFO - AssignWcsStep instance created.
2017-07-26 14:35:07,143 - stpipe.Spec2Pipeline.resample_spec - INFO - ResampleSpecStep instance created.
2017-07-26 14:35:07,143 - stpipe.Spec2Pipeline.pathloss - INFO - PathLossStep instance created.
2017-07-26 14:35:07,144 - stpipe.Spec2Pipeline.straylight - INFO - StraylightStep instance created.
2017-07-26 14:35:07,144 - stpipe - INFO - Hostname: inanna2.local.stsci.edu
2017-07-26 14:35:07,144 - stpipe - INFO - OS: Darwin
2017-07-26 14:35:11,011 - stpipe.Spec2Pipeline.fringe - INFO - Prefetch for FRINGE reference file is 'N/A'.
2017-07-26 14:35:12,431 - stpipe.Spec2Pipeline.extract_1d - INFO - Prefetch for EXTRACT1D reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_extract1d_0004.json'.
2017-07-26 14:35:13,247 - stpipe.Spec2Pipeline.photom - INFO - Prefetch for AREA reference file is 'N/A'.
2017-07-26 14:35:13,247 - stpipe.Spec2Pipeline.photom - INFO - Prefetch for PHOTOM reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_photom_0014.fits'.
2017-07-26 14:35:14,106 - stpipe.Spec2Pipeline.cube_build - INFO - Prefetch for CUBEPAR reference file is 'N/A'.
2017-07-26 14:35:14,106 - stpipe.Spec2Pipeline.cube_build - INFO - Prefetch for RESOL reference file is 'N/A'.
2017-07-26 14:35:15,833 - stpipe.Spec2Pipeline.flat_field - INFO - Prefetch for DFLAT reference file is 'N/A'.
2017-07-26 14:35:15,833 - stpipe.Spec2Pipeline.flat_field - INFO - Prefetch for FFLAT reference file is 'N/A'.
2017-07-26 14:35:15,833 - stpipe.Spec2Pipeline.flat_field - INFO - Prefetch for FLAT reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_flat_0244.fits'.
2017-07-26 14:35:15,833 - stpipe.Spec2Pipeline.flat_field - INFO - Prefetch for SFLAT reference file is 'N/A'.
2017-07-26 14:35:18,140 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for CAMERA reference file is 'N/A'.
2017-07-26 14:35:18,140 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for COLLIMATOR reference file is 'N/A'.
2017-07-26 14:35:18,140 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for DISPERSER reference file is 'N/A'.
2017-07-26 14:35:18,140 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for DISTORTION reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_distortion_0023.asdf'.
2017-07-26 14:35:18,140 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FILTEROFFSET reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FORE reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FPA reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUFORE reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUPOST reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUSLICER reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for MSA reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for OTE reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for REGIONS reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for SPECWCS reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_specwcs_0001.fits'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for V2V3 reference file is 'N/A'.
2017-07-26 14:35:18,141 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for WAVELENGTHRANGE reference file is 'N/A'.
2017-07-26 14:35:19,396 - stpipe.Spec2Pipeline.resample_spec - INFO - Prefetch for DRIZPARS reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_drizpars_0001.fits'.
2017-07-26 14:35:20,283 - stpipe.Spec2Pipeline.pathloss - INFO - Prefetch for PATHLOSS reference file is 'N/A'.
2017-07-26 14:35:21,167 - stpipe.Spec2Pipeline.straylight - INFO - Prefetch for STRAYMASK reference file is 'N/A'.
2017-07-26 14:35:21,234 - stpipe.Spec2Pipeline - INFO - Step Spec2Pipeline running with args ('/Users/eisenham/Documents/ssbdev/testdata/pandokia/jwcalibdev/data4/jwst_test_data/pipelines/jw00035001001_01101_00001_mirimage_rate.fits',).
2017-07-26 14:35:21,234 - stpipe.Spec2Pipeline - INFO - Starting calwebb_spec2 ...
2017-07-26 14:35:21,376 - stpipe.Spec2Pipeline - INFO - Processing product /Users/eisenham/Documents/ssbdev/testdata/pandokia/jwcalibdev/data4/jwst_test_data/pipelines/jw00035001001_01101_00001_mirimage
2017-07-26 14:35:21,377 - stpipe.Spec2Pipeline - INFO - Working on input /Users/eisenham/Documents/ssbdev/testdata/pandokia/jwcalibdev/data4/jwst_test_data/pipelines/jw00035001001_01101_00001_mirimage_rate.fits ...
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for CAMERA reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for COLLIMATOR reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for DISPERSER reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for DISTORTION reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_distortion_0023.asdf'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FILTEROFFSET reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FORE reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for FPA reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUFORE reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUPOST reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for IFUSLICER reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for MSA reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for OTE reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for REGIONS reference file is 'N/A'.
2017-07-26 14:35:21,891 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for SPECWCS reference file is '/Users/eisenham/Documents/ssbdev/testdata/crds-cache/references/jwst/miri/jwst_miri_specwcs_0001.fits'.
2017-07-26 14:35:21,892 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for V2V3 reference file is 'N/A'.
2017-07-26 14:35:21,892 - stpipe.Spec2Pipeline.assign_wcs - INFO - Prefetch for WAVELENGTHRANGE reference file is 'N/A'.
2017-07-26 14:35:21,926 - stpipe.Spec2Pipeline.assign_wcs - INFO - Step assign_wcs running with args (<jwst.datamodels.image.ImageModel object at 0x11aa5ae48>,).
===================================================================== 1 failed, 6 passed in 84.39 seconds ======================================================================
(spec2) [eisenham@inanna2 jwst]$

`crds list --status` contains summary with what appears to be a warning.

Running crds list --status as described in basic usage returns a CRDS Summary with what appears to be a warning about the unmaintained __rationale__

>>> crds list --status
CRDS Summary = 'The __rationale__ variable is no longer maintained and will be removed in a future release.'
CRDS Version = '11.17.2, b11.4.0, 64d96076d89b32a5687a6b77bb910ab93b3a99b3'
CRDS_MODE = 'auto'
...

StrConfigItem returns None instead of 'none' if os.environ is modified

This issue arose while attempting to get stdatamodels tests to run locally (fix and semi-related discussion in: spacetelescope/stdatamodels#117).

A set of tests including a local import of crds always failed after the first call. This was traced back to a use of CRDS_REFERENCE_URI that returned None instead of 'none'. Here's a reproducer:

import os
import pytest

@pytest.fixture
def jail_environ():
    """Lock changes to the environment"""
    original = os.environ.copy()
    try:
        yield
    finally:
        os.environ = original

@pytest.mark.parametrize('value', ['1', '2'])
def test_crds(jail_environ, value):
    import crds
    assert crds.core.config.CRDS_REFERENCE_URI.get() == 'none'

If the import crds is moved outside the test (and no longer 'jailed' by the fixture) the tests pass without issue.

I'm not certain if this is a crds bug as crds might assume that the environment variables are unchanged between calls. A minimal reproducer (without pytest is):

import os
import crds

assert crds.core.config.CRDS_REFERENCE_URI.get() == 'none'
del os.environ['CRDS_REFERENCE_URI']
assert crds.core.config.CRDS_REFERENCE_URI.get() is None

The 'issue' isn't seen with an unmodified environment because the first call to StrConfigItem.get occurs within StrConfigItem.__init__ and the return value is thrown away. This call also sets the environment variable so future calls to StrConfigItem.get return the expected 'none'.

self.get()

I think the issue could be addressed by changing these None values to 'none' (but am not familiar with the inner workings of CRDS to predict any knock-on effects).

crds/crds/core/config.py

Lines 735 to 749 in 4b19990

CRDS_CONFIG_URI = StrConfigItem("CRDS_CONFIG_URI", None,
"Defines the URL/URI from which CRDS config files are downloaded.",
lower=True)
CRDS_MAPPING_URI = StrConfigItem("CRDS_MAPPING_URI", None,
"Defines the URL/URI from which CRDS mapping files are downloaded.",
lower=True)
CRDS_REFERENCE_URI = StrConfigItem("CRDS_REFERENCE_URI", None,
"Defines the URL/URI from which CRDS reference files are downloaded.",
lower=True)
CRDS_PICKLE_URI = StrConfigItem("CRDS_PICKLE_URI", None,
"Defines the URL/URI from which CRDS pickle files are downloaded.",
lower=True)

Feature Request: Download bestref from AWS S3 buckets

In an R&D effort over at https://jira.stsci.edu/browse/JUSI-8 and trying to run ACS pipeline in a notebook, I see commands like:

import os

os.environ['CRDS_SERVER_URL'] = 'https://hst-crds.stsci.edu'
os.environ['CRDS_SERVER'] = 'https://hst-crds.stsci.edu'
os.environ['CRDS_PATH'] = './crds_cache'
os.environ['jref'] = './crds_cache/references/hst/acs/'
crds bestrefs --files j9l960a7q_raw.fits --sync-references=1 --update-bestrefs

While it works, when I am in a JupyterHub instance hosted on AWS and want to grab the bestrefs from existing S3 buckets, I can't think of a way to do it without bypassing CRDS interface (e.g., manually parsing FITS header and constructing URIs for each reference file).

Currently, ASB has all HST reference files uploaded at S3://stpubdata/hst/public/references/. For example:

  • s3://stpubdata/hst/public/references/hst_wfc3_bpixtab_0260.rmap
  • s3://stpubdata/hst/public/references/2ck1856fi_bpx.fits

I am wondering if it is a reasonable request to have CRDS have a "cloud" option like astroquery.mast does; see Python snippet in https://mast-labs.stsci.io/2018/06/hst-public-data-on-aws .

cc @stscicrawford @ivastar

Improve download options

What is the preferred way to download data automatically? It would be great if the download options are improved. This is what I currently have:

from urllib.request import urlretrieve 

os.environ['iref'] = '~/iref/'
if not os.path.exists('iref'):
    os.mkdir('iref')

os.environ['jref'] = '~/jref/'
if not os.path.exists('jref'):
    os.mkdir('jref')

base_url = 'https://hst-crds.stsci.edu/unchecked_get/references/hst/'

files = glob.glob('data_download/mastDownload/HST/*/*fl?.fits')

for file in files:
    with fits.open(file) as hdu:
        for key in ['IDCTAB','NPOLFILE','D2IMFILE']:
            reffile_name = hdu[0].header[key].replace('$', '/')
            print(reffile_name)
            if not os.path.exists(reffile_name):
                urlretrieve(base_url + os.path.basename(reffile_name), reffile_name)

Improve documentation to methods

Documentation for assign_bestrefs https://hst-crds.stsci.edu/static/users_guide/library_use.html#crds-assign-bestrefs should be improved and describe expected argument type and what arguments do. I came across a case when user was setting filepaths='ie6d07ujq_flc.fits' (as an example) and then CRDS erred with messages that it cannot find files i, e, 6, d, ...

It would be great if CRDS documentation could follow style guide https://github.com/spacetelescope/style-guides/blob/06111fd0e4054f7835a6cd83dec3ce9049b3b970/guides/python.md#docstrings. Other functions seems to be documented slightly better but each has its own style.

Deprecation raised during the install of CRDS

When one installs CRDS on python 3.11 using pip 23.0.1 the following warning gets issued:

DEPRECATION: lxml is being installed using the legacy 'setup.py install' method, 
because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. 
pip 23.1 will enforce this behaviour change. A possible replacement is to enable the 
'--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559

This appears to be because lxml relies only on a setup.py to control its install, so there is no wheel generated.

This may start creating issues for installing CRDS (and its downstream packages) on pip 23.1+, which seems like it will necessitate adding the --use-pep517 flag to pip install in these cases. This may create issues for our users in the near future.

There seems to be a bug reported to lxml: https://bugs.launchpad.net/lxml/+bug/1993882, but it does not appear to have much activity in attempting to fix it.

resolve SonarScan issues

Before the regression tests can be run in spacetelescope/RegressionTests, these issues must be resolved (ITSD requires that all code running on on-prem hardware pass SonarScan), or marked as non-issues. Can I mark any of these as "wontfix" or "false positive"?

https://plsonarqube.stsci.edu/project/issues?resolved=false&types=BUG&inNewCodePeriod=false&id=crds_client

  • Delete this unreachable code or refactor the code to make it reachable.

    crds/crds/core/config.py

    Lines 883 to 889 in 2d7c93b

    if get_cache_readonly(): # message and quit
    func("READONLY CACHE", *args, **keys)
    return False
    else:
    return True
    func_check_writable.__name__ = "wrapped_writable_" + func.__name__
    func_check_writable._wrapped_writable = True
  • Group parts of the regex together to make the intended operator precedence explicit.
    REF_EXT_RE = re.compile(r"\.fits|\.r\dh$")
  • Introduce a new variable or use its initial value before reassigning 'rmapping'.
    def fix_rmap_undefined_useafter(rmapping, new_filename, *args, **keys):
  • Group parts of the regex together to make the intended operator precedence explicit.
    REF_EXT_RE = re.compile(r"\.fits|\.r\dh$")
  • The return value of "repr" must be used.
    @mark.multimission
    @mark.certify
    def test_tpn_repr():
    # typical subtle expression error, "=" vs. "=="
    info = generic_tpn.TpnInfo('DETECTOR','H', 'C', 'R', ("FOO","BAR","BAZ"))
    repr(validators.validator(info))
  • Remove or refactor this statement; it has no side effects.

    crds/test/core/test_rmap.py

    Lines 983 to 994 in 2d7c93b

    @mark.hst
    @mark.core
    @mark.rmap
    def test_rmap_match_not_applicable(default_shared_state, hst_data):
    r = rmap.get_cached_mapping(f"{hst_data}/hst_acs_darkfile_na_omit.rmap")
    r.get_best_ref({
    "DETECTOR" : "SBC",
    "CCDAMP" : "A",
    "CCDGAIN" : "1.0",
    "DATE-OBS" : "1993-01-01",
    "TIME-OBS" : "12:00:00",
    }) == "NOT FOUNT n/a"

DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`

This line seems to trigger some deprecation warning in acstools test suite. Looks like this is only used for some ASDF stuff, @WilliamJamieson, any idea?

from pkg_resources import Requirement

acstools/tests/test_wfc_satdet.py:7: in <module>
    from acstools.tests.helpers import BaseACSTOOLS
acstools/tests/helpers.py:7: in <module>
    from ci_watson.hst_helpers import ref_from_image, download_crds
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
_pytest/assertion/rewrite.py:168: in exec_module
    exec(co, module.__dict__)
ci_watson/hst_helpers.py:8: in <module>
    import crds
crds/__init__.py:33: in <module>
    from .core.rmap import get_cached_mapping, asmapping
crds/core/rmap.py:62: in <module>
    from pkg_resources import Requirement
pkg_resources/__init__.py:3258: in <module>
    def _initialize_master_working_set():
pkg_resources/__init__.py:3232: in _call_aside
    f(*args, **kwargs)
pkg_resources/__init__.py:3283: in _initialize_master_working_set
    tuple(dist.activate(replace=False) for dist in working_set)
pkg_resources/__init__.py:3283: in <genexpr>
    tuple(dist.activate(replace=False) for dist in working_set)
pkg_resources/__init__.py:2804: in activate
    declare_namespace(pkg)
pkg_resources/__init__.py:2298: in declare_namespace
    warnings.warn(msg, DeprecationWarning, stacklevel=2)
E   DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
E   Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`.
See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

Failure downloading files that are visible in the web interface

Hi,
I am trying to get reference files for updating headers on some WFPC2 data (refid u2dk0202t). When running crds (installed with Astroconda) using

crds bestrefs --files u2d*_c0m.fits --sync-references=1 --update-bestrefs

(with CRDS_SERVER_URL=https://hst-crds.stsci.edu & CRDS_PATH=reference_files/)

I run into a problem with some files (specifically dbu1405iu.r1d, e371355iu.r5d , f151225pu.r3d, f1j1615tu.r2d, f8213081u.r0d, g6h0944pu.r4d):

CRDS - INFO - Fetching reference_files/references/hst/wfpc2/g6h0944pu.r4d 10.2 M bytes (6 / 6 files) (0 / 46.2 M bytes)

CRDS - ERROR - Failure downloading file 'g6h0944pu.r4d' : Error fetching data for 'g6h0944pu.r4d' at CRDS server 'https://hst-crds.stsci.edu' with mode 'http' : Uknown file type for: 'g6h0944pu.r4d'

I do not know why it refers to .r?d files given that the header specifies .r?h file (e.g. FLATFILE= 'uref$g6h0944pu.r4h'), and the flatfile is visible in the web interface (e.g. https://hst-crds.stsci.edu/browse/g6h0944pu.r4h), and I also do not understand why these files fail to download - is this a problem with my installation of crds? (given that all other files download correctly I am a bit puzzled)

bestrefs "--sync-references=1" option broken

In crds v7.0.10 of bestrefs, the --sync-references=1 option raises an error. This error is not produced in v7.0.7, or if the --sync-references=1 option is left out.

(recent) bash-3.2$ python -m crds.bestrefs --update-bestrefs --files obpz06030_wav.fits 
CRDS - INFO -  No comparison context or source comparison requested.
CRDS - INFO -  ===> Processing obpz06030_wav.fits
CRDS - INFO -  0 errors
CRDS - INFO -  0 warnings
CRDS - INFO -  2 infos

(recent) bash-3.2$ python -m crds.bestrefs --update-bestrefs --sync-references=1 --files obpz06030_wav.fits 
CRDS - INFO -  No comparison context or source comparison requested.
CRDS - INFO -  ===> Processing obpz06030_wav.fits
Traceback (most recent call last):
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1332, in <module>
    sys.exit(main())
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1327, in main
    errors = BestrefsScript()()
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/cmdline.py", line 174, in __call__
    self._main()
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/cmdline.py", line 155, in _main
    self._exit_status = self.main()
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1000, in main
    self.post_processing()
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1223, in post_processing
    self.sync_references()
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1302, in sync_references
    synced_references = {tup.new for tup in self.updates if tup.new not in ["N/A"]}
  File "/Users/lockwood/anaconda/envs/recent/lib/python2.7/site-packages/crds/bestrefs.py", line 1302, in <setcomp>
    synced_references = {tup.new for tup in self.updates if tup.new not in ["N/A"]}
AttributeError: 'str' object has no attribute 'new'

Move Roman Tests To Unique File

Move the Roman tests presently in test_certify to a new file (test_certify_roman?) for clarity and ease of Roman-specific testing.

crds.getreferences does not verify local files

If a file exists in the local cache, the file is not verifid on a call to getreferences. Using the example in this issue below, when run the first time (assuming no corresponding file exists) the file will be downloaded and verified as seen here

crds/crds/client/api.py

Lines 673 to 680 in aa0d8f3

def download_core(self, name, localpath):
"""Download and verify file `name` under context `pipeline_context` to `localpath`."""
if config.get_download_plugin():
self.plugin_download(name, localpath)
else:
generator = self.get_data_http(name)
self.generator_download(generator, localpath)
self.verify_file(name, localpath)

If run a second time (when the file exists) the file will be opened and not verified. This can be confirmed by replacing the file with a blank file of the same name.

import logging
import crds

logging.basicConfig(level=logging.DEBUG)
logging.root.setLevel(logging.DEBUG)
dd = {
    'roman.meta.instrument.name': 'WFI',
    'roman.meta.instrument.detector': 'WFI02',
     'roman.meta.exposure.start_time': '2021-01-01T00:00:00.000',
}

crds.getreferences(dd, reftypes=('mask',), observatory='roman')

@stscieisenhamer came up with the initial test (replacing the file with a blank file) and mentioned that this issue can result in an incorrect local crds cache if multiple processes attempt to fetch the same file (crds attempts to protect against this but may not be perfect). @zacharyburnett may have fixed the jwst regression tests to improve the reliability of crds syncing and these improvements might be port-able to roman to improve the reliability of regression tests.

crds issues warning on python 3.12 due to `ast.Str` deprecation

The following warning was seen in a python 3.12 test run in stdatamodels:
https://github.com/spacetelescope/stdatamodels/actions/runs/6611014333/job/18095432388

E               crds.core.exceptions.MappingError: Can't load file jwst_nirspec_apcorr_0009.rmap : ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead

Possibly due to usage here:

self.assert_(node, isinstance(node.value, (ast.Call, ast.Dict, ast.Str)),

Retire Python 2

Python 2 will not be maintained past Jan 1, 2020 (see https://pythonclock.org/). Please remove all Python 2 compatibility and move this package to Python 3 only.

For conda recipe (including astroconda-contrib), please include the following to prevent packaging it for Python 2 (https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html?preprocessing-selectors#skipping-builds):

build: 
  skip: true  # [py2k] 

Please close this issue if it is irrelevant to your repository. This is an automated issue. If this is opened in error, please let pllim know!

crds sync warns about unusual CRDS file state 'delivered'

I'm seeing a warning when using crds sync to pull over new reffiles to our JWST CRDS cache using https://jwst-crds-pub.stsci.edu.

2022-09-29 01:18:07,562 - CRDS - WARNING -  File 'jwst_0963.pmap' has an unusual CRDS file state 'delivered'
2022-09-29 01:18:07,563 - CRDS - WARNING -  File 'jwst_0964.pmap' has an unusual CRDS file state 'delivered'
2022-09-29 01:18:07,793 - CRDS - WARNING -  File 'jwst_nirspec_0274.imap' has an unusual CRDS file state 'delivered'
2022-09-29 01:18:07,794 - CRDS - WARNING -  File 'jwst_nirspec_0275.imap' has an unusual CRDS file state 'delivered'
2022-09-29 01:18:07,847 - CRDS - WARNING -  File 'jwst_nirspec_superbias_0049.rmap' has an unusual CRDS file state 'delivered'
2022-09-29 01:18:07,848 - CRDS - WARNING -  File 'jwst_nirspec_superbias_0050.rmap' has an unusual CRDS file state 'delivered'

It pulls the files over just fine, and syncs them, but the verification code is expecting the state to be either "archived" or "operational":

crds/crds/sync.py

Lines 618 to 619 in 6638682

if info["state"] not in ["archived", "operational"]:
log.warning("File", repr(base), "has an unusual CRDS file state", repr(info["state"]))

Is this a case where CRDS state usage at STScI has moved beyond what the code is expecting? Or is the state of "delivered" incorrect?

lock file already exists causing hang

While running the calwebb_spec2 pipeline, I interrupted the process. Then, went to run it again, and it hung after instantiating all the steps. When interrupting this process, the following traceback occurs:

2017-08-04 11:37:26,436 - stpipe.Spec2Pipeline - INFO - Spec2Pipeline instance created.
2017-08-04 11:37:26,436 - stpipe.Spec2Pipeline - INFO - Spec2Pipeline instance created.
2017-08-04 11:37:26,436 - stpipe.Spec2Pipeline - INFO - Spec2Pipeline instance created.
2017-08-04 11:37:26,436 - stpipe.Spec2Pipeline - INFO - Spec2Pipeline instance created.
2017-08-04 11:37:26,441 - stpipe.Spec2Pipeline.extract_1d - INFO - Extract1dStep instance created.
2017-08-04 11:37:26,441 - stpipe.Spec2Pipeline.extract_1d - INFO - Extract1dStep instance created.
2017-08-04 11:37:26,441 - stpipe.Spec2Pipeline.extract_1d - INFO - Extract1dStep instance created.
2017-08-04 11:37:26,441 - stpipe.Spec2Pipeline.extract_1d - INFO - Extract1dStep instance created.
2017-08-04 11:37:26,444 - stpipe.Spec2Pipeline.straylight - INFO - StraylightStep instance created.
2017-08-04 11:37:26,444 - stpipe.Spec2Pipeline.straylight - INFO - StraylightStep instance created.
2017-08-04 11:37:26,444 - stpipe.Spec2Pipeline.straylight - INFO - StraylightStep instance created.
2017-08-04 11:37:26,444 - stpipe.Spec2Pipeline.straylight - INFO - StraylightStep instance created.
2017-08-04 11:37:26,447 - stpipe.Spec2Pipeline.assign_wcs - INFO - AssignWcsStep instance created.
2017-08-04 11:37:26,447 - stpipe.Spec2Pipeline.assign_wcs - INFO - AssignWcsStep instance created.
2017-08-04 11:37:26,447 - stpipe.Spec2Pipeline.assign_wcs - INFO - AssignWcsStep instance created.
2017-08-04 11:37:26,447 - stpipe.Spec2Pipeline.assign_wcs - INFO - AssignWcsStep instance created.
2017-08-04 11:37:26,449 - stpipe.Spec2Pipeline.srctype - INFO - SourceTypeStep instance created.
2017-08-04 11:37:26,449 - stpipe.Spec2Pipeline.srctype - INFO - SourceTypeStep instance created.
2017-08-04 11:37:26,450 - stpipe.Spec2Pipeline.srctype - INFO - SourceTypeStep instance created.
2017-08-04 11:37:26,450 - stpipe.Spec2Pipeline.srctype - INFO - SourceTypeStep instance created.
2017-08-04 11:37:26,452 - stpipe.Spec2Pipeline.fringe - INFO - FringeStep instance created.
2017-08-04 11:37:26,452 - stpipe.Spec2Pipeline.fringe - INFO - FringeStep instance created.
2017-08-04 11:37:26,453 - stpipe.Spec2Pipeline.fringe - INFO - FringeStep instance created.
2017-08-04 11:37:26,452 - stpipe.Spec2Pipeline.fringe - INFO - FringeStep instance created.
2017-08-04 11:37:26,454 - stpipe.Spec2Pipeline.bkg_subtract - INFO - BackgroundStep instance created.
2017-08-04 11:37:26,455 - stpipe.Spec2Pipeline.bkg_subtract - INFO - BackgroundStep instance created.
2017-08-04 11:37:26,455 - stpipe.Spec2Pipeline.bkg_subtract - INFO - BackgroundStep instance created.
2017-08-04 11:37:26,456 - stpipe.Spec2Pipeline.bkg_subtract - INFO - BackgroundStep instance created.
2017-08-04 11:37:26,457 - stpipe.Spec2Pipeline.extract_2d - INFO - Extract2dStep instance created.
2017-08-04 11:37:26,457 - stpipe.Spec2Pipeline.extract_2d - INFO - Extract2dStep instance created.
2017-08-04 11:37:26,458 - stpipe.Spec2Pipeline.extract_2d - INFO - Extract2dStep instance created.
2017-08-04 11:37:26,458 - stpipe.Spec2Pipeline.extract_2d - INFO - Extract2dStep instance created.
2017-08-04 11:37:26,460 - stpipe.Spec2Pipeline.cube_build - INFO - CubeBuildStep instance created.
2017-08-04 11:37:26,461 - stpipe.Spec2Pipeline.cube_build - INFO - CubeBuildStep instance created.
2017-08-04 11:37:26,462 - stpipe.Spec2Pipeline.cube_build - INFO - CubeBuildStep instance created.
2017-08-04 11:37:26,462 - stpipe.Spec2Pipeline.cube_build - INFO - CubeBuildStep instance created.
2017-08-04 11:37:26,463 - stpipe.Spec2Pipeline.pathloss - INFO - PathLossStep instance created.
2017-08-04 11:37:26,463 - stpipe.Spec2Pipeline.pathloss - INFO - PathLossStep instance created.
2017-08-04 11:37:26,464 - stpipe.Spec2Pipeline.pathloss - INFO - PathLossStep instance created.
2017-08-04 11:37:26,465 - stpipe.Spec2Pipeline.pathloss - INFO - PathLossStep instance created.
2017-08-04 11:37:26,465 - stpipe.Spec2Pipeline.imprint_subtract - INFO - ImprintStep instance created.
2017-08-04 11:37:26,466 - stpipe.Spec2Pipeline.imprint_subtract - INFO - ImprintStep instance created.
2017-08-04 11:37:26,467 - stpipe.Spec2Pipeline.imprint_subtract - INFO - ImprintStep instance created.
2017-08-04 11:37:26,467 - stpipe.Spec2Pipeline.imprint_subtract - INFO - ImprintStep instance created.
2017-08-04 11:37:26,468 - stpipe.Spec2Pipeline.photom - INFO - PhotomStep instance created.
2017-08-04 11:37:26,468 - stpipe.Spec2Pipeline.photom - INFO - PhotomStep instance created.
2017-08-04 11:37:26,469 - stpipe.Spec2Pipeline.photom - INFO - PhotomStep instance created.
2017-08-04 11:37:26,470 - stpipe.Spec2Pipeline.photom - INFO - PhotomStep instance created.
2017-08-04 11:37:26,471 - stpipe.Spec2Pipeline.resample_spec - INFO - ResampleSpecStep instance created.
2017-08-04 11:37:26,472 - stpipe.Spec2Pipeline.resample_spec - INFO - ResampleSpecStep instance created.
2017-08-04 11:37:26,473 - stpipe.Spec2Pipeline.resample_spec - INFO - ResampleSpecStep instance created.
2017-08-04 11:37:26,473 - stpipe.Spec2Pipeline.resample_spec - INFO - ResampleSpecStep instance created.
2017-08-04 11:37:26,474 - stpipe.Spec2Pipeline.flat_field - INFO - FlatFieldStep instance created.
2017-08-04 11:37:26,475 - stpipe.Spec2Pipeline.flat_field - INFO - FlatFieldStep instance created.
2017-08-04 11:37:26,476 - stpipe.Spec2Pipeline.flat_field - INFO - FlatFieldStep instance created.
2017-08-04 11:37:26,476 - stpipe.Spec2Pipeline.flat_field - INFO - FlatFieldStep instance created.
2017-08-04 11:37:26,598 - stpipe.Spec2Pipeline - INFO - Step Spec2Pipeline running with args ('level2a/jw93135011001_02102_00001_nrs2_rate.fits',).
2017-08-04 11:37:26,598 - stpipe.Spec2Pipeline - INFO - Step Spec2Pipeline running with args ('level2a/jw93135011001_02104_00001_nrs2_rate.fits',).
2017-08-04 11:37:26,598 - stpipe.Spec2Pipeline - INFO - Step Spec2Pipeline running with args ('level2a/jw93135011001_02101_00001_nrs2_rate.fits',).
2017-08-04 11:37:26,598 - stpipe.Spec2Pipeline - INFO - Step Spec2Pipeline running with args ('level2a/jw93135011001_0210b_00001_nrs1_rate.fits',).
2017-08-04 11:37:26,600 - stpipe.Spec2Pipeline - INFO - Starting calwebb_spec2 ...
2017-08-04 11:37:26,600 - stpipe.Spec2Pipeline - INFO - Starting calwebb_spec2 ...
2017-08-04 11:37:26,600 - stpipe.Spec2Pipeline - INFO - Starting calwebb_spec2 ...
2017-08-04 11:37:26,600 - stpipe.Spec2Pipeline - INFO - Starting calwebb_spec2 ...
2017-08-04 11:37:27,210 - stpipe.Spec2Pipeline - INFO - Processing product level2a/jw93135011001_02102_00001_nrs2
2017-08-04 11:37:27,212 - stpipe.Spec2Pipeline - INFO - Working on input level2a/jw93135011001_02102_00001_nrs2_rate.fits ...
2017-08-04 11:37:27,222 - stpipe.Spec2Pipeline - INFO - Processing product level2a/jw93135011001_0210b_00001_nrs1
2017-08-04 11:37:27,224 - stpipe.Spec2Pipeline - INFO - Working on input level2a/jw93135011001_0210b_00001_nrs1_rate.fits ...
2017-08-04 11:37:27,227 - stpipe.Spec2Pipeline - INFO - Processing product level2a/jw93135011001_02101_00001_nrs2
2017-08-04 11:37:27,229 - stpipe.Spec2Pipeline - INFO - Working on input level2a/jw93135011001_02101_00001_nrs2_rate.fits ...
2017-08-04 11:37:27,230 - stpipe.Spec2Pipeline - INFO - Processing product level2a/jw93135011001_02104_00001_nrs2
2017-08-04 11:37:27,233 - stpipe.Spec2Pipeline - INFO - Working on input level2a/jw93135011001_02104_00001_nrs2_rate.fits ...
Process ForkPoolWorker-2:
Process ForkPoolWorker-1:
Process ForkPoolWorker-4:
Process ForkPoolWorker-3:
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 31, in acquire
    os.link(self.unique_name, self.lock_file)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 31, in acquire
    os.link(self.unique_name, self.lock_file)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 31, in acquire
    os.link(self.unique_name, self.lock_file)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 31, in acquire
    os.link(self.unique_name, self.lock_file)
FileExistsError: [Errno 17] File exists: '/tmp/inanna2.stsci.edu-cf39c3c0.36594319212574973908563' -> '/tmp/crds.cache.lock.lock'
FileExistsError: [Errno 17] File exists: '/tmp/inanna2.stsci.edu-cf39c3c0.36574319212574973908563' -> '/tmp/crds.cache.lock.lock'
FileExistsError: [Errno 17] File exists: '/tmp/inanna2.stsci.edu-cf39c3c0.36564319212574973908563' -> '/tmp/crds.cache.lock.lock'
FileExistsError: [Errno 17] File exists: '/tmp/inanna2.stsci.edu-cf39c3c0.36584319212574973908563' -> '/tmp/crds.cache.lock.lock'

During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap
    self.run()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "<ipython-input-5-db23127d4248>", line 5, in spec2run
    output_dir='level2b'
  File "<ipython-input-5-db23127d4248>", line 5, in spec2run
    output_dir='level2b'
  File "<ipython-input-5-db23127d4248>", line 5, in spec2run
    output_dir='level2b'
  File "<ipython-input-5-db23127d4248>", line 5, in spec2run
    output_dir='level2b'
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 479, in call
    return instance.run(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 479, in call
    return instance.run(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 479, in call
    return instance.run(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 479, in call
    return instance.run(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 361, in run
    result = self.process(*args)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 83, in process
    asn.filename
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 83, in process
    asn.filename
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 83, in process
    asn.filename
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 83, in process
    asn.filename
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 137, in process_exposure_product
    input = self.assign_wcs(input)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 137, in process_exposure_product
    input = self.assign_wcs(input)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 137, in process_exposure_product
    input = self.assign_wcs(input)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/pipeline/calwebb_spec2.py", line 137, in process_exposure_product
    input = self.assign_wcs(input)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 336, in run
    self._precache_reference_files(args[0])
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 336, in run
    self._precache_reference_files(args[0])
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 336, in run
    self._precache_reference_files(args[0])
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 336, in run
    self._precache_reference_files(args[0])
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 549, in _precache_reference_files
    self._precache_reference_files_opened(model)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 549, in _precache_reference_files
    self._precache_reference_files_opened(model)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 549, in _precache_reference_files
    self._precache_reference_files_opened(model)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 549, in _precache_reference_files
    self._precache_reference_files_opened(model)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 573, in _precache_reference_files_opened
    self._precache_reference_files_impl(model_or_container)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 573, in _precache_reference_files_opened
    self._precache_reference_files_impl(model_or_container)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 573, in _precache_reference_files_opened
    self._precache_reference_files_impl(model_or_container)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 573, in _precache_reference_files_opened
    self._precache_reference_files_impl(model_or_container)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 591, in _precache_reference_files_impl
    crds_refs = crds_client.get_multiple_reference_paths(model, fetch_types)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 591, in _precache_reference_files_impl
    crds_refs = crds_client.get_multiple_reference_paths(model, fetch_types)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 591, in _precache_reference_files_impl
    crds_refs = crds_client.get_multiple_reference_paths(model, fetch_types)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/step.py", line 591, in _precache_reference_files_impl
    crds_refs = crds_client.get_multiple_reference_paths(model, fetch_types)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/crds_client.py", line 97, in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/crds_client.py", line 97, in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/crds_client.py", line 97, in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/jwst-0.7.8rc1.dev296-py3.5-macosx-10.7-x86_64.egg/jwst/stpipe/crds_client.py", line 97, in get_multiple_reference_paths
    with crds_cache_locking.get_cache_lock():
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/__init__.py", line 197, in __enter__
    self.acquire()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/__init__.py", line 197, in __enter__
    self.acquire()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/__init__.py", line 197, in __enter__
    self.acquire()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/__init__.py", line 197, in __enter__
    self.acquire()
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/crds/core/crds_cache_locking.py", line 72, in acquire
    result = super(CrdsLockFile, self).acquire(*args, **keys)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/crds/core/crds_cache_locking.py", line 72, in acquire
    result = super(CrdsLockFile, self).acquire(*args, **keys)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/crds/core/crds_cache_locking.py", line 72, in acquire
    result = super(CrdsLockFile, self).acquire(*args, **keys)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/crds/core/crds_cache_locking.py", line 72, in acquire
    result = super(CrdsLockFile, self).acquire(*args, **keys)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 50, in acquire
    time.sleep(timeout is not None and timeout / 10 or 0.1)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 50, in acquire
    time.sleep(timeout is not None and timeout / 10 or 0.1)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 50, in acquire
    time.sleep(timeout is not None and timeout / 10 or 0.1)
  File "/Users/eisenham/anaconda3/envs/pipeline/lib/python3.5/site-packages/lockfile/linklockfile.py", line 50, in acquire
    time.sleep(timeout is not None and timeout / 10 or 0.1)
KeyboardInterrupt
KeyboardInterrupt
KeyboardInterrupt
KeyboardInterrupt
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-13-7a3c5c492271> in <module>()
      4         (
      5             product['members'][0]['expname']
----> 6             for product in lvl2_asn['products']
      7         )
      8     )

~/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py in map(self, func, iterable, chunksize)
    258         in a list that is returned.
    259         '''
--> 260         return self._map_async(func, iterable, mapstar, chunksize).get()
    261 
    262     def starmap(self, func, iterable, chunksize=None):

~/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py in get(self, timeout)
    600 
    601     def get(self, timeout=None):
--> 602         self.wait(timeout)
    603         if not self.ready():
    604             raise TimeoutError

~/anaconda3/envs/pipeline/lib/python3.5/multiprocessing/pool.py in wait(self, timeout)
    597 
    598     def wait(self, timeout=None):
--> 599         self._event.wait(timeout)
    600 
    601     def get(self, timeout=None):

~/anaconda3/envs/pipeline/lib/python3.5/threading.py in wait(self, timeout)
    547             signaled = self._flag
    548             if not signaled:
--> 549                 signaled = self._cond.wait(timeout)
    550             return signaled
    551 

~/anaconda3/envs/pipeline/lib/python3.5/threading.py in wait(self, timeout)
    291         try:    # restore state no matter what (e.g., KeyboardInterrupt)
    292             if timeout is None:
--> 293                 waiter.acquire()
    294                 gotit = True
    295             else:

KeyboardInterrupt: 

Mapping._parse_header_selector error under python 3.8

Python 3.7.4:

In [1]: from crds.core import rmap

In [2]: rmap.Mapping.from_file(basename='jwst_0558.pmap')
Out[2]: Mapping('jwst_0558.pmap')

Python 3.8.0

In [1]: %xmode Verbose
Exception reporting mode: Verbose

In [2]: from crds.core import rmap

In [3]: rmap.Mapping.from_file(basename='jwst_0558.pmap')
---------------------------------------------------------------------------
MappingFormatError                        Traceback (most recent call last)
~/venv/test/lib/python3.8/site-packages/crds/core/log.py in func_on_exception(*args=("Can't load file jwst_0558.pmap",), **keys={'end': ''})
    365         try:
--> 366             yield
    367         except Exception as exc:

~/venv/test/lib/python3.8/site-packages/crds/core/rmap.py in _parse_header_selector(cls=<class 'crds.core.rmap.Mapping'>, text="header = {\n    'derived_from' : 'jwst_0557.pmap'...imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n", where='jwst_0558.pmap')
    291                                    exception_class=crexc.MappingError):
--> 292             code = MAPPING_VERIFIER.compile_and_check(text)
        code = undefined
        global MAPPING_VERIFIER.compile_and_check = <bound method MappingVerifier.compile_and_check of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        text = "header = {\n    'derived_from' : 'jwst_0557.pmap',\n    'description' : 'Hand edited to add FGS, MIRI, NIRCAM, NIRISS PATHLOSS as N/A',\n    'mapping' : 'PIPELINE',\n    'name' : 'jwst_0558.pmap',\n    'observatory' : 'JWST',\n    'parkey' : ('META.INSTRUMENT.NAME',),\n    'sha1sum' : '0ee26a826da4643bddcd7466dd75240228f227e7',\n}\n\nselector = {\n    'FGS' : 'jwst_fgs_0075.imap',\n    'MIRI' : 'jwst_miri_0185.imap',\n    'NIRCAM' : 'jwst_nircam_0122.imap',\n    'NIRISS' : 'jwst_niriss_0121.imap',\n    'NIRSPEC' : 'jwst_nirspec_0193.imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n"
    293             header, selector, comment = cls._interpret(code)

~/venv/test/lib/python3.8/site-packages/crds/core/mapping_verifier.py in compile_and_check(self=<crds.core.mapping_verifier.MappingVerifier object>, text="header = {\n    'derived_from' : 'jwst_0557.pmap'...imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n", source='<ast>', mode='exec')
    121         if sys.version_info >= (2, 7, 0):
--> 122             self.visit(ast.parse(text))
        self.visit = <bound method NodeVisitor.visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        global ast.parse = <function parse at 0x1018d2dc0>
        text = "header = {\n    'derived_from' : 'jwst_0557.pmap',\n    'description' : 'Hand edited to add FGS, MIRI, NIRCAM, NIRISS PATHLOSS as N/A',\n    'mapping' : 'PIPELINE',\n    'name' : 'jwst_0558.pmap',\n    'observatory' : 'JWST',\n    'parkey' : ('META.INSTRUMENT.NAME',),\n    'sha1sum' : '0ee26a826da4643bddcd7466dd75240228f227e7',\n}\n\nselector = {\n    'FGS' : 'jwst_fgs_0075.imap',\n    'MIRI' : 'jwst_miri_0185.imap',\n    'NIRCAM' : 'jwst_nircam_0122.imap',\n    'NIRISS' : 'jwst_niriss_0121.imap',\n    'NIRSPEC' : 'jwst_nirspec_0193.imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n"
    123         return compile(text, source, mode)

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Module object>)
    359         visitor = getattr(self, method, self.generic_visit)
--> 360         return visitor(node)
        visitor = <bound method NodeVisitor.generic_visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        node = <_ast.Module object at 0x110175490>
    361 

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in generic_visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Module object>)
    367                     if isinstance(item, AST):
--> 368                         self.visit(item)
        self.visit = <bound method NodeVisitor.visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        item = <_ast.Assign object at 0x1101753a0>
    369             elif isinstance(value, AST):

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Assign object>)
    359         visitor = getattr(self, method, self.generic_visit)
--> 360         return visitor(node)
        visitor = <bound method MappingVerifier.visit_Assign of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        node = <_ast.Assign object at 0x1101753a0>
    361 

~/venv/test/lib/python3.8/site-packages/crds/core/mapping_verifier.py in visit_Assign(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Assign object>)
    167                      "Section value must be a selector call or dictionary or string")
--> 168         self.generic_visit(node)
        self.generic_visit = <bound method NodeVisitor.generic_visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        node = <_ast.Assign object at 0x1101753a0>
    169 

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in generic_visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Assign object>)
    369             elif isinstance(value, AST):
--> 370                 self.visit(value)
        self.visit = <bound method NodeVisitor.visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        value = <_ast.Dict object at 0x110175640>
    371 

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Dict object>)
    359         visitor = getattr(self, method, self.generic_visit)
--> 360         return visitor(node)
        visitor = <bound method NodeVisitor.generic_visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        node = <_ast.Dict object at 0x110175640>
    361 

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in generic_visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Dict object>)
    367                     if isinstance(item, AST):
--> 368                         self.visit(item)
        self.visit = <bound method NodeVisitor.visit of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        item = <_ast.Constant object at 0x110170ee0>
    369             elif isinstance(value, AST):

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ast.py in visit(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Constant object>)
    359         visitor = getattr(self, method, self.generic_visit)
--> 360         return visitor(node)
        visitor = <bound method MappingVerifier.visit_Unknown of <crds.core.mapping_verifier.MappingVerifier object at 0x1032930d0>>
        node = <_ast.Constant object at 0x110170ee0>
    361 

~/venv/test/lib/python3.8/site-packages/crds/core/mapping_verifier.py in visit_Unknown(self=<crds.core.mapping_verifier.MappingVerifier object>, node=<_ast.Constant object>)
    151         """Handle new / unforseen node types."""
--> 152         self.assert_(node, False, "Unknown node type in mapping " + repr(node))
        self.assert_ = <bound method MappingVerifier.assert_ of <class 'crds.core.mapping_verifier.MappingVerifier'>>
        node = <_ast.Constant object at 0x110170ee0>
        global repr = undefined
    153 

~/venv/test/lib/python3.8/site-packages/crds/core/mapping_verifier.py in assert_(cls=<class 'crds.core.mapping_verifier.MappingVerifier'>, node=<_ast.Constant object>, flag=False, message='Unknown node type in mapping <_ast.Constant object at 0x110170ee0>')
    141             if hasattr(node, "lineno"):
--> 142                 raise crexc.MappingFormatError(message + " at line " + str(node.lineno))
        global crexc.MappingFormatError = <class 'crds.core.exceptions.MappingFormatError'>
        message = 'Unknown node type in mapping <_ast.Constant object at 0x110170ee0>'
        global str = undefined
        node.lineno = 2
    143             else:

MappingFormatError: Unknown node type in mapping <_ast.Constant object at 0x110170ee0> at line 2

The above exception was the direct cause of the following exception:

MappingError                              Traceback (most recent call last)
<ipython-input-3-929d75afc3b6> in <module>
----> 1 rmap.Mapping.from_file(basename='jwst_0558.pmap')
        global rmap.Mapping.from_file = <bound method Mapping.from_file of <class 'crds.core.rmap.Mapping'>>
        global basename = undefined

~/venv/test/lib/python3.8/site-packages/crds/core/rmap.py in from_file(cls=<class 'crds.core.rmap.Mapping'>, basename='jwst_0558.pmap', *args=(), **keys={})
    263             filename = config.locate_mapping(basename)
    264         text = utils.get_uri_content(filename)
--> 265         return cls.from_string(text, basename, *args, **keys)
        cls.from_string = <bound method Mapping.from_string of <class 'crds.core.rmap.Mapping'>>
        text = "header = {\n    'derived_from' : 'jwst_0557.pmap',\n    'description' : 'Hand edited to add FGS, MIRI, NIRCAM, NIRISS PATHLOSS as N/A',\n    'mapping' : 'PIPELINE',\n    'name' : 'jwst_0558.pmap',\n    'observatory' : 'JWST',\n    'parkey' : ('META.INSTRUMENT.NAME',),\n    'sha1sum' : '0ee26a826da4643bddcd7466dd75240228f227e7',\n}\n\nselector = {\n    'FGS' : 'jwst_fgs_0075.imap',\n    'MIRI' : 'jwst_miri_0185.imap',\n    'NIRCAM' : 'jwst_nircam_0122.imap',\n    'NIRISS' : 'jwst_niriss_0121.imap',\n    'NIRSPEC' : 'jwst_nirspec_0193.imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n"
        basename = 'jwst_0558.pmap'
        args = ()
        keys = {}
    266 
    267     @classmethod

~/venv/test/lib/python3.8/site-packages/crds/core/rmap.py in from_string(cls=<class 'crds.core.rmap.Mapping'>, text="header = {\n    'derived_from' : 'jwst_0557.pmap'...imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n", basename='jwst_0558.pmap', *args=(), **keys={})
    269         """Construct a mapping from string `text` nominally named `basename`."""
    270         keys.pop("comment", None) #  discard comment if defined
--> 271         header, selector, comment = cls._parse_header_selector(text, basename)
        header = undefined
        selector = undefined
        comment = undefined
        cls._parse_header_selector = <bound method Mapping._parse_header_selector of <class 'crds.core.rmap.Mapping'>>
        text = "header = {\n    'derived_from' : 'jwst_0557.pmap',\n    'description' : 'Hand edited to add FGS, MIRI, NIRCAM, NIRISS PATHLOSS as N/A',\n    'mapping' : 'PIPELINE',\n    'name' : 'jwst_0558.pmap',\n    'observatory' : 'JWST',\n    'parkey' : ('META.INSTRUMENT.NAME',),\n    'sha1sum' : '0ee26a826da4643bddcd7466dd75240228f227e7',\n}\n\nselector = {\n    'FGS' : 'jwst_fgs_0075.imap',\n    'MIRI' : 'jwst_miri_0185.imap',\n    'NIRCAM' : 'jwst_nircam_0122.imap',\n    'NIRISS' : 'jwst_niriss_0121.imap',\n    'NIRSPEC' : 'jwst_nirspec_0193.imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n"
        basename = 'jwst_0558.pmap'
    272         mapping = cls(basename, header, selector, comment=comment, **keys)
    273         try:

~/venv/test/lib/python3.8/site-packages/crds/core/rmap.py in _parse_header_selector(cls=<class 'crds.core.rmap.Mapping'>, text="header = {\n    'derived_from' : 'jwst_0557.pmap'...imap',\n    'SYSTEM' : 'jwst_system_0019.imap',\n}\n", where='jwst_0558.pmap')
    291                                    exception_class=crexc.MappingError):
    292             code = MAPPING_VERIFIER.compile_and_check(text)
--> 293             header, selector, comment = cls._interpret(code)
        header = undefined
        selector = undefined
        comment = undefined
        cls._interpret = <bound method Mapping._interpret of <class 'crds.core.rmap.Mapping'>>
        code = undefined
    294         return LowerCaseDict(header), selector, comment
    295 

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py in __exit__(self=<contextlib._GeneratorContextManager object>, type=<class 'crds.core.exceptions.MappingFormatError'>, value=MappingFormatError('Unknown node type in mapping <_ast.Constant object at 0x110170ee0> at line 2'), traceback=<traceback object>)
    129                 value = type()
    130             try:
--> 131                 self.gen.throw(type, value, traceback)
        self.gen.throw = <built-in method throw of generator object at 0x1031494a0>
        type = <class 'crds.core.exceptions.MappingFormatError'>
        value = MappingFormatError('Unknown node type in mapping <_ast.Constant object at 0x110170ee0> at line 2')
        traceback = <traceback object at 0x11014f2c0>
    132             except StopIteration as exc:
    133                 # Suppress StopIteration *unless* it's the same exception that

~/venv/test/lib/python3.8/site-packages/crds/core/log.py in func_on_exception(*args=("Can't load file jwst_0558.pmap",), **keys={'end': ''})
    375                 exc_class = keys.pop("exception_class", exc.__class__)
    376                 keys["end"] = ""
--> 377                 raise exc_class(format(*args + (":", str(exc)), **keys)) from exc
        exc_class = <class 'crds.core.exceptions.MappingError'>
        global format = <bound method CrdsLogger.format of <crds.core.log.CrdsLogger object at 0x1031c2370>>
        args = ("Can't load file jwst_0558.pmap",)
        global str = undefined
        exc = undefined
        keys = {'end': ''}
    378             else:
    379                 pass # snuff the exception,  func() probably issued a log message.

MappingError: Can't load file jwst_0558.pmap : Unknown node type in mapping <_ast.Constant object at 0x110170ee0> at line 2

Make an importable version of bestrefs

Documenting here a summary of a conversation I had with @jaytmiller about the bestrefs tool. It would be great if instead of just a command line tool for bestrefs we also had a version we could import inside of Python code that could do all of the querying, updating of FITS headers, and downloading of reference files. Essentially, if I want to do a for loop over a bunch of FITS files inside a Python code, it would be great to have an importable module that replicates the behavior of:

crds bestrefs --files dataset*.fits --sync-references=1  --update-bestrefs

with something similar to:

crds.bestrefs('dataset.fits', sync_references=True, update_bestrefs=True)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.