skypilot icon indicating copy to clipboard operation
skypilot copied to clipboard

[Prototype] RESTful API for core

Open Michaelvll opened this issue 9 months ago • 1 comments

This is a prototype for client-server architecture.

Architecture

We now refactors the interface to 3 categories:

  1. Restful API
  2. SDK
  3. CLI image

Features

This is a list of features added (to be updated)

  1. API server CLI (it can be started automatically): sky api start; sky api stop; sky api logs
  2. sky status (through HTTP request)
  3. Automatic cluster status update periodically
  4. Async launch
$ curl -i -X POST http://127.0.0.1:8000/launch \
     -H "Content-Type: application/json" \
     -d '{"task": "resources:\n  cloud: aws\n  cpus: 2", "cluster_name": "test-10"}'

...
x-request-id: 7f6f0287-2448-42b8-bb0a-b9592b51eb1c
  1. Show all requests
$ curl -i -X GET http://127.0.0.1:8000/requests

[{"request_id":"7f6f0287-2448-42b8-bb0a-b9592b51eb1c","request_name":"launch","status":"RUNNING","return_value":null,"log_path":null,"pid":53345}]%  
  1. Wait for request and get the result
curl -i -X GET http://127.0.0.1:8000/get \
     -H "Content-Type: application/json" \                                         
     -d '{"request_id": "7f6f0287-2448-42b8-bb0a-b9592b51eb1c"}'
  1. Abort a request
curl -i -X POST http://127.0.0.1:8000/abort \
     -H "Content-Type: application/json" \
     -d '{"request_id": "7f6f0287-2448-42b8-bb0a-b9592b51eb1c"}'
  1. Stream the logs for a request
curl -i -X GET http://127.0.0.1:8000/stream \
     -H "Content-Type: application/json" \                                         
     -d '{"request_id": "7f6f0287-2448-42b8-bb0a-b9592b51eb1c"}'

TODOs

  • [ ] Stream logs for a request
    • [x] Stream logs
    • [ ] Fix the spinner for launching (rich.status)
  • [ ] Restful APIs
    • [ ] launch
      • [x] Basic support without file mounts
      • [x] Fix log tailing in sky launch
      • [ ] Design and support direct ssh
      • [ ] Support file mounts (automatically upload to the bucket and download to the VM)
  • [ ] Refine UX

Tested (run the relevant ones):

  • [ ] Code formatting: bash format.sh
  • [ ] Any manual or new tests for this PR (please specify below)
  • [ ] All smoke tests: pytest tests/test_smoke.py
  • [ ] Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • [ ] Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

Michaelvll avatar Oct 25 '23 09:10 Michaelvll