Python library to perform code execution in fully isolated environments
Project description
pascua
Description
Python library to perform code execution in fully isolated environments.
IMPORTANT: This repository is in the early stage of development, so its not recommended to be used yet. Nevertheless, contributions are welcome!
Installation
You can install the latest pascua version via pip:
pip install pascua
How it works?
pascua allow us to perform code executions in isolated environments through containerization techniques. The main idea is that pascua builds a docker image with the given parameters defined in the corresponding implementation of the Environment constructor.
When a call to exec(.) method is performed, it uses the generated docker image as the base in which it launches the proper interpreter or code compilation to execute the given source_code in combination with the variables defined in the context dictionary.
Usage
Python Environment
import pascua as psc
context = {
'size': 100,
}
source_code = [
'import numpy as np',
'random_numbers = np.random.uniform(size=size)',
]
env = psc.PythonEnvironment(
version='3.7.3',
pip_dependencies=[
'numpy>=1.14.0',
]
)
result = env.exec(source_code, context)
R Environment
import pascua as psc
context = {
'size': 100,
}
source_code = [
'random_numbers <- runif(n = size)',
]
env = psc.REnvironment(
version='latest',
)
result = env.exec(source_code, context)
C++ Environment
import pascua as psc
context = {
'size': 100,
}
source_code = [
'float r;',
'vector<float> random_numbers;',
'for (int i = 0; i < size; i++) {',
' r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);',
' random_numbers.push_back(r);',
'}',
]
env = psc.CCEnvironment(
version='latest',
includes=[
'vector',
'numeric',
]
)
result = env.exec(source_code, context)
Development
You can install it simply typing:
python setup.py install
To run the tests perform:
python -m unittest discover tests
License
- This project is licensed under MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pascua-0.0.2.tar.gz.
File metadata
- Download URL: pascua-0.0.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cbd638842d04be73f10e1ae4ad511f7f95f65557e7e2f8295c28979f3debaa9
|
|
| MD5 |
32c419b31fb67f154b2007614520856a
|
|
| BLAKE2b-256 |
efd8a206a80106e91bee80fac598a6cd49a34f6150f7ae64020fe2c2511a19d4
|
File details
Details for the file pascua-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pascua-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9a8b34282fb8443fc923f3f6f5c9fb2a64f77f734179cb9a0364c0789433b01
|
|
| MD5 |
0640f9a1590c48acfb71efcdd7efcdde
|
|
| BLAKE2b-256 |
137e02a0d4aa2a069adb3ff8ff66c8e4c87f49e32a3f8a7b3f94509ce0754fc6
|