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

API for customizing the conda base environment. #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ssurbhi560
Copy link
Contributor

Description

In this PR, we provide an API for users to customize the conda base environment during the condacolab's installation. Users will have the following options to specify:

  1. environment_file - This can be a URL or path to an environment.yaml file.
  2. specs - This is a list of additional specifications (packages) to install.
  3. python_version - Python version to use in the conda base environment, eg. "3.9".
  4. channels - Comma-separated list of channels to use in the conda base environment.
  5. pip_args - List of additional packages to be installed using pip
  6. extra_conda_args - This is a list of any extra conda arguments used during the installation.

You can check this example notebook demonstrating the new feature here.

Status

  • Ready to go

@jaimergp
Copy link
Member

We need to rebase / merge the contents of main after the recent merge. Please update @ssurbhi560 :)

condacolab.py Outdated
Comment on lines 25 to 36
from IPython.display import display

from IPython import get_ipython

try:
from ruamel.yaml import YAML
from ruamel.yaml.comments import CommentedMap
except ImportError as e:
raise RuntimeError("Could not find ruamel.yaml, plese install using `!pip install ruamel.yaml`!") from e

try:
import ipywidgets as widgets
Copy link
Member

Choose a reason for hiding this comment

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

Two things:

  1. Sort dependencies and separate stdlib from 3rd party
  2. Add 3rd party packages to pyproject.toml dependencies to ensure everything is available in case Google changes the bundled packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did it here: #41! :)

condacolab.py Outdated Show resolved Hide resolved
condacolab.py Outdated Show resolved Hide resolved
condacolab.py Outdated Show resolved Hide resolved
condacolab.py Show resolved Hide resolved
condacolab.py Outdated Show resolved Hide resolved
condacolab.py Outdated Show resolved Hide resolved
@jaimergp
Copy link
Member

jaimergp commented Nov 1, 2022

Also, make sure we don't overwrite the original sys.executable as present in google colab. Check for existence in this line before renaming:

https://github.com/conda-incubator/condacolab/pull/38/files#diff-f0c65246b372c57b50f20261e427c9f066c232c42bdf51ec2d78681a0e1b1ed7R333

condacolab.py Outdated Show resolved Hide resolved
condacolab.py Outdated
yaml.dump(env_details, f)

_run_subprocess(
[f"{prefix}/bin/python", "-m", "conda_env", "update", "-n", "base", "-f", environment_file_path, *extra_conda_args],
Copy link
Member

Choose a reason for hiding this comment

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

Let's pass conda_exe from the calling function to this one so we can use mamba if available. That should reduce solver times.

Suggested change
[f"{prefix}/bin/python", "-m", "conda_env", "update", "-n", "base", "-f", environment_file_path, *extra_conda_args],
[conda_exe, "env", "update", "-n", "base", "-f", environment_file_path, *extra_conda_args],

@jaimergp jaimergp mentioned this pull request Nov 7, 2022
@alimanfoo
Copy link

Hi, just stumbled on the nice blog post by @ssurbhi560 and came looking for the new features :)

@@ -297,6 +297,8 @@ def install_from_url(
"pip_task.log"
)

print("📦 Updating enviornment using YAML file...")
Copy link

Choose a reason for hiding this comment

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

print("📦 Updating environment using YAML file...")

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

Successfully merging this pull request may close these issues.

4 participants