PyStributed: Remote Execution Utility
This package allows users to mark specific code cells in a Jupyter Notebook for remote execution. Once marked, the code will be packaged into a Docker container, sent to a specified remote server for execution, and the results will be fetched back to the local machine.
Installation
- Extract the contents of this directory to a location on your machine.
- Navigate to the directory and run
pip install .to install the package.
Prerequisites
- Docker installed on both local and remote machines.
- SSH access to the remote machine.
- PyTorch and Transformers libraries if you are using them in your code.
Configuration
- Before using the package, you need to set up some configurations in
config.py. Template can be seen below. docker_utils.pyis used to set docker file and container environment variablesremote_utils.pyis used to set docker container volume and host save location
Usage
- In your Jupyter Notebook, import the package:
import pystributed.main as runner
- Use the
%%save_for_remotemagic command to mark the code cell you want to run remotely:
%%save_for_remote
# Your code here
# For example:
import torch
model = torch.load('my_model.pth')
result = model(some_data)
- After marking the desired code cell, run the cell to obtain results.
Under the Hood
The package works in the following sequence:
- The code cell marked with
%%save_for_remoteis saved to a Python script (temp_script.pyby default). - A Docker image is built with the user's code and necessary dependencies.
- The Docker image is pushed to the specified Docker registry.
- The package SSHs into the specified remote server, pulls the Docker image, and runs it.
- Once the code execution is complete on the remote server, the results are fetched and saved to the local machine.
Configuration
To customize the configuration for pystributed, create a config.json file in the following location:
~/.pystributed/config.json
Here's a detailed structure for the config.json file:
{
"BASE_IMAGE": "Name of the base docker image you want to use",
"PACKAGES_NEEDED": "Packages needed to execute code snippet",
"DOCKER_IMAGE_NAME": "Name of the Docker image that will be created.",
"DOCKER_REGISTRY": "Docker registry where the image will be pushed.",
"REMOTE_SERVER": "SSH-compatible address of your remote server (e.g., `user@remote_server_ip`).",
"REMOTE_WORKDIR": "Working directory on the remote server where results will be stored.",
"USER_CODE_PATH": "Temporary path on the local machine where the user's code will be saved before packaging.",
"SSH_PRIVATE_KEY_PATH": "Location of .pem file to access remote instance",
"GPU": "Set to 'True' if you are using a remote instance that requires your docker container to access the GPU on the instance"
}
Metadata
Release files for pystributed 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pystributed-0.2.0.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pystributed-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / pystributed-0.2.0.tar.gz
| Download URL | pystributed-0.2.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f0fd97ae7108271e6b02079cdacc97bb7ba2521b23ebd789bf74de66dc88a7d
|
|
BLAKE2b-256 checksum How to use checksums |
49085701805c79ecc503830b13a923aead805c08053d0f791508024cfacdde5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.65.0 urllib3/1.26.5 CPython/3.10.12
|
Release files / pystributed-0.2.0-py3-none-any.whl
| Download URL | pystributed-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7742992634fa2774a0946d42dc9ab07e9f6cd12a10641a0c7755e073f8d8662
|
|
BLAKE2b-256 checksum How to use checksums |
35cb86ec60dc54ca6e19fc308f5968d95c529ee27184168cb8effed4724a607a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.65.0 urllib3/1.26.5 CPython/3.10.12
|