Skip to content

Commit df24f9e

Browse files
committed
0.13.0rc9
1 parent dc42587 commit df24f9e

File tree

8 files changed

+86
-1053
lines changed

8 files changed

+86
-1053
lines changed

nbox/jobs.py

-1,018
Large diffs are not rendered by default.

nbox/lib/dist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from nbox.hyperloop.jobs.job_pb2 import Job
1818
from nbox.nbxlib.serving import serve_operator
1919

20-
from nbox.lmao import ExperimentConfig, LiveConfig, LMAO_RM_PREFIX, LMAO_SERVING_FILE
20+
from nbox.lmao_v4 import ExperimentConfig, LMAO_RM_PREFIX
2121
from nbox.projects import Project, ProjectState
2222

2323
# Manager

nbox/lmao_v4/common.py

+6
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ def to_dict(self):
173173
"save_to_relic": self.save_to_relic,
174174
"enable_system_monitoring": self.enable_system_monitoring,
175175
}
176+
177+
@classmethod
178+
def from_dict(cls, data):
179+
if not isinstance(data, Resource):
180+
data["resource"] = resource_from_dict(data["resource"])
181+
return cls(**data)
176182

177183
def to_json(self):
178184
return json.dumps(self.to_dict())

nbox/nbxlib/serving.py

+39-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,45 @@ async def who_are_you():
108108

109109
# print all the endpoints
110110
logger.info(lo("Here are all the endpoints:\n", "\n".join([f" {route.path}" for route in app.routes])))
111-
uvicorn.run(app, host = host, port = port)
111+
112+
# run the server with uvicorn and
113+
uvicorn.run(
114+
app,
115+
host = host,
116+
port = port,
117+
log_config = {
118+
"version": 1,
119+
"disable_existing_loggers": False,
120+
"formatters": {
121+
"default": {
122+
"()": "uvicorn.logging.DefaultFormatter",
123+
"fmt": "%(levelprefix)s %(message)s",
124+
"use_colors": None,
125+
},
126+
"access": {
127+
"()": "uvicorn.logging.AccessFormatter",
128+
"fmt": '%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s', # noqa: E501
129+
},
130+
},
131+
"handlers": {
132+
"default": {
133+
"formatter": "default",
134+
"class": "logging.StreamHandler",
135+
"stream": "ext://sys.stderr",
136+
},
137+
"access": {
138+
"formatter": "access",
139+
"class": "logging.StreamHandler",
140+
"stream": "ext://sys.stdout",
141+
},
142+
},
143+
"loggers": {
144+
"uvicorn": {"handlers": ["default"], "level": "INFO"},
145+
"uvicorn.error": {"level": "INFO"},
146+
"uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": False},
147+
},
148+
}
149+
)
112150

113151

114152
def get_fastapi_routes(op: Operator):

nbox/network.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -364,20 +364,18 @@ def _upload_job_zip(zip_path: str, job_proto: JobProto, workspace_id: str):
364364
auth_info = auth_info_pb()
365365
if new_job:
366366
logger.info("Creating a new job")
367-
mpb.rpc(
368-
stub = nbox_grpc_stub.CreateJob,
369-
message = JobRequest(job = job_proto, auth_info = auth_info),
370-
err_msg = "Failed to create job"
371-
)
367+
nbox_grpc_stub.CreateJob(JobRequest(
368+
job = job_proto,
369+
auth_info = auth_info
370+
))
372371

373372
if not old_job_proto.feature_gates:
374373
logger.info("Updating feature gates")
375-
mpb.rpc(
376-
stub = nbox_grpc_stub.UpdateJob,
377-
message = UpdateJobRequest(job = job_proto, update_mask = FieldMask(paths = ["feature_gates"]), auth_info = auth_info),
378-
err_msg = "Failed to update job",
379-
raise_on_error = False
380-
)
374+
nbox_grpc_stub.UpdateJob(UpdateJobRequest(
375+
job = job_proto,
376+
update_mask = FieldMask(paths = ["feature_gates"]),
377+
auth_info = auth_info
378+
))
381379

382380
# write out all the commands for this job
383381
# logger.info("Run is now created, to 'trigger' programatically, use the following commands:")

nbox/projects.py

