OHBA-analysis / osl

OHBA Software Library - MEG/EEG Analysis Tools
https://osl.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
39 stars 8 forks source link

yaml loader in preprocessing.batch.read_dataset() not working #306

Closed juliadabrowska-29 closed 3 months ago

juliadabrowska-29 commented 3 months ago

OSL 0.6.dev0 Python 3.10.13 PyYAML 6.0.1

When I try to use this function on my dataset preprocessed earlier by _run_procchain (formatted as {filename}_event-id.yml), an error is thrown when trying to use yaml.safe_load():

ConstructorError - could not determine a constructor tag for the tag [myfilename]

and the file does not load, stopping the rest of the script.

https://github.com/OHBA-analysis/osl/blob/3e21a1fe00461cb596f0e1958ba09e834b8e46b9/osl/preprocessing/batch.py#L490-L494

Manually re-defining this function on my local machine to contain

event_id = yaml.load(file, Loader=yaml.Loader)

instead of the current version has resolved the issue for me.

cgohil8 commented 3 months ago

Your solution looks fine to me. Any chance we can double check it's not a python version issue before we create a PR (the recommended python version currently is actually 3.8).

Could you do a fresh install with the instructions on the github homepage and confirm you still get the error? If so, we can merge your fix.

Thanks for your contribution.

juliadabrowska-29 commented 3 months ago

I've been using python 3.10 because that is the one recommended for osl-dynamics (and I am using the same virtual environment to use both packages), so not sure whether it makes sense to downgrade to 3.8 as this could break other things in the scripts?

Nonetheless, following your suggestion, the error persists in a newly created osl-only environment with python 3.8 and the dependencies listed in the mac.yml file.

cgohil8 commented 3 months ago

I set the package requirements of osl-dynamics to be compatible with 3.8 and 3.10.