Skip to content

GPU status endpoints #16

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

Open
wants to merge 19 commits into
base: gpu_cluster_grows_up
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gpu_cluster/controllers/container_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def launch_container(self, c_id):
'''
STATUS QUERIERS
'''

def verify_launch(self, c_id):
instance = db_session.query(Instance).filter_by(cid = c_id).first()
return True if instance.launched == True else False
Expand Down
15 changes: 13 additions & 2 deletions gpu_cluster/routes/cluster_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from ..database import db_session
from ..models import Instance
from flask import Flask, jsonify, request, abort
from nvdocker import NVDockerClient
import socket

class ClusterAPI():
def __init__(self, controller):
Expand All @@ -29,11 +31,20 @@ def confirm_launch(self):

if launched == False:
return jsonify({"error" : "non-existant container"})
return jsonify({"verified" : "confirmed"})

return jsonify({"verified" : "confirmed"})
def kill_container(self):
pass

def status(self):
Copy link
Member

Choose a reason for hiding this comment

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

You need to and an api rule in register routes for flask to see it

hostname = socket.gethostname()
available_gpu = NVDockerClient.least_used_gpu()
response = {
"hostname" : hostname,
"gpu" : available_gpu
}
return jsonify(response)

def register_routes(self, app):
app.add_url_rule('/create_container', 'create_container', self.create_container, methods=['POST'])
app.add_url_rule('/confirm', 'confirm', self.confirm_launch, methods=['POST'])
Expand Down