Skip to main content

Run FireWorks workflows in Google Cloud

Project description

Borealis

Runs FireWorks workflows on Google Compute Engine (GCE).

See the repo Borealis and the PyPI page borealis-fireworks.

  • Borealis is the git repo name.
  • borealis-fireworks is the PyPI package name.
  • borealis-fireworker.service is the name of the systemd service.
  • fireworker is the recommended process username and home directory name.

What is it?

FireWorks is open-source software for defining, managing, and executing workflows. Among the many workflow systems, FireWorks is exceptionally straightforward, lightweight, and adaptable. It's well tested and supported. The only shared services it needs are a MongoDB server (acting as the workflow "LaunchPad") and a file store.

Borealis lets you spin up as many temporary worker machines as you want in the Google Cloud Platform to run your workflow. That means pay-per-use and no contention between workflows.

How does Borealis support workflows on Google Cloud Platform?

TL;DR: Spin up worker machines when you need them, deploy your task code to the workers in Docker Images, and store the data in Google Cloud Storage instead of NFS.

Worker VMs: As a cloud computing platform, Google Compute Engine (GCE) has a vast number of machines available. You can spin up lots of GCE "instances" (also called Virtual Machines or VMs) to run your workflow, change your code, re-run some tasks, then let the workers time out and shut down. Google will charge you based on usage and there's no resource contention with your teammates.

Borealis provides the ComputeEngine class and its command line wrapper gce to create, tweak, and delete groups of worker VMs.

Borealis provides the fireworker Python script to run as the top level program of each worker. It calls FireWorks' rlaunch feature.

You can run these Fireworkers on and off GCE as long as they can connect to your MongoDB server and to the data store for their input and output files.

Docker: You need to deploy your payload task code to those GCE VMs. It might be Python source code and its runtime environment, e.g. Python 3.8, Python pip packages, Linux apt packages, compiled Cython code, data files, and environment variable settings. A GCE VM starts up from a GCE Disk Image which could have all that preinstalled (with or without the Python source code) but it'd be hard to keep it up to date and hard to keep track of how to reproduce it.

This is what Docker Images are designed for. You maintain a Dockerfile containing instructions to build the Docker Image, then use the Google Cloud Build service to build the Image and store it in the Google Container Registry.

Borealis provides the DockerTask Firetask to run a task in Docker. It pulls a named Docker Image, starts up a Docker Container, runs a given shell command in that Container, and shuts down the Container. Running in a Container also isolates the task's runtime environment and side effects from the Fireworker and other tasks.

Google Cloud Storage: Although you can set up an NFS shared file service for the workers' files, Google Cloud Storage (GCS) is the native storage service. GCS costs literally 1/10th as much as NFS service and it scales up better. GCS lets you archive your files in yet lower cost tiers intended for infrequent access. Pretty much all of Google's cloud services revolve around GCS, e.g., Pub/Sub can trigger an action on a particular upload to GCS.

But Cloud Storage is not a file system. It's an object store with a light weight protocol to fetch/store/list whole files, called "blobs." It does not support simultaneous writers. Instead, the last "store" of a blob wins. Blob pathnames can contain / characters but GCS doesn't have actual directory objects, so e.g. there's no way to atomically rename a directory.

DockerTask supports Cloud Storage by fetching the task's input files from GCS and storing its output files to GCS.

You can access your GCS files via the gsutil command line tool, the gcsfuse mounting tool, and the Storage Browser in the Google Cloud Platform web console.

Logging: DockerTask logs the Container's stdout and stderr, and fireworker sets up Python logging to write to Google's StackDriver logging service so you can watch all your workers running in real time.

Projects: With Google Cloud Platform, you set up a project for your team to use. All services, VMs, data, and access controls are scoped by the project.

How to run a workflow

After doing one-time setup, the steps to run a workflow are:

  1. Build a Docker container Image containing your payload task code to run in the workflow. The gcloud builds submit command will upload your code and a Dockerfile, then trigger a Google Cloud Build server server to build the Docker Image and store it in the Google Container Registry.

  2. Build your workflow and upload it to MongoDB. You can do this manually by writing a .yaml file and running the lpad command line tool, or automate it as a workflow builder that calls FireWorks APIs to construct a Workflow object and upload it.

    The workflow will run instances of the DockerTask Firetask.

    If you need to open a secure ssh tunnel to the MongoDB server running in a Google Compute Engine VM, use the borealis/setup/example_mongo_ssh.sh shell script.

  3. Start one or more fireworker processes to do the work. You can run the fireworker Python script locally (which is handy for debugging) or launch Compute Engine VMs that run fireworker (handy for running lots of tasks in parallel).

    You can run the Python script gce to launch a batch of workers, or automate it by calling its ComputeEngine class from your workflow builder.

