sibis-platform / ncanda-data-integration

This is the Data Integration, MRI, and Bioinformatics Component of the National Consortium on Alcohol and NeuroDevelopment in Adolescence (NCANDA), funded by the NIAAA.
https://www.nitrc.org/projects/ncanda-datacore
BSD 3-Clause "New" or "Revised" License
4 stars 10 forks source link

Started catching 'invalid response from xnatsession' error #471

Closed gcyoung1 closed 2 years ago

kipohl commented 2 years ago

@gcyoung1 can you please post a test run ?

gcyoung1 commented 2 years ago

Yup, I'm in the process of writing a test for it.

kipohl commented 2 years ago

@gcyoung1 what was the outcome ?

gcyoung1 commented 2 years ago

@kipohl I have to refactor some of the check_phantom_scans code so that check_experiments can be imported in the test file. Currently check_phantom_scans is just an executable, so I have to remove some of the global variables and turn it back into a regular .py file with a main function. I'll link that PR here when I finish.

gcyoung1 commented 2 years ago

474

gcyoung1 commented 2 years ago

I couldn't really figure out how patching works, so the test is kind of hacky, but this passes the test:

ncanda@pipeline-back[pipeline_back_1]:/fs/ncanda-share/beta/griffin/ncanda-data-integration/test/scripts/xnat (bug/catch_xnat_response_error)$ pytest test_check_phantom_scans.py
=========================== test session starts ===========================
platform linux -- Python 3.8.7, pytest-7.1.1, pluggy-1.0.0
cachedir: /home/ncanda/.pytest_cache
rootdir: /fs/ncanda-share/beta/griffin/ncanda-data-integration/test, configfile: pytest.ini
plugins: mock-3.5.1, snapshot-0.5.0, anyio-3.5.0, shutil-1.4.0, svn-1.4.0
collected 1 item                                                          

test_check_phantom_scans.py .                                       [100%]

============================ warnings summary =============================
test_check_phantom_scans.py:62
  /fs/ncanda-share/beta/griffin/ncanda-data-integration/test/scripts/xnat/test_check_phantom_scans.py:62: PytestAssertRewriteWarning: assertion is always true, perhaps remove parentheses?
    assert(sibis_config, "Could not get operations directory from session")

../../../../../../../../usr/local/lib/python3.8/site-packages/future/standard_library/__init__.py:65
  /usr/local/lib/python3.8/site-packages/future/standard_library/__init__.py:65: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:10
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:10: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _nlv = LooseVersion(_np_version)

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:11
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:11: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p16 = _nlv < LooseVersion("1.16")

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:12
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:12: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p17 = _nlv < LooseVersion("1.17")

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:13
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:13: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p18 = _nlv < LooseVersion("1.18")

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:14
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:14: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p19 = _nlv < LooseVersion("1.19")

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:15
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/__init__.py:15: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    _np_version_under1p20 = _nlv < LooseVersion("1.20")

../../../../../../../../usr/local/lib/python3.8/site-packages/setuptools/_distutils/version.py:351
  /usr/local/lib/python3.8/site-packages/setuptools/_distutils/version.py:351: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    other = LooseVersion(other)

../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125
../../../../../../../../usr/local/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125
  /usr/local/lib/python3.8/site-packages/pandas/compat/numpy/function.py:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(_np_version) >= LooseVersion("1.17.0"):

../../../../../../../../usr/local/lib/python3.8/site-packages/xnat/core.py:19
../../../../../../../../usr/local/lib/python3.8/site-packages/xnat/core.py:19
../../../../../../../../usr/local/lib/python3.8/site-packages/xnat/core.py:19
../../../../../../../../usr/local/lib/python3.8/site-packages/xnat/core.py:19
  /usr/local/lib/python3.8/site-packages/xnat/core.py:19: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    from collections import MutableMapping, MutableSequence, Mapping, Sequence, namedtuple

scripts/xnat/test_check_phantom_scans.py::test_select_experiments[/home/ncanda/.sibis-general-config.yml]
  /usr/local/lib/python3.8/site-packages/yaml/constructor.py:126: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
    if not isinstance(key, collections.Hashable):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================== 1 passed, 16 warnings in 17.02s =====================
kipohl commented 2 years ago

@gcyoung1 sorry to be dense here, but should the try / except not be part of a sibispy function that is used across scripts ? lets maybe talk about it today at 1pm