Skip to main content

Swarmer

Build Status

Python application and API to run services from within a docker swarm.

NOTE

There have been some significant changes between versions 0.2.6 and version 0.3.0 that change the way swarmer is installed and works to provide authentication to private docker registries. This documentation will be updated soon to reflect that.

How it works

The swarmer lives in a service inside a docker swarm. Once exposed, it offers an API to activate one shot docker service runs. There is a companion application to this service that is responsible for reporting the results back to this service. Once all tasks within a job are complete, the complete set of results is posted back to a specified callback URL.

Clients

While any client that is compatible of running your subject code from within another container based on the values passed will work, there is a default client you can view. This list will be updated when more default clients become available:

Dependencies

To run, this image requires a redis service to be available, and to receive results, you'll need a callback url accepting POST data (application/json) that is accessible from the your swarm location.

Getting started

You can take the compose example in this repository and run it as it is in your docker swarm via docker stack deploy -c docker-compose.yml, changing any of the values that you see fit.

Once started, there will be a service exposed at the address of your swarm that you can post jobs to.

The initial request

When you want to submit a new job, you send a request to the /submit endpoint, with a content type of application/json and a body with the following:

{
  "image_name": "some-image:latest",
  "callback_url": "your postback url"
}

You will receive a response with an identifier, this is a unique job id you can use to submit tasks to your job.

Adding tasks

Once your job has been created, you can submit a list of tasks to it. This is done via the /submit/<identifier>/tasks POST endpoint, where identifier is the id value you were given when the job was created. The body of this request should look like the following:

{
  "tasks": [
    {
      "task_name": "<Name>",
      "task_args": ["arg-one", "arg-two", ...]
    },
    ...
  ]
}

Once the tasks have been submitted, they will begin running immediately.

Checking the status of a job

If you have a running job that you would like to check on, you can send a GET request to the /status/<identifier> resource, where identifier is the id value of your job.

Getting your results

Once all the tasks for your job are complete, the URL you specified in the callback_url field will receive a POST request with the collected results. The general format is:

{
  "__image": "your image",
  "__callback_url": "your url",
  "tasks": [
    {
      "name": "task name",
      "status": 0,
      "args": ["your", "args"],
      "result": {
        "stdout": "the output written to stdout",
        "stderr": "the output written to stderr"
      }
    },
    ...
  ]
}

For each task, the status field represents the exit status of the task process, while the result object contains the output that your task wrote to the two output streams.

Release files for swarmer 0.5.0

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

Source distribution (sdist)

Source distribution for swarmer 0.5.0
File Size Uploaded
swarmer-0.5.0.tar.gz 15.3 kB Details

Built distribution (wheel)

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

Total release size: 34.5 kB

Release files / swarmer-0.5.0.tar.gz

Download URL swarmer-0.5.0.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0b4543e82643655207974141f594ff6dd81b8df85b0fe6ec32ba61b800794f31
BLAKE2b-256 checksum
How to use checksums
75c87eae86a97016d871885b24106d59c41f470601a33a3852a5fbac1725b79e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0a4+

Release files / swarmer-0.5.0-py3-none-any.whl

Download URL swarmer-0.5.0-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00f8b7e6273523d0666317d419471a2e9b674489455cf0485f786e0a76f2c3d8
BLAKE2b-256 checksum
How to use checksums
75b0bb7c8a7c4707985070e5ea1fd4cb11ed5e6bf4a77a4ebf878e554896313f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0a4+

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.0

2 release files

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