Conversation
NicolasHug
left a comment
There was a problem hiding this comment.
Thanks @pmeier , this LGTM but I'll have to import this into fbcode before merging to make sure this doesn't toast the internal infra.... I'll get back to you
|
The problem lies in the fact that the test is invoked with Lines 500 to 501 in a2b4c65 the So the question is, if we want to retain the ability to run tests by invoking the module with |
|
Let's just assume that tests are run with |
|
I recommend to introduce another directory in
|
|
These are good points @mthrok , thanks. Pytest actually has a few guidelines on this: https://docs.pytest.org/en/6.2.x/goodpractices.html#choosing-a-test-layout-import-rules Their recommendation would be to move This makes me wonder whether this is worth it or not. Would it be possible to have a |
Yes, I think it is possible. Currently, I don't need access to anything, but that might be a problem in the future. |
I considered doing so for audio since it would not be difficult but I was afraid that it might give degraded developer experience to folks work on multiple repos. I also see that data is following the pattern. |
With that approach, I assume that CI test script needs to be updated so as to run the tests in CI. Prototype features can come and go. I think it's best to reduce the number of places one need to update. |
We could have a separate job to run |
|
I'm not sure I understand the concern @mthrok , is this about test discovery? I think we would just need to change -pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test --ignore=test/test_datasets_download.py
+pytest --cov=torchvision --junitxml=test-results/junit.xml -v --durations 20 test torchvision --ignore=test/test_datasets_download.pyin (there might be options in |
Nope, we don't need to change anything to run the "normal" test suite. Lines 9 to 10 in 1140ecf |
|
I'm assuming that we want all CIs to run both the tests in That's why I'm saying we just need to add Or better then, edit |
|
There are three ways forward here:
For all three variants we can have a separate prototype workflow with minimal effort. |
I think 1 is the minimal effort for the long term. It does not prevent the prototype test from using the common test utilities, it does not require any change to the CI, and it has an added benefit of running the tests for package installations. I feel that 2. is going against the already established code organization, without justification why it has to be that way. And one has to remember to enforce it every time a new prototype is added, why the tests for prototype have to be placed alongside of code, unlike the rest of the code. Once you have a good justification of why it has to be that way, you probably need to document it somewhere. |
|
Something that I missed earlier and that @pmeier clarified in our chat is that the main goal here is to separate our regular tests from the prototype tests, because the prototype tests are much more subject to fail than the rest, and we want to separate these signals in the CI. With that in mind, I'm not sure I see how option 1. really solves this? |
If we go for a |
|
Thanks @pmeier
I understand the constraint, but this seems to apply to all 3 proposed solutions? None of them completely follow the current code organization I would say. My personal (decreasing) order of preference would be 3 -> 2 -> 1. Option 1. would require to create an additional folder, whether it's |
Every option will add an folder:
Note that this will not solve the issue we are trying to solve here, since it only changes how |
yes but option 1., i.e. making This is the extra directory that I'm taking about |
|
I've had an offline discussion with @NicolasHug about his concerns. There was some confusion about how the We do that in CI and also recommend it in our contribution guide, so we should be fine. This PR already implements it and minus all the unrelated CI failures it works out. Edit: After some more discussion we realized that I was in fact wrong and Nicolas' concerns are valid. To import the Thus, I now agree with @NicolasHug's order of preference, i.e. 3. -> 2. -> 1. Sorry for the confusion. |
|
After some more investigation, there might be another option. This whole issue revolves around the fact that |
|
Unfortunately, Edit: I've hacked together https://github.com/pmeier/pytest-import as a PoC |
|
I propose a different option to move forward here: keep the hierarchy flat, add test files like One possible option is probably to use https://docs.pytest.org/en/stable/reference.html#pytest-importorskip-ref |
|
Thanks everyone for the input on this. It's great to see that lots of thought was put on the solution. I wonder if we can make the necessary changes and unblock this PR? I'm not going to pitch in on which direction we will follow as I think you got enough options. I just want to make sure that the prototype area has an agreed initial way to support tests because we plan to introduce more soon. If we all agree, we could adopt the quick an easy approach mentioned by Francisco at #4436 (comment) and then provide a better approach as we improve our test suite? |
|
We opted to ignore prototype tests by default and only run them if specifically requested. That way we can keep them in the |
This solves two issues:
test/common_utils.pyintest/prototype/*. With this change, we can dofrom test.common_utils import foofrom anywhere in our test suite.pytestrequires unique module names in non-package folders. That means, we cannot havetest/protototype/datasets/test_utils.pyiftest/test_utils.pyalready exists. See this CI run from Add prototype namespace and datasets #4433 for an example.cc @pmeier