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

Fix notebook tests #675

Merged
merged 1 commit into from Nov 21, 2022

Conversation

ascillitoe
Copy link
Contributor

pytest-randomly is disabled in the notebook CI in order to resolve #664 (see pytest-dev/pytest-randomly#495). This isn't an ideal long-term solution, we might want to think about replacing pytest-randomly if pytest-dev/pytest-randomly#495 is not going to be fixed.

@ascillitoe
Copy link
Contributor Author

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2022

Codecov Report

Merging #675 (477d7c3) into master (5748864) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #675   +/-   ##
=======================================
  Coverage   79.12%   79.12%           
=======================================
  Files         126      126           
  Lines        8895     8895           
=======================================
  Hits         7038     7038           
  Misses       1857     1857           
Flag Coverage Δ
macos-latest-3.10 76.23% <ø> (ø)
ubuntu-latest-3.10 79.01% <ø> (ø)
ubuntu-latest-3.7 78.91% <ø> (ø)
ubuntu-latest-3.8 78.95% <ø> (ø)
ubuntu-latest-3.9 78.95% <ø> (ø)
windows-latest-3.9 76.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@@ -11,13 +11,8 @@ addopts =
--tb native
-W ignore
--cov=alibi_detect
--randomly-dont-reorganize
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we remove this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For --randomly-seed=0, I've moved it to ci.yml because having it in the global pytest config caused an error in the notebook CI because pytest-randomly is now disabled there.

For --randomly-dont-reorganize, I decided we could remove it anyway. This controls whether or not the order of tests is randomly reorganized. From the pytest-randomly docs:

By randomly ordering the tests, the risk of surprising inter-test dependencies is reduced - a technique used in many places, for example Google’s C++ test runner googletest. Research suggests that “dependent tests do exist in practice” and a random order of test executions can effectively detect such dependencies [1].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btw we can add --randomly-dont-reorganize to ci.yml if you think this change shouldn't be made without further discussion...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yeah, I was curious about --randomly-dont-reorganise, it seems useful no? I suppose because we don't really deal with persistent state it's not the type of thing that's going to help us much. Although perhaps it's worth keeping in for the saving tests, that's the only place where I can image one test leaking into another...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeh agree that I can't think of any obvious places where tests might be leaky. I hope that the saving ones are ok since they use pytest's tmp_path. I sort of think if we keep pytest_randomly it doesn't hurt to randomise test order, but if we're removing it its not worth implementing an alternative solution to randomise tests.

Copy link
Member

Choose a reason for hiding this comment

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

Removing --randomly-dont-reorganise actually enables random order, right? In which case it seems useful to have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, random order has been enabled by removing the flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jklaise just to confirm, are you saying random order seems useful to have? i.e. we stick to having the flag removed...

Copy link
Member

Choose a reason for hiding this comment

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

Correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK thanks. Think this is good to merge then 👍🏻

Copy link
Collaborator

@mauicv mauicv left a comment

Choose a reason for hiding this comment

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

One minor question otherwise LGTM!

@ascillitoe
Copy link
Contributor Author

@jklaise @mauicv I'm now wondering whether we park this until we've decided what to do about pytest-randomly. I added this plugin in #496 to give the ability to set random seeds within a context manager for testing (useful when repeatedly perfoming random operations i.e. instantiating some detectors, during testing).

However, #664 uncovered a problematic issue with the way custom pytest_randomly seeders are defined via entry_points. Essentially at present there is no way to disable entry points added by our deps (in this case thinc). I came opened a PR on pytest-randomly with an idea for a fix, but the devs don't seem to be super responsive at the moment. I'm starting to think we either need to fork pytest-randomly, drop it, or be patient!

@jklaise
Copy link
Member

jklaise commented Nov 17, 2022

@ascillitoe I think it would be great if we could get the notebook tests passing again, I don't think it's a big deal to disable pytest-randomly for those for the time being.

@ascillitoe ascillitoe merged commit 94a379c into SeldonIO:master Nov 21, 2022
@ascillitoe ascillitoe deleted the fix/disable_pytest_randomly branch November 21, 2022 09:46
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.

Notebook CI failing
4 participants