Service
  • Print
  • Share
  • Dark
    Light

Service

  • Print
  • Share
  • Dark
    Light

Services

A Service is a running deployment of Modules within a Package.
You must have a bot in order to deploy and run a service. For more information go to bots.
A Service entity specifies from which Module it should be deployed, what arguments should be passed to the Module's exported class' init method, and the infrastructural configuration for it, such as the number of replicas and the CPU/memory requirements per replica.

Replica is the number of machines that run at the same time.

Once the service is ready, one may execute any available function on any input.
Note that multiple services can be deployed from the same module.
service.jpg

The "init" Method

The "init" method is a unique method in the exported class that you can use if needed.
It is used for uploading heavy pre-processing or models on a service level, so you wont need to upload it on every execution.

This method is invoked immediately after loading the Module and it is used for initializing the replica of the Service.
For example, for an image bounding box classifier, the "init" method will download the model and load it to its memory.
All subsequent invocations of a function in the Service will use the loaded model to calculate the bounding box for the image.
The schema for the inputs of the "init" method of the Module is defined in the "initInputs" field of the Module.
The actual value passed to the "init" method at loading time will be taken from the "initParams" field of the service.
init_input.jpg

Status

Service can be active and inactive (paused). When a service is active it means that there are running replicas for the service or there is an autoscaler that will automatically create replicas when executions are created for the service. To change service status, please follow these instructions.

Versioning

A deployed service gets a version that represents its state. Every time you update a service it will bump its version and its previous state will be saved in the service revision. Later on, you can re-deploy the service with an earlier revision. To view the service revisions run:

service.revisions

Service JSON

{
  "name": "service-name",           # service name
  "packageName": "default_package", # package name
  "packageRevision": "latest",      # what package version to run?
  "runtime": {
    "gpu": false,                   # Does the service require a GPU?
    "replicas": 1,                  # How many replicas should the service create
    "concurrency": 6,               # How many executions can run simultaneously?
    "runnerImage": ""               # You can provide your own docker image for                                                                         the service to run on.
  },
    "triggers": [],                 # List of triggers to trigger service
    "initParams": {},               # Does your init method expects input if it                                                                              does provide it here.
    "moduleName": "default_module"  # Which module to deploy?
}

Advanced Information on Services can be found in the Advanced Guides Section.

Was This Article Helpful?