The env-isolation is a library that allows to create isolated environments for running Python code. It is useful for seperating pip environments.
Note: The Library do not isolate the environments for security purposes.
Installation
Install this library in a venv using pip. venv is a tool to create isolated Python environments.
Supported Python Versions
Python >= 3.6
Mac/Linux
pip install venv
python -m venv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install env-isolation
Windows
pip install venv
python -m venv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install env-isolation
Example Usage
Create a directory test-model with a file test-model/requirements.txt with the following content:
pandas
Create a file test-model/main.py with the following content:
import logging
import pandas as pd
class Model():
def __init__(self, arguments: dict):
logging.info(f'Test Model initialised arguments: {arguments}')
def execute(self, arguments: dict) -> dict:
logging.info(f'Test Model executed with arguments: {arguments}')
return pd.read_csv('test.csv').to_dict()
Execute the following code:
import logging
logging.basicConfig(level=logging.INFO)
from envisolation import EnvIsolatedModel
model = EnvIsolatedModel(model_id="test-model", model_path="test_model", pip_requirements_path="test_model/requirements.txt", model_arguments={"test_argument":1})
logging.info(model.execute({"input": "test"}))
model.unload()
Metadata
Release files for env-isolation 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| env_isolation-0.8.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Release files / env_isolation-0.8.0-py2.py3-none-any.whl
| Download URL | env_isolation-0.8.0-py2.py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ad9996bc9434fcf05ae270086101f625c0a3b8c07cd66104fcaa5a41882ac723
|
|
BLAKE2b-256 checksum How to use checksums |
545445aa3e40ed50c2d5b5e48ed1780662f2ee3dcc53e168853a9f3a107bc247
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|