neurodatascience / cohort_creator

Creates a neuroimaging cohort by aggregating data across datasets.
https://cohort-creator.readthedocs.io/en/latest/
MIT License
1 stars 2 forks source link

[BUG] Local setup and system-test seem broken for the `get` subcommand #241

Open surchs opened 2 days ago

surchs commented 2 days ago

Is there an existing issue for this?

Expected Behavior

I can follow the setup instructions and then run a successful get example

Current Behavior

I am unable to get a dataset

Error message

Traceback (most recent call last):
  File "/home/surchs/miniconda3/envs/cohort/bin/cohort_creator", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/_cli.py", line 104, in cli
    get_data(
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/main.py", line 192, in get_data
    uri = get_dataset_url(dataset_, dataset_type_)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/_utils.py", line 625, in get_dataset_url
    datasets = known_datasets_df()
               ^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/data/utils.py", line 48, in known_datasets_df
    openneuro_df = _load_known_datasets(_openneuro_listing_tsv())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/data/utils.py", line 88, in _load_known_datasets
    df["duration"] = df["duration"].apply(_convert_duration)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/site-packages/pandas/core/series.py", line 4924, in apply
    ).apply()
      ^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/site-packages/pandas/core/apply.py", line 1427, in apply
    return self.apply_standard()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/site-packages/pandas/core/apply.py", line 1507, in apply_standard
    mapped = obj._map_values(
             ^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/site-packages/pandas/core/base.py", line 921, in _map_values
    return algorithms.map_array(arr, mapper, na_action=na_action, convert=convert)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/site-packages/pandas/core/algorithms.py", line 1743, in map_array
    return lib.map_infer(values, mapper, convert=convert)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib.pyx", line 2972, in pandas._libs.lib.map_infer
  File "/home/surchs/Repositories/external/cohort_creator/cohort_creator/data/utils.py", line 96, in _convert_duration
    x = literal_eval(x.replace("nan", "None"))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 112, in literal_eval
    return _convert(node_or_string)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 101, in _convert
    return dict(zip(map(_convert, node.keys),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 101, in _convert
    return dict(zip(map(_convert, node.keys),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 92, in _convert
    return list(map(_convert, node.elts))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 111, in _convert
    return _convert_signed_num(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 85, in _convert_signed_num
    return _convert_num(node)
           ^^^^^^^^^^^^^^^^^^
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 76, in _convert_num
    _raise_malformed_node(node)
  File "/home/surchs/miniconda3/envs/cohort/lib/python3.12/ast.py", line 73, in _raise_malformed_node
    raise ValueError(msg + f': {node!r}')
ValueError: malformed node or string on line 1: <ast.Call object at 0x7f33d8808a10>

See also similar error in the CI: https://github.com/neurodatascience/cohort_creator/actions/runs/11661670629/job/32466433271#step:8:92

Environment

How to reproduce

Anything else?

No response

Remi-Gau commented 2 days ago

OK it seems that I need to do some serious clean up here.

Will get on this next week, when the next release of Nilearn is done.