A Python package for managing remote environment requirements
Project description
Remote Twin Baker
Remote Twin Baker is a Python framework for seamless remote task execution. By adding a simple decorator to your Python functions, it automates file synchronization, environment validation, and result retrieval between a local client and a remote server. Designed for data science, AI, edge computing, and collaborative development, it minimizes manual overhead while ensuring consistency across environments.
Key Features
- Decorator-Based Execution: Use
@remote_execution_decoratorto run local Python functions on a remote server. - Efficient File Sync: Transfers only new or modified files using MD5 hash checks.
- Environment Validation: Compares client and server environments, reporting mismatches for manual correction.
- Environment Sync: Use
utils/merge_env_requirements.pyto merge base and custom requirements and update the remote server. - Result Retrieval: Returns Python objects and new files, with 10-second polling for asynchronous file sync.
- Scalable Deployment: Runs a FastAPI server on port 7777, with Nginx for HTTPS in production.
- Versatile Use Cases: Supports large-scale data processing, AI model training, IoT, and team collaboration.
Project Structure
remote-twin-baker/
├── LICENSE
├── README.md
├── app/
│ └── server.py # FastAPI server for remote execution
├── client/
│ └── remote_execution.py # Client-side decorator logic
├── config.local.yaml # Local testing configuration
├── config.yaml # Production configuration
├── nginx/
│ └── remote_twin_baker.conf # Nginx configuration for HTTPS
├── requirements.txt # Base dependencies for client and server
├── test/
│ └── test_server.py # Test script for local validation
└── utils/
└── merge_env_requirements.py # Utility for merging and syncing environments
Installation
-
Clone the Repository:
git clone https://github.com/your-username/remote-twin-baker.git cd remote-twin-baker
-
Set Up Environment: Create a Python 3.12 Conda/virtual environment:
conda create -n remote_twin_baker python=3.12 conda activate remote_twin_baker pip install -r requirements.txt
-
Configure the Server:
- For local testing, use
config.local.yaml(setsurl: http://localhost:7777). - For production, update
config.yamlwith your server URL (e.g.,https://xxx.com/twin_baker).
- For local testing, use
-
Set Up Nginx (Production):
- Copy
nginx/remote_twin_baker.confto/etc/nginx/conf.d/. - Update SSL certificate paths in the config.
- Test and reload Nginx:
nginx -t systemctl reload nginx
- Copy
Usage
-
Start the Server:
python app/server.pyThe server runs on
http://localhost:7777. In production, Nginx proxieshttps://xxx.com/twin_bakerto this port. -
Use the Decorator: Apply the decorator to any function:
from client.remote_execution import remote_execution_decorator import pandas as pd @remote_execution_decorator def process_big_excel(file_path: str) -> str: df = pd.read_excel(file_path) result = df.describe().to_string() output_path = "result.xlsx" df.to_excel(output_path, index=False) return result result = process_big_excel(file_path="data.xlsx") print(result)
This syncs
data.xlsxto the server, executes the function remotely, and returns the result andresult.xlsx. -
Sync Environments: If an environment mismatch is detected (e.g., during execution or tests), run:
python utils/merge_env_requirements.py- This merges
requirements.txtwithcustom_requirements.txt(if exists). - Uploads the merged file to the server.
- Triggers
pip installon the remote server to align environments. - Note: Create
custom_requirements.txtin the root directory for additional packages.
- This merges
-
Run Tests: Validate the system locally:
python -m pytest test/test_server.py -v
Tests verify connectivity, execution, file sync, and environment consistency.
Developer Tasks
- Nginx Setup: Configure SSL certificates and DNS for
xxx.com. Ensure HTTPS requests to/twin_bakerproxy tolocalhost:7777. - Environment Sync: Run
utils/merge_env_requirements.pyto align client and server environments. Fix any remaining mismatches manually based on test reports. - Server Deployment: Deploy
app/server.pyon the remote host, ensuring port 7777 is accessible. - Configuration: Update
config.yamlwith the production URL (https://xxx.com/twin_baker).
Testing Locally
- Activate the environment:
conda activate remote_twin_baker
- Start the server:
python app/server.py - Run tests:
python -m pytest test/test_server.py -v
- Check for test results and environment mismatch reports.
Use Cases
- Data Science/AI: Offload large Excel processing or model training to remote GPUs.
- Team Collaboration: Ensure environment consistency across development, testing, and ops.
- Edge Computing/IoT: Enable resource-constrained devices to leverage remote compute power.
- Personal Projects: Develop locally while executing heavy tasks on cloud servers.
Contributing
Submit pull requests or open issues for bugs, features, or improvements. Follow the coding style in existing files.
License
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 remote_twin_baker-0.1.0.tar.gz.
File metadata
- Download URL: remote_twin_baker-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae03a6e9e942270b45b594eee1ae1ad4420c31490bc7a35aa33dd364f47a9922
|
|
| MD5 |
f8eca99b7a94210daba868991b5bc3cb
|
|
| BLAKE2b-256 |
3a57780e272fe5b386eecc57f350b2e6a20b0c10078d1a81196b71718a38da32
|
File details
Details for the file remote_twin_baker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: remote_twin_baker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb0ac3ea1032d66f724de2df2c165352e21d1c8f31db4ffef201caa7ef3b9c9d
|
|
| MD5 |
bef3e35e1f7fb59735360939491a13ea
|
|
| BLAKE2b-256 |
3ae387adc5ceec000a2be336db4f785f189f9e7801866b250754036fc880a9fa
|