Skip to content

Commit

Permalink
Minor Fixed for Local testing (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
luv-bansal authored Dec 19, 2024
1 parent 76b0c04 commit 2be4814
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 1 addition & 13 deletions clarifai/runners/models/model_run_locally.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import time
import traceback
import venv
import psutil

from clarifai_grpc.grpc.api import resources_pb2, service_pb2
from clarifai_grpc.grpc.api.status import status_code_pb2, status_pb2
Expand Down Expand Up @@ -116,6 +115,7 @@ def _build_request(self):
text=resources_pb2.Text(raw="How many people live in new york?"),
image=resources_pb2.Image(url="https://samples.clarifai.com/metro-north.jpg"),
audio=resources_pb2.Audio(url="https://samples.clarifai.com/GoodMorning.wav"),
video=resources_pb2.Video(url="https://samples.clarifai.com/beer.mp4"),
))
],
)
Expand Down Expand Up @@ -247,18 +247,6 @@ def test_model(self):
# Kill the process if it doesn't terminate after 5 seconds
process.kill()

# Terminate any child processes that may have been spawned by the main process
if process:
try:
parent = psutil.Process(process.pid)
# Get all child processes recursively
for child in parent.children(recursive=True):
child.kill()
except psutil.NoSuchProcess:
pass
except Exception as e:
logger.error(f"Error terminating child processes: {e}")

# run the model server
def run_model_server(self, port=8080):
"""Run the Clarifai Runners's model server."""
Expand Down
5 changes: 4 additions & 1 deletion clarifai/runners/models/model_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def get_model_version_proto(self):
labels = sorted(labels.items(), key=lambda x: int(x[0]))

config_file = os.path.join(self.folder, 'config.yaml')
self.hf_labels_to_config(labels, config_file)
try:
self.hf_labels_to_config(labels, config_file)
except Exception as e:
logger.error(f"Failed to update the config.yaml file with the concepts: {e}")

model_version_proto.output_info.data.concepts.extend(
self._concepts_protos_from_concepts(labels))
Expand Down

0 comments on commit 2be4814

Please sign in to comment.