[ARVADOS] updated: fe21e5236f596001d22e4b28519d1c5ef32a7e3c
git at public.curoverse.com
git at public.curoverse.com
Wed Oct 15 17:13:04 EDT 2014
Summary of changes:
sdk/python/arvados/commands/ws.py | 11 +++++---
sdk/python/arvados/events.py | 30 ++++++++++++----------
.../controllers/arvados/v1/schema_controller.rb | 4 +--
3 files changed, 26 insertions(+), 19 deletions(-)
via fe21e5236f596001d22e4b28519d1c5ef32a7e3c (commit)
via 4ff82f5fdc5d0e663da809823f25155d09609cc1 (commit)
from 758d59141102b29371f44512671b9efe0cf62821 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit fe21e5236f596001d22e4b28519d1c5ef32a7e3c
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Oct 15 17:12:59 2014 -0400
3609: PollClient waits on event object instead of time.sleep, fix filters. Also fix --poll-interval and --no-poll
diff --git a/sdk/python/arvados/commands/ws.py b/sdk/python/arvados/commands/ws.py
index c27503c..142a205 100644
--- a/sdk/python/arvados/commands/ws.py
+++ b/sdk/python/arvados/commands/ws.py
@@ -5,6 +5,7 @@ import logging
import argparse
import arvados
import json
+import time
from arvados.events import subscribe
def main(arguments=None):
@@ -15,8 +16,8 @@ def main(arguments=None):
parser.add_argument('-f', '--filters', type=str, default="", help="Arvados query filter to apply to log events (JSON encoded)")
group = parser.add_argument_group('Polling fallback')
- group.add_argument('--poll-interval', default=15, help="If websockets is not available, specify the polling interval, default is every 15 seconds")
- group.add_argument('--no-poll', action='store_false', dest='poll_fallback', help="Do not poll if websockets are not available, just fail")
+ group.add_argument('--poll-interval', default=15, type=int, help="If websockets is not available, specify the polling interval, default is every 15 seconds")
+ group.add_argument('--no-poll', action='store_false', dest='poll_interval', help="Do not poll if websockets are not available, just fail")
group = parser.add_argument_group('Jobs and Pipelines')
group.add_argument('-p', '--pipeline', type=str, default="", help="Supply pipeline uuid, print log output from pipeline and its jobs")
@@ -69,8 +70,10 @@ def main(arguments=None):
print json.dumps(ev)
try:
- ws = subscribe(api, filters, on_message, poll_fallback=args.poll_fallback)
- ws.run_forever()
+ ws = subscribe(api, filters, on_message, poll_fallback=args.poll_interval)
+ if ws:
+ while True:
+ time.sleep(60)
except KeyboardInterrupt:
pass
except Exception:
diff --git a/sdk/python/arvados/events.py b/sdk/python/arvados/events.py
index 489be5a..df64b4e 100644
--- a/sdk/python/arvados/events.py
+++ b/sdk/python/arvados/events.py
@@ -48,32 +48,36 @@ class PollClient(threading.Thread):
def __init__(self, api, filters, on_event, poll_time):
super(PollClient, self).__init__()
self.api = api
- self.filters = filters
+ self.filters = [filters]
self.on_event = on_event
- items = self.api.logs().list(limit=1, order=["id desc"], filters=filters).execute()['items']
+ items = self.api.logs().list(limit=1, order="id desc", filters=filters).execute()['items']
if len(items) > 0:
self.id = items[0]["id"]
else:
self.id = 0
self.poll_time = poll_time
- self.loop = True
+ self.stop = threading.Event()
self.on_event({'status': 200})
def run(self):
- while self.loop:
- time.sleep(self.poll_time)
- items = self.api.logs().list(order=["id asc"], filters=self.filters+[["id", ">", str(self.id)]]).execute()['items']
- for i in items:
- self.id = i['id']
- self.on_event(i)
+ while not self.stop.isSet():
+ max_id = 0
+ for f in self.filters:
+ items = self.api.logs().list(order="id asc", filters=f+[["id", ">", str(self.id)]]).execute()['items']
+ for i in items:
+ if i['id'] > max_id:
+ max_id = i['id']
+ self.on_event(i)
+ self.id = max_id
+ self.stop.wait(self.poll_time)
def close(self):
- self.loop = False
+ self.stop.set()
self.join()
def subscribe(self, filters):
self.on_event({'status': 200})
- self.filters += filters
+ self.filters.append(filters)
def unsubscribe(self, filters):
del self.filters[self.filters.index(filters)]
@@ -87,9 +91,9 @@ def subscribe(api, filters, on_event, poll_fallback=15):
ws.connect()
return ws
except Exception as e:
- _logger.warn("Got exception %s trying to connect to web sockets" % e)
+ _logger.warn("Got exception %s trying to connect to web sockets at %s" % (e, api._rootDesc['websocketUrl']))
if ws:
- ws.close()
+ ws.close_connection()
if poll_fallback:
_logger.warn("Web sockets not available, falling back to log table polling")
p = PollClient(api, filters, on_event, poll_fallback)
commit 4ff82f5fdc5d0e663da809823f25155d09609cc1
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Oct 15 17:09:52 2014 -0400
3609: Roll back schema change, not appropriate for this branch
diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb
index eef8e65..c5b2bcf 100644
--- a/services/api/app/controllers/arvados/v1/schema_controller.rb
+++ b/services/api/app/controllers/arvados/v1/schema_controller.rb
@@ -230,8 +230,8 @@ class Arvados::V1::SchemaController < ApplicationController
location: "query"
},
order: {
- type: "array",
- description: "Fields to use to determine order for returning #{k.to_s.underscore.pluralize} object matches.",
+ type: "string",
+ description: "Order in which to return matching #{k.to_s.underscore.pluralize}.",
location: "query"
},
select: {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list