add --sample to signal.py
This commit is contained in:
parent
76e172da0f
commit
66acbde1d8
@ -26,3 +26,4 @@ class ElasticSearchPush(Task):
|
||||
id=doc_id)
|
||||
except Exception as e:
|
||||
kernel.log(self.action, doc_id, error=True, exception=str(e))
|
||||
raise
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
from celery.execute import send_task
|
||||
from celery import current_app
|
||||
|
||||
from oyster.core import kernel
|
||||
|
||||
@ -12,6 +13,7 @@ def main():
|
||||
parser.add_argument('task', type=str, help='task name to apply')
|
||||
parser.add_argument('doc_class', type=str,
|
||||
help='doc_class to apply function to')
|
||||
parser.add_argument('--sample', action='store_true')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -20,8 +22,16 @@ def main():
|
||||
}, timeout=False)
|
||||
print '%s docs in %s' % (docs.count(), args.doc_class)
|
||||
|
||||
for doc in docs:
|
||||
send_task(args.task, (doc['_id'], ))
|
||||
if args.sample:
|
||||
print 'sampling 100 documents'
|
||||
docs = docs.limit(100)
|
||||
task = current_app.tasks[name]
|
||||
for doc in docs:
|
||||
task.apply((doc['_id'],))
|
||||
|
||||
else:
|
||||
for doc in docs:
|
||||
send_task(args.task, (doc['_id'], ))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user