All Projects → hammerlab → Ketrew

hammerlab / Ketrew

Licence: apache-2.0
Keep Track of Experimental Workflows

Programming Languages

ocaml
1615 projects

Labels

Projects that are alternatives of or similar to Ketrew

Gh Action Pypi Publish
GitHub Action, for publishing distribution files to PyPI
Stars: ✭ 317 (+334.25%)
Mutual labels:  workflows
Community Skeleton
UVDesk Opensource Community Helpdesk Project built for all to make a full Ticketing Support System along with many more other features.
Stars: ✭ 540 (+639.73%)
Mutual labels:  workflows
River Admin
🚀 A shiny admin interface for django-river built with DRF, Vue & Vuetify
Stars: ✭ 55 (-24.66%)
Mutual labels:  workflows
Cancel Workflow Action
⏹️ GitHub Action to cancel previous running workflows on push
Stars: ✭ 383 (+424.66%)
Mutual labels:  workflows
Openproject
OpenProject is the leading open source project management software.
Stars: ✭ 5,337 (+7210.96%)
Mutual labels:  workflows
Corewf
WF runtime ported to work on .NET 5
Stars: ✭ 757 (+936.99%)
Mutual labels:  workflows
modules
Repository to host tool-specific module files for the Nextflow DSL2 community!
Stars: ✭ 94 (+28.77%)
Mutual labels:  workflows
Maestrowf
A tool to easily orchestrate general computational workflows both locally and on supercomputers
Stars: ✭ 72 (-1.37%)
Mutual labels:  workflows
Cadence
Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.
Stars: ✭ 5,522 (+7464.38%)
Mutual labels:  workflows
Whyliam.workflows.youdao
使用有道翻译你想知道的单词和语句
Stars: ✭ 837 (+1046.58%)
Mutual labels:  workflows
Odin
A programmable, observable and distributed job orchestration system.
Stars: ✭ 405 (+454.79%)
Mutual labels:  workflows
St2
StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, security responses, troubleshooting, deployments, and more. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html. Questions? https://…
Stars: ✭ 4,600 (+6201.37%)
Mutual labels:  workflows
Argo Events
Event-driven workflow automation framework
Stars: ✭ 821 (+1024.66%)
Mutual labels:  workflows
Actions
A collection of useful GitHub Actions
Stars: ✭ 383 (+424.66%)
Mutual labels:  workflows
Flyte
Flyte binds together the tools you use into easily defined, automated workflows
Stars: ✭ 67 (-8.22%)
Mutual labels:  workflows
Cadence Web
Web UI for visualizing workflows on Cadence
Stars: ✭ 261 (+257.53%)
Mutual labels:  workflows
Rain
Framework for large distributed pipelines
Stars: ✭ 645 (+783.56%)
Mutual labels:  workflows
Flux Core
core services for the Flux resource management framework
Stars: ✭ 73 (+0%)
Mutual labels:  workflows
Porcupine
Express parametrable, composable and portable data pipelines
Stars: ✭ 70 (-4.11%)
Mutual labels:  workflows
Gush
Fast and distributed workflow runner using ActiveJob and Redis
Stars: ✭ 894 (+1124.66%)
Mutual labels:  workflows

Ketrew: Keep Track of Experimental Workflows

Ketrew is:

  1. An OCaml library providing an EDSL API to define complex and convoluted workflows (interdependent steps/programs using a lot of data, with many parameter variations, running on different hosts with various schedulers).
  2. A client-server application to interact with these workflows. The engine at heart of the server takes care of orchestrating workflows, and keeps track of everything that succeeds, fails, or gets lost.

See also the documentation for various releases.

If you have any questions, you may submit an issue, or join the authors on the public “Slack” channel of the Hammer Lab: Slack Status

Build & Install

See the specific documentation on building and installing. TL;DR for OCaml hackers:

opam switch 4.03.0
opam install [postgresql] [tls] ketrew

