Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prototype] RESTful API for core #2735

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft

[Prototype] RESTful API for core #2735

wants to merge 47 commits into from

Conversation

Michaelvll
Copy link
Collaborator

@Michaelvll Michaelvll commented Oct 25, 2023

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 https://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 https://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 https://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 https://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 https://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
    • Stream logs
    • Fix the spinner for launching (rich.status)
  • Restful APIs
    • launch
      • Basic support without file mounts
      • 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

sky/api/rest.py Outdated
"""Periodically refresh the cluster status."""
background_tasks = fastapi.BackgroundTasks()
while True:
background_tasks.add_task(core.status, refresh=True)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pingsutw
Copy link

@Michaelvll Any ETA on this? We're interested in the Async launch.

@Michaelvll Michaelvll force-pushed the restapi branch 2 times, most recently from 57260e2 to 987ae3b Compare August 23, 2024 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants