This repository was archived by the owner on Aug 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
archive/src/main/java/org/pytorch/serve/archive/model
server/src/main/java/org/pytorch/serve/wlm Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1111public class ModelConfig {
1212 private static final Logger logger = LoggerFactory .getLogger (ModelConfig .class );
1313
14+ public static final int defaultStartupTimeout = 120 ; // unit: sec
15+ public static final int defaultResponseTimeout = 120 ; // unit: sec
16+
1417 /** the minimum number of workers of a model */
1518 private int minWorkers ;
1619 /** the maximum number of workers of a model */
@@ -20,9 +23,9 @@ public class ModelConfig {
2023 /** the maximum delay in msec of a batch of a model */
2124 private int maxBatchDelay ;
2225 /** the timeout in sec of a specific model's response. */
23- private int responseTimeout = 120 ; // unit: sec
26+ private int responseTimeout = defaultResponseTimeout ;
2427 /** the timeout in sec of a specific model's startup. */
25- private int startupTimeout = 120 ; // unit: sec
28+ private int startupTimeout = defaultStartupTimeout ;
2629 /**
2730 * the device type where the model is loaded. It can be gpu, cpu. The model is loaded on CPU if
2831 * deviceType: "cpu" is set on a GPU host.
Original file line number Diff line number Diff line change @@ -193,9 +193,17 @@ public void setModelState(JsonObject modelInfo) {
193193 minWorkers = modelInfo .get (MIN_WORKERS ).getAsInt ();
194194 maxWorkers = modelInfo .get (MAX_WORKERS ).getAsInt ();
195195 maxBatchDelay = modelInfo .get (MAX_BATCH_DELAY ).getAsInt ();
196- responseTimeout = modelInfo .get (RESPONSE_TIMEOUT ).getAsInt ();
197- startupTimeout = modelInfo .get (STARTUP_TIMEOUT ).getAsInt ();
198196 batchSize = modelInfo .get (BATCH_SIZE ).getAsInt ();
197+ responseTimeout =
198+ modelInfo .has (RESPONSE_TIMEOUT ) && !modelInfo .get (RESPONSE_TIMEOUT ).isJsonNull ()
199+ ? modelInfo .get (RESPONSE_TIMEOUT ).getAsInt ()
200+ : modelArchive .getModelConfig ()
201+ .defaultResponseTimeout ; // default value for responseTimeout
202+ startupTimeout =
203+ modelInfo .has (STARTUP_TIMEOUT ) && !modelInfo .get (STARTUP_TIMEOUT ).isJsonNull ()
204+ ? modelInfo .get (STARTUP_TIMEOUT ).getAsInt ()
205+ : modelArchive .getModelConfig ()
206+ .defaultStartupTimeout ; // default value for startupTimeout
199207
200208 JsonElement runtime = modelInfo .get (RUNTIME_TYPE );
201209 String runtime_str = Manifest .RuntimeType .PYTHON .getValue ();
You can’t perform that action at this time.
0 commit comments