public final class ModelInfo
extends java.lang.Object
implements java.lang.AutoCloseable
Constructor and Description |
---|
ModelInfo(java.lang.String modelName,
java.lang.String version,
java.lang.String modelUrl,
ai.djl.repository.zoo.ZooModel<ai.djl.modality.Input,ai.djl.modality.Output> model,
int queueSize,
int maxIdleTime,
int maxBatchDelay,
int batchSize)
Constructs a new
ModelInfo instance. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
ModelInfo |
configureModelBatch(int batchSize,
int maxBatchDelay)
Sets a new batchSize and returns a new configured ModelInfo object.
|
ModelInfo |
configurePool(int maxIdleTime)
Sets new configuration for the workerPool backing this model and returns a new configured
ModelInfo object.
|
boolean |
equals(java.lang.Object o) |
int |
getBatchSize()
Returns the configured batch size.
|
int |
getMaxBatchDelay()
Returns the maximum delay in milliseconds to aggregate a batch.
|
int |
getMaxIdleTime()
returns the configured maxIdleTime of workers.
|
int |
getMaxWorkers()
Returns the configured maximum number of workers.
|
int |
getMinWorkers()
Returns the configured minimum number of workers.
|
ai.djl.repository.zoo.ZooModel<ai.djl.modality.Input,ai.djl.modality.Output> |
getModel()
Returns the loaded
ZooModel . |
java.nio.file.Path |
getModelDir()
Returns the model cache directory.
|
java.lang.String |
getModelName()
Returns the model name.
|
java.lang.String |
getModelUrl()
Returns the model url.
|
int |
getQueueSize()
Returns the configured size of the workers queue.
|
java.lang.String |
getVersion()
Returns the model version.
|
int |
hashCode() |
static java.lang.String |
inferModelNameFromUrl(java.lang.String url)
Infer model name form model URL in case model name is not provided.
|
ModelInfo |
scaleWorkers(int minWorkers,
int maxWorkers)
Sets new workers capcities for this model and returns a new configured ModelInfo object.
|
java.lang.String |
toString() |
public ModelInfo(java.lang.String modelName, java.lang.String version, java.lang.String modelUrl, ai.djl.repository.zoo.ZooModel<ai.djl.modality.Input,ai.djl.modality.Output> model, int queueSize, int maxIdleTime, int maxBatchDelay, int batchSize)
ModelInfo
instance.modelName
- the name of the model that will be used as HTTP endpointversion
- the version of the modelmodelUrl
- the model urlmodel
- the ZooModel
queueSize
- the maximum request queue sizemaxIdleTime
- the initial maximum idle time for workers.maxBatchDelay
- the initial maximum delay when scaling up before giving up.batchSize
- the batch size for this model.public ModelInfo configureModelBatch(int batchSize, int maxBatchDelay)
ModelManager
using this new model.batchSize
- the batchSize to setmaxBatchDelay
- maximum time to wait for a free space in worker queue after scaling up
workers before giving up to offer the job to the queue.public ModelInfo scaleWorkers(int minWorkers, int maxWorkers)
ModelManager
using this new model.minWorkers
- minimum amount of workers.maxWorkers
- maximum amount of workers.public ModelInfo configurePool(int maxIdleTime)
ModelManager
using this new
model.maxIdleTime
- time a WorkerThread can be idle before scaling down this worker.public ai.djl.repository.zoo.ZooModel<ai.djl.modality.Input,ai.djl.modality.Output> getModel()
ZooModel
.ZooModel
public java.lang.String getModelName()
public java.lang.String getVersion()
public java.lang.String getModelUrl()
public java.nio.file.Path getModelDir()
public int getMaxIdleTime()
public int getMinWorkers()
public int getMaxWorkers()
public int getBatchSize()
public int getMaxBatchDelay()
public int getQueueSize()
public void close()
close
in interface java.lang.AutoCloseable
public static java.lang.String inferModelNameFromUrl(java.lang.String url)
url
- the model URLpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object