-
Notifications
You must be signed in to change notification settings - Fork 814
Create pytest fixture to auto delete model checkpoints within integration tests #1886
Create pytest fixture to auto delete model checkpoints within integration tests #1886
Conversation
mthrok
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, instead of manually calling conditional_remove, the deletion logic should be automated and the pre-condition should be configured in a way it's independent from rest of the test/library logic. (i.e. it should be turned on/off independent of what ever library/test logics are)
That will avoid the case where future contributors forget to add conditional_remove.
…on tests" This reverts commit 8694c20.
mthrok
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stamp
h-vetinari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @pytest.fixture(scope="class") | ||
| def temp_hub_dir(tmp_path_factory, pytestconfig): | ||
| if not pytestconfig.getoption("--use-tmp-hub-dir"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up in #1889 aside, I don't understand how this can work at all.
Both tmp_path_factory and pytestconfig appear nowhere else in the code base (as far as GH search and git grep go, at least), and based on the pytest docs this should probably be
| @pytest.fixture(scope="class") | |
| def temp_hub_dir(tmp_path_factory, pytestconfig): | |
| if not pytestconfig.getoption("--use-tmp-hub-dir"): | |
| @pytest.fixture(scope="class") | |
| def temp_hub_dir(tmp_path_factory, request): | |
| if not request.config.getoption("--use-tmp-hub-dir"): |
but that still leaves me mystified as to where tmp_path_factory is coming from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but that still leaves me mystified as to where
tmp_path_factoryis coming from.
Ah, just found that it's a fixture that comes with pytest by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, and so's pytestconfig. In any case, my suspicion now is that this only works when called from within the integration_tests folder, because (I guess) recursive conftest.pys are not evaluated when the CLI is called from a folder that's further out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h-vetinari yup I think your understanding is correct. Does only being able to run this test from within the integration_tests folder pose an issue for adding torchtext to conda-forge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does only being able to run this test from within the
integration_testsfolder pose an issue for adding torchtext toconda-forge?
No, I just had to realise the reason, after that it's simple. ;)
Description
Testing
pytest test/prototype/integration_tests/test_models.pypytest test/integration_tests/test_models.pyFollowup Items
torchtext_unittestfolder and create a separate workflow to run all integration tests (Fix test execution in torchtext #1889)TorchtextTestCasefor integration tests to remove any conflicts betweenunittest.TestCaseand pytext