nimblebox logo
Docs
v3.3.1b

nbox.jobs

nbox.Job and nbox.Serve are wrappers to the NBX-Jobs and NBX-Deploy APIs and contains staticmethods for convinience from the CLI.

  • datetime.now(timezone.utc) is incorrect, use this method.

Functions

iconfunctionupload_job_folder
[source]
(method:str,init_folder:str,name:str,id:str,trigger:bool,resource_cpu:str,resource_memory:str,resource_disk_size:str,resource_gpu:str,resource_gpu_count:str,resource_timeout:int,resource_max_retries:int,cron:str,workspace_id:str,init_kwargs:dict)
Parameters
  • method -

    The method to use, either "job" or "serving"

  • init_folder -

    folder with all the relevant files or file_path:fn_name pair so you can use it as the entrypoint.

  • name -

    Name of the job. Defaults to "".

  • id -

    ID of the job. Defaults to "".

  • trigger -

    If uploading a "job" trigger the job after uploading. Defaults to False.

  • resource_cpu -

    CPU resource. Defaults to "100m".

  • resource_memory -

    Memory resource. Defaults to "128Mi".

  • resource_disk_size -

    Disk size resource. Defaults to "3Gi".

  • resource_gpu -

    GPU resource. Defaults to "none".

  • resource_gpu_count -

    GPU count resource. Defaults to "0".

  • resource_timeout -

    Timeout resource. Defaults to 120_000.

  • resource_max_retries -

    Max retries resource. Defaults to 2.

  • cron -

    Cron string for scheduling. Defaults to "".

  • workspace_id -

    Workspace ID, if None uses the one from config. Defaults to "".

  • init_kwargs -

    kwargs to pass to the init function / class, if possible

Upload the code for a job or serving to the NBX.

Engineer's Note

This function is supposed to be exposed via CLI, you can of course make a programtic call to this as well. This is a reason why this function can keep on taking many arguments. However with greatm number of arguments comes great responsibility, ie. lots of if/else conditions. Broadly speaking this should manage all the complexity and pass along simple reduced intstructions to the underlying methods. Currently the arguments that are required in Jinja templates are packed as exe_jinja_kwargs and we call the deploy_job and deploy_serving.

iconfunction_get_deployment_data
[source]
(name:str,id:str)
Parameters
  • name -

    Name of the deployment. Defaults to "".

  • id -

    ID of the deployment. Defaults to "".

Get the deployment data, either by name or id

Returns:

  • Tuple[str, str]: (id, name)
iconfunctionprint_serving_list
[source]
(sort:str)
Parameters
  • sort -

    Sort by. Defaults to "created_on".

Print the list of deployments

iconfunction_get_job_data
[source]
(name:str,id:str,remove_archived:bool)
Parameters
  • name -

    Job name. Defaults to "".

  • id -

    Job ID. Defaults to "".

  • remove_archived -

    If True, will remove archived jobs. Defaults to True.

Returns the job id and name

Returns:

  • Tuple[str, str]: Job ID, Job Name
iconfunctionget_job_list
[source]
(sort:str)
Parameters
  • sort -

    Sort key. Defaults to "name".

Get list of jobs

Classes

iconclassSchedule
[source]
iconfunction__init__
[source]
(hour:int,minute:int,days:str/list,months:str/list,starts:datetime,ends:datetime)
Parameters
  • hour -

    Hour of the day, if only this value is passed it will run every hour

  • minute -

    Minute of the hour, if only this value is passed it will run every minute

  • days -

    List of days (first three chars) of the week, if not passed it will run every day.

  • months -

    List of months (first three chars) of the year, if not passed it will run every month.

  • starts -

    UTC Start time of the schedule, if not passed it will start now.

  • ends -

    UTC End time of the schedule, if not passed it will end in 7 days.

Make scheduling natural. Uses 24-hour nomenclature.

Example:

Python
Loading...
iconfunctioncron
[source]

Get the cron string for the given schedule

iconfunctionget_dict
[source]

Get the dictionary representation of this Schedule

iconfunctionget_message
[source]

Get the JobProto.Schedule object for this Schedule

iconfunction__repr__
[source]
iconclassServe
[source]
iconfunction__init__
[source]
(serving_id:str,model_id:str)
Parameters
  • serving_id -

    Serving ID. Defaults to None.

  • model_id -

    Model ID. Defaults to None.

Python wrapper for NBX-Serving gRPC API

iconfunctionpin
[source]
(model_id:str,workspace_id:str)
Parameters
  • model_id -

    Model ID. Defaults to None.

  • workspace_id -

    Workspace ID. Defaults to "".

Pin a model to the deployment

iconfunctionunpin
[source]
(model_id:str,workspace_id:str)
Parameters
  • model_id -

    Model ID. Defaults to None.

  • workspace_id -

    Workspace ID. Defaults to "".

Pin a model to the deployment

iconfunctionscale
[source]
(replicas:int)
Parameters
  • replicas -

    Number of replicas

Scale the model deployment

iconfunctionlogs
[source]
(f:file)
Parameters
  • f -

    File to write the logs to. Defaults to sys.stdout.

Get the logs of the model deployment

iconfunction__repr__
[source]
iconclassJob
[source]
iconfunction__init__
[source]
(job_name:str,job_id:str)
Parameters
  • job_name -

    Job name. Defaults to "".

  • job_id -

    Job ID. Defaults to "".

Python wrapper for NBX-Jobs gRPC API, when both arguments are not passed, an unintialiased object is created.

iconfunctionexists
[source]

Check if this job exists in the workspace

iconfunctionnew
[source]
(job_name:str,description:str)
Parameters
  • job_name -

    Job name

  • description -

    Job description. Defaults to "".

Create a new job

Returns:

  • Job: Job object
iconfunctionchange_schedule
[source]
(new_schedule:Schedule)
Parameters
  • new_schedule -

    New schedule

Change schedule this job

iconfunction__repr__
[source]
iconfunctionlogs
[source]

Stream logs of the job, f can be anything has a .write/.flush methods

iconfunctiondelete
[source]

Delete this job

iconfunctionrefresh
[source]

Refresh Job data

iconfunctiontrigger
[source]
(tag:str)
Parameters
  • tag -

    Tag to be set in the run metadata, read in more detail before trying to use this. Defaults to "".

Manually triger this job.

iconfunctionpause
[source]

Pause the execution of this job. WARNING: This will "cancel" all the scheduled runs, if present

iconfunctionresume
[source]

Resume the Job with the current schedule, if provided else simlpy sets status as ACTIVE

iconfunction_get_runs
[source]
iconfunctionget_runs
[source]
(page:int,sort:str,limit:int)
Parameters
  • page -

    Page number. Defaults to -1.

  • sort -

    Sort by. Defaults to "s_no".

  • limit -

    Number of runs to return. Defaults to 10.

Get runs for this job

Returns:

  • List[Dict]: List of runs
iconfunctiondisplay_runs
[source]
(sort:str,page:int,limit:int)
Parameters
  • sort -

    Sort by. Defaults to "created_at".

  • page -

    Page number. Defaults to -1.

  • limit -

    Number of runs to return. Defaults to 10.

Display runs for this job

iconfunctionlast_n_runs
[source]
(n:int)
Parameters
  • n -

    Number of runs to return. Defaults to 10.

Get last n runs for this job

Returns:

  • List[Dict]: List of runs
nbox SDKnbox provides built in access to all the APIs and packages them in the most user friendly manner.Star 0