In the python version of the Google App Engine mapreduce, how do you access counters from done_callback?

I use the Google App Engine mapreduce to analyze some data. I am creating several counters that would like to create a simple google chart from my done_callback file. How to access the resulting counters from a callback?

#The map method
def count_created_since(entity):
  now = datetime.datetime.now()
  delta = now-entity.created

  #analyze last 12 weeks
  for x in range(12):
    start = 7*x
    stop = 7*(x+1)

    if delta.days >= start and delta.days < stop:
      #The counters
      yield op.counters.Increment(str(x)+" weeks ago")


def my_callback(request):
  # fetch counter results to create a simple Google chart url
+5
source share
1 answer

You can access the counter through an attribute .MapreduceState counter_map

from mapreduce import model
state = model.MapreduceState.get_by_job_id(your_job_id)
# counters live in state.counters_map

The mailing list reported a month ago

+5
source

All Articles