Skip to main content

Isolates the environment to seperate pip environments.

Project description

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

env_isolation-0.4.0-py2.py3-none-any.whl (18.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file env_isolation-0.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: env_isolation-0.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for env_isolation-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e5a243f6c00af9dfc15e5d5a2e7686596cade7e4996fafc87bfe93ec71daf0b9
MD5 20b1855d239a7af66ecfc5934932c02e
BLAKE2b-256 2ea7904037c41f46e85829d39942edc27abab2532b707a54c6beb2c689d189f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page