Spaces:
Build error
Build error
Dmitry Trifonov commited on
Commit ·
96fce2c
1
Parent(s): 411fbd1
update to follow the new Fair API
Browse files
fair.py
CHANGED
|
@@ -63,9 +63,9 @@ class FairApiClient:
|
|
| 63 |
def put_job(self, image: str, command: List[str], ports: List[tuple[int, int]], input_files, output_files):
|
| 64 |
url = f"{self.server_address}/jobs"
|
| 65 |
data = {
|
| 66 |
-
'
|
| 67 |
'container_desc': {
|
| 68 |
-
'type': '
|
| 69 |
'image': image,
|
| 70 |
'runtime': 'nvidia',
|
| 71 |
'ports': [[{"port": host_port, "ip": 'null'}, {"port": container_port, "protocol": "Tcp"}] for (host_port, container_port) in ports],
|
|
@@ -75,9 +75,9 @@ class FairApiClient:
|
|
| 75 |
'output_files': output_files,
|
| 76 |
'target_node': TARGET_NODE,
|
| 77 |
}
|
| 78 |
-
response = self.put(url=url, data=data)
|
| 79 |
|
| 80 |
-
return
|
| 81 |
|
| 82 |
def get_job_status(self, job_id):
|
| 83 |
url = f"{self.server_address}/jobs/{job_id}/status"
|
|
@@ -163,14 +163,14 @@ def start_server():
|
|
| 163 |
client = FairApiClient(SERVER_ADDRESS)
|
| 164 |
client.authenticate(email=email, password=password)
|
| 165 |
|
| 166 |
-
job_id = client.put_job(
|
| 167 |
image=DOCKER_IMAGE,
|
| 168 |
command=[],
|
| 169 |
ports=[(5000, 8080)],
|
| 170 |
input_files=[],
|
| 171 |
output_files=[])
|
| 172 |
|
| 173 |
-
logger.info(job_id)
|
| 174 |
|
| 175 |
status = client.get_job_status(job_id=job_id)
|
| 176 |
logger.info(status)
|
|
|
|
| 63 |
def put_job(self, image: str, command: List[str], ports: List[tuple[int, int]], input_files, output_files):
|
| 64 |
url = f"{self.server_address}/jobs"
|
| 65 |
data = {
|
| 66 |
+
'version': 'V018',
|
| 67 |
'container_desc': {
|
| 68 |
+
'type': 'V018',
|
| 69 |
'image': image,
|
| 70 |
'runtime': 'nvidia',
|
| 71 |
'ports': [[{"port": host_port, "ip": 'null'}, {"port": container_port, "protocol": "Tcp"}] for (host_port, container_port) in ports],
|
|
|
|
| 75 |
'output_files': output_files,
|
| 76 |
'target_node': TARGET_NODE,
|
| 77 |
}
|
| 78 |
+
response = self.put(url=url, data=data).json()
|
| 79 |
|
| 80 |
+
return response['id'], response['pid']
|
| 81 |
|
| 82 |
def get_job_status(self, job_id):
|
| 83 |
url = f"{self.server_address}/jobs/{job_id}/status"
|
|
|
|
| 163 |
client = FairApiClient(SERVER_ADDRESS)
|
| 164 |
client.authenticate(email=email, password=password)
|
| 165 |
|
| 166 |
+
job_id, job_pid = client.put_job(
|
| 167 |
image=DOCKER_IMAGE,
|
| 168 |
command=[],
|
| 169 |
ports=[(5000, 8080)],
|
| 170 |
input_files=[],
|
| 171 |
output_files=[])
|
| 172 |
|
| 173 |
+
logger.info(f"Job id: {job_id}, pid: {job_pid}")
|
| 174 |
|
| 175 |
status = client.get_job_status(job_id=job_id)
|
| 176 |
logger.info(status)
|