Repository navigation
Conversation
|
Need some advice on a couple of things:
Ideally, I was thinking it might be easier to scale across developers if the clean up happens at the TestBase superclass level so that every unit test need not be modified for this purpose. |
|
My first concern on test-level clean-up is accidentally deleting files which were not generated by the executed unit test, but by a different unit test that is being executed in parallel (by default for CI we run up to 4 tests in parallel). Unless you know for a fact which files were generated by the unit test, I would not delete temporary files while other tests are still running. Per session clean up should avoid this issue, if I understand it correctly. I wasn't personally involved with the initial unit test design, so I can't tell if not doing Could you point me to a specific task unit test that leaves behind files? |
|
@PGijsbers, these tests (from the develop branch) should dump files. |
|
Both of those tests seem to work with the static cache directory that is purposefully part of the repositories. I don't see new files being generated for this. I'm sorry if I missed the point, but which files are generated/downloaded and left behind, but should not be? |
|
I just checked on the
Is this reproducible?
Given that these 3 paths/files are generated by running this test case, I presume these are to be cleared, as issue #447 mentions. That's my assumption and hence this approach. |
|
You're right, my bad. I can reproduce this. The files should definitely be cleaned up, at least after all unit tests are complete. The problem with cleaning up these files after each unit test, is that we tend to use the same tasks/datasets across multiple unit tests to speed them up (make use of caching). This violates unit test independence, but I think is worth the benefit. Any files that would only be used/generated by one unit test should be cleaned up immediately. But I don't think that's the case for any of those three files. |
|
Alright. I'll then try to see how a session-level fixture works, and also maybe a class level tearDown. Though the latter again may not allow the leveraging of caching. |
Codecov Report
@@ Coverage Diff @@
## develop #721 +/- ##
==========================================
- Coverage 87.78% 87.68% -0.1%
==========================================
Files 36 36
Lines 3961 3979 +18
==========================================
+ Hits 3477 3489 +12
- Misses 484 490 +6
Continue to review full report at Codecov.
|
|
@PGijsbers However, to abate your valid concerns, the session-level fixture with yield seemed to work well with There are two things that I would like your opinion on:
|
|
From what I understand, the
I tried this, however, to not be hard-coded at all, I still need the I think the primary design decision here would be the placement of the @PGijsbers I am also looking to fix #261. I feel the solution will be quite close to the one for this PR. Shall I include it here or make a new PR? |
|
@PGijsbers I put the fixture function into the TestBase class. Now the same behaviour is maintained without additional imports. Hence, removed the F401 PEP8 ignore too. |
Defining it once and importing it in other files does seem like the way to go to me. For future reference, if you had had to go with the ignore on F401 to achieve this, you can do this on a per-line basis: Ignores the warning for that specific line only. This would be better because otherwise other lines/files with actual unused imports might have been ignored too.
I think a new PR is preferred. |
|
Thanks for the tip. 😄 I think in that case, I am done with this PR unless there is anything more specific required. |
mfeurer
left a comment
There was a problem hiding this comment.
Could you please add a line to ci_scripts/test.sh to make sure that there are no files left which are not checked in after running all tests? Something like
status=`git status --porcelain -b`
if [ "$status" != "## master..origin/master" ]; then
exit 1
fi
Then we'd also be sure that no files are left behind. Since the tests are actually run in a different directory, it would be good if could check that that one is empty, too.
|
|
||
| * ADD #687: Adds a function to retrieve the list of evaluation measures available. | ||
| * ADD #695: A function to retrieve all the data quality measures available. | ||
| * FIX #447: All files created by unit tests no longer persist. |
There was a problem hiding this comment.
Could you please rewrite to highlight that the files are actually deleted now?
| the unit tests of the sub class. When all the tests end, execution | ||
| resumes from the checkpoint. | ||
| """ | ||
| # TODO: generalize this path better akin to static_cache_dir |
There was a problem hiding this comment.
Yep, could you please work on this? Right now it appears that this unit test can only be executed from the main directory. You can have a look at how the static cache dir is obtained and use a similar logic here (except that you don't use n_levels but go back until you hit a directory called openml (which contains the package)).
There was a problem hiding this comment.
go back until you hit a directory called
openml(which contains the package))
so this would be to simulate n_levels wherein we go back till we are in the main directory again?
| ): | ||
| pickle_path = os.path.join(cache_dir, 'datasets', did, | ||
| 'dataset.pkl') | ||
| if sys.version[0] == '3': |
There was a problem hiding this comment.
This should no longer be necessary since we dropped Python2 support.
| ) | ||
| # TODO Needs to be adapted regarding the python version | ||
| self.pd_filename = self.arff_filename.replace(".arff", ".pkl") | ||
| if sys.version[0] == '3': |
There was a problem hiding this comment.
Same here, you can also remove the TODO above.
Made a slight change to this design, to not have a branch-specific check. Hope both the above is okay and if not I'll revert them. |
Reference Issue
Addresses #447.
What does this PR implement/fix? Explain your changes.
Cleans up files generated during unit testing to prevent untracked files for git.
How should this PR be tested?
Running
pytestfollowed bygit status, should show no untracked files.