From 5882a2f8cf1d68aa1feeb0b9aea49988c36cdb8e Mon Sep 17 00:00:00 2001 From: Brandon Myers Date: Thu, 27 Aug 2015 11:55:40 -0700 Subject: [PATCH 1/2] expose profiling in a limited way --- myria/connection.py | 4 ++-- myria/query.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/myria/connection.py b/myria/connection.py index d4025aa..6d13d71 100644 --- a/myria/connection.py +++ b/myria/connection.py @@ -267,7 +267,7 @@ def upload_source(self, relation_key, schema, source): return self._make_request(POST, '/dataset', json.dumps(body)) - def execute_program(self, program, language="MyriaL", server=None): + def execute_program(self, program, language="MyriaL", server=None, profile=False): """Execute the program in the specified language on Myria, polling its status until the query is finished. Returns the query status struct. @@ -278,7 +278,7 @@ def execute_program(self, program, language="MyriaL", server=None): (default: MyriaL). """ - body = {"query": program, "language": language} + body = {"query": program, "language": language, "profile": str(profile)} r = requests.post((server or self.execution_url) + '/execute', data=body) if r.status_code != 201: diff --git a/myria/query.py b/myria/query.py index b146038..521d224 100644 --- a/myria/query.py +++ b/myria/query.py @@ -31,15 +31,15 @@ def __init__(self, query_id, connection=None, @staticmethod def submit(query, language="MyriaL", - connection=None, - timeout=60): + connection=None, + timeout=60, profile=False): """ Submit a query to Myria and return a new query instance """ connection = connection or MyriaRelation.DefaultConnection return MyriaQuery( connection.execute_program( query, language=language)['queryId'], - connection, timeout) + connection, timeout, profile) @staticmethod def submit_plan(plan, connection=None, From 7e803823df69e483169e38eb7124f08220b16bc6 Mon Sep 17 00:00:00 2001 From: Brandon Myers Date: Thu, 27 Aug 2015 13:42:00 -0700 Subject: [PATCH 2/2] pep passing --- myria/connection.py | 10 +++++++--- myria/query.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/myria/connection.py b/myria/connection.py index 6d13d71..ac15f0e 100644 --- a/myria/connection.py +++ b/myria/connection.py @@ -25,6 +25,7 @@ class MyriaConnection(object): + """Contains a connection the Myria REST server.""" _DEFAULT_HEADERS = { @@ -149,7 +150,7 @@ def _make_request(self, method, url, body=None, params=None, if accept == JSON: try: return r.json() - except ValueError, e: + except ValueError as e: raise MyriaError( 'Error %d: %s' % (r.status_code, r.text)) else: @@ -267,7 +268,8 @@ def upload_source(self, relation_key, schema, source): return self._make_request(POST, '/dataset', json.dumps(body)) - def execute_program(self, program, language="MyriaL", server=None, profile=False): + def execute_program(self, program, language="MyriaL", server=None, + profile=False): """Execute the program in the specified language on Myria, polling its status until the query is finished. Returns the query status struct. @@ -278,7 +280,9 @@ def execute_program(self, program, language="MyriaL", server=None, profile=False (default: MyriaL). """ - body = {"query": program, "language": language, "profile": str(profile)} + body = {"query": program, + "language": language, + "profile": str(profile)} r = requests.post((server or self.execution_url) + '/execute', data=body) if r.status_code != 201: diff --git a/myria/query.py b/myria/query.py index 521d224..f157932 100644 --- a/myria/query.py +++ b/myria/query.py @@ -12,6 +12,7 @@ class MyriaQuery(object): + """ Represents a Myria query """ nonterminal_states = ['ACCEPTED', 'RUNNING'] @@ -31,7 +32,7 @@ def __init__(self, query_id, connection=None, @staticmethod def submit(query, language="MyriaL", - connection=None, + connection=None, timeout=60, profile=False): """ Submit a query to Myria and return a new query instance """ connection = connection or MyriaRelation.DefaultConnection