Skip to content

Commit c161926

Browse files
udaij12agunapal
andauthored
fix for snapshot variables missing/null (#3328)
* testing adding startup * testing adding default * testing newer docker * adding default values for model * testing specific docker * testing specific docker image * fixed format * merge ready * adding source of truth * adding source of truth * fixing tests * format * removing defaults --------- Co-authored-by: Ankith Gunapal <[email protected]>
1 parent 6881ec5 commit c161926

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

frontend/archive/src/main/java/org/pytorch/serve/archive/model/ModelConfig.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
public 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.

frontend/server/src/main/java/org/pytorch/serve/wlm/Model.java

+10-2
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)