Getting Started

Ketrew is very flexible and hence may seem difficult to understand and setup at first. Let's get a minimal setup ready and a workflow running on it.

Server-side Setup

This tutorial requires docker and docker-compose:

alias kdc='./tools/docker-compose/kdc.sh'
kdc config --services

Let's get a Ketrew server with a PostgreSQL database and a Coclobas scheduler talking to each other:

kdc up -d

Check that everything is running:

kdc ps

Check the Ketrew server status:

curl http://127.0.0.1:8123/hello || echo 'Not ready'

After a minute or two you can check that everything is setup by visiting the Ketrew UI: http://127.0.0.1:8123/gui?token=nekot:

At any moment you can take everything down with:

kdc down

Or use other inspection commands:

kdc --help

Client

We can now create a Ketrew client configuration, please choose a directory:

export KETREW_ROOT=$HOME/tmp/kclient-config/

and initialize Ketrew there:

ketrew init --configuration-path $KETREW_ROOT \
    --just-client http://127.0.0.1:8123/gui?token=nekot

The ketrew submit sub-command can create one-command workflows (uses the $KETREW_ROOT path):

ketrew submit \
     --wet-run --tag 1st-workflow --tag command-line \
     --daemonize /tmp/KT,'du -sh $HOME'

The job will appear on the WebUI and you can inspect/restart/kill it.

If you don't like Web UI's you can use the text-based UI:

$ ketrew interact
[ketrew]
    Main menu
    Press a single key:
    * [q]: Quit
    * [v]: Toggle verbose
    * [s]: Display current status
    * [l]: Loop displaying the status
    * [k]: Kill targets
    * [e]: The Target Explorer™

As you can see, just from the command line, you can use ketrew submit to launch daemonized tasks. To go further we need to use Ketrew's EDSL.

The EDSL: Defining Workflows

Overview

The EDSL is an OCaml library where functions are used to build a workflow data-structure. Ketrew.Client.submit_workflow is used to submit that datastructure to the engine.

A workflow is a graph of “workflow-nodes” (sometimes called “targets”).

There are three kinds of links (edges) between nodes:

  • depends_on: nodes that need to be ensured or satisfied before a node can start,
  • on_failure_activate: nodes that will be activated if the node fails, and
  • on_success_activate: nodes that will be activated only after a node succeeds.

See the Ketrew.EDSL.workflow_node function documentation for details. Any OCaml program can use the EDSL (script, compiled, or even inside the toplevel). See the documentation of the EDSL API (Ketrew.EDSL).

A Quick Taste

You can run these commands for example in utop (opam install utop).

Load the Ketrew library to build and submit workflows:

#use "topfind";;
#thread;;
#require "ketrew";;

Globally tell the Ketrew client to get its configuration from the file created above:

let () =
  Unix.putenv
    "KETREW_CONFIGURATION"
    (Sys.getenv "HOME" ^ "/tmp/kclient-config/configuration.ml");;

Submit an “empty” workflow-node to Ketrew (i.e. a node that does not do nor ensure anything):

let () =
  let open Ketrew.EDSL in
  workflow_node without_product
    ~name:"Mostly Empty Node"
  |> Ketrew.Client.submit_workflow;;

Submit a node mostly equivalent to the one submitted from the command-line (ketrew submit --daemonize ...):

