Spaces:
Sleeping
Sleeping
Dmitry Trifonov
commited on
Commit
·
784c8c5
1
Parent(s):
5fff7ad
disable server start logic
Browse files
fair.py
CHANGED
@@ -14,10 +14,10 @@ logger = logging.getLogger()
|
|
14 |
import requests
|
15 |
import tempfile
|
16 |
|
17 |
-
SERVER_ADDRESS = "https://faircompute.com:8000/api/
|
18 |
ENDPOINT_ADDRESS = "http://dikobraz.mooo.com:5000"
|
19 |
TARGET_NODE = "119eccba-2388-43c1-bdb9-02133049604c"
|
20 |
-
# SERVER_ADDRESS = "http://localhost:8000/api/
|
21 |
# ENDPOINT_ADDRESS = "http://localhost:5000"
|
22 |
# TARGET_NODE = None
|
23 |
|
@@ -31,7 +31,7 @@ class FairApiClient:
|
|
31 |
|
32 |
def authenticate(self, email: str, password: str):
|
33 |
url = f'{self.server_address}/auth/login'
|
34 |
-
json_obj = {"email": email, "password": password}
|
35 |
resp = requests.post(url, json=json_obj)
|
36 |
self.token = resp.json()["token"]
|
37 |
|
@@ -65,7 +65,7 @@ class FairApiClient:
|
|
65 |
data = {
|
66 |
'version': 'V018',
|
67 |
'container_desc': {
|
68 |
-
'
|
69 |
'image': image,
|
70 |
'runtime': 'nvidia',
|
71 |
'ports': [[{"port": host_port, "ip": 'null'}, {"port": container_port, "protocol": "Tcp"}] for (host_port, container_port) in ports],
|
@@ -159,7 +159,7 @@ def wait_for_server(retries, timeout, delay=1.0):
|
|
159 |
|
160 |
def start_server():
|
161 |
# default credentials will work only for local server built in debug mode
|
162 |
-
email = os.getenv('FAIRCOMPUTE_EMAIL', "debug-
|
163 |
password = os.environ.get('FAIRCOMPUTE_PASSWORD', "debug-pwd")
|
164 |
client = FairApiClient(SERVER_ADDRESS)
|
165 |
client.authenticate(email=email, password=password)
|
@@ -186,10 +186,10 @@ def start_server():
|
|
186 |
|
187 |
|
188 |
def text_to_image(text):
|
189 |
-
try:
|
190 |
-
|
191 |
-
except ServerNotReadyException:
|
192 |
-
|
193 |
|
194 |
client = EndpointClient()
|
195 |
return client.infer(text)
|
|
|
14 |
import requests
|
15 |
import tempfile
|
16 |
|
17 |
+
SERVER_ADDRESS = "https://faircompute.com:8000/api/v0"
|
18 |
ENDPOINT_ADDRESS = "http://dikobraz.mooo.com:5000"
|
19 |
TARGET_NODE = "119eccba-2388-43c1-bdb9-02133049604c"
|
20 |
+
# SERVER_ADDRESS = "http://localhost:8000/api/v0"
|
21 |
# ENDPOINT_ADDRESS = "http://localhost:5000"
|
22 |
# TARGET_NODE = None
|
23 |
|
|
|
31 |
|
32 |
def authenticate(self, email: str, password: str):
|
33 |
url = f'{self.server_address}/auth/login'
|
34 |
+
json_obj = {"email": email, "password": password, "version": "V018"}
|
35 |
resp = requests.post(url, json=json_obj)
|
36 |
self.token = resp.json()["token"]
|
37 |
|
|
|
65 |
data = {
|
66 |
'version': 'V018',
|
67 |
'container_desc': {
|
68 |
+
'version': 'V018',
|
69 |
'image': image,
|
70 |
'runtime': 'nvidia',
|
71 |
'ports': [[{"port": host_port, "ip": 'null'}, {"port": container_port, "protocol": "Tcp"}] for (host_port, container_port) in ports],
|
|
|
159 |
|
160 |
def start_server():
|
161 |
# default credentials will work only for local server built in debug mode
|
162 |
+
email = os.getenv('FAIRCOMPUTE_EMAIL', "debug-usr")
|
163 |
password = os.environ.get('FAIRCOMPUTE_PASSWORD', "debug-pwd")
|
164 |
client = FairApiClient(SERVER_ADDRESS)
|
165 |
client.authenticate(email=email, password=password)
|
|
|
186 |
|
187 |
|
188 |
def text_to_image(text):
|
189 |
+
# try:
|
190 |
+
# wait_for_server(retries=1, timeout=1.0, delay=0.0)
|
191 |
+
# except ServerNotReadyException:
|
192 |
+
# start_server()
|
193 |
|
194 |
client = EndpointClient()
|
195 |
return client.infer(text)
|