Skip to content

Commit

Permalink
[EAGLE-5500] Fixed Docker test locally (#505)
Browse files Browse the repository at this point in the history
* Fix test-model-locally container

* Fix test-model-locally container
  • Loading branch information
luv-bansal authored Feb 5, 2025
1 parent 4231441 commit 32fac23
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions clarifai/runners/models/model_run_locally.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ def build_docker_image(
# Comment out the COPY instruction that copies the current folder
modified_lines = []
for line in lines:
if 'COPY .' in line and '/app/model_dir/main' in line:
if 'COPY' in line and '/home/nonroot/main' in line:
modified_lines.append(f'# {line}')
elif 'download-checkpoints' in line and '/home/nonroot/main' in line:
modified_lines.append(f'# {line}')
else:
modified_lines.append(line)
Expand Down Expand Up @@ -338,15 +340,15 @@ def run_docker_container(self,
if self._gpu_is_available():
cmd.extend(["--gpus", "all"])
# Add volume mappings
cmd.extend(["-v", f"{self.model_path}:/app/model_dir/main"])
cmd.extend(["-v", f"{self.model_path}:/home/nonroot/main"])
# Add environment variables
if env_vars:
for key, value in env_vars.items():
cmd.extend(["-e", f"{key}={value}"])
# Add the image name
cmd.append(image_name)
# update the CMD to run the server
cmd.extend(["--model_path", "/app/model_dir/main", "--grpc", "--port", str(port)])
cmd.extend(["--model_path", "/home/nonroot/main", "--grpc", "--port", str(port)])
# Run the container
process = subprocess.Popen(cmd,)
logger.info(
Expand Down Expand Up @@ -387,7 +389,7 @@ def test_model_container(self,
# update the entrypoint for testing the model
cmd.extend(["--entrypoint", "python"])
# Add volume mappings
cmd.extend(["-v", f"{self.model_path}:/app/model_dir/main"])
cmd.extend(["-v", f"{self.model_path}:/home/nonroot/main"])
# Add environment variables
if env_vars:
for key, value in env_vars.items():
Expand All @@ -397,7 +399,7 @@ def test_model_container(self,
# update the CMD to test the model inside the container
cmd.extend([
"-c",
"from clarifai.runners.models.model_run_locally import ModelRunLocally; ModelRunLocally('/app/model_dir/main')._run_test()"
"from clarifai.runners.models.model_run_locally import ModelRunLocally; ModelRunLocally('/home/nonroot/main')._run_test()"
])
# Run the container
subprocess.check_call(cmd)
Expand Down

0 comments on commit 32fac23

Please sign in to comment.