More detail on the Borealis components

gce: The ComputeEngine class and its command line wrapper gce will create, tweak, and delete a group of worker VMs.

After you generate a workflow, call FireWorks' LaunchPad.add_wf() (or run FireWorks' lpad add command line tool) to upload it to the LaunchPad. Then call ComputeEngine.create() (or the gce command line) to spin up a batch of worker VMs to run the workflow. This passes in parameters including the LaunchPad host and name.

ComputeEngine and gce can also immediately delete a batch of worker VMs or ask them to quit cleanly between Firetasks, although the workers will shut down on their own after an idle timeout.

ComputeEngine and gce can also set GCE metadata fields on a batch of workers. This is used to implement the --quit-soon feature.

fireworker: Borealis provides the fireworker Python script to run as as the top level program of each worker. fireworker reads the worker launch parameters and calls the FireWorks library to "rapidfire" launch your FireWorks "rockets." It also handles server shutdown.

fireworker connects Python logging to Google Cloud's StackDriver logging so you can watch all your worker machines in real time.

To run fireworker on GCE VMs, you'll need to create a GCE Disk Image that contains Python, the borealis-fireworks pip, and such. See the instructions in how-to-install-gce-server.txt.

The fireworker command can also run on your local computer for easier debugging. For that, you'll need to install the borealis-fireworks pip and set up your computer to access the right Google Cloud Project.

DockerTask: The DockerTask Firetask pulls a named Docker Image, starts up a Docker Container, runs a given shell command in that Container, and stops the container.

Docker always runs a shell command in the Container. If you want to run a Firetask in the Container, include a little Python script to bridge the gap: Take a Firetask name and a JSON dictionary as command line arguments, instantiate the Firetask with those arguments, and call the Firetask's run_task() method.

DockerTask supports Google Cloud Storage (GCS) by fetching the task's input files from GCS, mapping it into the Docker Container, running the task, and storing its output files to GCS. This requires you to declare the input and output paths. (A workflow builder can use these declarations to compute the task interdependencies that FireWorks needs.)

For each path you specify in DockerTask's inputs and outputs, it denotes a directory tree of files iff it ends with a /.

When storing task output files, DockerTask creates blobs with names ending in / to act as "directory placeholders" to speed up tree-oriented traversal. This means you can run gcsfuse without using the --implicit-dirs flag, resulting in mounted directories that run 10x faster.

DockerTask imposes a given timeout on the task running in the Docker container.

DockerTask logs the Container's stdout and stderr to a file and to Python logging (which fireworker connects to StackDriver).

Team Setup

TODO: Install & configure dev tools, create a GCP project, auth stuff, install MongoDB on a GCE VM or set up Google-managed MongoDB, create a Fireworker disk image & image family, ...

See borealis/setup/how-to-install-gce-server.txt for detail instructions to set up your Compute Engine Disk Image and its "Service Account" for authorization.

xxxxx to connect to the LaunchPad MongoDB server. Metadata parameters and the worker's my_launchpad.yaml file configure the Fireworker's MongoDB host, port, DB name, and idle timeout durations. Users can have their own DB names on a shared MongoDB server, and each user can have multiple DB names -- each an independent launchpad space for workflows and their Fireworker nodes.

Individual Developer Setup

TODO: Install & configure dev tools, make a storage bucket with a globally-unique name, build a Docker image to run, ...

Run

TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

borealis-fireworks-0.6.1.tar.gz (36.7 kB view details)

Uploaded Source

Built Distribution

borealis_fireworks-0.6.1-py2.py3-none-any.whl (36.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file borealis-fireworks-0.6.1.tar.gz.

File metadata

  • Download URL: borealis-fireworks-0.6.1.tar.gz
  • Upload date:
  • Size: 36.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for borealis-fireworks-0.6.1.tar.gz
Algorithm Hash digest
SHA256 2878e1ab4e091cd0fe8d282dddf0642f245996c4dfe31e940ba2c98ec85dad22
MD5 015a89fa49023b2185a5a7342f7e2d38
BLAKE2b-256 b2be8e4b8d7babbdc51625843de92f73df21e16cdbd7f1feea480d4fabdc18c6

See more details on using hashes here.

File details

Details for the file borealis_fireworks-0.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: borealis_fireworks-0.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.0

File hashes

Hashes for borealis_fireworks-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bc633667cbaa7ea7eb49552da92212f0f0fa2e2fc9bb6d0143bc58f46eadd9f1
MD5 d1ae86284c96ea1324eaaa7a59a0efe4
BLAKE2b-256 ad5d8479922b399a18cdb599af3c2a0a9e907942b3b16167725362c284cb6963

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page