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
fix: Make sure to delete local temporary clones #802
Conversation
Codecov Report
@@ Coverage Diff @@
## master #802 +/- ##
==========================================
- Coverage 96.68% 96.48% -0.21%
==========================================
Files 41 41
Lines 2959 2986 +27
==========================================
+ Hits 2861 2881 +20
- Misses 98 105 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
OK, I was able to fix the env on gitpod by upgrading pip and setuptools in both the pyenv version and the poetry venv. |
Network failure in job ubuntu 3.8, re-running it should fix it. |
Don't you think we need to fix this too? Line 133 in 890ac86
|
Oh, that's exactly what gets deleted by the added code. Sorry for not making it clear. I'll update the PR description accordingly. |
Maybe a cleaner solution would be to add a |
I'm not sure to follow.
Where would it be? I can't seem to find an attribute or property pointing to a temporary directory in the Template class.
That would be best indeed, but I don't see how we could use it in methods/properties as it's a context manager, and the temporary clone needs to exist for a longer time than the scope of the Template class' methods/properties. |
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've reviewed this deeper and now I understand better what you said and why this is a good design. ❤️
I think it's good for a class to provision the paths it needs and clean them up, so let's move that logic to Template
itself. It should be:
- Define
Template._cleanup()
. - Call it in
Worker.__exit__()
. - Define
Template._temp_clone
as explained below.
This way, the template creates the paths and provides the way to remove it.
Adding context manager support to Worker
also seems to be the way to go. TBH I was thinking that implementing __del__()
would be better, but I've now learned that can lead to other problems.
Please don't forget to add a couple of tests:
- The temporary clone is removed.
- Copying from a local repo is not removed.
Also the API docs to use Worker
as a context manager.
Thanks!
6a6de2e
to
ce65dc7
Compare
Closes #709
I implemented that on GitPod.io but have a lot of test failures due to pexpect timeouts, and
pkg_resources
module not being found (it seems the env on gitpod is kinda broken). Opening to see how CI behaves.