From ea3cf74c870e5b81872ec55ab7f8e9b9c964bac2 Mon Sep 17 00:00:00 2001 From: lacava Date: Wed, 31 May 2017 17:49:47 -0400 Subject: [PATCH] adds test extraction of experiments code directly to ai check_results method --- ai/ai.py | 13 +++++++++++-- tests/extract_ml_experiments.py | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ai/ai.py b/ai/ai.py index 85ea79e7f..8d620abd1 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 @@ -108,10 +109,18 @@ def check_results(self,timestamp=None): payload={'apikey':self.api_key} #payload.update(self.static_payload) # get new results - r = requests.post(self.exp_path,data=json.dumps(payload)) + # 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 4a7ba687c..83d88314a 100644 --- a/tests/extract_ml_experiments.py +++ b/tests/extract_ml_experiments.py @@ -1,9 +1,9 @@ import urllib.request, urllib.parse import json import os -baseURL = os.environ['FGLAB_URL'] +baseURL = 'http://hoth.pmacs.upenn.edu:5080' experimentsURL=baseURL+'/api/experiments' -postvars = {'apikey':os.environ['APIKEY']} +postvars = {'apikey':'Oed+kIyprDrUq/3oWU5Jpyd22PqhG/CsUvI8oc9l39E='} params = json.dumps(postvars).encode('utf8') req = urllib.request.Request(experimentsURL, data=params, headers={'content-type': 'application/json'})