opencadc / caom2tools

Common Archive Observation Model - data engineering tools
4 stars 13 forks source link

WCS validation is inconsistent between the caom2.4 service and the python wcsvalidator.py module #127

Open SharonGoliath opened 4 years ago

SharonGoliath commented 4 years ago

Get a test observation by:

caom2-repo read --cert $HOME/.ssl/cadcproxy.pem GEMINI GS-2019A-Q-404-122-015 > GS-2019A-Q-404-122-015.xml

Try to store that same xml to sc2repo, which has the latest version of the service WCS validation:

root@a5237b388ada:/usr/src/app/omm2caom2/int_test# caom2-repo create --netrc ./test_netrc --resource-id ivo://cadc.nrc.ca/sc2repo GS-2019A-Q-404-122-015.xml 
/usr/src/app/caom2tools/caom2/caom2/plane.py:1062: DeprecationWarning: Call to deprecated function (or staticmethod) em_band. (Replaced by energy_bands, gone in 2.5) -- Deprecated since version CAOM2.4.
  self.em_band = em_band
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/cadcutils/net/ws.py", line 534, in check_status
    response.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://sc2.canfar.net/sc2repo/auth-observations23/GEMINI/GS-2019A-Q-404-122-015

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/caom2-repo", line 8, in <module>
    sys.exit(main_app())
  File "/usr/local/lib/python3.8/site-packages/caom2repo/core.py", line 719, in main_app
    client.put_observation(obs_reader.read(args.observation))
  File "/usr/local/lib/python3.8/site-packages/caom2repo/core.py", line 479, in put_observation
    self._repo_client.put(
  File "/usr/local/lib/python3.8/site-packages/cadcutils/net/ws.py", line 306, in put
    return self._get_session().put(self._get_url(resource), **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 590, in put
    return self.request('PUT', url, data=data, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/cadcutils/net/ws.py", line 483, in send
    self.check_status(response)
  File "/usr/local/lib/python3.8/site-packages/cadcutils/net/ws.py", line 543, in check_status
    raise exceptions.BadRequestException(orig_exception=e)
cadcutils.exceptions.BadRequestException: invalid input: caom:GEMINI/GS-2019A-Q-404-122-015java.lang.IllegalArgumentException: invalid input: caom:GEMINI/GS-2019A-Q-404-122-015
cause: java.lang.IllegalArgumentException: Invalid Axes: missing axis 1

Try to validate that same xml with the python wcsvalidator module:

root@a5237b388ada:/usr/src/app/omm2caom2/int_test# python
Python 3.8.2 (default, Feb 26 2020, 15:09:34) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from caom2utils import wcsvalidator as wv
INFO:config:Using config file /root/.config/vos/vos-config.
>>> from caom2pipe import manage_composable as mc
>>> obs = mc.read_obs_from_file('./GS-2019A-Q-404-122-015.xml')
/usr/src/app/caom2tools/caom2/caom2/plane.py:1062: DeprecationWarning: Call to deprecated function (or staticmethod) em_band. (Replaced by energy_bands, gone in 2.5) -- Deprecated since version CAOM2.4.
  self.em_band = em_band
>>> wv.validate_wcs(obs)
>>> 

Should the python and the service have generally the same failure modes?

SharonGoliath commented 4 years ago

Negative time delta is an additional case of validation inconsistency e.g. ad:CFHT/11Bm04.flat.u.36.00.fits.fz:

2020-06-01 23:47:02,482:ERROR:root :3993:'Invalid Temporal WCS: ValueError("Invalid function in Temporal WCS: ValueError(\'CoordFunction1D.naxis : 1\\nCoordFunction1D.delta : -23.0\\nCoordFunction1D.ref_coord : RefCoord.pix : 0.5\\nRefCoord.val : 55959.0 delta must be greater than 0.0\')"): TemporalWCS.axis : CoordAxis1D.axis : Axis.ctype : TIME\nAxis.cunit : d\nCoordAxis1D.error : CoordError.syser : 1e-07\nCoordError.rnder : 1e-07\nCoordAxis1D.range : None\nCoordAxis1D.bounds : None\nCoordAxis1D.function : CoordFunction1D.naxis : 1\nCoordFunction1D.delta : -23.0\nCoordFunction1D.ref_coord : RefCoord.pix : 0.5\nRefCoord.val : 55959.0\nTemporalWCS.timesys : UTC\nTemporalWCS.trefpos : None\nTemporalWCS.mjdref : None\nTemporalWCS.exposure : 1.132\nTemporalWCS.resolution : 1.132' 2020-06-01 23:47:02,483:ERROR:root :3995:Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/caom2utils/fits2caom2.py", line 3991, in _augment validate(obs) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 103, in validate _validate_observation(caom2_entity, deep) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 140, in _validate_observation _validate_plane(plane) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 162, in _validate_plane _validate_artifact(artifact) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 177, in _validate_artifact _validate_part(value) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 192, in _validate_part _validate_chunk(chunk) File "/usr/local/lib/python3.8/site-packages/caom2utils/caomvalidator.py", line 205, in _validate_chunk validate_wcs(caom2_entity) File "/usr/local/lib/python3.8/site-packages/caom2utils/wcsvalidator.py", line 116, in validate_wcs _validate_chunk(caom2_entity) File "/usr/local/lib/python3.8/site-packages/caom2utils/wcsvalidator.py", line 155, in _validate_chunk _validate_temporal_wcs(chunk.time) File "/usr/local/lib/python3.8/site-packages/caom2utils/wcsvalidator.py", line 260, in _validate_temporal_wcs raise InvalidWCSError( caom2utils.wcsvalidator.InvalidWCSError: 'Invalid Temporal WCS: ValueError("Invalid function in Temporal WCS: ValueError(\'CoordFunction1D.naxis : 1\\nCoordFunction1D.delta : -23.0\\nCoordFunction1D.ref_coord : RefCoord.pix : 0.5\\nRefCoord.val : 55959.0 delta must be greater than 0.0\')"): TemporalWCS.axis : CoordAxis1D.axis : Axis.ctype : TIME\nAxis.cunit : d\nCoordAxis1D.error : CoordError.syser : 1e-07\nCoordError.rnder : 1e-07\nCoordAxis1D.range : None\nCoordAxis1D.bounds : None\nCoordAxis1D.function : CoordFunction1D.naxis : 1\nCoordFunction1D.delta : -23.0\nCoordFunction1D.ref_coord : RefCoord.pix : 0.5\nRefCoord.val : 55959.0\nTemporalWCS.timesys : UTC\nTemporalWCS.trefpos : None\nTemporalWCS.mjdref : None\nTemporalWCS.exposure : 1.132\nTemporalWCS.resolution : 1.132'

where-as a direct write to /sc2repo succeeds.