Skip to content

Commit

Permalink
Merge pull request #174 from openvinotoolkit/improve-error-handling-f…
Browse files Browse the repository at this point in the history
…or-ovms-deployment

Improve error handling for OVMS deployment
  • Loading branch information
ljcornel authored Mar 27, 2023
2 parents 6b8dfef + b8b212f commit c3de022
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion geti_sdk/deployment/deployed_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import shutil
import sys
import tempfile
import time
import zipfile
from typing import Any, Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -49,6 +50,8 @@
LABEL_GROUPS_KEY = "label_groups"
ALL_LABELS_KEY = "all_labels"

OVMS_TIMEOUT = 10 # Max time to wait for OVMS models to become available


@attr.define
class DeployedModel(OptimizedModel):
Expand Down Expand Up @@ -229,7 +232,16 @@ def load_inference_model(
model_address = generate_ovms_model_address(
ovms_address=device, model_name=model_name
)
model_adapter = OVMSAdapter(model_address)

ovms_connected = False
t_start = time.time()
while not ovms_connected and time.time() - t_start < OVMS_TIMEOUT:
# If OVMS has just started, model needs some time to initialize
try:
model_adapter = OVMSAdapter(model_address)
ovms_connected = True
except RuntimeError:
time.sleep(0.5)

# Load model configuration
config_path = os.path.join(self._model_data_path, "config.json")
Expand Down

0 comments on commit c3de022

Please sign in to comment.