11import os
22import sys
33import ast
4- import json
54import shlex
65import zipfile
7- from pprint import pformat
86from subprocess import Popen
97from typing import Tuple , Dict
108
11- from google .protobuf import field_mask_pb2
12-
13- from nbox .utils import logger
149from 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
1812from nbox .relics import Relics
13+ from nbox import messages as mpb
14+ from nbox .init import nbox_ws_v1
1915from 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+
2217from 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
2526def _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
7467class 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 } " )
0 commit comments