Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including a .json sidecar for events.tsv files causes a SQLAlchemy Tag conflict #465

Closed
oesteban opened this issue Aug 7, 2019 · 7 comments

Comments

@oesteban
Copy link
Collaborator

commented Aug 7, 2019

We have an fMRIPrep user experiencing the following issue (more details here https://neurostars.org/t/naming-of-bids-events-tsv-files-seems-to-disrupt-fmriprep-1-5-0rc1/4771):

  File "/usr/local/miniconda/lib/python3.7/site-packages/fmriprep/cli/run.py", line 524, in build_workflow
    layout = BIDSLayout(str(bids_dir), validate=False)
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/layout.py", line 212, in __init__
    indexer.index_metadata()
  File "/usr/local/miniconda/lib/python3.7/site-packages/bids/layout/index.py", line 338, in index_metadata
    self.session.commit()
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1027, in commit
    self.transaction.commit()
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 494, in commit
    self._prepare_impl()
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 473, in _prepare_impl
    self.session.flush()
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2459, in flush
    self._flush(objects)
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2597, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
    flush_context.execute()
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
    rec.execute(self)
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
    uow,
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 213, in save_obj
    ) in _organize_states_for_save(base_mapper, states, uowtransaction):
  File "/usr/local/miniconda/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 408, in _organize_states_for_save
    % (state_str(state), instance_key, state_str(existing))
sqlalchemy.orm.exc.FlushError: New instance <Tag at 0x2b66784f7ba8> with identity key (<class 'bids.layout.models.Tag'>, ('/inp/sub-02/func/sub-02_task-Emotion_run-1_events.tsv', 'run'), None) conflicts with persistent instance <Tag at 0x2b66784c6630>

@oesteban oesteban added the bug label Aug 7, 2019

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 7, 2019

It's hard to know if this is a bug without knowing what other files are in the BIDS project. My sense is it could be a genuine conflict between file names induced by some minor departure from the BIDS standard. It would be helpful if the user could provide a list of all of the events.tsv files in the project.

@oesteban oesteban removed the bug label Aug 7, 2019

@oesteban

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 7, 2019

If it is not a bug, I'd say a more descriptive error message would improve user experience a lot.

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 7, 2019

Well, if we had a more descriptive error message, it would be easier for me to tell you if it's a bug or not. :p

@tyarkoni tyarkoni changed the title sqlalchemy.orm.exc.FlushError - conflicting instances Including a .json sidecar for events.tsv files causes a SQLAlchemy Tag conflict Aug 7, 2019

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 7, 2019

Per discussion in the linked NeuroStars thread, this seems like a bug induced by the inclusion of a .json file with the same filename (except for extension) as an events.tsv file.

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 7, 2019

This wasn't actually fixed in #467; I'm working on a fix now.

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 7, 2019

@oesteban I fixed this in #468; we'll cut a new release as soon as it's merged so you can update fmriprep. Thanks for reporting!

@tyarkoni tyarkoni closed this in #468 Aug 8, 2019

@tyarkoni

This comment has been minimized.

Copy link
Collaborator

commented Aug 8, 2019

@oesteban it's out. Feel free to bump the pybids requirement in fmriprep to 0.9.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.