def get_official_client(username, password): """ Get official vantage6 client. :param username: :param password: :return: """ client = Client(_HOST, _PORT) client.authenticate(username, password) client.setup_encryption(None) return client
def create_client_and_authenticate(ctx): """Create a client and authenticate.""" host = ctx.config['server_url'] port = ctx.config['port'] api_path = ctx.config['api_path'] info(f"Connecting to server at '{host}:{port}{api_path}'") username = q.text("Username:"******"Password:"******"Could not authenticate with server!") debug(e) exit(1) return client
for result in results: node_id = result.get("node") print("-" * 80) print(f"Results from node = {node_id}") print(result.get("result")) # central server configuration host = "http://192.168.37.1" port = 5000 collaboration_id = 3 # 1. authenticate to the central server client = Client(host=host, port=port, path="/api") client.setup_encryption(None) client.authenticate("root", "admin") # 2. connect to websocket interface bearer_token = client.token socket = SocketIO(host, port=port, headers={"Authorization": f"Bearer {bearer_token}"}) # subscribe to the websocket channel. taskNamespace = socket.define(TasksNamespace, "/tasks") taskNamespace.emit("join_room", f"collaboration_{collaboration_id}") # input for the dsummary Docker image (algorithm) input_ = { "master": "true", "method": "master",
def setup_client() -> Client: client = Client(HOST, PORT) client.authenticate(FAKE_USERNAME, FAKE_PASSWORD) client.setup_encryption(None) return client
from vantage6.client import Client from pathlib import Path import time print("Attempt login to Vantage6 API") client = Client("http://localhost", 5000, "/api") client.authenticate("johan", "1234") client.setup_encryption(None) input_ = {"master": "true", "method": "master", "args": [], "kwargs": {}} print("Requesting to execute summary algorithm") task = client.post_task(name="testing", image="docker.io/username/imagename", collaboration_id=1, input_=input_, organization_ids=[1]) print("Wait and fetch results") res = client.result.get(id_=task.get("results")[0]['id']) attempts = 1 while ((res["result"] == None) and attempts < 7): print("waiting...") time.sleep(5) res = client.result.get(id_=task.get("results")[0]['id']) attempts += 1 print(res)