nox icon indicating copy to clipboard operation
nox copied to clipboard

CondaEnv auto-offline behaviour with local package repositories

Open Tolker-KU opened this issue 2 years ago • 2 comments

How would this feature be useful? Inside some companies a local repository of Conda packages is used. This means that a dev is able to connect to the local package repository and download packages without being able to access repo.anaconda.com. We are testing for access to this site when determining if CondaEnv should auto-offline: https://github.com/theacodes/nox/blob/8b12711d43a4c7b231c18c9b124501e4d23d5b53/nox/virtualenv.py#L286 It would be useful to be able to check for connection to a local package repository for determining if Nox should go into "auto-offline mode".

Describe the solution you'd like I think this is quite tricky to solve, so I've more a list of possible solutions than a solution I want:

  • Parse the users .condarc file to determine what site to use for testing if online. This can become quite complicated as the .condarc file can be saved many different place, may change format, have multiple channels and so on.
  • Make the site to use for testing if online settable by the user in some way. The best place for this is probably some config file specific to the users machine, but having such a config file is not very 'noxy' as I see it.
  • Make a option to disable the "auto-offline" thing. This has its own drawbacks of course.

Describe alternatives you've considered Alternatively one can use it auto_offline=False argument in Session.conda_install() but it is not very elegant to set this everywhere.

Tolker-KU avatar Dec 29 '21 12:12 Tolker-KU

A question to those more familiar with conda than me:

Instead of automatically switching to offlline mode, can we expose conda's --offline flag through the Nox CLI, letting users choose offline mode explicitly?

Offline-mode seems to be a feature that should be controlled by the Nox user, not the Noxfile author. Our automatic offline detection seems error-prone at best. If this use case can be solved by exposing --offline, I'd argue that we should deprecate the auto-offline mode altogether.

What am I missing?

cjolowicz avatar Dec 29 '21 13:12 cjolowicz

A question to those more familiar with conda than me:

Instead of automatically switching to offlline mode, can we expose conda's --offline flag through the Nox CLI, letting users choose offline mode explicitly?

Offline-mode seems to be a feature that should be controlled by the Nox user, not the Noxfile author. Our automatic offline detection seems error-prone at best. If this use case can be solved by exposing --offline, I'd argue that we should deprecate the auto-offline mode altogether.

What am I missing?

I agree with all of this and I'm fan of making --offline a CLI argument.

The feature is described and introduced here FTR: #313 #314

Tolker-KU avatar Dec 29 '21 18:12 Tolker-KU