Skip to main content

Lug

PyPI

Lug is an open source package that allows you to move the execution of specific Python functions to different environments on each call. This means that instead of deploying a function permanently to a specific environment (e.g. your local computer or a cloud-based server), you can choose where you want to run the function at the time of execution. This flexibility allows you to optimize your resource consumption and cost for the needs of the specific function.

Lug is particularly useful for computational science, where researchers and scientists often have programs that are challenging to install and run. Lug automatically detects and packages pip-installed dependencies and local modules, and you can even attach a sidecar Docker image for the command-line programs that need their own image – making it simple to debug and scale your code.

Check out the full docs at lug.dev

Highlights

  • 📦 Automatic dependency detection and propagation
  • 🐳 Attach function-scoped sidecar Docker images
  • ☁️ Execute on your computer, the cloud, or on your own servers

Prerequisites

  • macOS or Linux
  • Docker Engine, if you're using Lug Docker Sidecar functions

Install

Install Docker Engine and the CLI, if you don't have it.

With pip:

pip install lug

Get started

There are two ways to use Lug:

  1. Creating a Lug Hybrid function that executes on your computer or in the cloud.
  2. Creating a Lug Docker Sidecar function, which is the same as a Lug Hybrid function but with a function-scoped Docker image.

On this readme, we'll just create a short Lug Hybrid function, but there's more detail in the docs.

Quick start:

Let's create a simple Python function that tells us how many CPUs our system has:

import lug
import multiprocessing

@lug.hybrid(cloud=False)
def num_cpus():
    return multiprocessing.cpu_count()

print(num_cpus())

This function will execute locally and print the number of CPUs on the system. To run on the cloud, first generate a Toolchest API key and set key to your Toolchest API key and cloud=True:

import lug
import multiprocessing

@lug.hybrid(cloud=True, key="YOUR_KEY_HERE")
def num_cpus():
    return multiprocessing.cpu_count()

print(num_cpus())

This function will execute on the cloud and print the number of CPUs on the cloud-based server.

For more detail, check out the docs at lug.dev

Open-source roadmap

  • Run a Python function in a local container
  • Maintain Python major.version in function and in container
  • Serialize and deserialize Python function and Python dependencies
  • os.system(), subprocess.run(), and subprocess.Popen() redirect to a user-specified container
  • Local files passed to as input go to ./input/ in remote Docker container
  • Remote files written to ./output/ in the container are written to local output Path
  • Runs locally
  • Run in the cloud with Toolchest
  • Stream live stdout during remote cloud execution
  • pip-based environment propagation
  • conda-based environment propagation (help needed)

License

Lug is licensed under the Apache License 2.0

Metadata

Release files for lug 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lug 0.3.8
File Size Uploaded
lug-0.3.8.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lug 0.3.8
File Interpreter ABI Platform
lug-0.3.8-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / lug-0.3.8.tar.gz

Download URL lug-0.3.8.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b07781f6b4b08a33366a4d42bd9a5c4edc2b4896c5668564f6c9a8f38a05beee
BLAKE2b-256 checksum
How to use checksums
1cf93f1813ff6730b1695096aabaa285807d90d48699fbff2d0172045da768f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.8.16 Linux/5.15.0-1030-aws

Release files / lug-0.3.8-py3-none-any.whl

Download URL lug-0.3.8-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b033a5cf8d8cc4f0226e395d7033f433bc7fabb248e034fae3d3852fc04e927
BLAKE2b-256 checksum
How to use checksums
80e982d4e9a771f1e107cc8e410b3d229f65a61323bef4ba9627c89fe5fbe7da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.8.16 Linux/5.15.0-1030-aws

Release history Release notifications | RSS feed

This release

0.3.8 This release

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page