templateflow / python-client

A python client to query TemplateFlow via pyBIDS
https://templateflow.org/python-client/
Apache License 2.0
8 stars 12 forks source link

Obscure error during datalad install #130

Closed oesteban closed 3 weeks ago

oesteban commented 6 months ago

This used to be rare, but now it looks systematic. I can't replicate locally:

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f35b0b2b5d0>
tmp_path = PosixPath('/tmp/pytest-of-circleci/pytest-1/test_setup_home_on_0')
capsys = <_pytest.capture.CaptureFixture object at 0x7f35b0b2a910>
use_datalad = 'on'

    @pytest.mark.parametrize('use_datalad', ['off', 'on'])
    def test_setup_home(monkeypatch, tmp_path, capsys, use_datalad):
        """Check the correct functioning of the installation hook."""
        home = (tmp_path / '-'.join(('tf', 'dl', use_datalad))).resolve()
        monkeypatch.setenv('TEMPLATEFLOW_USE_DATALAD', use_datalad)
        monkeypatch.setenv('TEMPLATEFLOW_HOME', str(home))

>       reload(tfc)

../src/templateflow/templateflow/conf/tests/test_conf.py:65: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/circleci/.pyenv/versions/3.11.8/lib/python3.11/importlib/__init__.py:169: in reload
    _bootstrap._exec(spec, module)
<frozen importlib._bootstrap>:621: in _exec
    ???
<frozen importlib._bootstrap_external>:940: in exec_module
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
../src/templateflow/templateflow/conf/__init__.py:56: in <module>
    _init_cache()
../src/templateflow/templateflow/conf/__init__.py:48: in _init_cache
    install(path=str(TF_HOME), source=TF_GITHUB_SOURCE, recursive=True)
../venv/lib/python3.11/site-packages/datalad/interface/base.py:773: in eval_func
    return return_func(*args, **kwargs)
../venv/lib/python3.11/site-packages/datalad/interface/base.py:763: in return_func
    results = list(results)
../venv/lib/python3.11/site-packages/datalad/interface/base.py:873: in _execute_command_
    for r in _process_results(
../venv/lib/python3.11/site-packages/datalad/interface/utils.py:375: in _process_results
    _render_result_generic(
../venv/lib/python3.11/site-packages/datalad/interface/utils.py:427: in _render_result_generic
    generic_result_renderer(res)
../venv/lib/python3.11/site-packages/datalad/interface/utils.py:239: in generic_result_renderer
    ui.message('{action}({status}):{path}{type}{msg}{err}'.format(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = SilentConsoleLog(out=<CaptureIO>)
msg = 'install(ok): /tmp/pytest-of-circleci/pytest-1/test_setup_home_on_0/tf-dl-on (dataset)'
cr = '\n'

    def message(self, msg, cr='\n'):
        from datalad.log import no_progress
        with no_progress():
            try:
>               self.out.write(msg)
E               ValueError: I/O operation on closed file.

../venv/lib/python3.11/site-packages/datalad/ui/dialog.py:77: ValueError

On that reload, we trigger a datalad install and there we get the ValueError.

Any ideas @yarikoptic ?

oesteban commented 6 months ago

Okay, it has to do with the test status. When ssh'ing into Circle, if I run all tests the error shows up but if I run only this particular test then things are okay.