+29-20
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import os
22
import sys
33
import ast
4-
import json
54
import shlex
65
import zipfile
7-
from pprint import pformat
86
from subprocess import Popen
97
from typing import Tuple, Dict
108

11-
from google.protobuf import field_mask_pb2
12-
13-
from nbox.utils import logger
149
from nbox import utils as U
15-
from nbox.auth import secret, AuthConfig, auth_info_pb
16-
from nbox.init import nbox_ws_v1, nbox_model_service_stub
17-
from nbox import messages as mpb
10+
from nbox.auth import secret
11+
from nbox.utils import logger
1812
from nbox.relics import Relics
13+
from nbox import messages as mpb
14+
from nbox.init import nbox_ws_v1
1915
from nbox.jd_core import Job, Serve, upload_job_folder
20-
from nbox.hyperloop.deploy import serve_pb2
21-
from nbox.hyperloop.common.common_pb2 import Resource
16+
2217
from nbox.nbxlib.astea import Astea
2318

19+
from nbox.hyperloop.common.common_pb2 import Resource
20+
from nbox.lmao_v4 import get_lmao_stub, get_git_details, LMAO_RM_PREFIX, ExperimentConfig, Tracker
21+
from nbox.lmao_v4.proto.lmao_service_pb2_grpc import LMAOStub
22+
from nbox.lmao_v4.proto import tracker_pb2 as t_pb
23+
from nbox.lmao_v4.proto import project_pb2 as p_pb
24+
2425

2526
def _parse_job_code(init_path: str, run_kwargs) -> Tuple[str, Dict]:
2627
# analyse the input file and function, extract the types and build the run_kwargs
@@ -59,17 +60,9 @@ def _parse_job_code(init_path: str, run_kwargs) -> Tuple[str, Dict]:
5960

6061
### ---------------
6162
# this will be eventually merged with the project in the root scope
62-
from nbox.init import nbox_ws_v1
63-
from nbox.utils import logger
64-
from nbox.auth import secret
65-
from nbox.relics import Relics
66-
from nbox import messages as mpb
6763

68-
from nbox.lmao_v4 import get_lmao_stub, get_git_details, LMAO_RM_PREFIX, ExperimentConfig, Tracker
69-
from nbox.lmao_v4.proto.lmao_service_pb2_grpc import LMAOStub
70-
from nbox.lmao_v4.proto import tracker_pb2 as t_pb
71-
from nbox.lmao_v4.proto import project_pb2 as p_pb
7264

65+
_SUPPORTED_SERVER_TYPES = ["fastapi"]
7366

7467
class ProjectState:
7568
project_id: str = ""
@@ -305,7 +298,7 @@ def run(
305298
upload_job_folder(
306299
method = "job",
307300
init_folder = init_path,
308-
id = job.id,
301+
project_id = self.project_pb.id,
309302

310303
# pass along the resource requirements
311304
resource_cpu = resource_cpu,
@@ -325,3 +318,19 @@ def run(
325318
# finally print the location of the run where the users can track this
326319
logger.info(f"Run location: {secret.nbx_url}/workspace/{secret.workspace_id}/projects/{self.project_pb.id}#Experiments")
327320

321+
def serve(
322+
self,
323+
init_path: str,
324+
server_type: str = "fastapi",
325+
326+
# all the things for resources
327+
resource_cpu: str = "",
328+
resource_memory: str = "",
329+
resource_disk_size: str = "",
330+
resource_gpu: str = "",
331+
resource_gpu_count: str = "",
332+
resource_max_retries: int = 0,
333+
):
334+
raise NotImplementedError("This is not implemented yet")
335+
if server_type not in _SUPPORTED_SERVER_TYPES:
336+
raise ValueError(f"server_type must be one of {_SUPPORTED_SERVER_TYPES}")

nbox/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.13.0c7"
1+
__version__ = "0.13.0c9"
22
_major, _minor, _patch = __version__.split(".")
33
_major = int(_major)
44
_minor = int(_minor)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nbox"
3-
version = "0.13.0c7"
3+
version = "0.13.0c9"
44
description = "ML Inference 🥶"
55
authors = [
66
"NBX Research <research@nimblebox.ai>",

0 commit comments

Comments
 (0)