repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/model_datastore_input_reader.py
ModelDatastoreInputReader.split_input
def split_input(cls, job_config): """Inherit docs.""" params = job_config.input_reader_params shard_count = job_config.shard_count query_spec = cls._get_query_spec(params) if not property_range.should_shard_by_property_range(query_spec.filters): return super(ModelDatastoreInputReader, cls).sp...
python
def split_input(cls, job_config): """Inherit docs.""" params = job_config.input_reader_params shard_count = job_config.shard_count query_spec = cls._get_query_spec(params) if not property_range.should_shard_by_property_range(query_spec.filters): return super(ModelDatastoreInputReader, cls).sp...
[ "def", "split_input", "(", "cls", ",", "job_config", ")", ":", "params", "=", "job_config", ".", "input_reader_params", "shard_count", "=", "job_config", ".", "shard_count", "query_spec", "=", "cls", ".", "_get_query_spec", "(", "params", ")", "if", "not", "pr...
Inherit docs.
[ "Inherit", "docs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/model_datastore_input_reader.py#L53-L96
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/model_datastore_input_reader.py
ModelDatastoreInputReader.validate
def validate(cls, job_config): """Inherit docs.""" super(ModelDatastoreInputReader, cls).validate(job_config) params = job_config.input_reader_params entity_kind = params[cls.ENTITY_KIND_PARAM] # Fail fast if Model cannot be located. try: model_class = util.for_name(entity_kind) except...
python
def validate(cls, job_config): """Inherit docs.""" super(ModelDatastoreInputReader, cls).validate(job_config) params = job_config.input_reader_params entity_kind = params[cls.ENTITY_KIND_PARAM] # Fail fast if Model cannot be located. try: model_class = util.for_name(entity_kind) except...
[ "def", "validate", "(", "cls", ",", "job_config", ")", ":", "super", "(", "ModelDatastoreInputReader", ",", "cls", ")", ".", "validate", "(", "job_config", ")", "params", "=", "job_config", ".", "input_reader_params", "entity_kind", "=", "params", "[", "cls", ...
Inherit docs.
[ "Inherit", "docs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/model_datastore_input_reader.py#L99-L115
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/model_datastore_input_reader.py
ModelDatastoreInputReader._validate_filters
def _validate_filters(cls, filters, model_class): """Validate user supplied filters. Validate filters are on existing properties and filter values have valid semantics. Args: filters: user supplied filters. Each filter should be a list or tuple of format (<property_name_as_str>, <query_o...
python
def _validate_filters(cls, filters, model_class): """Validate user supplied filters. Validate filters are on existing properties and filter values have valid semantics. Args: filters: user supplied filters. Each filter should be a list or tuple of format (<property_name_as_str>, <query_o...
[ "def", "_validate_filters", "(", "cls", ",", "filters", ",", "model_class", ")", ":", "if", "not", "filters", ":", "return", "properties", "=", "model_class", ".", "properties", "(", ")", "for", "f", "in", "filters", ":", "prop", ",", "_", ",", "val", ...
Validate user supplied filters. Validate filters are on existing properties and filter values have valid semantics. Args: filters: user supplied filters. Each filter should be a list or tuple of format (<property_name_as_str>, <query_operator_as_str>, <value_of_certain_type>). Value ...
[ "Validate", "user", "supplied", "filters", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/model_datastore_input_reader.py#L118-L150
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/model_datastore_input_reader.py
ModelDatastoreInputReader._validate_filters_ndb
def _validate_filters_ndb(cls, filters, model_class): """Validate ndb.Model filters.""" if not filters: return properties = model_class._properties for f in filters: prop, _, val = f if prop not in properties: raise errors.BadReaderParamsError( "Property %s is not...
python
def _validate_filters_ndb(cls, filters, model_class): """Validate ndb.Model filters.""" if not filters: return properties = model_class._properties for f in filters: prop, _, val = f if prop not in properties: raise errors.BadReaderParamsError( "Property %s is not...
[ "def", "_validate_filters_ndb", "(", "cls", ",", "filters", ",", "model_class", ")", ":", "if", "not", "filters", ":", "return", "properties", "=", "model_class", ".", "_properties", "for", "f", "in", "filters", ":", "prop", ",", "_", ",", "val", "=", "f...
Validate ndb.Model filters.
[ "Validate", "ndb", ".", "Model", "filters", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/model_datastore_input_reader.py#L154-L173
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_normalize_entity
def _normalize_entity(value): """Return an entity from an entity or model instance.""" if ndb is not None and isinstance(value, ndb.Model): return None if getattr(value, "_populate_internal_entity", None): return value._populate_internal_entity() return value
python
def _normalize_entity(value): """Return an entity from an entity or model instance.""" if ndb is not None and isinstance(value, ndb.Model): return None if getattr(value, "_populate_internal_entity", None): return value._populate_internal_entity() return value
[ "def", "_normalize_entity", "(", "value", ")", ":", "if", "ndb", "is", "not", "None", "and", "isinstance", "(", "value", ",", "ndb", ".", "Model", ")", ":", "return", "None", "if", "getattr", "(", "value", ",", "\"_populate_internal_entity\"", ",", "None",...
Return an entity from an entity or model instance.
[ "Return", "an", "entity", "from", "an", "entity", "or", "model", "instance", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L71-L77
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_normalize_key
def _normalize_key(value): """Return a key from an entity, model instance, key, or key string.""" if ndb is not None and isinstance(value, (ndb.Model, ndb.Key)): return None if getattr(value, "key", None): return value.key() elif isinstance(value, basestring): return datastore.Key(value) else: ...
python
def _normalize_key(value): """Return a key from an entity, model instance, key, or key string.""" if ndb is not None and isinstance(value, (ndb.Model, ndb.Key)): return None if getattr(value, "key", None): return value.key() elif isinstance(value, basestring): return datastore.Key(value) else: ...
[ "def", "_normalize_key", "(", "value", ")", ":", "if", "ndb", "is", "not", "None", "and", "isinstance", "(", "value", ",", "(", "ndb", ".", "Model", ",", "ndb", ".", "Key", ")", ")", ":", "return", "None", "if", "getattr", "(", "value", ",", "\"key...
Return a key from an entity, model instance, key, or key string.
[ "Return", "a", "key", "from", "an", "entity", "model", "instance", "key", "or", "key", "string", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L80-L89
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_ItemList.append
def append(self, item): """Add new item to the list. If needed, append will first flush existing items and clear existing items. Args: item: an item to add to the list. """ if self.should_flush(): self.flush() self.items.append(item)
python
def append(self, item): """Add new item to the list. If needed, append will first flush existing items and clear existing items. Args: item: an item to add to the list. """ if self.should_flush(): self.flush() self.items.append(item)
[ "def", "append", "(", "self", ",", "item", ")", ":", "if", "self", ".", "should_flush", "(", ")", ":", "self", ".", "flush", "(", ")", "self", ".", "items", ".", "append", "(", "item", ")" ]
Add new item to the list. If needed, append will first flush existing items and clear existing items. Args: item: an item to add to the list.
[ "Add", "new", "item", "to", "the", "list", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L133-L143
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_ItemList.flush
def flush(self): """Force a flush.""" if not self.items: return retry = 0 options = {"deadline": DATASTORE_DEADLINE} while retry <= self.__timeout_retries: try: self.__flush_function(self.items, options) self.clear() break except db.Timeout, e: logg...
python
def flush(self): """Force a flush.""" if not self.items: return retry = 0 options = {"deadline": DATASTORE_DEADLINE} while retry <= self.__timeout_retries: try: self.__flush_function(self.items, options) self.clear() break except db.Timeout, e: logg...
[ "def", "flush", "(", "self", ")", ":", "if", "not", "self", ".", "items", ":", "return", "retry", "=", "0", "options", "=", "{", "\"deadline\"", ":", "DATASTORE_DEADLINE", "}", "while", "retry", "<=", "self", ".", "__timeout_retries", ":", "try", ":", ...
Force a flush.
[ "Force", "a", "flush", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L145-L167
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool.put
def put(self, entity): """Registers entity to put to datastore. Args: entity: an entity or model instance to put. """ actual_entity = _normalize_entity(entity) if actual_entity is None: return self.ndb_put(entity) self.puts.append(actual_entity)
python
def put(self, entity): """Registers entity to put to datastore. Args: entity: an entity or model instance to put. """ actual_entity = _normalize_entity(entity) if actual_entity is None: return self.ndb_put(entity) self.puts.append(actual_entity)
[ "def", "put", "(", "self", ",", "entity", ")", ":", "actual_entity", "=", "_normalize_entity", "(", "entity", ")", "if", "actual_entity", "is", "None", ":", "return", "self", ".", "ndb_put", "(", "entity", ")", "self", ".", "puts", ".", "append", "(", ...
Registers entity to put to datastore. Args: entity: an entity or model instance to put.
[ "Registers", "entity", "to", "put", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L249-L258
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool.ndb_put
def ndb_put(self, entity): """Like put(), but for NDB entities.""" assert ndb is not None and isinstance(entity, ndb.Model) self.ndb_puts.append(entity)
python
def ndb_put(self, entity): """Like put(), but for NDB entities.""" assert ndb is not None and isinstance(entity, ndb.Model) self.ndb_puts.append(entity)
[ "def", "ndb_put", "(", "self", ",", "entity", ")", ":", "assert", "ndb", "is", "not", "None", "and", "isinstance", "(", "entity", ",", "ndb", ".", "Model", ")", "self", ".", "ndb_puts", ".", "append", "(", "entity", ")" ]
Like put(), but for NDB entities.
[ "Like", "put", "()", "but", "for", "NDB", "entities", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L260-L263
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool.delete
def delete(self, entity): """Registers entity to delete from datastore. Args: entity: an entity, model instance, or key to delete. """ key = _normalize_key(entity) if key is None: return self.ndb_delete(entity) self.deletes.append(key)
python
def delete(self, entity): """Registers entity to delete from datastore. Args: entity: an entity, model instance, or key to delete. """ key = _normalize_key(entity) if key is None: return self.ndb_delete(entity) self.deletes.append(key)
[ "def", "delete", "(", "self", ",", "entity", ")", ":", "key", "=", "_normalize_key", "(", "entity", ")", "if", "key", "is", "None", ":", "return", "self", ".", "ndb_delete", "(", "entity", ")", "self", ".", "deletes", ".", "append", "(", "key", ")" ]
Registers entity to delete from datastore. Args: entity: an entity, model instance, or key to delete.
[ "Registers", "entity", "to", "delete", "from", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L265-L274
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool.ndb_delete
def ndb_delete(self, entity_or_key): """Like delete(), but for NDB entities/keys.""" if ndb is not None and isinstance(entity_or_key, ndb.Model): key = entity_or_key.key else: key = entity_or_key self.ndb_deletes.append(key)
python
def ndb_delete(self, entity_or_key): """Like delete(), but for NDB entities/keys.""" if ndb is not None and isinstance(entity_or_key, ndb.Model): key = entity_or_key.key else: key = entity_or_key self.ndb_deletes.append(key)
[ "def", "ndb_delete", "(", "self", ",", "entity_or_key", ")", ":", "if", "ndb", "is", "not", "None", "and", "isinstance", "(", "entity_or_key", ",", "ndb", ".", "Model", ")", ":", "key", "=", "entity_or_key", ".", "key", "else", ":", "key", "=", "entity...
Like delete(), but for NDB entities/keys.
[ "Like", "delete", "()", "but", "for", "NDB", "entities", "/", "keys", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L276-L282
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool.flush
def flush(self): """Flush(apply) all changed to datastore.""" self.puts.flush() self.deletes.flush() self.ndb_puts.flush() self.ndb_deletes.flush()
python
def flush(self): """Flush(apply) all changed to datastore.""" self.puts.flush() self.deletes.flush() self.ndb_puts.flush() self.ndb_deletes.flush()
[ "def", "flush", "(", "self", ")", ":", "self", ".", "puts", ".", "flush", "(", ")", "self", ".", "deletes", ".", "flush", "(", ")", "self", ".", "ndb_puts", ".", "flush", "(", ")", "self", ".", "ndb_deletes", ".", "flush", "(", ")" ]
Flush(apply) all changed to datastore.
[ "Flush", "(", "apply", ")", "all", "changed", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L284-L289
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool._flush_puts
def _flush_puts(self, items, options): """Flush all puts to datastore.""" datastore.Put(items, config=self._create_config(options))
python
def _flush_puts(self, items, options): """Flush all puts to datastore.""" datastore.Put(items, config=self._create_config(options))
[ "def", "_flush_puts", "(", "self", ",", "items", ",", "options", ")", ":", "datastore", ".", "Put", "(", "items", ",", "config", "=", "self", ".", "_create_config", "(", "options", ")", ")" ]
Flush all puts to datastore.
[ "Flush", "all", "puts", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L315-L317
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool._flush_deletes
def _flush_deletes(self, items, options): """Flush all deletes to datastore.""" datastore.Delete(items, config=self._create_config(options))
python
def _flush_deletes(self, items, options): """Flush all deletes to datastore.""" datastore.Delete(items, config=self._create_config(options))
[ "def", "_flush_deletes", "(", "self", ",", "items", ",", "options", ")", ":", "datastore", ".", "Delete", "(", "items", ",", "config", "=", "self", ".", "_create_config", "(", "options", ")", ")" ]
Flush all deletes to datastore.
[ "Flush", "all", "deletes", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L319-L321
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool._flush_ndb_puts
def _flush_ndb_puts(self, items, options): """Flush all NDB puts to datastore.""" assert ndb is not None ndb.put_multi(items, config=self._create_config(options))
python
def _flush_ndb_puts(self, items, options): """Flush all NDB puts to datastore.""" assert ndb is not None ndb.put_multi(items, config=self._create_config(options))
[ "def", "_flush_ndb_puts", "(", "self", ",", "items", ",", "options", ")", ":", "assert", "ndb", "is", "not", "None", "ndb", ".", "put_multi", "(", "items", ",", "config", "=", "self", ".", "_create_config", "(", "options", ")", ")" ]
Flush all NDB puts to datastore.
[ "Flush", "all", "NDB", "puts", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L323-L326
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool._flush_ndb_deletes
def _flush_ndb_deletes(self, items, options): """Flush all deletes to datastore.""" assert ndb is not None ndb.delete_multi(items, config=self._create_config(options))
python
def _flush_ndb_deletes(self, items, options): """Flush all deletes to datastore.""" assert ndb is not None ndb.delete_multi(items, config=self._create_config(options))
[ "def", "_flush_ndb_deletes", "(", "self", ",", "items", ",", "options", ")", ":", "assert", "ndb", "is", "not", "None", "ndb", ".", "delete_multi", "(", "items", ",", "config", "=", "self", ".", "_create_config", "(", "options", ")", ")" ]
Flush all deletes to datastore.
[ "Flush", "all", "deletes", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L328-L331
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_MutationPool._create_config
def _create_config(self, options): """Creates datastore Config. Returns: A datastore_rpc.Configuration instance. """ return datastore.CreateConfig(deadline=options["deadline"], force_writes=self.force_writes)
python
def _create_config(self, options): """Creates datastore Config. Returns: A datastore_rpc.Configuration instance. """ return datastore.CreateConfig(deadline=options["deadline"], force_writes=self.force_writes)
[ "def", "_create_config", "(", "self", ",", "options", ")", ":", "return", "datastore", ".", "CreateConfig", "(", "deadline", "=", "options", "[", "\"deadline\"", "]", ",", "force_writes", "=", "self", ".", "force_writes", ")" ]
Creates datastore Config. Returns: A datastore_rpc.Configuration instance.
[ "Creates", "datastore", "Config", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L333-L340
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/context.py
_Counters.increment
def increment(self, counter_name, delta=1): """Increment counter value. Args: counter_name: name of the counter as string. delta: increment delta as int. """ self._shard_state.counters_map.increment(counter_name, delta)
python
def increment(self, counter_name, delta=1): """Increment counter value. Args: counter_name: name of the counter as string. delta: increment delta as int. """ self._shard_state.counters_map.increment(counter_name, delta)
[ "def", "increment", "(", "self", ",", "counter_name", ",", "delta", "=", "1", ")", ":", "self", ".", "_shard_state", ".", "counters_map", ".", "increment", "(", "counter_name", ",", "delta", ")" ]
Increment counter value. Args: counter_name: name of the counter as string. delta: increment delta as int.
[ "Increment", "counter", "value", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L358-L365
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_PropertyRangeModelIterator.to_json
def to_json(self): """Inherit doc.""" cursor = self._cursor if self._query is not None: if isinstance(self._query, db.Query): cursor = self._query.cursor() else: cursor = self._query.cursor_after() if cursor is None or isinstance(cursor, basestring): cursor_object = Fa...
python
def to_json(self): """Inherit doc.""" cursor = self._cursor if self._query is not None: if isinstance(self._query, db.Query): cursor = self._query.cursor() else: cursor = self._query.cursor_after() if cursor is None or isinstance(cursor, basestring): cursor_object = Fa...
[ "def", "to_json", "(", "self", ")", ":", "cursor", "=", "self", ".", "_cursor", "if", "self", ".", "_query", "is", "not", "None", ":", "if", "isinstance", "(", "self", ".", "_query", ",", "db", ".", "Query", ")", ":", "cursor", "=", "self", ".", ...
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L195-L215
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_PropertyRangeModelIterator.from_json
def from_json(cls, json): """Inherit doc.""" obj = cls(property_range.PropertyRange.from_json(json["property_range"]), namespace_range.NamespaceRange.from_json_object(json["ns_range"]), model.QuerySpec.from_json(json["query_spec"])) cursor = json["cursor"] # lint bug. Class m...
python
def from_json(cls, json): """Inherit doc.""" obj = cls(property_range.PropertyRange.from_json(json["property_range"]), namespace_range.NamespaceRange.from_json_object(json["ns_range"]), model.QuerySpec.from_json(json["query_spec"])) cursor = json["cursor"] # lint bug. Class m...
[ "def", "from_json", "(", "cls", ",", "json", ")", ":", "obj", "=", "cls", "(", "property_range", ".", "PropertyRange", ".", "from_json", "(", "json", "[", "\"property_range\"", "]", ")", ",", "namespace_range", ".", "NamespaceRange", ".", "from_json_object", ...
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L222-L234
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_MultiPropertyRangeModelIterator.to_json
def to_json(self): """Inherit doc.""" json = {"name": self.__class__.__name__, "num_ranges": len(self._iters)} for i in xrange(len(self._iters)): json_item = self._iters[i].to_json() query_spec = json_item["query_spec"] item_name = json_item["name"] # Delete and move one...
python
def to_json(self): """Inherit doc.""" json = {"name": self.__class__.__name__, "num_ranges": len(self._iters)} for i in xrange(len(self._iters)): json_item = self._iters[i].to_json() query_spec = json_item["query_spec"] item_name = json_item["name"] # Delete and move one...
[ "def", "to_json", "(", "self", ")", ":", "json", "=", "{", "\"name\"", ":", "self", ".", "__class__", ".", "__name__", ",", "\"num_ranges\"", ":", "len", "(", "self", ".", "_iters", ")", "}", "for", "i", "in", "xrange", "(", "len", "(", "self", "."...
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L262-L279
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_MultiPropertyRangeModelIterator.from_json
def from_json(cls, json): """Inherit doc.""" num_ranges = int(json["num_ranges"]) query_spec = json["query_spec"] item_name = json["item_name"] p_range_iters = [] for i in xrange(num_ranges): json_item = json[str(i)] # Place query_spec, name back into each iterator json_item["...
python
def from_json(cls, json): """Inherit doc.""" num_ranges = int(json["num_ranges"]) query_spec = json["query_spec"] item_name = json["item_name"] p_range_iters = [] for i in xrange(num_ranges): json_item = json[str(i)] # Place query_spec, name back into each iterator json_item["...
[ "def", "from_json", "(", "cls", ",", "json", ")", ":", "num_ranges", "=", "int", "(", "json", "[", "\"num_ranges\"", "]", ")", "query_spec", "=", "json", "[", "\"query_spec\"", "]", "item_name", "=", "json", "[", "\"item_name\"", "]", "p_range_iters", "=",...
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L282-L297
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_KeyRangesIterator.to_json
def to_json(self): """Inherit doc.""" current_iter = None if self._current_iter: current_iter = self._current_iter.to_json() return {"key_ranges": self._key_ranges.to_json(), "query_spec": self._query_spec.to_json(), "current_iter": current_iter, "key_range_ite...
python
def to_json(self): """Inherit doc.""" current_iter = None if self._current_iter: current_iter = self._current_iter.to_json() return {"key_ranges": self._key_ranges.to_json(), "query_spec": self._query_spec.to_json(), "current_iter": current_iter, "key_range_ite...
[ "def", "to_json", "(", "self", ")", ":", "current_iter", "=", "None", "if", "self", ".", "_current_iter", ":", "current_iter", "=", "self", ".", "_current_iter", ".", "to_json", "(", ")", "return", "{", "\"key_ranges\"", ":", "self", ".", "_key_ranges", "....
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L339-L349
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
_KeyRangesIterator.from_json
def from_json(cls, json): """Inherit doc.""" key_range_iter_cls = _KEY_RANGE_ITERATORS[json["key_range_iter_cls"]] obj = cls(key_ranges.KeyRangesFactory.from_json(json["key_ranges"]), model.QuerySpec.from_json(json["query_spec"]), key_range_iter_cls) current_iter = None ...
python
def from_json(cls, json): """Inherit doc.""" key_range_iter_cls = _KEY_RANGE_ITERATORS[json["key_range_iter_cls"]] obj = cls(key_ranges.KeyRangesFactory.from_json(json["key_ranges"]), model.QuerySpec.from_json(json["query_spec"]), key_range_iter_cls) current_iter = None ...
[ "def", "from_json", "(", "cls", ",", "json", ")", ":", "key_range_iter_cls", "=", "_KEY_RANGE_ITERATORS", "[", "json", "[", "\"key_range_iter_cls\"", "]", "]", "obj", "=", "cls", "(", "key_ranges", ".", "KeyRangesFactory", ".", "from_json", "(", "json", "[", ...
Inherit doc.
[ "Inherit", "doc", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L352-L364
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
AbstractKeyRangeIterator.to_json
def to_json(self): """Serializes all states into json form. Returns: all states in json-compatible map. """ cursor = self._get_cursor() cursor_object = False if cursor and isinstance(cursor, datastore_query.Cursor): cursor = cursor.to_websafe_string() cursor_object = True ...
python
def to_json(self): """Serializes all states into json form. Returns: all states in json-compatible map. """ cursor = self._get_cursor() cursor_object = False if cursor and isinstance(cursor, datastore_query.Cursor): cursor = cursor.to_websafe_string() cursor_object = True ...
[ "def", "to_json", "(", "self", ")", ":", "cursor", "=", "self", ".", "_get_cursor", "(", ")", "cursor_object", "=", "False", "if", "cursor", "and", "isinstance", "(", "cursor", ",", "datastore_query", ".", "Cursor", ")", ":", "cursor", "=", "cursor", "."...
Serializes all states into json form. Returns: all states in json-compatible map.
[ "Serializes", "all", "states", "into", "json", "form", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L405-L419
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/datastore_range_iterators.py
AbstractKeyRangeIterator.from_json
def from_json(cls, json): """Reverse of to_json.""" obj = cls(key_range.KeyRange.from_json(json["key_range"]), model.QuerySpec.from_json(json["query_spec"])) cursor = json["cursor"] # lint bug. Class method can access protected fields. # pylint: disable=protected-access if cursor a...
python
def from_json(cls, json): """Reverse of to_json.""" obj = cls(key_range.KeyRange.from_json(json["key_range"]), model.QuerySpec.from_json(json["query_spec"])) cursor = json["cursor"] # lint bug. Class method can access protected fields. # pylint: disable=protected-access if cursor a...
[ "def", "from_json", "(", "cls", ",", "json", ")", ":", "obj", "=", "cls", "(", "key_range", ".", "KeyRange", ".", "from_json", "(", "json", "[", "\"key_range\"", "]", ")", ",", "model", ".", "QuerySpec", ".", "from_json", "(", "json", "[", "\"query_spe...
Reverse of to_json.
[ "Reverse", "of", "to_json", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/datastore_range_iterators.py#L422-L433
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/status.py
find_mapreduce_yaml
def find_mapreduce_yaml(status_file=__file__): """Traverse directory trees to find mapreduce.yaml file. Begins with the location of status.py and then moves on to check the working directory. Args: status_file: location of status.py, overridable for testing purposes. Returns: the path of mapreduce....
python
def find_mapreduce_yaml(status_file=__file__): """Traverse directory trees to find mapreduce.yaml file. Begins with the location of status.py and then moves on to check the working directory. Args: status_file: location of status.py, overridable for testing purposes. Returns: the path of mapreduce....
[ "def", "find_mapreduce_yaml", "(", "status_file", "=", "__file__", ")", ":", "checked", "=", "set", "(", ")", "yaml", "=", "_find_mapreduce_yaml", "(", "os", ".", "path", ".", "dirname", "(", "status_file", ")", ",", "checked", ")", "if", "not", "yaml", ...
Traverse directory trees to find mapreduce.yaml file. Begins with the location of status.py and then moves on to check the working directory. Args: status_file: location of status.py, overridable for testing purposes. Returns: the path of mapreduce.yaml file or None if not found.
[ "Traverse", "directory", "trees", "to", "find", "mapreduce", ".", "yaml", "file", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/status.py#L161-L177
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/status.py
_find_mapreduce_yaml
def _find_mapreduce_yaml(start, checked): """Traverse the directory tree identified by start until a directory already in checked is encountered or the path of mapreduce.yaml is found. Checked is present both to make loop termination easy to reason about and so that the same directories do not get rechecked. ...
python
def _find_mapreduce_yaml(start, checked): """Traverse the directory tree identified by start until a directory already in checked is encountered or the path of mapreduce.yaml is found. Checked is present both to make loop termination easy to reason about and so that the same directories do not get rechecked. ...
[ "def", "_find_mapreduce_yaml", "(", "start", ",", "checked", ")", ":", "dir", "=", "start", "while", "dir", "not", "in", "checked", ":", "checked", ".", "add", "(", "dir", ")", "for", "mr_yaml_name", "in", "MR_YAML_NAMES", ":", "yaml_path", "=", "os", "....
Traverse the directory tree identified by start until a directory already in checked is encountered or the path of mapreduce.yaml is found. Checked is present both to make loop termination easy to reason about and so that the same directories do not get rechecked. Args: start: the path to start in and wor...
[ "Traverse", "the", "directory", "tree", "identified", "by", "start", "until", "a", "directory", "already", "in", "checked", "is", "encountered", "or", "the", "path", "of", "mapreduce", ".", "yaml", "is", "found", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/status.py#L180-L202
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/status.py
parse_mapreduce_yaml
def parse_mapreduce_yaml(contents): """Parses mapreduce.yaml file contents. Args: contents: mapreduce.yaml file contents. Returns: MapReduceYaml object with all the data from original file. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file. """ try: builder = y...
python
def parse_mapreduce_yaml(contents): """Parses mapreduce.yaml file contents. Args: contents: mapreduce.yaml file contents. Returns: MapReduceYaml object with all the data from original file. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file. """ try: builder = y...
[ "def", "parse_mapreduce_yaml", "(", "contents", ")", ":", "try", ":", "builder", "=", "yaml_object", ".", "ObjectBuilder", "(", "MapReduceYaml", ")", "handler", "=", "yaml_builder", ".", "BuilderHandler", "(", "builder", ")", "listener", "=", "yaml_listener", "....
Parses mapreduce.yaml file contents. Args: contents: mapreduce.yaml file contents. Returns: MapReduceYaml object with all the data from original file. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file.
[ "Parses", "mapreduce", ".", "yaml", "file", "contents", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/status.py#L205-L239
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/status.py
get_mapreduce_yaml
def get_mapreduce_yaml(parse=parse_mapreduce_yaml): """Locates mapreduce.yaml, loads and parses its info. Args: parse: Used for testing. Returns: MapReduceYaml object. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file or the file is missing. """ mr_yaml_path = ...
python
def get_mapreduce_yaml(parse=parse_mapreduce_yaml): """Locates mapreduce.yaml, loads and parses its info. Args: parse: Used for testing. Returns: MapReduceYaml object. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file or the file is missing. """ mr_yaml_path = ...
[ "def", "get_mapreduce_yaml", "(", "parse", "=", "parse_mapreduce_yaml", ")", ":", "mr_yaml_path", "=", "find_mapreduce_yaml", "(", ")", "if", "not", "mr_yaml_path", ":", "raise", "errors", ".", "MissingYamlError", "(", ")", "mr_yaml_file", "=", "open", "(", "mr_...
Locates mapreduce.yaml, loads and parses its info. Args: parse: Used for testing. Returns: MapReduceYaml object. Raises: errors.BadYamlError: when contents is not a valid mapreduce.yaml file or the file is missing.
[ "Locates", "mapreduce", ".", "yaml", "loads", "and", "parses", "its", "info", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/status.py#L242-L262
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/status.py
MapReduceYaml.to_dict
def to_dict(mapreduce_yaml): """Converts a MapReduceYaml file into a JSON-encodable dictionary. For use in user-visible UI and internal methods for interfacing with user code (like param validation). as a list Args: mapreduce_yaml: The Pyton representation of the mapreduce.yaml document. Re...
python
def to_dict(mapreduce_yaml): """Converts a MapReduceYaml file into a JSON-encodable dictionary. For use in user-visible UI and internal methods for interfacing with user code (like param validation). as a list Args: mapreduce_yaml: The Pyton representation of the mapreduce.yaml document. Re...
[ "def", "to_dict", "(", "mapreduce_yaml", ")", ":", "all_configs", "=", "[", "]", "for", "config", "in", "mapreduce_yaml", ".", "mapreduce", ":", "out", "=", "{", "\"name\"", ":", "config", ".", "name", ",", "\"mapper_input_reader\"", ":", "config", ".", "m...
Converts a MapReduceYaml file into a JSON-encodable dictionary. For use in user-visible UI and internal methods for interfacing with user code (like param validation). as a list Args: mapreduce_yaml: The Pyton representation of the mapreduce.yaml document. Returns: A list of configuration...
[ "Converts", "a", "MapReduceYaml", "file", "into", "a", "JSON", "-", "encodable", "dictionary", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/status.py#L120-L155
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/input_reader.py
InputReader.validate
def validate(cls, job_config): """Validates relevant parameters. This method can validate fields which it deems relevant. Args: job_config: an instance of map_job.JobConfig. Raises: errors.BadReaderParamsError: required parameters are missing or invalid. """ if job_config.input_re...
python
def validate(cls, job_config): """Validates relevant parameters. This method can validate fields which it deems relevant. Args: job_config: an instance of map_job.JobConfig. Raises: errors.BadReaderParamsError: required parameters are missing or invalid. """ if job_config.input_re...
[ "def", "validate", "(", "cls", ",", "job_config", ")", ":", "if", "job_config", ".", "input_reader_cls", "!=", "cls", ":", "raise", "errors", ".", "BadReaderParamsError", "(", "\"Expect input reader class %r, got %r.\"", "%", "(", "cls", ",", "job_config", ".", ...
Validates relevant parameters. This method can validate fields which it deems relevant. Args: job_config: an instance of map_job.JobConfig. Raises: errors.BadReaderParamsError: required parameters are missing or invalid.
[ "Validates", "relevant", "parameters", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/input_reader.py#L104-L118
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_sort_records_map
def _sort_records_map(records): """Map function sorting records. Converts records to KeyValue protos, sorts them by key and writes them into new GCS file. Creates _OutputFile entity to record resulting file name. Args: records: list of records which are serialized KeyValue protos. """ ctx = context....
python
def _sort_records_map(records): """Map function sorting records. Converts records to KeyValue protos, sorts them by key and writes them into new GCS file. Creates _OutputFile entity to record resulting file name. Args: records: list of records which are serialized KeyValue protos. """ ctx = context....
[ "def", "_sort_records_map", "(", "records", ")", ":", "ctx", "=", "context", ".", "get", "(", ")", "l", "=", "len", "(", "records", ")", "key_records", "=", "[", "None", "]", "*", "l", "logging", ".", "debug", "(", "\"Parsing\"", ")", "for", "i", "...
Map function sorting records. Converts records to KeyValue protos, sorts them by key and writes them into new GCS file. Creates _OutputFile entity to record resulting file name. Args: records: list of records which are serialized KeyValue protos.
[ "Map", "function", "sorting", "records", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L124-L164
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_merge_map
def _merge_map(key, values, partial): """A map function used in merge phase. Stores (key, values) into KeyValues proto and yields its serialization. Args: key: values key. values: values themselves. partial: True if more values for this key will follow. False otherwise. Yields: The proto. "...
python
def _merge_map(key, values, partial): """A map function used in merge phase. Stores (key, values) into KeyValues proto and yields its serialization. Args: key: values key. values: values themselves. partial: True if more values for this key will follow. False otherwise. Yields: The proto. "...
[ "def", "_merge_map", "(", "key", ",", "values", ",", "partial", ")", ":", "proto", "=", "kv_pb", ".", "KeyValues", "(", ")", "proto", ".", "set_key", "(", "key", ")", "proto", ".", "value_list", "(", ")", ".", "extend", "(", "values", ")", "yield", ...
A map function used in merge phase. Stores (key, values) into KeyValues proto and yields its serialization. Args: key: values key. values: values themselves. partial: True if more values for this key will follow. False otherwise. Yields: The proto.
[ "A", "map", "function", "used", "in", "merge", "phase", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L561-L577
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_hashing_map
def _hashing_map(binary_record): """A map function used in hash phase. Reads KeyValue from binary record. Args: binary_record: The binary record. Yields: The (key, value). """ proto = kv_pb.KeyValue() proto.ParseFromString(binary_record) yield (proto.key(), proto.value())
python
def _hashing_map(binary_record): """A map function used in hash phase. Reads KeyValue from binary record. Args: binary_record: The binary record. Yields: The (key, value). """ proto = kv_pb.KeyValue() proto.ParseFromString(binary_record) yield (proto.key(), proto.value())
[ "def", "_hashing_map", "(", "binary_record", ")", ":", "proto", "=", "kv_pb", ".", "KeyValue", "(", ")", "proto", ".", "ParseFromString", "(", "binary_record", ")", "yield", "(", "proto", ".", "key", "(", ")", ",", "proto", ".", "value", "(", ")", ")" ...
A map function used in hash phase. Reads KeyValue from binary record. Args: binary_record: The binary record. Yields: The (key, value).
[ "A", "map", "function", "used", "in", "hash", "phase", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L618-L631
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_MergingReader.split_input
def split_input(cls, mapper_spec): """Split input into multiple shards.""" filelists = mapper_spec.params[cls.FILES_PARAM] max_values_count = mapper_spec.params.get(cls.MAX_VALUES_COUNT_PARAM, -1) max_values_size = mapper_spec.params.get(cls.MAX_VALUES_SIZE_PARAM, -1) return [cls([0] * len(files), m...
python
def split_input(cls, mapper_spec): """Split input into multiple shards.""" filelists = mapper_spec.params[cls.FILES_PARAM] max_values_count = mapper_spec.params.get(cls.MAX_VALUES_COUNT_PARAM, -1) max_values_size = mapper_spec.params.get(cls.MAX_VALUES_SIZE_PARAM, -1) return [cls([0] * len(files), m...
[ "def", "split_input", "(", "cls", ",", "mapper_spec", ")", ":", "filelists", "=", "mapper_spec", ".", "params", "[", "cls", ".", "FILES_PARAM", "]", "max_values_count", "=", "mapper_spec", ".", "params", ".", "get", "(", "cls", ".", "MAX_VALUES_COUNT_PARAM", ...
Split input into multiple shards.
[ "Split", "input", "into", "multiple", "shards", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L386-L392
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_MergingReader.validate
def validate(cls, mapper_spec): """Validate reader parameters in mapper_spec.""" if mapper_spec.input_reader_class() != cls: raise errors.BadReaderParamsError("Input reader class mismatch") params = mapper_spec.params if cls.FILES_PARAM not in params: raise errors.BadReaderParamsError("Missi...
python
def validate(cls, mapper_spec): """Validate reader parameters in mapper_spec.""" if mapper_spec.input_reader_class() != cls: raise errors.BadReaderParamsError("Input reader class mismatch") params = mapper_spec.params if cls.FILES_PARAM not in params: raise errors.BadReaderParamsError("Missi...
[ "def", "validate", "(", "cls", ",", "mapper_spec", ")", ":", "if", "mapper_spec", ".", "input_reader_class", "(", ")", "!=", "cls", ":", "raise", "errors", ".", "BadReaderParamsError", "(", "\"Input reader class mismatch\"", ")", "params", "=", "mapper_spec", "....
Validate reader parameters in mapper_spec.
[ "Validate", "reader", "parameters", "in", "mapper_spec", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L395-L401
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.validate
def validate(cls, mapper_spec): """Validates mapper specification. Args: mapper_spec: an instance of model.MapperSpec to validate. Raises: BadWriterParamsError: when Output writer class mismatch. """ if mapper_spec.output_writer_class() != cls: raise errors.BadWriterParamsError("O...
python
def validate(cls, mapper_spec): """Validates mapper specification. Args: mapper_spec: an instance of model.MapperSpec to validate. Raises: BadWriterParamsError: when Output writer class mismatch. """ if mapper_spec.output_writer_class() != cls: raise errors.BadWriterParamsError("O...
[ "def", "validate", "(", "cls", ",", "mapper_spec", ")", ":", "if", "mapper_spec", ".", "output_writer_class", "(", ")", "!=", "cls", ":", "raise", "errors", ".", "BadWriterParamsError", "(", "\"Output writer class mismatch\"", ")", "params", "=", "output_writers",...
Validates mapper specification. Args: mapper_spec: an instance of model.MapperSpec to validate. Raises: BadWriterParamsError: when Output writer class mismatch.
[ "Validates", "mapper", "specification", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L429-L444
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.to_json
def to_json(self): """Returns writer state to serialize in json. Returns: A json-izable version of the OutputWriter state. """ # Use the member variable (since we don't have access to the context) to # flush each pool to minimize the size of each filehandle before we # serialize it. f...
python
def to_json(self): """Returns writer state to serialize in json. Returns: A json-izable version of the OutputWriter state. """ # Use the member variable (since we don't have access to the context) to # flush each pool to minimize the size of each filehandle before we # serialize it. f...
[ "def", "to_json", "(", "self", ")", ":", "# Use the member variable (since we don't have access to the context) to", "# flush each pool to minimize the size of each filehandle before we", "# serialize it.", "for", "pool", "in", "self", ".", "_pools", ":", "if", "pool", "is", "n...
Returns writer state to serialize in json. Returns: A json-izable version of the OutputWriter state.
[ "Returns", "writer", "state", "to", "serialize", "in", "json", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L458-L470
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.create
def create(cls, mr_spec, shard_number, shard_attempt, _writer_state=None): """Inherit docs.""" mapper_spec = mr_spec.mapper params = output_writers._get_params(mapper_spec) bucket_name = params.get(cls.BUCKET_NAME_PARAM) shards = mapper_spec.shard_count filehandles = [] filename = (mr_spec....
python
def create(cls, mr_spec, shard_number, shard_attempt, _writer_state=None): """Inherit docs.""" mapper_spec = mr_spec.mapper params = output_writers._get_params(mapper_spec) bucket_name = params.get(cls.BUCKET_NAME_PARAM) shards = mapper_spec.shard_count filehandles = [] filename = (mr_spec....
[ "def", "create", "(", "cls", ",", "mr_spec", ",", "shard_number", ",", "shard_attempt", ",", "_writer_state", "=", "None", ")", ":", "mapper_spec", "=", "mr_spec", ".", "mapper", "params", "=", "output_writers", ".", "_get_params", "(", "mapper_spec", ")", "...
Inherit docs.
[ "Inherit", "docs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L473-L486
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.get_filenames
def get_filenames(cls, mapreduce_state): """See parent class.""" shards = mapreduce_state.mapreduce_spec.mapper.shard_count filenames = [] for _ in range(shards): filenames.append([None] * shards) shard_states = model.ShardState.find_all_by_mapreduce_state(mapreduce_state) for x, shard_sta...
python
def get_filenames(cls, mapreduce_state): """See parent class.""" shards = mapreduce_state.mapreduce_spec.mapper.shard_count filenames = [] for _ in range(shards): filenames.append([None] * shards) shard_states = model.ShardState.find_all_by_mapreduce_state(mapreduce_state) for x, shard_sta...
[ "def", "get_filenames", "(", "cls", ",", "mapreduce_state", ")", ":", "shards", "=", "mapreduce_state", ".", "mapreduce_spec", ".", "mapper", ".", "shard_count", "filenames", "=", "[", "]", "for", "_", "in", "range", "(", "shards", ")", ":", "filenames", "...
See parent class.
[ "See", "parent", "class", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L489-L500
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.finalize
def finalize(self, ctx, shard_state): """See parent class.""" filenames = [] for filehandle in self._filehandles: filenames.append(filehandle.name) filehandle.close() shard_state.writer_state = {"shard_filenames": filenames}
python
def finalize(self, ctx, shard_state): """See parent class.""" filenames = [] for filehandle in self._filehandles: filenames.append(filehandle.name) filehandle.close() shard_state.writer_state = {"shard_filenames": filenames}
[ "def", "finalize", "(", "self", ",", "ctx", ",", "shard_state", ")", ":", "filenames", "=", "[", "]", "for", "filehandle", "in", "self", ".", "_filehandles", ":", "filenames", ".", "append", "(", "filehandle", ".", "name", ")", "filehandle", ".", "close"...
See parent class.
[ "See", "parent", "class", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L502-L508
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/shuffler.py
_HashingGCSOutputWriter.write
def write(self, data): """Write data. Args: data: actual data yielded from handler. Type is writer-specific. """ ctx = context.get() if len(data) != 2: logging.error("Got bad tuple of length %d (2-tuple expected): %s", len(data), data) try: key = str(data[...
python
def write(self, data): """Write data. Args: data: actual data yielded from handler. Type is writer-specific. """ ctx = context.get() if len(data) != 2: logging.error("Got bad tuple of length %d (2-tuple expected): %s", len(data), data) try: key = str(data[...
[ "def", "write", "(", "self", ",", "data", ")", ":", "ctx", "=", "context", ".", "get", "(", ")", "if", "len", "(", "data", ")", "!=", "2", ":", "logging", ".", "error", "(", "\"Got bad tuple of length %d (2-tuple expected): %s\"", ",", "len", "(", "data"...
Write data. Args: data: actual data yielded from handler. Type is writer-specific.
[ "Write", "data", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/shuffler.py#L510-L543
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_config.py
JobConfig._get_mapper_params
def _get_mapper_params(self): """Converts self to model.MapperSpec.params.""" reader_params = self.input_reader_cls.params_to_json( self.input_reader_params) # TODO(user): Do the same for writer params. return {"input_reader": reader_params, "output_writer": self.output_writer_params...
python
def _get_mapper_params(self): """Converts self to model.MapperSpec.params.""" reader_params = self.input_reader_cls.params_to_json( self.input_reader_params) # TODO(user): Do the same for writer params. return {"input_reader": reader_params, "output_writer": self.output_writer_params...
[ "def", "_get_mapper_params", "(", "self", ")", ":", "reader_params", "=", "self", ".", "input_reader_cls", ".", "params_to_json", "(", "self", ".", "input_reader_params", ")", "# TODO(user): Do the same for writer params.", "return", "{", "\"input_reader\"", ":", "reade...
Converts self to model.MapperSpec.params.
[ "Converts", "self", "to", "model", ".", "MapperSpec", ".", "params", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_config.py#L114-L120
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_config.py
JobConfig._get_mapper_spec
def _get_mapper_spec(self): """Converts self to model.MapperSpec.""" # pylint: disable=g-import-not-at-top from mapreduce import model return model.MapperSpec( handler_spec=util._obj_to_path(self.mapper), input_reader_spec=util._obj_to_path(self.input_reader_cls), params=self._g...
python
def _get_mapper_spec(self): """Converts self to model.MapperSpec.""" # pylint: disable=g-import-not-at-top from mapreduce import model return model.MapperSpec( handler_spec=util._obj_to_path(self.mapper), input_reader_spec=util._obj_to_path(self.input_reader_cls), params=self._g...
[ "def", "_get_mapper_spec", "(", "self", ")", ":", "# pylint: disable=g-import-not-at-top", "from", "mapreduce", "import", "model", "return", "model", ".", "MapperSpec", "(", "handler_spec", "=", "util", ".", "_obj_to_path", "(", "self", ".", "mapper", ")", ",", ...
Converts self to model.MapperSpec.
[ "Converts", "self", "to", "model", ".", "MapperSpec", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_config.py#L122-L132
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_config.py
JobConfig._get_mr_params
def _get_mr_params(self): """Converts self to model.MapreduceSpec.params.""" return {"force_writes": self._force_writes, "done_callback": self.done_callback_url, "user_params": self.user_params, "shard_max_attempts": self.shard_max_attempts, "task_max_attempts": s...
python
def _get_mr_params(self): """Converts self to model.MapreduceSpec.params.""" return {"force_writes": self._force_writes, "done_callback": self.done_callback_url, "user_params": self.user_params, "shard_max_attempts": self.shard_max_attempts, "task_max_attempts": s...
[ "def", "_get_mr_params", "(", "self", ")", ":", "return", "{", "\"force_writes\"", ":", "self", ".", "_force_writes", ",", "\"done_callback\"", ":", "self", ".", "done_callback_url", ",", "\"user_params\"", ":", "self", ".", "user_params", ",", "\"shard_max_attemp...
Converts self to model.MapreduceSpec.params.
[ "Converts", "self", "to", "model", ".", "MapreduceSpec", ".", "params", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_config.py#L134-L146
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_config.py
JobConfig._get_default_mr_params
def _get_default_mr_params(cls): """Gets default values for old API.""" cfg = cls(_lenient=True) mr_params = cfg._get_mr_params() mr_params["api_version"] = 0 return mr_params
python
def _get_default_mr_params(cls): """Gets default values for old API.""" cfg = cls(_lenient=True) mr_params = cfg._get_mr_params() mr_params["api_version"] = 0 return mr_params
[ "def", "_get_default_mr_params", "(", "cls", ")", ":", "cfg", "=", "cls", "(", "_lenient", "=", "True", ")", "mr_params", "=", "cfg", ".", "_get_mr_params", "(", ")", "mr_params", "[", "\"api_version\"", "]", "=", "0", "return", "mr_params" ]
Gets default values for old API.
[ "Gets", "default", "values", "for", "old", "API", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_config.py#L154-L159
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_config.py
JobConfig._to_map_job_config
def _to_map_job_config(cls, mr_spec, # TODO(user): Remove this parameter after it can be # read from mr_spec. queue_name): """Converts model.MapreduceSpec back to JobConfig. This method allows our internal metho...
python
def _to_map_job_config(cls, mr_spec, # TODO(user): Remove this parameter after it can be # read from mr_spec. queue_name): """Converts model.MapreduceSpec back to JobConfig. This method allows our internal metho...
[ "def", "_to_map_job_config", "(", "cls", ",", "mr_spec", ",", "# TODO(user): Remove this parameter after it can be", "# read from mr_spec.", "queue_name", ")", ":", "mapper_spec", "=", "mr_spec", ".", "mapper", "# 0 means all the old APIs before api_version is introduced.", "api_...
Converts model.MapreduceSpec back to JobConfig. This method allows our internal methods to use JobConfig directly. This method also allows us to expose JobConfig as an API during execution, despite that it is not saved into datastore. Args: mr_spec: model.MapreduceSpec. queue_name: queue n...
[ "Converts", "model", ".", "MapreduceSpec", "back", "to", "JobConfig", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_config.py#L162-L226
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsWriter.__write_record
def __write_record(self, record_type, data): """Write single physical record.""" length = len(data) crc = crc32c.crc_update(crc32c.CRC_INIT, [record_type]) crc = crc32c.crc_update(crc, data) crc = crc32c.crc_finalize(crc) self.__writer.write( struct.pack(_HEADER_FORMAT, _mask_crc(crc),...
python
def __write_record(self, record_type, data): """Write single physical record.""" length = len(data) crc = crc32c.crc_update(crc32c.CRC_INIT, [record_type]) crc = crc32c.crc_update(crc, data) crc = crc32c.crc_finalize(crc) self.__writer.write( struct.pack(_HEADER_FORMAT, _mask_crc(crc),...
[ "def", "__write_record", "(", "self", ",", "record_type", ",", "data", ")", ":", "length", "=", "len", "(", "data", ")", "crc", "=", "crc32c", ".", "crc_update", "(", "crc32c", ".", "CRC_INIT", ",", "[", "record_type", "]", ")", "crc", "=", "crc32c", ...
Write single physical record.
[ "Write", "single", "physical", "record", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L160-L171
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsWriter.write
def write(self, data): """Write single record. Args: data: record data to write as string, byte array or byte sequence. """ block_remaining = _BLOCK_SIZE - self.__position % _BLOCK_SIZE if block_remaining < _HEADER_LENGTH: # Header won't fit into remainder self.__writer.write('\x...
python
def write(self, data): """Write single record. Args: data: record data to write as string, byte array or byte sequence. """ block_remaining = _BLOCK_SIZE - self.__position % _BLOCK_SIZE if block_remaining < _HEADER_LENGTH: # Header won't fit into remainder self.__writer.write('\x...
[ "def", "write", "(", "self", ",", "data", ")", ":", "block_remaining", "=", "_BLOCK_SIZE", "-", "self", ".", "__position", "%", "_BLOCK_SIZE", "if", "block_remaining", "<", "_HEADER_LENGTH", ":", "# Header won't fit into remainder", "self", ".", "__writer", ".", ...
Write single record. Args: data: record data to write as string, byte array or byte sequence.
[ "Write", "single", "record", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L173-L202
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsWriter._pad_block
def _pad_block(self): """Pad block with 0. Pad current block with 0. Reader will simply treat these as corrupted record and skip the block. This method is idempotent. """ pad_length = _BLOCK_SIZE - self.__position % _BLOCK_SIZE if pad_length and pad_length != _BLOCK_SIZE: self.__writ...
python
def _pad_block(self): """Pad block with 0. Pad current block with 0. Reader will simply treat these as corrupted record and skip the block. This method is idempotent. """ pad_length = _BLOCK_SIZE - self.__position % _BLOCK_SIZE if pad_length and pad_length != _BLOCK_SIZE: self.__writ...
[ "def", "_pad_block", "(", "self", ")", ":", "pad_length", "=", "_BLOCK_SIZE", "-", "self", ".", "__position", "%", "_BLOCK_SIZE", "if", "pad_length", "and", "pad_length", "!=", "_BLOCK_SIZE", ":", "self", ".", "__writer", ".", "write", "(", "'\\x00'", "*", ...
Pad block with 0. Pad current block with 0. Reader will simply treat these as corrupted record and skip the block. This method is idempotent.
[ "Pad", "block", "with", "0", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L213-L224
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsReader.__try_read_record
def __try_read_record(self): """Try reading a record. Returns: (data, record_type) tuple. Raises: EOFError: when end of file was reached. InvalidRecordError: when valid record could not be read. """ block_remaining = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE if block_re...
python
def __try_read_record(self): """Try reading a record. Returns: (data, record_type) tuple. Raises: EOFError: when end of file was reached. InvalidRecordError: when valid record could not be read. """ block_remaining = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE if block_re...
[ "def", "__try_read_record", "(", "self", ")", ":", "block_remaining", "=", "_BLOCK_SIZE", "-", "self", ".", "__reader", ".", "tell", "(", ")", "%", "_BLOCK_SIZE", "if", "block_remaining", "<", "_HEADER_LENGTH", ":", "return", "(", "''", ",", "_RECORD_TYPE_NONE...
Try reading a record. Returns: (data, record_type) tuple. Raises: EOFError: when end of file was reached. InvalidRecordError: when valid record could not be read.
[ "Try", "reading", "a", "record", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L239-L278
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsReader.__sync
def __sync(self): """Skip reader to the block boundary.""" pad_length = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE if pad_length and pad_length != _BLOCK_SIZE: data = self.__reader.read(pad_length) if len(data) != pad_length: raise EOFError('Read %d bytes instead of %d' % ...
python
def __sync(self): """Skip reader to the block boundary.""" pad_length = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE if pad_length and pad_length != _BLOCK_SIZE: data = self.__reader.read(pad_length) if len(data) != pad_length: raise EOFError('Read %d bytes instead of %d' % ...
[ "def", "__sync", "(", "self", ")", ":", "pad_length", "=", "_BLOCK_SIZE", "-", "self", ".", "__reader", ".", "tell", "(", ")", "%", "_BLOCK_SIZE", "if", "pad_length", "and", "pad_length", "!=", "_BLOCK_SIZE", ":", "data", "=", "self", ".", "__reader", "....
Skip reader to the block boundary.
[ "Skip", "reader", "to", "the", "block", "boundary", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L280-L287
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/records.py
RecordsReader.read
def read(self): """Reads record from current position in reader. Returns: original bytes stored in a single record. """ data = None while True: last_offset = self.tell() try: (chunk, record_type) = self.__try_read_record() if record_type == _RECORD_TYPE_NONE: ...
python
def read(self): """Reads record from current position in reader. Returns: original bytes stored in a single record. """ data = None while True: last_offset = self.tell() try: (chunk, record_type) = self.__try_read_record() if record_type == _RECORD_TYPE_NONE: ...
[ "def", "read", "(", "self", ")", ":", "data", "=", "None", "while", "True", ":", "last_offset", "=", "self", ".", "tell", "(", ")", "try", ":", "(", "chunk", ",", "record_type", ")", "=", "self", ".", "__try_read_record", "(", ")", "if", "record_type...
Reads record from current position in reader. Returns: original bytes stored in a single record.
[ "Reads", "record", "from", "current", "position", "in", "reader", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/records.py#L289-L338
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/mapper_pipeline.py
MapperPipeline.run
def run(self, job_name, handler_spec, input_reader_spec, output_writer_spec=None, params=None, shards=None, base_path=None): """Start a mapreduce job. Args: job_name: mapreduce name. Only for display purpose. handler_spec: fully ...
python
def run(self, job_name, handler_spec, input_reader_spec, output_writer_spec=None, params=None, shards=None, base_path=None): """Start a mapreduce job. Args: job_name: mapreduce name. Only for display purpose. handler_spec: fully ...
[ "def", "run", "(", "self", ",", "job_name", ",", "handler_spec", ",", "input_reader_spec", ",", "output_writer_spec", "=", "None", ",", "params", "=", "None", ",", "shards", "=", "None", ",", "base_path", "=", "None", ")", ":", "if", "shards", "is", "Non...
Start a mapreduce job. Args: job_name: mapreduce name. Only for display purpose. handler_spec: fully qualified name to your map function/class. input_reader_spec: fully qualified name to input reader class. output_writer_spec: fully qualified name to output writer class. params: a dic...
[ "Start", "a", "mapreduce", "job", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/mapper_pipeline.py#L65-L106
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/mapper_pipeline.py
MapperPipeline.callback
def callback(self): """Callback after this async pipeline finishes.""" if self.was_aborted: return mapreduce_id = self.outputs.job_id.value mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id) if mapreduce_state.result_status != model.MapreduceState.RESULT_SUCCESS: self.re...
python
def callback(self): """Callback after this async pipeline finishes.""" if self.was_aborted: return mapreduce_id = self.outputs.job_id.value mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id) if mapreduce_state.result_status != model.MapreduceState.RESULT_SUCCESS: self.re...
[ "def", "callback", "(", "self", ")", ":", "if", "self", ".", "was_aborted", ":", "return", "mapreduce_id", "=", "self", ".", "outputs", ".", "job_id", ".", "value", "mapreduce_state", "=", "model", ".", "MapreduceState", ".", "get_by_job_id", "(", "mapreduce...
Callback after this async pipeline finishes.
[ "Callback", "after", "this", "async", "pipeline", "finishes", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/mapper_pipeline.py#L112-L133
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/control.py
start_map
def start_map(name, handler_spec, reader_spec, mapper_parameters, shard_count=None, output_writer_spec=None, mapreduce_parameters=None, base_path=None, queue_name=None, eta=None, c...
python
def start_map(name, handler_spec, reader_spec, mapper_parameters, shard_count=None, output_writer_spec=None, mapreduce_parameters=None, base_path=None, queue_name=None, eta=None, c...
[ "def", "start_map", "(", "name", ",", "handler_spec", ",", "reader_spec", ",", "mapper_parameters", ",", "shard_count", "=", "None", ",", "output_writer_spec", "=", "None", ",", "mapreduce_parameters", "=", "None", ",", "base_path", "=", "None", ",", "queue_name...
Start a new, mapper-only mapreduce. Deprecated! Use map_job.start instead. If a value can be specified both from an explicit argument and from a dictionary, the value from the explicit argument wins. Args: name: mapreduce name. Used only for display purposes. handler_spec: fully qualified name of map...
[ "Start", "a", "new", "mapper", "-", "only", "mapreduce", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/control.py#L37-L125
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.get_status
def get_status(self): """Get status enum. Returns: One of the status enum. """ self.__update_state() if self._state.active: return self.RUNNING else: return self._state.result_status
python
def get_status(self): """Get status enum. Returns: One of the status enum. """ self.__update_state() if self._state.active: return self.RUNNING else: return self._state.result_status
[ "def", "get_status", "(", "self", ")", ":", "self", ".", "__update_state", "(", ")", "if", "self", ".", "_state", ".", "active", ":", "return", "self", ".", "RUNNING", "else", ":", "return", "self", ".", "_state", ".", "result_status" ]
Get status enum. Returns: One of the status enum.
[ "Get", "status", "enum", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L70-L80
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.get_counter
def get_counter(self, counter_name, default=0): """Get the value of the named counter from this job. When a job is running, counter values won't be very accurate. Args: counter_name: name of the counter in string. default: default value if the counter doesn't exist. Returns: Value i...
python
def get_counter(self, counter_name, default=0): """Get the value of the named counter from this job. When a job is running, counter values won't be very accurate. Args: counter_name: name of the counter in string. default: default value if the counter doesn't exist. Returns: Value i...
[ "def", "get_counter", "(", "self", ",", "counter_name", ",", "default", "=", "0", ")", ":", "self", ".", "__update_state", "(", ")", "return", "self", ".", "_state", ".", "counters_map", ".", "get", "(", "counter_name", ",", "default", ")" ]
Get the value of the named counter from this job. When a job is running, counter values won't be very accurate. Args: counter_name: name of the counter in string. default: default value if the counter doesn't exist. Returns: Value in int of the named counter.
[ "Get", "the", "value", "of", "the", "named", "counter", "from", "this", "job", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L98-L111
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.get_outputs
def get_outputs(self): """Get outputs of this job. Should only call if status is SUCCESS. Yields: Iterators, one for each shard. Each iterator is from the argument of map_job.output_writer.commit_output. """ assert self.SUCCESS == self.get_status() ss = model.ShardState.find_all_by...
python
def get_outputs(self): """Get outputs of this job. Should only call if status is SUCCESS. Yields: Iterators, one for each shard. Each iterator is from the argument of map_job.output_writer.commit_output. """ assert self.SUCCESS == self.get_status() ss = model.ShardState.find_all_by...
[ "def", "get_outputs", "(", "self", ")", ":", "assert", "self", ".", "SUCCESS", "==", "self", ".", "get_status", "(", ")", "ss", "=", "model", ".", "ShardState", ".", "find_all_by_mapreduce_state", "(", "self", ".", "_state", ")", "for", "s", "in", "ss", ...
Get outputs of this job. Should only call if status is SUCCESS. Yields: Iterators, one for each shard. Each iterator is from the argument of map_job.output_writer.commit_output.
[ "Get", "outputs", "of", "this", "job", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L113-L125
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.submit
def submit(cls, job_config, in_xg_transaction=False): """Submit the job to run. Args: job_config: an instance of map_job.MapJobConfig. in_xg_transaction: controls what transaction scope to use to start this MR job. If True, there has to be an already opened cross-group transaction s...
python
def submit(cls, job_config, in_xg_transaction=False): """Submit the job to run. Args: job_config: an instance of map_job.MapJobConfig. in_xg_transaction: controls what transaction scope to use to start this MR job. If True, there has to be an already opened cross-group transaction s...
[ "def", "submit", "(", "cls", ",", "job_config", ",", "in_xg_transaction", "=", "False", ")", ":", "cls", ".", "__validate_job_config", "(", "job_config", ")", "mapper_spec", "=", "job_config", ".", "_get_mapper_spec", "(", ")", "# Create mr spec.", "mapreduce_para...
Submit the job to run. Args: job_config: an instance of map_job.MapJobConfig. in_xg_transaction: controls what transaction scope to use to start this MR job. If True, there has to be an already opened cross-group transaction scope. MR will use one entity group from it. If False,...
[ "Submit", "the", "job", "to", "run", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L128-L168
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.__update_state
def __update_state(self): """Fetches most up to date state from db.""" # Only if the job was not in a terminal state. if self._state.active: self._state = self.__get_state_by_id(self.job_config.job_id)
python
def __update_state(self): """Fetches most up to date state from db.""" # Only if the job was not in a terminal state. if self._state.active: self._state = self.__get_state_by_id(self.job_config.job_id)
[ "def", "__update_state", "(", "self", ")", ":", "# Only if the job was not in a terminal state.", "if", "self", ".", "_state", ".", "active", ":", "self", ".", "_state", "=", "self", ".", "__get_state_by_id", "(", "self", ".", "job_config", ".", "job_id", ")" ]
Fetches most up to date state from db.
[ "Fetches", "most", "up", "to", "date", "state", "from", "db", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L170-L174
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.__get_state_by_id
def __get_state_by_id(cls, job_id): """Get job state by id. Args: job_id: job id. Returns: model.MapreduceState for the job. Raises: ValueError: if the job state is missing. """ state = model.MapreduceState.get_by_job_id(job_id) if state is None: raise ValueError("...
python
def __get_state_by_id(cls, job_id): """Get job state by id. Args: job_id: job id. Returns: model.MapreduceState for the job. Raises: ValueError: if the job state is missing. """ state = model.MapreduceState.get_by_job_id(job_id) if state is None: raise ValueError("...
[ "def", "__get_state_by_id", "(", "cls", ",", "job_id", ")", ":", "state", "=", "model", ".", "MapreduceState", ".", "get_by_job_id", "(", "job_id", ")", "if", "state", "is", "None", ":", "raise", "ValueError", "(", "\"Job state for job %s is missing.\"", "%", ...
Get job state by id. Args: job_id: job id. Returns: model.MapreduceState for the job. Raises: ValueError: if the job state is missing.
[ "Get", "job", "state", "by", "id", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L177-L192
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.__create_and_save_state
def __create_and_save_state(cls, job_config, mapreduce_spec): """Save map job state to datastore. Save state to datastore so that UI can see it immediately. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec. Returns: model.MapreduceState for this job. """ ...
python
def __create_and_save_state(cls, job_config, mapreduce_spec): """Save map job state to datastore. Save state to datastore so that UI can see it immediately. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec. Returns: model.MapreduceState for this job. """ ...
[ "def", "__create_and_save_state", "(", "cls", ",", "job_config", ",", "mapreduce_spec", ")", ":", "state", "=", "model", ".", "MapreduceState", ".", "create_new", "(", "job_config", ".", "job_id", ")", "state", ".", "mapreduce_spec", "=", "mapreduce_spec", "stat...
Save map job state to datastore. Save state to datastore so that UI can see it immediately. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec. Returns: model.MapreduceState for this job.
[ "Save", "map", "job", "state", "to", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L202-L221
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/map_job_control.py
Job.__add_kickoff_task
def __add_kickoff_task(cls, job_config, mapreduce_spec): """Add kickoff task to taskqueue. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec, """ params = {"mapreduce_id": job_config.job_id} # Task is not named so that it can be added within a transaction. kic...
python
def __add_kickoff_task(cls, job_config, mapreduce_spec): """Add kickoff task to taskqueue. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec, """ params = {"mapreduce_id": job_config.job_id} # Task is not named so that it can be added within a transaction. kic...
[ "def", "__add_kickoff_task", "(", "cls", ",", "job_config", ",", "mapreduce_spec", ")", ":", "params", "=", "{", "\"mapreduce_id\"", ":", "job_config", ".", "job_id", "}", "# Task is not named so that it can be added within a transaction.", "kickoff_task", "=", "taskqueue...
Add kickoff task to taskqueue. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec,
[ "Add", "kickoff", "task", "to", "taskqueue", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/map_job_control.py#L224-L245
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
JsonMixin.to_json_str
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ _json = self.to_json() try: return json.dumps(_json, sort_keys=True, cls=JsonEncoder) except: logging.exception("Could not serialize JSON: %r", _json) raise
python
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ _json = self.to_json() try: return json.dumps(_json, sort_keys=True, cls=JsonEncoder) except: logging.exception("Could not serialize JSON: %r", _json) raise
[ "def", "to_json_str", "(", "self", ")", ":", "_json", "=", "self", ".", "to_json", "(", ")", "try", ":", "return", "json", ".", "dumps", "(", "_json", ",", "sort_keys", "=", "True", ",", "cls", "=", "JsonEncoder", ")", "except", ":", "logging", ".", ...
Convert data to json string representation. Returns: json representation as string.
[ "Convert", "data", "to", "json", "string", "representation", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L135-L146
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
JsonMixin.from_json_str
def from_json_str(cls, json_str): """Convert json string representation into class instance. Args: json_str: json representation as string. Returns: New instance of the class with data loaded from json string. """ return cls.from_json(json.loads(json_str, cls=JsonDecoder))
python
def from_json_str(cls, json_str): """Convert json string representation into class instance. Args: json_str: json representation as string. Returns: New instance of the class with data loaded from json string. """ return cls.from_json(json.loads(json_str, cls=JsonDecoder))
[ "def", "from_json_str", "(", "cls", ",", "json_str", ")", ":", "return", "cls", ".", "from_json", "(", "json", ".", "loads", "(", "json_str", ",", "cls", "=", "JsonDecoder", ")", ")" ]
Convert json string representation into class instance. Args: json_str: json representation as string. Returns: New instance of the class with data loaded from json string.
[ "Convert", "json", "string", "representation", "into", "class", "instance", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L149-L158
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
JsonProperty.get_value_for_datastore
def get_value_for_datastore(self, model_instance): """Gets value for datastore. Args: model_instance: instance of the model class. Returns: datastore-compatible value. """ value = super(JsonProperty, self).get_value_for_datastore(model_instance) if not value: return None ...
python
def get_value_for_datastore(self, model_instance): """Gets value for datastore. Args: model_instance: instance of the model class. Returns: datastore-compatible value. """ value = super(JsonProperty, self).get_value_for_datastore(model_instance) if not value: return None ...
[ "def", "get_value_for_datastore", "(", "self", ",", "model_instance", ")", ":", "value", "=", "super", "(", "JsonProperty", ",", "self", ")", ".", "get_value_for_datastore", "(", "model_instance", ")", "if", "not", "value", ":", "return", "None", "json_value", ...
Gets value for datastore. Args: model_instance: instance of the model class. Returns: datastore-compatible value.
[ "Gets", "value", "for", "datastore", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L183-L201
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
JsonProperty.make_value_from_datastore
def make_value_from_datastore(self, value): """Convert value from datastore representation. Args: value: datastore value. Returns: value to store in the model. """ if value is None: return None _json = json.loads(value, cls=JsonDecoder) if self.data_type == dict: r...
python
def make_value_from_datastore(self, value): """Convert value from datastore representation. Args: value: datastore value. Returns: value to store in the model. """ if value is None: return None _json = json.loads(value, cls=JsonDecoder) if self.data_type == dict: r...
[ "def", "make_value_from_datastore", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "_json", "=", "json", ".", "loads", "(", "value", ",", "cls", "=", "JsonDecoder", ")", "if", "self", ".", "data_type", "==", "d...
Convert value from datastore representation. Args: value: datastore value. Returns: value to store in the model.
[ "Convert", "value", "from", "datastore", "representation", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L203-L218
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/json_util.py
JsonProperty.validate
def validate(self, value): """Validate value. Args: value: model value. Returns: Whether the specified value is valid data type value. Raises: BadValueError: when value is not of self.data_type type. """ if value is not None and not isinstance(value, self.data_type): r...
python
def validate(self, value): """Validate value. Args: value: model value. Returns: Whether the specified value is valid data type value. Raises: BadValueError: when value is not of self.data_type type. """ if value is not None and not isinstance(value, self.data_type): r...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "self", ".", "data_type", ")", ":", "raise", "datastore_errors", ".", "BadValueError", "(", "\"Property %s must be conv...
Validate value. Args: value: model value. Returns: Whether the specified value is valid data type value. Raises: BadValueError: when value is not of self.data_type type.
[ "Validate", "value", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/json_util.py#L220-L236
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
HugeTask.add
def add(self, queue_name, transactional=False): """Add task to the queue.""" task = self.to_task() task.add(queue_name, transactional)
python
def add(self, queue_name, transactional=False): """Add task to the queue.""" task = self.to_task() task.add(queue_name, transactional)
[ "def", "add", "(", "self", ",", "queue_name", ",", "transactional", "=", "False", ")", ":", "task", "=", "self", ".", "to_task", "(", ")", "task", ".", "add", "(", "queue_name", ",", "transactional", ")" ]
Add task to the queue.
[ "Add", "task", "to", "the", "queue", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L161-L164
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
HugeTask.to_task
def to_task(self): """Convert to a taskqueue task.""" # Never pass params to taskqueue.Task. Use payload instead. Otherwise, # it's up to a particular taskqueue implementation to generate # payload from params. It could blow up payload size over limit. return taskqueue.Task( url=self.url, ...
python
def to_task(self): """Convert to a taskqueue task.""" # Never pass params to taskqueue.Task. Use payload instead. Otherwise, # it's up to a particular taskqueue implementation to generate # payload from params. It could blow up payload size over limit. return taskqueue.Task( url=self.url, ...
[ "def", "to_task", "(", "self", ")", ":", "# Never pass params to taskqueue.Task. Use payload instead. Otherwise,", "# it's up to a particular taskqueue implementation to generate", "# payload from params. It could blow up payload size over limit.", "return", "taskqueue", ".", "Task", "(", ...
Convert to a taskqueue task.
[ "Convert", "to", "a", "taskqueue", "task", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L166-L177
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
HugeTask.decode_payload
def decode_payload(cls, request): """Decode task payload. HugeTask controls its own payload entirely including urlencoding. It doesn't depend on any particular web framework. Args: request: a webapp Request instance. Returns: A dict of str to str. The same as the params argument to __...
python
def decode_payload(cls, request): """Decode task payload. HugeTask controls its own payload entirely including urlencoding. It doesn't depend on any particular web framework. Args: request: a webapp Request instance. Returns: A dict of str to str. The same as the params argument to __...
[ "def", "decode_payload", "(", "cls", ",", "request", ")", ":", "# TODO(user): Pass mr_id into headers. Otherwise when payload decoding", "# failed, we can't abort a mr.", "if", "request", ".", "headers", ".", "get", "(", "cls", ".", "PAYLOAD_VERSION_HEADER", ")", "!=", "c...
Decode task payload. HugeTask controls its own payload entirely including urlencoding. It doesn't depend on any particular web framework. Args: request: a webapp Request instance. Returns: A dict of str to str. The same as the params argument to __init__. Raises: DeprecationWar...
[ "Decode", "task", "payload", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L180-L202
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
CountersMap.increment
def increment(self, counter_name, delta): """Increment counter value. Args: counter_name: counter name as String. delta: increment delta as Integer. Returns: new counter value. """ current_value = self.counters.get(counter_name, 0) new_value = current_value + delta self.c...
python
def increment(self, counter_name, delta): """Increment counter value. Args: counter_name: counter name as String. delta: increment delta as Integer. Returns: new counter value. """ current_value = self.counters.get(counter_name, 0) new_value = current_value + delta self.c...
[ "def", "increment", "(", "self", ",", "counter_name", ",", "delta", ")", ":", "current_value", "=", "self", ".", "counters", ".", "get", "(", "counter_name", ",", "0", ")", "new_value", "=", "current_value", "+", "delta", "self", ".", "counters", "[", "c...
Increment counter value. Args: counter_name: counter name as String. delta: increment delta as Integer. Returns: new counter value.
[ "Increment", "counter", "value", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L263-L276
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
CountersMap.add_map
def add_map(self, counters_map): """Add all counters from the map. For each counter in the passed map, adds its value to the counter in this map. Args: counters_map: CounterMap instance to add. """ for counter_name in counters_map.counters: self.increment(counter_name, counters_map...
python
def add_map(self, counters_map): """Add all counters from the map. For each counter in the passed map, adds its value to the counter in this map. Args: counters_map: CounterMap instance to add. """ for counter_name in counters_map.counters: self.increment(counter_name, counters_map...
[ "def", "add_map", "(", "self", ",", "counters_map", ")", ":", "for", "counter_name", "in", "counters_map", ".", "counters", ":", "self", ".", "increment", "(", "counter_name", ",", "counters_map", ".", "counters", "[", "counter_name", "]", ")" ]
Add all counters from the map. For each counter in the passed map, adds its value to the counter in this map. Args: counters_map: CounterMap instance to add.
[ "Add", "all", "counters", "from", "the", "map", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L278-L288
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
CountersMap.sub_map
def sub_map(self, counters_map): """Subtracts all counters from the map. For each counter in the passed map, subtracts its value to the counter in this map. Args: counters_map: CounterMap instance to subtract. """ for counter_name in counters_map.counters: self.increment(counter_na...
python
def sub_map(self, counters_map): """Subtracts all counters from the map. For each counter in the passed map, subtracts its value to the counter in this map. Args: counters_map: CounterMap instance to subtract. """ for counter_name in counters_map.counters: self.increment(counter_na...
[ "def", "sub_map", "(", "self", ",", "counters_map", ")", ":", "for", "counter_name", "in", "counters_map", ".", "counters", ":", "self", ".", "increment", "(", "counter_name", ",", "-", "counters_map", ".", "counters", "[", "counter_name", "]", ")" ]
Subtracts all counters from the map. For each counter in the passed map, subtracts its value to the counter in this map. Args: counters_map: CounterMap instance to subtract.
[ "Subtracts", "all", "counters", "from", "the", "map", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L290-L300
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapperSpec.to_json
def to_json(self): """Serializes this MapperSpec into a json-izable object.""" result = { "mapper_handler_spec": self.handler_spec, "mapper_input_reader": self.input_reader_spec, "mapper_params": self.params, "mapper_shard_count": self.shard_count } if self.output_writer_...
python
def to_json(self): """Serializes this MapperSpec into a json-izable object.""" result = { "mapper_handler_spec": self.handler_spec, "mapper_input_reader": self.input_reader_spec, "mapper_params": self.params, "mapper_shard_count": self.shard_count } if self.output_writer_...
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "{", "\"mapper_handler_spec\"", ":", "self", ".", "handler_spec", ",", "\"mapper_input_reader\"", ":", "self", ".", "input_reader_spec", ",", "\"mapper_params\"", ":", "self", ".", "params", ",", "\"mapper_...
Serializes this MapperSpec into a json-izable object.
[ "Serializes", "this", "MapperSpec", "into", "a", "json", "-", "izable", "object", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L412-L422
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceSpec.get_hooks
def get_hooks(self): """Returns a hooks.Hooks class or None if no hooks class has been set.""" if self.__hooks is None and self.hooks_class_name is not None: hooks_class = util.for_name(self.hooks_class_name) if not isinstance(hooks_class, type): raise ValueError("hooks_class_name must refer...
python
def get_hooks(self): """Returns a hooks.Hooks class or None if no hooks class has been set.""" if self.__hooks is None and self.hooks_class_name is not None: hooks_class = util.for_name(self.hooks_class_name) if not isinstance(hooks_class, type): raise ValueError("hooks_class_name must refer...
[ "def", "get_hooks", "(", "self", ")", ":", "if", "self", ".", "__hooks", "is", "None", "and", "self", ".", "hooks_class_name", "is", "not", "None", ":", "hooks_class", "=", "util", ".", "for_name", "(", "self", ".", "hooks_class_name", ")", "if", "not", ...
Returns a hooks.Hooks class or None if no hooks class has been set.
[ "Returns", "a", "hooks", ".", "Hooks", "class", "or", "None", "if", "no", "hooks", "class", "has", "been", "set", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L488-L500
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceSpec.to_json
def to_json(self): """Serializes all data in this mapreduce spec into json form. Returns: data in json format. """ mapper_spec = self.mapper.to_json() return { "name": self.name, "mapreduce_id": self.mapreduce_id, "mapper_spec": mapper_spec, "params": self.para...
python
def to_json(self): """Serializes all data in this mapreduce spec into json form. Returns: data in json format. """ mapper_spec = self.mapper.to_json() return { "name": self.name, "mapreduce_id": self.mapreduce_id, "mapper_spec": mapper_spec, "params": self.para...
[ "def", "to_json", "(", "self", ")", ":", "mapper_spec", "=", "self", ".", "mapper", ".", "to_json", "(", ")", "return", "{", "\"name\"", ":", "self", ".", "name", ",", "\"mapreduce_id\"", ":", "self", ".", "mapreduce_id", ",", "\"mapper_spec\"", ":", "ma...
Serializes all data in this mapreduce spec into json form. Returns: data in json format.
[ "Serializes", "all", "data", "in", "this", "mapreduce", "spec", "into", "json", "form", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L502-L515
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceSpec.from_json
def from_json(cls, json): """Create new MapreduceSpec from the json, encoded by to_json. Args: json: json representation of MapreduceSpec. Returns: an instance of MapreduceSpec with all data deserialized from json. """ mapreduce_spec = cls(json["name"], json["m...
python
def from_json(cls, json): """Create new MapreduceSpec from the json, encoded by to_json. Args: json: json representation of MapreduceSpec. Returns: an instance of MapreduceSpec with all data deserialized from json. """ mapreduce_spec = cls(json["name"], json["m...
[ "def", "from_json", "(", "cls", ",", "json", ")", ":", "mapreduce_spec", "=", "cls", "(", "json", "[", "\"name\"", "]", ",", "json", "[", "\"mapreduce_id\"", "]", ",", "json", "[", "\"mapper_spec\"", "]", ",", "json", ".", "get", "(", "\"params\"", ")"...
Create new MapreduceSpec from the json, encoded by to_json. Args: json: json representation of MapreduceSpec. Returns: an instance of MapreduceSpec with all data deserialized from json.
[ "Create", "new", "MapreduceSpec", "from", "the", "json", "encoded", "by", "to_json", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L518-L532
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceSpec._get_mapreduce_spec
def _get_mapreduce_spec(cls, mr_id): """Get Mapreduce spec from mr id.""" key = 'GAE-MR-spec: %s' % mr_id spec_json = memcache.get(key) if spec_json: return cls.from_json(spec_json) state = MapreduceState.get_by_job_id(mr_id) spec = state.mapreduce_spec spec_json = spec.to_json() m...
python
def _get_mapreduce_spec(cls, mr_id): """Get Mapreduce spec from mr id.""" key = 'GAE-MR-spec: %s' % mr_id spec_json = memcache.get(key) if spec_json: return cls.from_json(spec_json) state = MapreduceState.get_by_job_id(mr_id) spec = state.mapreduce_spec spec_json = spec.to_json() m...
[ "def", "_get_mapreduce_spec", "(", "cls", ",", "mr_id", ")", ":", "key", "=", "'GAE-MR-spec: %s'", "%", "mr_id", "spec_json", "=", "memcache", ".", "get", "(", "key", ")", "if", "spec_json", ":", "return", "cls", ".", "from_json", "(", "spec_json", ")", ...
Get Mapreduce spec from mr id.
[ "Get", "Mapreduce", "spec", "from", "mr", "id", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L543-L553
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceState.get_key_by_job_id
def get_key_by_job_id(cls, mapreduce_id): """Retrieves the Key for a Job. Args: mapreduce_id: The job to retrieve. Returns: Datastore Key that can be used to fetch the MapreduceState. """ return db.Key.from_path(cls.kind(), str(mapreduce_id))
python
def get_key_by_job_id(cls, mapreduce_id): """Retrieves the Key for a Job. Args: mapreduce_id: The job to retrieve. Returns: Datastore Key that can be used to fetch the MapreduceState. """ return db.Key.from_path(cls.kind(), str(mapreduce_id))
[ "def", "get_key_by_job_id", "(", "cls", ",", "mapreduce_id", ")", ":", "return", "db", ".", "Key", ".", "from_path", "(", "cls", ".", "kind", "(", ")", ",", "str", "(", "mapreduce_id", ")", ")" ]
Retrieves the Key for a Job. Args: mapreduce_id: The job to retrieve. Returns: Datastore Key that can be used to fetch the MapreduceState.
[ "Retrieves", "the", "Key", "for", "a", "Job", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L614-L623
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceState.set_processed_counts
def set_processed_counts(self, shards_processed, shards_status): """Updates a chart url to display processed count for each shard. Args: shards_processed: list of integers with number of processed entities in each shard """ chart = google_chart_api.BarChart() def filter_status(status...
python
def set_processed_counts(self, shards_processed, shards_status): """Updates a chart url to display processed count for each shard. Args: shards_processed: list of integers with number of processed entities in each shard """ chart = google_chart_api.BarChart() def filter_status(status...
[ "def", "set_processed_counts", "(", "self", ",", "shards_processed", ",", "shards_status", ")", ":", "chart", "=", "google_chart_api", ".", "BarChart", "(", ")", "def", "filter_status", "(", "status_to_filter", ")", ":", "return", "[", "count", "if", "status", ...
Updates a chart url to display processed count for each shard. Args: shards_processed: list of integers with number of processed entities in each shard
[ "Updates", "a", "chart", "url", "to", "display", "processed", "count", "for", "each", "shard", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L637-L690
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceState.create_new
def create_new(mapreduce_id=None, gettime=datetime.datetime.now): """Create a new MapreduceState. Args: mapreduce_id: Mapreduce id as string. gettime: Used for testing. """ if not mapreduce_id: mapreduce_id = MapreduceState.new_mapreduce_id() state = MapreduceStat...
python
def create_new(mapreduce_id=None, gettime=datetime.datetime.now): """Create a new MapreduceState. Args: mapreduce_id: Mapreduce id as string. gettime: Used for testing. """ if not mapreduce_id: mapreduce_id = MapreduceState.new_mapreduce_id() state = MapreduceStat...
[ "def", "create_new", "(", "mapreduce_id", "=", "None", ",", "gettime", "=", "datetime", ".", "datetime", ".", "now", ")", ":", "if", "not", "mapreduce_id", ":", "mapreduce_id", "=", "MapreduceState", ".", "new_mapreduce_id", "(", ")", "state", "=", "Mapreduc...
Create a new MapreduceState. Args: mapreduce_id: Mapreduce id as string. gettime: Used for testing.
[ "Create", "a", "new", "MapreduceState", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L703-L716
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
TransientShardState.reset_for_retry
def reset_for_retry(self, output_writer): """Reset self for shard retry. Args: output_writer: new output writer that contains new output files. """ self.input_reader = self.initial_input_reader self.slice_id = 0 self.retries += 1 self.output_writer = output_writer self.handler = s...
python
def reset_for_retry(self, output_writer): """Reset self for shard retry. Args: output_writer: new output writer that contains new output files. """ self.input_reader = self.initial_input_reader self.slice_id = 0 self.retries += 1 self.output_writer = output_writer self.handler = s...
[ "def", "reset_for_retry", "(", "self", ",", "output_writer", ")", ":", "self", ".", "input_reader", "=", "self", ".", "initial_input_reader", "self", ".", "slice_id", "=", "0", "self", ".", "retries", "+=", "1", "self", ".", "output_writer", "=", "output_wri...
Reset self for shard retry. Args: output_writer: new output writer that contains new output files.
[ "Reset", "self", "for", "shard", "retry", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L776-L786
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
TransientShardState.advance_for_next_slice
def advance_for_next_slice(self, recovery_slice=False): """Advance relavent states for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info. """ if recovery_slice: self....
python
def advance_for_next_slice(self, recovery_slice=False): """Advance relavent states for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info. """ if recovery_slice: self....
[ "def", "advance_for_next_slice", "(", "self", ",", "recovery_slice", "=", "False", ")", ":", "if", "recovery_slice", ":", "self", ".", "slice_id", "+=", "2", "# Restore input reader to the beginning of the slice.", "self", ".", "input_reader", "=", "self", ".", "inp...
Advance relavent states for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info.
[ "Advance", "relavent", "states", "for", "next", "slice", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L788-L801
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
TransientShardState.to_dict
def to_dict(self): """Convert state to dictionary to save in task payload.""" result = {"mapreduce_spec": self.mapreduce_spec.to_json_str(), "shard_id": self.shard_id, "slice_id": str(self.slice_id), "input_reader_state": self.input_reader.to_json_str(), "...
python
def to_dict(self): """Convert state to dictionary to save in task payload.""" result = {"mapreduce_spec": self.mapreduce_spec.to_json_str(), "shard_id": self.shard_id, "slice_id": str(self.slice_id), "input_reader_state": self.input_reader.to_json_str(), "...
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "{", "\"mapreduce_spec\"", ":", "self", ".", "mapreduce_spec", ".", "to_json_str", "(", ")", ",", "\"shard_id\"", ":", "self", ".", "shard_id", ",", "\"slice_id\"", ":", "str", "(", "self", ".", "sl...
Convert state to dictionary to save in task payload.
[ "Convert", "state", "to", "dictionary", "to", "save", "in", "task", "payload", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L803-L817
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
TransientShardState.from_request
def from_request(cls, request): """Create new TransientShardState from webapp request.""" mapreduce_spec = MapreduceSpec.from_json_str(request.get("mapreduce_spec")) mapper_spec = mapreduce_spec.mapper input_reader_spec_dict = json.loads(request.get("input_reader_state"), ...
python
def from_request(cls, request): """Create new TransientShardState from webapp request.""" mapreduce_spec = MapreduceSpec.from_json_str(request.get("mapreduce_spec")) mapper_spec = mapreduce_spec.mapper input_reader_spec_dict = json.loads(request.get("input_reader_state"), ...
[ "def", "from_request", "(", "cls", ",", "request", ")", ":", "mapreduce_spec", "=", "MapreduceSpec", ".", "from_json_str", "(", "request", ".", "get", "(", "\"mapreduce_spec\"", ")", ")", "mapper_spec", "=", "mapreduce_spec", ".", "mapper", "input_reader_spec_dict...
Create new TransientShardState from webapp request.
[ "Create", "new", "TransientShardState", "from", "webapp", "request", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L820-L855
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.reset_for_retry
def reset_for_retry(self): """Reset self for shard retry.""" self.retries += 1 self.last_work_item = "" self.active = True self.result_status = None self.input_finished = False self.counters_map = CountersMap() self.slice_id = 0 self.slice_start_time = None self.slice_request_id ...
python
def reset_for_retry(self): """Reset self for shard retry.""" self.retries += 1 self.last_work_item = "" self.active = True self.result_status = None self.input_finished = False self.counters_map = CountersMap() self.slice_id = 0 self.slice_start_time = None self.slice_request_id ...
[ "def", "reset_for_retry", "(", "self", ")", ":", "self", ".", "retries", "+=", "1", "self", ".", "last_work_item", "=", "\"\"", "self", ".", "active", "=", "True", "self", ".", "result_status", "=", "None", "self", ".", "input_finished", "=", "False", "s...
Reset self for shard retry.
[ "Reset", "self", "for", "shard", "retry", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L973-L985
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.advance_for_next_slice
def advance_for_next_slice(self, recovery_slice=False): """Advance self for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info. """ self.slice_start_time = None self.sli...
python
def advance_for_next_slice(self, recovery_slice=False): """Advance self for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info. """ self.slice_start_time = None self.sli...
[ "def", "advance_for_next_slice", "(", "self", ",", "recovery_slice", "=", "False", ")", ":", "self", ".", "slice_start_time", "=", "None", "self", ".", "slice_request_id", "=", "None", "self", ".", "slice_retries", "=", "0", "self", ".", "acquired_once", "=", ...
Advance self for next slice. Args: recovery_slice: True if this slice is running recovery logic. See handlers.MapperWorkerCallbackHandler._attempt_slice_recovery for more info.
[ "Advance", "self", "for", "next", "slice", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L987-L1002
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.copy_from
def copy_from(self, other_state): """Copy data from another shard state entity to self.""" for prop in self.properties().values(): setattr(self, prop.name, getattr(other_state, prop.name))
python
def copy_from(self, other_state): """Copy data from another shard state entity to self.""" for prop in self.properties().values(): setattr(self, prop.name, getattr(other_state, prop.name))
[ "def", "copy_from", "(", "self", ",", "other_state", ")", ":", "for", "prop", "in", "self", ".", "properties", "(", ")", ".", "values", "(", ")", ":", "setattr", "(", "self", ",", "prop", ".", "name", ",", "getattr", "(", "other_state", ",", "prop", ...
Copy data from another shard state entity to self.
[ "Copy", "data", "from", "another", "shard", "state", "entity", "to", "self", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1026-L1029
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.find_all_by_mapreduce_state
def find_all_by_mapreduce_state(cls, mapreduce_state): """Find all shard states for given mapreduce. Args: mapreduce_state: MapreduceState instance Yields: shard states sorted by shard id. """ keys = cls.calculate_keys_by_mapreduce_state(mapreduce_state) i = 0 while i < len(key...
python
def find_all_by_mapreduce_state(cls, mapreduce_state): """Find all shard states for given mapreduce. Args: mapreduce_state: MapreduceState instance Yields: shard states sorted by shard id. """ keys = cls.calculate_keys_by_mapreduce_state(mapreduce_state) i = 0 while i < len(key...
[ "def", "find_all_by_mapreduce_state", "(", "cls", ",", "mapreduce_state", ")", ":", "keys", "=", "cls", ".", "calculate_keys_by_mapreduce_state", "(", "mapreduce_state", ")", "i", "=", "0", "while", "i", "<", "len", "(", "keys", ")", ":", "@", "db", ".", "...
Find all shard states for given mapreduce. Args: mapreduce_state: MapreduceState instance Yields: shard states sorted by shard id.
[ "Find", "all", "shard", "states", "for", "given", "mapreduce", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1106-L1127
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.calculate_keys_by_mapreduce_state
def calculate_keys_by_mapreduce_state(cls, mapreduce_state): """Calculate all shard states keys for given mapreduce. Args: mapreduce_state: MapreduceState instance Returns: A list of keys for shard states, sorted by shard id. The corresponding shard states may not exist. """ if m...
python
def calculate_keys_by_mapreduce_state(cls, mapreduce_state): """Calculate all shard states keys for given mapreduce. Args: mapreduce_state: MapreduceState instance Returns: A list of keys for shard states, sorted by shard id. The corresponding shard states may not exist. """ if m...
[ "def", "calculate_keys_by_mapreduce_state", "(", "cls", ",", "mapreduce_state", ")", ":", "if", "mapreduce_state", "is", "None", ":", "return", "[", "]", "keys", "=", "[", "]", "for", "i", "in", "range", "(", "mapreduce_state", ".", "mapreduce_spec", ".", "m...
Calculate all shard states keys for given mapreduce. Args: mapreduce_state: MapreduceState instance Returns: A list of keys for shard states, sorted by shard id. The corresponding shard states may not exist.
[ "Calculate", "all", "shard", "states", "keys", "for", "given", "mapreduce", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1130-L1147
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
ShardState.create_new
def create_new(cls, mapreduce_id, shard_number): """Create new shard state. Args: mapreduce_id: unique mapreduce id as string. shard_number: shard number for which to create shard state. Returns: new instance of ShardState ready to put into datastore. """ shard_id = cls.shard_id_...
python
def create_new(cls, mapreduce_id, shard_number): """Create new shard state. Args: mapreduce_id: unique mapreduce id as string. shard_number: shard number for which to create shard state. Returns: new instance of ShardState ready to put into datastore. """ shard_id = cls.shard_id_...
[ "def", "create_new", "(", "cls", ",", "mapreduce_id", ",", "shard_number", ")", ":", "shard_id", "=", "cls", ".", "shard_id_from_number", "(", "mapreduce_id", ",", "shard_number", ")", "state", "=", "cls", "(", "key_name", "=", "shard_id", ",", "mapreduce_id",...
Create new shard state. Args: mapreduce_id: unique mapreduce id as string. shard_number: shard number for which to create shard state. Returns: new instance of ShardState ready to put into datastore.
[ "Create", "new", "shard", "state", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1150-L1163
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceControl.get_key_by_job_id
def get_key_by_job_id(cls, mapreduce_id): """Retrieves the Key for a mapreduce ID. Args: mapreduce_id: The job to fetch. Returns: Datastore Key for the command for the given job ID. """ return db.Key.from_path(cls.kind(), "%s:%s" % (mapreduce_id, cls._KEY_NAME))
python
def get_key_by_job_id(cls, mapreduce_id): """Retrieves the Key for a mapreduce ID. Args: mapreduce_id: The job to fetch. Returns: Datastore Key for the command for the given job ID. """ return db.Key.from_path(cls.kind(), "%s:%s" % (mapreduce_id, cls._KEY_NAME))
[ "def", "get_key_by_job_id", "(", "cls", ",", "mapreduce_id", ")", ":", "return", "db", ".", "Key", ".", "from_path", "(", "cls", ".", "kind", "(", ")", ",", "\"%s:%s\"", "%", "(", "mapreduce_id", ",", "cls", ".", "_KEY_NAME", ")", ")" ]
Retrieves the Key for a mapreduce ID. Args: mapreduce_id: The job to fetch. Returns: Datastore Key for the command for the given job ID.
[ "Retrieves", "the", "Key", "for", "a", "mapreduce", "ID", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1188-L1197
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/model.py
MapreduceControl.abort
def abort(cls, mapreduce_id, **kwargs): """Causes a job to abort. Args: mapreduce_id: The job to abort. Not verified as a valid job. """ cls(key_name="%s:%s" % (mapreduce_id, cls._KEY_NAME), command=cls.ABORT).put(**kwargs)
python
def abort(cls, mapreduce_id, **kwargs): """Causes a job to abort. Args: mapreduce_id: The job to abort. Not verified as a valid job. """ cls(key_name="%s:%s" % (mapreduce_id, cls._KEY_NAME), command=cls.ABORT).put(**kwargs)
[ "def", "abort", "(", "cls", ",", "mapreduce_id", ",", "*", "*", "kwargs", ")", ":", "cls", "(", "key_name", "=", "\"%s:%s\"", "%", "(", "mapreduce_id", ",", "cls", ".", "_KEY_NAME", ")", ",", "command", "=", "cls", ".", "ABORT", ")", ".", "put", "(...
Causes a job to abort. Args: mapreduce_id: The job to abort. Not verified as a valid job.
[ "Causes", "a", "job", "to", "abort", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1200-L1207
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/api/map_job/datastore_input_reader.py
DatastoreInputReader.validate
def validate(cls, job_config): """Inherit docs.""" super(DatastoreInputReader, cls).validate(job_config) params = job_config.input_reader_params entity_kind = params[cls.ENTITY_KIND_PARAM] # Check for a "." in the entity kind. if "." in entity_kind: logging.warning( ". detected i...
python
def validate(cls, job_config): """Inherit docs.""" super(DatastoreInputReader, cls).validate(job_config) params = job_config.input_reader_params entity_kind = params[cls.ENTITY_KIND_PARAM] # Check for a "." in the entity kind. if "." in entity_kind: logging.warning( ". detected i...
[ "def", "validate", "(", "cls", ",", "job_config", ")", ":", "super", "(", "DatastoreInputReader", ",", "cls", ")", ".", "validate", "(", "job_config", ")", "params", "=", "job_config", ".", "input_reader_params", "entity_kind", "=", "params", "[", "cls", "."...
Inherit docs.
[ "Inherit", "docs", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/api/map_job/datastore_input_reader.py#L32-L49
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/base_handler.py
TaskQueueHandler.initialize
def initialize(self, request, response): """Initialize. 1. call webapp init. 2. check request is indeed from taskqueue. 3. check the task has not been retried too many times. 4. run handler specific processing logic. 5. run error handling logic if precessing failed. Args: request: a ...
python
def initialize(self, request, response): """Initialize. 1. call webapp init. 2. check request is indeed from taskqueue. 3. check the task has not been retried too many times. 4. run handler specific processing logic. 5. run error handling logic if precessing failed. Args: request: a ...
[ "def", "initialize", "(", "self", ",", "request", ",", "response", ")", ":", "super", "(", "TaskQueueHandler", ",", "self", ")", ".", "initialize", "(", "request", ",", "response", ")", "# Check request is from taskqueue.", "if", "\"X-AppEngine-QueueName\"", "not"...
Initialize. 1. call webapp init. 2. check request is indeed from taskqueue. 3. check the task has not been retried too many times. 4. run handler specific processing logic. 5. run error handling logic if precessing failed. Args: request: a webapp.Request instance. response: a webap...
[ "Initialize", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/base_handler.py#L93-L134
GoogleCloudPlatform/appengine-mapreduce
python/src/mapreduce/base_handler.py
TaskQueueHandler.retry_task
def retry_task(self): """Ask taskqueue to retry this task. Even though raising an exception can cause a task retry, it will flood logs with highly visible ERROR logs. Handlers should uses this method to perform controlled task retries. Only raise exceptions for those deserve ERROR log entries. ...
python
def retry_task(self): """Ask taskqueue to retry this task. Even though raising an exception can cause a task retry, it will flood logs with highly visible ERROR logs. Handlers should uses this method to perform controlled task retries. Only raise exceptions for those deserve ERROR log entries. ...
[ "def", "retry_task", "(", "self", ")", ":", "self", ".", "response", ".", "set_status", "(", "httplib", ".", "SERVICE_UNAVAILABLE", ",", "\"Retry task\"", ")", "self", ".", "response", ".", "clear", "(", ")" ]
Ask taskqueue to retry this task. Even though raising an exception can cause a task retry, it will flood logs with highly visible ERROR logs. Handlers should uses this method to perform controlled task retries. Only raise exceptions for those deserve ERROR log entries.
[ "Ask", "taskqueue", "to", "retry", "this", "task", "." ]
train
https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/base_handler.py#L163-L172