pepkit / looper

A job submitter for Portable Encapsulated Projects
http://looper.databio.org
BSD 2-Clause "Simplified" License
20 stars 7 forks source link

An HTTP API for the `looper run` command that works with the `pydantic`-based command models #441

Closed zz1874 closed 7 months ago

zz1874 commented 8 months ago

[!WARNING] Currently based on #440. Once that is merged, we'll make a new branch, feature-http-api, that will be based on the then updated dev branch and target feature-http-api with this PR. So don't merge just quite yet :slightly_smiling_face:

This PR introduces a first version of an HTTP API to execute looper commands (#433).

Changes made:

Endpoints

Usage:

Run the app:

looper-serve [--host <host IP address>] [--port <port>]

[!NOTE] This assumes that all files specified in the arguments are available on the file system of the machine that is running the HTTP API server. Best make sure you use absolute file paths in all looper YAML configuration files.

To test this, you can clone the hello_looper repository and then run (for example) the following in a second terminal:

curl -X POST -H "Content-Type: application/json" -d '{"run": {"time_delay": 5}, "looper_config": "/path/to/hello_looper/.looper.yaml"}' "http://127.0.0.1:8000"

This will return a six-letter job ID, say abc123. Then get the result / output of the run with

curl -X GET -v localhost:8000/status/abc123

For better visualization / readability, you can post-process the output by piping it to jq (| jq -r .console_output).

nsheff commented 8 months ago

can you put the usage information into a readme?

simeoncarstens commented 7 months ago

Done :slightly_smiling_face: