简体   繁体   中英

How to start mapreduce job from cron on GAE Python

I have mapreduce job defined in mapreduce.yaml:

mapreduce:
- name: JobName 
  mapper:
    input_reader: google.appengine.ext.mapreduce.input_readers.DatastoreInputReader
    handler: handler_name
    params:
    - name: entity_kind
      default: KindName

How to start it from cron? Is there some url that can run it?

You can start a mapreduce task from any kind of AppEngine handler using control.py

from mapreduce import control

mapreduce_id = control.start_map(
    "My Mapper",
    "main.my_mapper",
    "mapreduce.input_readers.DatastoreInputReader",
    {"entity_kind": "models.MyEntity"},
    shard_count=10)

Yes, if you look at the Getting Started page, it shows that you set the URL in your app.yaml :

handlers:
- url: /mapreduce(/.*)?
  script: mapreduce/main.py
  login: admin

You then can just cron it in the usual App Engine fashion, which in this example would be writing a cron.yaml like this:

cron:
- description: daily summary job
  url: /mapreduce
  schedule: every 24 hours

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM