support HTTP_ADDRESS for url address
Browse files- experimental/clip_app.py +1 -3
- experimental/clip_app_client.py +4 -12
experimental/clip_app.py
CHANGED
|
@@ -10,9 +10,7 @@ from ray import serve
|
|
| 10 |
from clip_retrieval.load_clip import load_clip, get_tokenizer
|
| 11 |
# from clip_retrieval.clip_client import ClipClient, Modality
|
| 12 |
|
| 13 |
-
|
| 14 |
-
# @serve.deployment(num_replicas=1, ray_actor_options={"num_cpus": 0.2, "num_gpus": 0.0})
|
| 15 |
-
@serve.deployment(num_replicas=10, ray_actor_options={"num_cpus": .2, "num_gpus": 0.1})
|
| 16 |
class CLIPTransform:
|
| 17 |
def __init__(self):
|
| 18 |
# os.environ["OMP_NUM_THREADS"] = "20"
|
|
|
|
| 10 |
from clip_retrieval.load_clip import load_clip, get_tokenizer
|
| 11 |
# from clip_retrieval.clip_client import ClipClient, Modality
|
| 12 |
|
| 13 |
+
@serve.deployment(num_replicas=6, ray_actor_options={"num_cpus": .2, "num_gpus": 0.1})
|
|
|
|
|
|
|
| 14 |
class CLIPTransform:
|
| 15 |
def __init__(self):
|
| 16 |
# os.environ["OMP_NUM_THREADS"] = "20"
|
experimental/clip_app_client.py
CHANGED
|
@@ -1,19 +1,11 @@
|
|
| 1 |
# File name: graph_client.py
|
| 2 |
from concurrent.futures import ThreadPoolExecutor
|
| 3 |
import json
|
|
|
|
| 4 |
import requests
|
| 5 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 6 |
import time
|
| 7 |
|
| 8 |
-
# english_text = (
|
| 9 |
-
# "It was the best of times, it was the worst of times, it was the age "
|
| 10 |
-
# "of wisdom, it was the age of foolishness, it was the epoch of belief"
|
| 11 |
-
# )
|
| 12 |
-
# response = requests.post("http://127.0.0.1:8000/", json=english_text)
|
| 13 |
-
# french_text = response.text
|
| 14 |
-
|
| 15 |
-
# print(french_text)
|
| 16 |
-
|
| 17 |
test_image_url = "https://static.wixstatic.com/media/4d6b49_42b9435ce1104008b1b5f7a3c9bfcd69~mv2.jpg/v1/fill/w_454,h_333,fp_0.50_0.50,q_90/4d6b49_42b9435ce1104008b1b5f7a3c9bfcd69~mv2.jpg"
|
| 18 |
english_text = (
|
| 19 |
"It was the best of times, it was the worst of times, it was the age "
|
|
@@ -23,7 +15,8 @@ english_text = (
|
|
| 23 |
|
| 24 |
def send_text_request(number):
|
| 25 |
json = {"text": english_text}
|
| 26 |
-
|
|
|
|
| 27 |
embeddings = response.text
|
| 28 |
return number, embeddings
|
| 29 |
|
|
@@ -41,10 +34,9 @@ def process_text(numbers, max_workers=10):
|
|
| 41 |
# result = json.loads(result)
|
| 42 |
# print (f"{n_result} : {len(result[0])}")
|
| 43 |
|
| 44 |
-
|
| 45 |
if __name__ == "__main__":
|
| 46 |
# n_calls = 100000
|
| 47 |
-
n_calls =
|
| 48 |
numbers = list(range(n_calls))
|
| 49 |
start_time = time.monotonic()
|
| 50 |
process_text(numbers)
|
|
|
|
| 1 |
# File name: graph_client.py
|
| 2 |
from concurrent.futures import ThreadPoolExecutor
|
| 3 |
import json
|
| 4 |
+
import os
|
| 5 |
import requests
|
| 6 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 7 |
import time
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
test_image_url = "https://static.wixstatic.com/media/4d6b49_42b9435ce1104008b1b5f7a3c9bfcd69~mv2.jpg/v1/fill/w_454,h_333,fp_0.50_0.50,q_90/4d6b49_42b9435ce1104008b1b5f7a3c9bfcd69~mv2.jpg"
|
| 10 |
english_text = (
|
| 11 |
"It was the best of times, it was the worst of times, it was the age "
|
|
|
|
| 15 |
|
| 16 |
def send_text_request(number):
|
| 17 |
json = {"text": english_text}
|
| 18 |
+
url = os.environ.get("HTTP_ADDRESS", "http://127.0.0.1:8000/")
|
| 19 |
+
response = requests.post(url, json=json)
|
| 20 |
embeddings = response.text
|
| 21 |
return number, embeddings
|
| 22 |
|
|
|
|
| 34 |
# result = json.loads(result)
|
| 35 |
# print (f"{n_result} : {len(result[0])}")
|
| 36 |
|
|
|
|
| 37 |
if __name__ == "__main__":
|
| 38 |
# n_calls = 100000
|
| 39 |
+
n_calls = 10000
|
| 40 |
numbers = list(range(n_calls))
|
| 41 |
start_time = time.monotonic()
|
| 42 |
process_text(numbers)
|