-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Check versions used to create the venv and auto-wipe #3432
Conversation
Looks like a good start! |
This is getting better, I think. Some notes on this:
Questions:
|
|
) | ||
|
||
@property | ||
def is_obsolete(self): |
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 wrote this at PythonEnvironment level, but @ericholscher said that conda won't be affected by this. Should I leave this here or move it to Virtualenv and write something customized by Conda?
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.
Honestly not sure. @willingc do you know anything about how conda will be effected by underlying docker image changes? My thought if that it's self-contained, but not really sure.
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.
Hmm... not sure. My understanding is docker images are built in layers so if you change an underlying layer it impacts the layers above.
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 would be changing out the underlying system python or conda version, I believe, is that main worry. We have the files on disk from a previous run, but we're hoping to let users change their docker image. We're planning to blow away the virtualenvs, because it breaks, but curious if conda will be effected.
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.
@willingc if a virtualenv is created with python 2.7.13 and we change the python version to 2.7.14, the venv stop working and need to be re-created. In the case of Conda we are not sure about that case but also the case that the conda environment was created with conda 4.x and then it's ran with conda 4.(x+1). What would happen in this case? Do you know?
ccing @juanlu001 who was my Conda teacher :)
config=config, | ||
) | ||
env_json_data = '{"build": {"image": "readthedocs/build:2.0"}, "python": {"version": 3.5}}' | ||
with patch('os.path.exists') as exists, patch('readthedocs.doc_builder.python_environments.open', mock_open(read_data=env_json_data)) as _open: # noqa |
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.
These with patch()
lines are terrible, but I didn't find a better way to write them :(
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.
It's fine to escape with backslash here according to pep8 https://www.python.org/dev/peps/pep-0008/#maximum-line-length
exists.return_value = True | ||
self.assertTrue(python_env.is_obsolete) | ||
|
||
@pytest.mark.xfail(reason='build.image is not being considered yet') |
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.
to make this test pass, we need the PR that get the image from yaml merged... then we can remove this line and it should pass :)
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.
Looks like a great change to me!
"""Return the path to the ``environment.json`` file for this venv.""" | ||
return os.path.join( | ||
self.venv_path(), | ||
'environment.json', |
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 do wonder if this should be namespaced a bit more (readthedocs-environment.json
?) so that it doesn't conflict with anything in the future.
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.
Agree.
|
||
:rtype: bool | ||
""" | ||
# Always return True if we don't have information about what Python |
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 returns False.
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.
Ha! I did it wrong at first, then I fix the return
statement and forgot the comment :)
Is this now clearing conda envs? If so, I think we're good to go. |
Yes. It's clearing the conda env if it's was created with a different python/build image version; but it's not checking the I think it's should be a good start but maybe we will want to check the |
Great. Have you tested it locally w/ the docker image changes and virtualenv? If that works, it would be great to get this all merged so we can test it locally before deploying it next week. |
3e464e2
to
da1fde3
Compare
I tested this manually with the python version change from the YAML and docker image from Besides,
Finally, I just realized that the conda env is always deleted if its exist at these lines: Those lines were added at 475cf0b So, if we are going to leave those lines there it seems useless to add the logic of this PR at PythonEnvironment class level, and should be moved to Virtualenv class I think. Please, take a look again at these changes and give me your feedback. |
Sorry I didn't have the time to review this. Just let me add that be
careful with conda 4.4, since it breaks a number of things and it's causing
some problems.
…On Dec 23, 2017 1:20 AM, "Manuel Kaufmann" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In readthedocs/doc_builder/python_environments.py
<#3432 (comment)>:
> @@ -87,6 +98,70 @@ def venv_bin(self, filename=None):
parts.append(filename)
return os.path.join(*parts)
+ def environment_json_path(self):
+ """Return the path to the ``environment.json`` file for this venv."""
+ return os.path.join(
+ self.venv_path(),
+ 'environment.json',
+ )
+
+ @Property
+ def is_obsolete(self):
@willingc <https://github.com/willingc> if a virtualenv is created with
python 2.7.13 and we change the python version to 2.7.14, the venv stop
working and need to be re-created. In the case of Conda we are not sure
about that case but also the case that the conda environment was created
with conda 4.x and then it's ran with conda 4.(x+1). What would happen in
this case? Do you know?
ccing @Juanlu001 <https://github.com/juanlu001> who was my Conda teacher
:)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3432 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AATUZT2rKaYqCrDHPp_qA241ExsgLKI2ks5tDEcvgaJpZM4RKNru>
.
|
Initial drawing of ideas on how to implement #3190