8000 Make tests runnable out-of-tree for help with conda-packaging by h-vetinari · Pull Request #307 · allenai/tango · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make tests runnable out-of-tree for help with conda-packaging #307

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

Merged
merged 16 commits into from
Jul 22, 2022

Conversation

h-vetinari
Copy link
Contributor

This is the equivalent of allenai/allennlp#5560, but for tango.

I've been carrying a simpler version of this patch since the beginning of the feedstock (since conda does not run the tests in a source checkout, but for the finished package) - this version allows introduces an override also for other users along the model introduced for allennlp.

However, as of 0.7.0 this is not complete (and I've been struggling with this in conda-forge/tango-feedstock#8), because multicore_executor_test does not respect this infrastructure. I'm going to need some help on the latter (unless I just unconditionally skip all tests from that module) - my first impression is that test_fixtures.package.steps should be in some auxiliary module as part of tango, not in the fixtures.

@epwalsh
Copy link
Member
epwalsh commented Jun 7, 2022

I'm certainly okay with moving the test steps into the tango module somewhere. Maybe at tango.common.testing to be consistent with allennlp. But we should make sure to exclude them from being built into the package (just need to add a line to the setup.py).

@h-vetinari
Copy link
Contributor Author

I'm certainly okay with moving the test steps into the tango module somewhere. Maybe at tango.common.testing to be consistent with allennlp.

Cool!

But we should make sure to exclude them from being built into the package (just need to add a line to the setup.py).

Then I still don't see a way how the multicore tests should be runnable out-of-tree...

@epwalsh
Copy link
Member
epwalsh commented Jun 7, 2022

I guess I misunderstood how the tests need to run in this case. But that's fine, it's okay to include those files in the build if we have to.

@h-vetinari
Copy link
Contributor Author

@epwalsh @dirkgr
I'm going to need help on this one, especially the multicore tests (or an instruction from you to skip them all).

@dirkgr
Copy link
Member
dirkgr commented Jul 5, 2022

What's the problem here? It looks like the tests failed that need secrets, probably because @h-vetinari is not a member of the AI2 org. That's not a real failure though. Is there anything wrong with the multicore tests now?

@h-vetinari
Copy link
Contributor Author

What's the problem here?

The issue is that the multicore tests cannot run out of tree due to the way they import the Steps. From the OP:

However, as of 0.7.0 this is not complete (and I've been struggling with this in conda-forge/tango-feedstock#8), because multicore_executor_test does not respect this infrastructure. I'm going to need some help on the latter (unless I just unconditionally skip all tests from that module) - my first impression is that test_fixtures.package.steps should be in some auxiliary module as part of tango, not in the fixtures.

@epwalsh
Copy link
Member
epwalsh commented Jul 6, 2022

Hey @h-vetinari, per the above conversation I thought we had decided to move the test steps into a proper tango submodule, like tango.common.testing. Does that sound good? If so, do you want to make that change in this PR?

@h-vetinari
Copy link
Contributor Author

Does that sound good?

Yes!

If so, do you want to make that change in this PR?

Sorry, been pretty busy and only getting to this now.

@h-vetinari
Copy link
Contributor Author

The 0.7.0 version of these patches now passed the test suite in conda-forge/tango-feedstock#8. :)

If/once you approve this, I'll be happy to rebuild the other versions in between.

@h-vetinari
Copy link
Contributor Author

PS. I needed to skip TestRun.test_deterministic_experiment though - the test hardcodes specific hashes for the workers(?) and this is simply not reproducible with a slightly different setup, I believe.

@h-vetinari
Copy link
Contributor Author

Ping @dirkgr @epwalsh

Copy link
Member
@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

Hey @h-vetinari, sorry for the slow response (Dirk is on vacation this week). I just have an organization suggestion.

@@ -145,3 +172,146 @@ def requires_gpus(test_method):
test_method
)
)

Copy link
Member

Choose a reason for hiding this comment

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

Can you move these to a separate module? I don't want these steps to necessarily be registered when someone just wants to import the TangoTestCase class.

I would suggest making tango/common/testing/ directory, and move this file to tango/common/testing/__init__.py, then have a separate file tango/common/testing/steps.py where you put these steps (don't import anything from steps.py into __init__.py).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review - no worries, I was slow too!

I don't want these steps to necessarily be registered when someone just wants to import the TangoTestCase class.

I don't see how that would happen except with * imports, which are discouraged anyway?

I mean I can do the change of course, I just don't really understand the gain...

Copy link
Member

Choose a reason for hiding this comment

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

If those test steps are in the same file as TangoTestCase they will be registered when you import TangoTestCase even if you don't import those steps since every global statement in the file, including the @Step.register() statements, will be evaluated on import.

You can check this:

from tango.step import Step

assert Step.list_available() == []

from tango.common.testing import TangoTestCase

assert "float" in Step.list_available()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there is one substantial advantage of this approach - the diff gets much smaller. ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If those test steps are in the same file as TangoTestCase they will be registered when you import TangoTestCase even if you don't import those steps since every global statement in the file, including the @Step.register() statements, will be evaluated on import.

Ah, I was not aware there were some global shenanigans going on 😅

Also, it seems our responses were seconds apart. ;-)

@epwalsh
Copy link
Member
epwalsh commented Jul 22, 2022

Looks like there's some more imports that need to be updated in tests.

@h-vetinari
Copy link
Contributor Author

Looks like there's some more imports that need to be updated in tests.

Feel free to push into this PR. I'm not at a computer right now, and waiting for approval for CI each time drags out finding these trivial issues quite a bit 😅
(No idea why it didn't fail in the previous commit, I thought I had fixed everything)

@epwalsh
Copy link
Member
epwalsh commented Jul 22, 2022

Cool I'll take a look. Can you make sure you have the "Allow edits from maintainers" option checked?

Copy link
Member
@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

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

LGTM! There are still some failing tests but those are due to missing secrets because of GitHub security. Once this merges into main those tests should pass. Let me know if you're satisfied with everything and I'll hit the merge button!

@h-vetinari
Copy link
Contributor Author

Let me know if you're satisfied with everything and I'll hit the merge button!

Yeah this looks good, thanks a lot for pushing through the final clean ups!

@epwalsh epwalsh merged commit 57096b2 into allenai:main Jul 22, 2022
@h-vetinari h-vetinari deleted the fallback branch July 23, 2022 00:50
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.

3 participants
0