SIMEXP / giga_auto_qc

Automatic quality control for fMRIPrep outputs aimed for large dataset
MIT License
1 stars 2 forks source link

Remove layout.sqlite in the test data #26

Open clarkenj opened 1 year ago

clarkenj commented 1 year ago

I am using the command pytest -m "not smoke" --doctest-modules -v --pyargs giga_auto_qc and the output is below. It seems to be looking in /home/haoting/projects/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmriprep22.0.1-downsampled for the test data (which I have downloaded to data/test_data/) so gets permission denied. I can't figure out how to fix this, I tried using an absolute path in test_cli.py

======================================================= test session starts =======================================================
platform linux -- Python 3.10.2, pytest-7.4.0, pluggy-1.2.0 -- /cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Core/python/3.10.2/bin/python
cachedir: .pytest_cache
rootdir: /lustre03/project/6003287/nclarke/giga_preprocess2/giga_auto_qc
collected 7 items                                                                                                                 

giga_auto_qc/tests/test_assessments.py::test_quality_accessments PASSED                                                     [ 14%]
giga_auto_qc/tests/test_assessments.py::test_dice_coefficient PASSED                                                        [ 28%]
giga_auto_qc/tests/test_assessments.py::test_check_mask_affine PASSED                                                       [ 42%]
giga_auto_qc/tests/test_assessments.py::test_get_consistent_masks PASSED                                                    [ 57%]
giga_auto_qc/tests/test_cli.py::test_smoke FAILED                                                                           [ 71%]
giga_auto_qc/tests/test_utils.py::test_get_subject_lists PASSED                                                             [ 85%]
giga_auto_qc/tests/test_utils.py::test_parse_scan_information PASSED                                                        [100%]

============================================================ FAILURES =============================================================
___________________________________________________________ test_smoke ____________________________________________________________

tmp_path = PosixPath('/tmp/pytest-of-nclarke/pytest-2/test_smoke0')

    @pytest.mark.skipif(
        IN_GITHUB_ACTIONS, reason="Test doesn't work in Github Actions."
    )
    def test_smoke(tmp_path):
        bids_dir = ("/home/nclarke/projects/rrg-pbellec/nclarke/giga_preprocess2/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmriprep22.0.1-downsampled-nosurface")

        args = argparse.Namespace(
            reindex_bids=False,
            verbose=1,
            participant_label=[],
            task=None,
            quality_control_parameters=None,
            analysis_level="participant",
            bids_dir=Path(bids_dir),
            output_dir=tmp_path,
        )

        # Smoke test the participant level
>       workflow(args)

giga_auto_qc/tests/test_cli.py:31: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
giga_auto_qc/workflow.py:47: in workflow
    fmriprep_bids_layout = BIDSLayout(
/home/nclarke/.local/lib/python3.10/site-packages/bids/layout/layout.py:128: in __init__
    root, description = validate_root(root, validate)
/home/nclarke/.local/lib/python3.10/site-packages/bids/layout/validation.py:69: in validate_root
    if not root.exists():
/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Core/python/3.10.2/lib/python3.10/pathlib.py:1288: in exists
    self.stat()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = PosixPath('/home/haoting/projects/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmriprep22.0.1-downsampled')

    def stat(self, *, follow_symlinks=True):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
>       return self._accessor.stat(self, follow_symlinks=follow_symlinks)
E       PermissionError: [Errno 13] Permission denied: '/home/haoting/projects/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmriprep22.0.1-downsampled'

/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx512/Core/python/3.10.2/lib/python3.10/pathlib.py:1095: PermissionError
------------------------------------------------------ Captured stdout call -------------------------------------------------------
Namespace(reindex_bids=False, verbose=1, participant_label=[], task=None, quality_control_parameters=None, analysis_level='participant', bids_dir=PosixPath('/home/nclarke/projects/rrg-pbellec/nclarke/giga_preprocess2/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmriprep22.0.1-downsampled-nosurface'), output_dir=PosixPath('/tmp/pytest-of-nclarke/pytest-2/test_smoke0'))
Quality control parameters: {'mean_fd': 0.55, 'scrubbing_fd': 0.2, 'proportion_kept': 0.5, 'anatomical_dice': 0.97, 'functional_dice': 0.89}
===================================================== short test summary info =====================================================
FAILED giga_auto_qc/tests/test_cli.py::test_smoke - PermissionError: [Errno 13] Permission denied: '/home/haoting/projects/giga_auto_qc/giga_auto_qc/data/test_data/ds000017-fmrip...
================================================== 1 failed, 6 passed in 29.48s ==================================================
htwangtw commented 1 year ago

That's because the bidslayout in the download data was indexed on my machine. You will need to set reindexing to true And I should delete the SQL database in the test data ....