diff --git a/alfalfa_client/alfalfa_client.py b/alfalfa_client/alfalfa_client.py index 5ab9b4b..d6a603a 100644 --- a/alfalfa_client/alfalfa_client.py +++ b/alfalfa_client/alfalfa_client.py @@ -28,7 +28,6 @@ **************************************************************************************************** """ -import json from multiprocessing import Pool import requests @@ -154,7 +153,7 @@ def outputs(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = {} @@ -176,7 +175,7 @@ def all_cur_points(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = [] @@ -196,7 +195,7 @@ def all_cur_points_with_units(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = {} @@ -216,7 +215,7 @@ def get_sim_time(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() dt = j["data"]["viewer"]["runs"]["sim_time"] return dt @@ -229,7 +228,7 @@ def all_writable_points(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = [] @@ -247,7 +246,7 @@ def all_cur_writable_points(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = [] @@ -323,7 +322,7 @@ def inputs(self, site_id): payload = {'query': query} response = requests.post(self.url + '/graphql', json=payload) - j = json.loads(response.text) + j = response.json() points = j["data"]["viewer"]["sites"][0]["points"] result = {} diff --git a/alfalfa_client/lib.py b/alfalfa_client/lib.py index e22836a..7ffa82d 100644 --- a/alfalfa_client/lib.py +++ b/alfalfa_client/lib.py @@ -28,7 +28,6 @@ **************************************************************************************************** """ -import json import os import time import uuid @@ -70,7 +69,7 @@ def status(url, run_id): if response.status_code != 200: print("Could not get status") - j = json.loads(response.text) + j = response.json() runs = j["data"]["viewer"]["runs"] if runs: status = runs["status"] @@ -89,7 +88,7 @@ def get_error_log(url, run_id): if response.status_code != 200: print("Could not get error log") - j = json.loads(response.text) + j = response.json() runs = j["data"]["viewer"]["runs"] if runs: error_log = runs["error_log"] @@ -155,16 +154,18 @@ def submit_one(args): # After the file has been uploaded, then tell BOPTEST to process the site # This is done not via the haystack api, but through a graphql api mutation = 'mutation { addSite(modelName: "%s", uploadID: "%s") }' % (filename, uid) + run_id = None for _ in range(3): response = requests.post(url + '/graphql', json={'query': mutation}) if response.status_code == 200: + run_id = response.json()['data']['addSite'] break if response.status_code != 200: print("Could not addSite") - wait(url, uid, "READY") + wait(url, run_id, "READY") - return uid + return run_id def start_one(args): diff --git a/tox.ini b/tox.ini index b254937..e99e3b5 100644 --- a/tox.ini +++ b/tox.ini @@ -6,5 +6,5 @@ envlist = python3.7, python3.8, python3.9 whitelist_externals = poetry commands = poetry install -v - poetry run pytest tests/ + poetry run pytest tests poetry run pre-commit run -a