Skip to content
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

394 integrates no install flag #411

Closed

Conversation

gwynforthewyn
Copy link

@gwynforthewyn gwynforthewyn commented Mar 27, 2021

  • Adds a new option, --no-install. This is used to skip installing packages if the packages have been installed once.
  • Adds a boolean to the virtualenv base class, venv_created, which tracks whether or not the virtual environment has already been created. The --no-install flag behaves differently dependent upon whether a venv is already created or not.
    • If no virtualenv is present, a message is logged that no-install is being ignored and normal installations proceed.
    • If a virtualenv is already present, --no-install prevents the installation of packages.
  • Adds tests to validate the above
  • Also refactors SessionNoSlots into an extracted class MockableSession. This followed from scratching my head trying to understand what SessionNoSlots provided, and then heading to the PR which implemented it (Adding Session.__slots__. #128) to see what the class was buying the tests. I'm happy to put this back how I found it 😅

Closes #394

Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jamandbees thanks for the new PR 👍

Can you please run nox -s blacken in your branch? This should take care of the failed lint session in CI.

I left a few more quick comments inline.

nox/sessions.py Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
nox/virtualenv.py Outdated Show resolved Hide resolved
@gwynforthewyn gwynforthewyn force-pushed the 394-integrates-no-install-flag branch 2 times, most recently from 394f9c4 to 8262d67 Compare March 28, 2021 00:05
@gwynforthewyn
Copy link
Author

Hi @jamandbees thanks for the new PR 👍

Can you please run nox -s blacken in your branch? This should take care of the failed lint session in CI.

I left a few more quick comments inline.

I didn't make this clear, but linting etc are all passing now. 🙂

noxfile.py Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looking nice! Some more comments inline.

nox/sessions.py Outdated Show resolved Hide resolved
@gwynforthewyn gwynforthewyn force-pushed the 394-integrates-no-install-flag branch 2 times, most recently from 4ac9bc1 to 7144b11 Compare April 3, 2021 15:28
Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jamandbees thanks for the update! Here are some suggestions. This should also take care of the coverage woes you mentioned.

docs/config.rst Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
nox/sessions.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@cjolowicz cjolowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jamandbees here's a fresh review, see the inline comments 👍

I think we're quite close to wrapping this up. The shorthand for -r --no-install and the documentation can also be left to a follow-up PR. But feel free to have a go at these if you want to.

In case you do want to tackle the shorthand option: I liked the option name you proposed (the second one). Also, a short option -R would make sense to me (mirroring -r for plain reuse). You could probably implement this using a finalizer function, see _color_finalizer in _options.py for an example.

@@ -399,6 +402,8 @@ def create(self) -> bool:
self.location_name
)
)
self._reused = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be True not False, because the virtualenv is being reused.

Suggested change
self._reused = False
self._reused = True

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(BTW it would be great if the tests would catch this.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a couple of assertions for _reused, one in the tests/test_virtualenv.py in test_condaenv_create and the other in test_create.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're quite close to wrapping this up. The shorthand for -r --no-install and the documentation can also be left to a follow-up PR. But feel free to have a go at these if you want to.

@cjolowicz I think it makes sense to relegate those to a follow-up PR. I think I've had this one hanging out for long enough 🙂

Thanks for your help and patience so far!

nox/sessions.py Outdated Show resolved Hide resolved
gwynforthewyn and others added 12 commits May 6, 2021 19:30
…ntrblm#394)

  * skips pip installs
  * skips conda installs
  * skips run_always if no-install is set
…trblm#394)

reuse_existing is now true if we are not installing pacakges.
This boolean informs us whether we need to ignore the "no-install"
command line option.
Extracted and renamed SessionNoSlots to MockableSession to clarify
what it is used for. Reduced duplication of that code.

Duplicated several tests for conda installs but ensured that the
no-install flag was set and ignored.
* Updates venv_created to a private data member.
* Removes irrelevant interpolation from no-install log messages.
Also removed unnecessary whitespace lines.

Co-authored-by: Claudio Jolowicz <cjolowicz@gmail.com>
This was good advice from @cjolowicz helping to clarify the intention
of this boolean.
_clean_location already detects whether a venv is being reused or not,
so setting the boolean within this is safe.

whether a venv exists or not.
…#394)

Also reduces log verbosity by only noting package reinstallation
when venv is not explicitly reused.
Removes unneeded logger messages when --no-install is ignored.
Simplifies tests and restores 100% test coverage.
@gwynforthewyn gwynforthewyn force-pushed the 394-integrates-no-install-flag branch 2 times, most recently from 5498014 to 61dbefe Compare May 8, 2021 16:40
Also removes logging for no_install.
@gwynforthewyn gwynforthewyn force-pushed the 394-integrates-no-install-flag branch from 61dbefe to 0a088ae Compare May 8, 2021 16:41
@cjolowicz
Copy link
Collaborator

@jamandbees Thanks for the update! I enabled your CI run, and it looks like some tests need adapting to your latest changes. Could you take a look?

@gwynforthewyn
Copy link
Author

@cjolowicz I'm honestly not sure how to adapt them; when I check git, I get the impression that this is from a recent merge, but I'm not confident that I understand what's going on.

@cjolowicz
Copy link
Collaborator

Hey @jamandbees , no problem and thanks for your work so far! I picked this up in #432 and credited you as co-author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to skip install commands
2 participants