Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
magdyksaleh committed Nov 8, 2024
1 parent 79c8174 commit 038d69c
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions integration-tests-2/utils/docker_runner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import docker
import json
import tempfile
import time
import os
import requests
Expand All @@ -20,6 +20,8 @@ def start_container(self, model_config: Dict[str, Any]) -> None:
for key, value in model_config["docker_args"].items():
cmd.extend([f"--{key.replace('_', '-')}", str(value)])

data_temp_dir = tempfile.mkdtemp()
print("Using temporary directory for data: ", data_temp_dir)
# Start container
self.container = self.client.containers.run(
"ghcr.io/predibase/lorax:main",
Expand All @@ -29,7 +31,7 @@ def start_container(self, model_config: Dict[str, Any]) -> None:
},
device_requests=[docker.types.DeviceRequest(count=-1, capabilities=[["gpu"]])],
ports={"80": 8080},
volumes={f"{os.getcwd()}/data": {"bind": "/data", "mode": "rw"}},
volumes={data_temp_dir: {"bind": "/data", "mode": "rw"}},
shm_size="1g",
detach=True,
name=f"lorax-test-{model_config['name']}-{time.time()}",
Expand All @@ -55,19 +57,3 @@ def stop_container(self) -> None:
self.container.stop()
self.container.remove()
self.container = None


if __name__ == "__main__":
with open("configs.json", "r") as f:
model_configs = json.load(f)
runner = DockerModelRunner()
runner.start_container(model_configs[0])
runner.wait_for_healthy()
response = requests.post(
"http://localhost:8080/generate",
json={"inputs": model_configs[0]["test_prompt"], "parameters": {"max_new_tokens": 10}},
)
response.raise_for_status()
print(response.json())
runner.stop_container()
print("Done")

0 comments on commit 038d69c

Please sign in to comment.