Skip to content

Run any long-running python script or container easily until it completes, on AWS.

Notifications You must be signed in to change notification settings

niklas-palm/oneoff-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneOff

CLI that helps you quickly and easily run a long-running python program or any Docker container in a fargate task untill it completes.

Prerequisites

  • Active AWS credentials in your environment.

Installation

To install the CLI tool, navigate to the root of the project directory and run:

pip install .

Setup

Initialize the CLI tool by running:

oneoff init

This command will set up the necessary AWS infrastructure (which incurs no cost) to enable you to quickly run containers in ECS Fargate.

After initialization, you can view available commands by running:

oneoff --help

to see available commands.

Overview

The CLI helps you run any python script or Docker container in a task in ECS Fargate until the container or script completes and the task is terminated.

There are three types of invocations:

  1. Run a Python script without dependencies: Executes a Python script using a default container.
  2. Run a Python script with a custom requirements.txt file: Uses a requirements.txt file located at the same level as the script to install additional dependencies.
  3. Run an arbitrary container from a Dockerfile: Builds and runs a Docker container using a Dockerfile located in the specified path.

Usage

Running a Python Script

To run a Python script (with or without a requirements.txt):

oneoff run my_scripy.py --name test-run

Running a Docker Container

To run a Docker container from a Dockerfile located in the current directory:

oneoff run . --name test-run

Listing Running Jobs

To list all running oneoff jobs:

oneoff ls

This command displays the job name, status, and creation time of each running job.

Fetching Logs

To fetch the logs for a specific job:

oneoff logs -n job-name

To continuously tail the logs (real-time updates) for a job:

oneoff logs -n job-name -t

Note

Logs are automatically deleted after 7 days.

Killing a running job

To kill a running job:

oneoff kill name_of_job

Clean up old state

To remove old jobs from the ls output and clean up metadata:

oneoff prune

Viewing Current Configuration

To view the current configuration:

oneoff get_conf

Notes

CPU and Memory.

When specifying CPU and memory, the combination of values supported can be found in the AWS docs here

Warning

The IAM role created for the task contains admin permissions for simplicity.

About

Run any long-running python script or container easily until it completes, on AWS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages