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_documentation_string stringlengths 1 47.2k | 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... | Inherit docs. | 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... | Inherit docs. | 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... | 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 ... | 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... | Validate ndb.Model filters. | 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 | Return an entity from an entity or model instance. | 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:
... | Return a key from an entity, model instance, key, or key string. | 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) | 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. | 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... | Force a flush. | 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) | Registers entity to put to datastore.
Args:
entity: an entity or model instance to put. | 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) | Like put(), but for NDB entities. | 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) | Registers entity to delete from datastore.
Args:
entity: an entity, model instance, or key to delete. | 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) | Like delete(), but for NDB entities/keys. | 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() | Flush(apply) all changed to datastore. | 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)) | Flush all puts to datastore. | 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)) | Flush all deletes to datastore. | 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)) | Flush all NDB puts to datastore. | 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)) | Flush all deletes to datastore. | 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) | Creates datastore Config.
Returns:
A datastore_rpc.Configuration instance. | 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) | Increment counter value.
Args:
counter_name: name of the counter as string.
delta: increment delta as int. | 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... | Inherit doc. | 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... | Inherit doc. | 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... | Inherit doc. | 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["... | Inherit doc. | 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... | Inherit doc. | 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
... | Inherit doc. | 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
... | Serializes all states into json form.
Returns:
all states in json-compatible map. | 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... | Reverse of to_json. | 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.... | 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. | 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.
... | 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... | 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... | 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. | 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 = ... | 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. | 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... | 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... | 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... | 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. | 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.... | 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. | 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.
"... | 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. | 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()) | A map function used in hash phase.
Reads KeyValue from binary record.
Args:
binary_record: The binary record.
Yields:
The (key, value). | 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... | Split input into multiple shards. | 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... | Validate reader parameters in mapper_spec. | 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... | Validates mapper specification.
Args:
mapper_spec: an instance of model.MapperSpec to validate.
Raises:
BadWriterParamsError: when Output writer class mismatch. | 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... | Returns writer state to serialize in json.
Returns:
A json-izable version of the OutputWriter state. | 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.... | Inherit docs. | 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... | See parent class. | 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} | See parent class. | 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[... | Write data.
Args:
data: actual data yielded from handler. Type is writer-specific. | 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... | Converts self to model.MapperSpec.params. | 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... | Converts self to model.MapperSpec. | 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... | Converts self to model.MapreduceSpec.params. | 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 | Gets default values for old API. | 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... | 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... | 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),... | Write single physical record. | 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... | Write single record.
Args:
data: record data to write as string, byte array or byte sequence. | 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... | 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. | 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... | 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. | 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' %
... | Skip reader to the block boundary. | 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:
... | Reads record from current position in reader.
Returns:
original bytes stored in a single record. | 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 ... | 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... | 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... | Callback after this async pipeline finishes. | 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... | 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... | 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 | Get status enum.
Returns:
One of the status enum. | 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... | 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. | 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... | 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. | 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... | 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,... | 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) | Fetches most up to date state from db. | 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("... | Get job state by id.
Args:
job_id: job id.
Returns:
model.MapreduceState for the job.
Raises:
ValueError: if the job state is missing. | 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.
"""
... | 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. | 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... | Add kickoff task to taskqueue.
Args:
job_config: map_job.JobConfig.
mapreduce_spec: model.MapreduceSpec, | 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 | Convert data to json string representation.
Returns:
json representation as string. | 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)) | 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. | 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
... | Gets value for datastore.
Args:
model_instance: instance of the model class.
Returns:
datastore-compatible value. | 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... | Convert value from datastore representation.
Args:
value: datastore value.
Returns:
value to store in the model. | 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... | 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. | 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) | Add task to the queue. | 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,
... | Convert to a taskqueue task. | 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 __... | 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... | 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... | Increment counter value.
Args:
counter_name: counter name as String.
delta: increment delta as Integer.
Returns:
new counter value. | 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... | 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. | 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... | 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. | 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_... | Serializes this MapperSpec into a json-izable object. | 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... | Returns a hooks.Hooks class or None if no hooks class has been set. | 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... | Serializes all data in this mapreduce spec into json form.
Returns:
data in json format. | 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... | 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. | 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... | Get Mapreduce spec from mr id. | 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)) | Retrieves the Key for a Job.
Args:
mapreduce_id: The job to retrieve.
Returns:
Datastore Key that can be used to fetch the MapreduceState. | 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... | 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 | 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... | Create a new MapreduceState.
Args:
mapreduce_id: Mapreduce id as string.
gettime: Used for testing. | 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... | Reset self for shard retry.
Args:
output_writer: new output writer that contains new output files. | 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.... | 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. | 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(),
"... | Convert state to dictionary to save in task payload. | 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"),
... | Create new TransientShardState from webapp request. | 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 ... | Reset self for shard retry. | 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... | 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. | 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)) | Copy data from another shard state entity to self. | 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... | Find all shard states for given mapreduce.
Args:
mapreduce_state: MapreduceState instance
Yields:
shard states sorted by shard id. | 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... | 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. | 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_... | 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. | 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)) | 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. | 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) | Causes a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job. | 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... | Inherit docs. | 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 ... | 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... | 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.
... | 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. | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/base_handler.py#L163-L172 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.