You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.5 KiB
58 lines
1.5 KiB
2 years ago
|
import time
|
||
|
from eden.client import Client
|
||
|
from eden.datatypes import Image
|
||
|
|
||
|
import subprocess
|
||
|
import socket
|
||
|
|
||
|
# Get IP address of eden-server service
|
||
|
hostname = 'eden-server'
|
||
|
port = 5656
|
||
|
network_name = 'eden-network'
|
||
|
import docker
|
||
|
client = docker.from_env()
|
||
|
project_name = 'not_so_minimal'
|
||
|
container_name = f'{project_name}_{hostname}_1'
|
||
|
container = client.containers.get(container_name)
|
||
|
ip_address = container.attrs['NetworkSettings']['Networks'][network_name]['IPAddress']
|
||
|
print(ip_address)
|
||
|
url = f"http://{ip_address}:{port}"
|
||
|
|
||
|
## set up a client
|
||
|
c = Client(url=url, username="abraham")
|
||
|
|
||
|
# get server's identity
|
||
|
generator_id = c.get_generator_identity()
|
||
|
print(generator_id)
|
||
|
|
||
|
## define input args to be sent
|
||
|
config = {
|
||
|
"width": 2000, ## width
|
||
|
"height": 1000, ## height
|
||
|
"input_image": Image(
|
||
|
"/home/mm/Downloads/FF06F0EC-1B54-458A-BF12-FF7FC2A43C10.jpeg"
|
||
|
), ## images require eden.datatypes.Image()
|
||
|
}
|
||
|
|
||
|
# start the task
|
||
|
run_response = c.run(config)
|
||
|
|
||
|
print("Intitial response")
|
||
|
# check status of the task, returns the output too if the task is complete
|
||
|
results = c.fetch(token=run_response["token"])
|
||
|
print(results)
|
||
|
|
||
|
# one eternity later
|
||
|
# time.sleep(5)
|
||
|
|
||
|
print("Trying")
|
||
|
while results["status"].get("status") != "complete":
|
||
|
results = c.fetch(token=run_response["token"])
|
||
|
print(results)
|
||
|
time.sleep(0.1)
|
||
|
|
||
|
## check status again, hopefully the task is complete by now
|
||
|
# results = c.fetch(token=run_response["token"])
|
||
|
# print(results)
|
||
|
# results['output']['image'].show()
|