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
Ensure that the straightening.cache
file is output to the PWD during template registration
#4156
Ensure that the straightening.cache
file is output to the PWD during template registration
#4156
Conversation
This is a necessary prerequisite for testing whether the straightening files were created in the correct directory. (Because, if we don't use a tmp_path and check for the files in the `sct_testing_data` directory, then we could get a false negative due to other tests creating these exact same straightening files.)
The `sct_label_vertebrae` test will pass, but the `sct_register_to_template` test will fail, because `straightening.cache` is improperly output to the working directory.
Previously, the `cachefile` path made it so that `cache_save()` saved the file to `curdir` (i.e. the working directory). After this change, `curdir` is only used to check whether an *input* cache file exists. But, for saving, we now A) save to the temporary directory and B) copy it to the output directory.
…ate` Instead of saving the cache file directly to the output directory, we now follow the same logic as the registration script: A) save to the temporary directory and B) copy it to the output directory.
Later code (namely, `generate_output_file`) expects it to be present.
Other file names are spelled out, and it wasn't being used consistently anyway.
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.
This seems fine, although our tests caught a corner case, which I think I fixed.
Hrm. Just to make sure that I understand why the test failed:
If that's the case, then the fix from b44f463 makes perfect sense to me. Thank you for this! (Though, as a side note, I didn't realize that the |
Yep! That's it exactly.
I had the same worry, but I don't think that's the case. If you look at the test in question, it's a single test that calls Wait, actually, you're right that |
I guess perhaps we could merge this PR as-is for now, but tackle this further as part of #2911? i.e. when we change the test suite so that tests are inherently run in a temporary directory, we make sure to explicitly test these scripts' ability to load cached files (as opposed to testing this behavior implicitly, as we're doing now.) |
Well, we can't really claim to be fixing #4138 unless we understand what's going on here, I think. |
Ah, sorry. I thought we understood what was going on?
So, I figured that the former issue had been solved by this PR, while the latter issue was more of a "tests don't clean up after themselves" issue (hence #2911). |
Ah ok, makes sense. |
Description
This PR adds a check that tests for the existence of straightening files generated by
sct_register_to_template
andsct_label_vertebrae
. Notably, this test initially fails forsct_register_to_template
due to #4138.Then, this PR updates the cache-saving behavior so that A) the cache file is first saved to the temporary directory used by both scripts, then B) the cache file is copied to the output directory along with the other straightening files.
Linked issues
Fixes #4138.