Python Environments
One key advantage of the Altair AI Tools Python Devkit is that developers don't need to worry about Python environments on end-user machines. The devkit automatically handles environment management for Python Extensions, significantly simplifying deployment and distribution.
When you develop an extension, the devkit captures your development environment's configuration and packages this information with your extension, ensuring that your code runs consistently across different systems regardless of their pre-existing Python setup. The user does not even need to have Python installed.
Understanding Python Environment Management
The Python Extension Loader (PEL) manages its own dedicated conda installation, designed to remain as isolated as possible from any existing user conda setups. However, due to shared resources such as conda-related files in the user's home directory, the environments managed by AI Studio may still appear in tools like conda env list
during development. This is expected behavior. Users should avoid manually activating, using, or modifying these environments to prevent conflicts or unexpected issues.
Distribute the environment
The devkit offers two approaches for shipping your environment.
Online Mode (default)
- Bundles only the environment definition with the extension zip file
- Packages are downloaded during installation
- Results in smaller extension file size
- Requires internet connectivity during installation
- Best for most standard scenarios.
When to use: This is the recommended approach for most extensions that use publicly available packages and will be installed in environments with reliable internet access.
Read more: Environment creation via Miniforge (online)
Offline Mode
- Includes all packages from your active environment in the extension zip file
- Packages pip dependencies directly in the bundle
- No internet connection required during installation
- Results in significantly larger extension file size to support multiple operating systems
When to use: Choose this approach for air-gapped environments, or when internet connectivity is limited to restricted.
Read more: Environment creation via Miniforge (offline)
Note: Choose offline mode when deploying to environments with limited internet access, but be aware that this significantly increases the extension file size.
Configure the environment
When building the extension, the environment definition is captured from the activated conda environment. The environment is captured and stored as an env.yml file with the extension in case of online environment.
The Python Extension Loader provides various settings to control the environments on user's machine.
Next, lets look at how to configure extensions.