Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds version and broker info to qinfo #89

Merged
merged 2 commits into from
Oct 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions django_q/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django_q.conf import Conf
from django_q.status import Stat
from django_q.brokers import get_broker
from django_q import models
from django_q import models, VERSION


def monitor(run_once=False, broker=None):
Expand Down Expand Up @@ -146,7 +146,10 @@ def info(broker=None):
# print to terminal
print(term.clear_eos())
col_width = int(term.width / 6)
print(term.black_on_green(term.center(_('-- {} summary --').format(Conf.PREFIX))))
print(term.black_on_green(
term.center(
_('-- {} {} on {} --').format(Conf.PREFIX.capitalize(), '.'.join(str(v) for v in VERSION),
broker.info()))))
print(term.cyan(_('Clusters')) +
term.move_x(1 * col_width) +
term.white(str(clusters)) +
Expand Down
8 changes: 4 additions & 4 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,17 @@ Alternatively the ``parzen_async()`` function can also be written with :func:`as

# create 100 calculations and return the collated result
def parzen_async():
mu_vec = numpy.array([0, 0])
mu_vec = numpy.array([0, 0])n this case, but without hook support.
cov_mat = numpy.array([[1, 0], [0, 1]])
sample = numpy.random. \
multivariate_normal(mu_vec, cov_mat, 10000)
widths = numpy.linspace(1.0, 1.2, 100)
x = numpy.array([[0], [0]])
# async them with async iterable
args = [(sample, x, w) for w in widths]
result_id = async_iter(parzen_estimation, args)
# return the result or timeout after 10 seconds
return result(result_id, wait=10000)
result_id = async_iter(parzen_estimation, args, cached=True)
# return the cached result or timeout after 10 seconds
return result(result_id, wait=10000, cached=True)


.. note::
Expand Down
4 changes: 3 additions & 1 deletion docs/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ This works both globally or on individual async executions.::
# and then save it to the database
task.save()

As you can see you can easily turn a cached result into a permanent database result by calling ``save()`` on it.

This also works for group actions::

# cached group example
Expand All @@ -225,7 +227,7 @@ This also works for group actions::
# wait max 50ms for one hundred results to return
result_group('frexp', wait=50, count=100, cached=True)

Note that exact same result can be achieved by using the more convenient :func:`async_iter` in this case, but without hook support.
If you don't need hooks, that exact same result can be achieved by using the more convenient :func:`async_iter`.

Synchronous testing
-------------------
Expand Down