let () =
  let open Ketrew.EDSL in
  workflow_node without_product
    ~name:"Equivalent to the Command Line one"
    ~make:(
      daemonize
        ~using:`Python_daemon
        ~host:Host.(parse "/tmp/KT")
        Program.(sh "du -sh $HOME")
    )
    ~tags:["not-1st-workflow"; "not-command-line"]
  |> Ketrew.Client.submit_workflow;;

Run a command, in a docker container scheduler by the Coclobas server (also setup by docker-compose above):

#require "coclobas.ketrew_backend";;

let () =
  let open Ketrew.EDSL in
  workflow_node without_product
    ~name:"Uses a docker image to run some commands"
    ~make:(
      (* We use a different “backend”: *)
      Coclobas_ketrew_backend.Plugin.local_docker_program
        ~tmp_dir:"/tmp/secotrec-local-shared-temp"
        ~base_url:"http://coclo:8082"
        ~image:"ubuntu"
        Program.(
          (* sh "sudo mkdir -m 777 -p /cloco-kube/playground" && *)
          sh "echo User" && sh "whoami" &&
          sh "echo Host" && sh "hostname" &&
          sh "echo Machine" && sh "uname -a" &&
          exec ["sleep"; "42"]
        )
    )
    ~tags:["using-coclobas"; "from-utop"]
  |> Ketrew.Client.submit_workflow;;

The Ketrew WebUI should look like this:

Bigger Example

The following script extends the previous examples with the capability to send emails upon the success or failure of your command.

#use "topfind"
#thread
#require "ketrew"

let run_command_with_daemonize ~cmd ~email =
  let module KEDSL = Ketrew.EDSL in
  (* Where to run stuff: *)
  let host = KEDSL.Host.tmp_on_localhost in
  (* A node that Ketrew will activate after cmd completes,
     on its success or failure. *)
  let email_target ~success =
    let msg_string = if success then "succeeded" else "failed" in
    let e_program =
      KEDSL.Program.shf "echo \"'%s' %s\" | mail -s \"Status update\" %s"
        cmd msg_string
        email
    in
    let e_process =
      KEDSL.daemonize ~using:`Python_daemon ~host e_program in
    KEDSL.workflow_node KEDSL.without_product
      ~name:("email result " ^ msg_string)
      ~make:e_process
  in
  (* The function `KEDSL.workflow_node` creates a node in the workflow graph.
     The value `KEDSL.without_product` means this node does not
     “produce” anything, it is like a `.PHONY` target in `make`. *)
  KEDSL.workflow_node KEDSL.without_product
    ~name:"daemonized command with email notification"
    ~make:(
      (* A “program” is a datastructure representing an “extended shell script”. *)
      let program = KEDSL.Program.sh cmd in
      KEDSL.daemonize ~host ~using:`Python_daemon program
    )
    ~edges:[
      KEDSL.on_success_activate (email_target true);
      KEDSL.on_failure_activate (email_target false);
    ]

let () =
  (* Grab the command line arguments. *)
  let cmd   = Sys.argv.(1) in
  let email = Sys.argv.(2) in
  (* Create the  workflow with the first argument of the command line: *)
  let workflow = run_command_with_daemonize ~cmd ~email in
  (* Then, `Client.submit_workflow` is the only function that “does”
     something, it submits the constructed workflow to the engine: *)
  Ketrew.Client.submit_workflow workflow

You can run this script from the shell with

export KETREW_CONFIGURATION=$HOME/kclient-config/configuration.ml
ocaml daemonize_workflow.ml 'du -sh $HOME' [email protected]

Checking in with the GUI, we'll have a few new nodes, here is an example of execution where the daemonized program does not know about the mail command:

Where to Go Next

From here:

  • To write workflows for Ketrew see:
  • To configure Ketrew use the configuration file documentation.
  • You may want to “extend” Ketrew with new ways of running “long-running" computations: see the documentation on plugins, and the examples in the library: like Ketrew.Lsf or in the tests: src/test/dummy_plugin.ml.
  • You may want to extend Ketrew, or preconfigure it, without configuration files or dynamically loaded libraries: just create your own comand-line app.
  • If you are using Ketrew in server mode, you may want to know about the commands that the server can understand as it listens on a Unix-pipe.
  • You may want to call out directly to the HTTP API (i.e. without ketrew as a client).
  • If you want to help or simply to understand Ketrew see the development documentation, and have a look at the modules like Ketrew.Engine.

License

It's Apache 2.0.

Badges

master Branch Build Status DOI

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].