Skip to content

Conversation

@cbrnr
Copy link
Contributor

@cbrnr cbrnr commented Oct 29, 2021

Fixes #9662.

@cbrnr
Copy link
Contributor Author

cbrnr commented Oct 30, 2021

This has not been super fun (simply replacing tmpdir with tmp_path didn't cut it), but now it is almost working except for the following two issues (@larsoner @drammock?):

@larsoner
Copy link
Member

larsoner commented Nov 1, 2021

There's one failing test that I haven't fixed yet, because when saving an already loaded Raw object, it now raises a FileExistsError

This to me suggests that there is some problem with the first check that's supposed to see "if data are not preloaded and we're trying to save to self._filenames[0], raise a ValueError", and instead you hit the second / subsequent check that is "if the filename exists and overwrite is False (default), then raise a FileExistsError". I would look into why using this new fixture has changed the behavior of the first check

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 1, 2021

@larsoner the issue is that fname = _check_fname(fname) raises a FileExistsError: Destination file exists. Please use option "overwrite=True" to force overwriting. even before the other exception (if not self.preload and fname in self._filenames:) can be raised. I could of course set overwrite=True, but I guess this defeats the purpose of the other check. Any suggestions on how to proceed?

@larsoner
Copy link
Member

larsoner commented Nov 1, 2021

I could of course set overwrite=True, but I guess this defeats the purpose of the other check.

I would use overwrite=True because you don't want/need that function to do an overwrite check, because you're doing a more targeted one later

@cbrnr cbrnr marked this pull request as ready for review November 2, 2021 06:11
@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

This is now ready for review. Maybe worth a changelog entry too, but we can do this as the final step.

@cbrnr cbrnr requested review from drammock, hoechenberger and larsoner and removed request for britta-wstnr and sappelhoff November 2, 2021 06:16
@agramfort
Copy link
Member

@cbrnr can we now remove tmpdir from our fixtures? Did you already take care of this? 🙏 for the cleanup

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

What do you mean by remove? I replaced tmpdir with tmp_path everywhere, is there some config file I need to update?

@sappelhoff
Copy link
Member

And if you're in the flow of it @cbrnr perhaps you wanna do a quick pass on mne-bids as well, replacing the tmpdir -> tmp_path there? 😏

But I see your comment:

This has not been super fun

so if you've had enough for now, we'll just do it some other time when one of us has time and energy

@agramfort
Copy link
Member

agramfort commented Nov 2, 2021 via email

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

@agramfort thanks for double-checking, I missed those. Now there are no tmpdir fixtures anymore.

@sappelhoff I can take a look, mne-bids is much smaller and therefore this should be much faster.

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

@larsoner now in addition to CircleCI most (all?) Azure jobs are failing because of an issue with OpenGL install?

@larsoner
Copy link
Member

larsoner commented Nov 2, 2021

#9943

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

Please ping me once that is merged.

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

(This might be something where merge queues could be useful – we should definitely try them when they are available.)

@larsoner
Copy link
Member

larsoner commented Nov 2, 2021

Please ping me once that is merged.

If you go to the PR and click the "subscribe" you'll get notified automatically

@cbrnr
Copy link
Contributor Author

cbrnr commented Nov 2, 2021

pytest.raises(ValueError, stc.save, tmpdir.join('tmp'),
ftype='foo')
out_name = tmpdir.join('tmp')
pytest.raises(ValueError, stc.save, tmp_path / 'tmp', ftype='foo')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pytest.raises(ValueError, stc.save, tmp_path / 'tmp', ftype='foo')
# different errors for (non)vector STCs
match = (r"(Invalid value for the 'ftype' par)|"
r"(VectorSourceEstimate objects can only be written ad HDF5)*")
with pytest.raises(ValueError, match=match):
stc.save(tmp_path / 'tmp', ftype='foo')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we go with this more specific error message catching or wait for the fix in #9944?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think my fix in #9944 will impact this comment -- it looks like this comment just improves/modernizes the pytest.raises usage. So yes feel free to commit this suggestion separately

@larsoner larsoner added this to the 0.24 milestone Nov 2, 2021
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will merge once CIs come back happy. Thanks @cbrnr

@agramfort agramfort merged commit b97da43 into mne-tools:main Nov 2, 2021
@agramfort
Copy link
Member

thx @cbrnr !

@cbrnr cbrnr deleted the tmp_path branch November 3, 2021 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use tmp_path instead of tmpdir pytest fixture

5 participants