diff --git a/ai/ai.py b/ai/ai.py index 40201e240..6c22c925b 100644 --- a/ai/ai.py +++ b/ai/ai.py @@ -9,6 +9,7 @@ import json import pickle import requests +import urllib.request, urllib.parse import pdb import time import ai.ml_ids @@ -110,9 +111,18 @@ def check_results(self,timestamp=None): #payload.update(self.static_payload) # get new results r = requests.post(self.exp_path,data=json.dumps(payload),headers={'content-type': 'application/json'}) + # r = requests.post(self.exp_path,data=json.dumps(payload)) + baseURL = 'http://hoth.pmacs.upenn.edu:5080' + experimentsURL=baseURL+'/api/experiments' + postvars = {'apikey':'Oed+kIyprDrUq/3oWU5Jpyd22PqhG/CsUvI8oc9l39E='} + params = json.dumps(postvars).encode('utf8') + req = urllib.request.Request(experimentsURL, data=params, + headers={'content-type': 'application/json'}) + r = urllib.request.urlopen(req) + data = json.loads(r.read().decode(r.info().get_param('charset') or 'utf-8')) # if there are new results, return True pdb.set_trace() - if len(json.loads(r.text)) > 0: + if len(data) > 0: if self.verbose: print(time.strftime("%Y %I:%M:%S %p %Z",time.localtime()), 'new results!') diff --git a/tests/extract_ml_experiments.py b/tests/extract_ml_experiments.py index 4a7dca7eb..0ba8ddabc 100644 --- a/tests/extract_ml_experiments.py +++ b/tests/extract_ml_experiments.py @@ -5,9 +5,11 @@ unixtime = int(datetime.datetime.now().strftime("%s")) * 1000 #last 8 hours lastupdate = unixtime - (8 * 60 * 60 * 1000 ) -baseURL = os.environ['FGLAB_URL'] +#baseURL = os.environ['FGLAB_URL'] +baseURL = 'http://hoth.pmacs.upenn.edu:5080' experimentsURL=baseURL+'/api/experiments' -postvars = {'apikey':os.environ['APIKEY'],'date_start':lastupdate} +#postvars = {'apikey':os.environ['APIKEY'],'date_start':lastupdate} +postvars = {'apikey':'Oed+kIyprDrUq/3oWU5Jpyd22PqhG/CsUvI8oc9l39E=','date_start':lastupdate} params = json.dumps(postvars).encode('utf8') req = urllib.request.Request(experimentsURL, data=params, headers={'content-type': 'application/json'})