repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
b3j0f/schema | b3j0f/schema/registry.py | getbydatatype | def getbydatatype(data_type, besteffort=True):
"""Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subclass of
input da... | python | def getbydatatype(data_type, besteffort=True):
"""Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subclass of
input da... | [
"def",
"getbydatatype",
"(",
"data_type",
",",
"besteffort",
"=",
"True",
")",
":",
"return",
"_REGISTRY",
".",
"getbydatatype",
"(",
"data_type",
"=",
"data_type",
",",
"besteffort",
"=",
"besteffort",
")"
] | Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subclass of
input data_type.
:return: sub class of Schema.
:rtype:... | [
"Get",
"schema",
"class",
"by",
"data",
"type",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L246-L256 |
b3j0f/schema | b3j0f/schema/registry.py | unregistercls | def unregistercls(self, schemacls=None, data_types=None):
"""Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister.
"""
return _REGISTRY.unregistercls(schemacls=schemacls, data_types=data_types) | python | def unregistercls(self, schemacls=None, data_types=None):
"""Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister.
"""
return _REGISTRY.unregistercls(schemacls=schemacls, data_types=data_types) | [
"def",
"unregistercls",
"(",
"self",
",",
"schemacls",
"=",
"None",
",",
"data_types",
"=",
"None",
")",
":",
"return",
"_REGISTRY",
".",
"unregistercls",
"(",
"schemacls",
"=",
"schemacls",
",",
"data_types",
"=",
"data_types",
")"
] | Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister. | [
"Unregister",
"schema",
"class",
"or",
"associated",
"data_types",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L272-L278 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.register | def register(self, schema):
"""Register input schema class.
When registering a schema, all inner schemas are registered as well.
:param Schema schema: schema to register.
:return: old registered schema.
:rtype: type
"""
result = None
uuid = schema.uuid
... | python | def register(self, schema):
"""Register input schema class.
When registering a schema, all inner schemas are registered as well.
:param Schema schema: schema to register.
:return: old registered schema.
:rtype: type
"""
result = None
uuid = schema.uuid
... | [
"def",
"register",
"(",
"self",
",",
"schema",
")",
":",
"result",
"=",
"None",
"uuid",
"=",
"schema",
".",
"uuid",
"if",
"uuid",
"in",
"self",
".",
"_schbyuuid",
":",
"result",
"=",
"self",
".",
"_schbyuuid",
"[",
"uuid",
"]",
"if",
"result",
"!=",
... | Register input schema class.
When registering a schema, all inner schemas are registered as well.
:param Schema schema: schema to register.
:return: old registered schema.
:rtype: type | [
"Register",
"input",
"schema",
"class",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L69-L100 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.registercls | def registercls(self, data_types, schemacls=None):
"""Register schema class with associated data_types.
Can be used such as a decorator.
:param list data_types: data types to associate with schema class.
:param type schemacls: schema class to register.
:return: schemacls.
... | python | def registercls(self, data_types, schemacls=None):
"""Register schema class with associated data_types.
Can be used such as a decorator.
:param list data_types: data types to associate with schema class.
:param type schemacls: schema class to register.
:return: schemacls.
... | [
"def",
"registercls",
"(",
"self",
",",
"data_types",
",",
"schemacls",
"=",
"None",
")",
":",
"if",
"schemacls",
"is",
"None",
":",
"return",
"lambda",
"schemacls",
":",
"self",
".",
"registercls",
"(",
"data_types",
"=",
"data_types",
",",
"schemacls",
"... | Register schema class with associated data_types.
Can be used such as a decorator.
:param list data_types: data types to associate with schema class.
:param type schemacls: schema class to register.
:return: schemacls.
:rtype: type | [
"Register",
"schema",
"class",
"with",
"associated",
"data_types",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L102-L120 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.unregister | def unregister(self, uuid):
"""Unregister a schema registered with input uuid.
:raises: KeyError if uuid is not already registered.
"""
schema = self._schbyuuid.pop(uuid)
# clean schemas by name
self._schbyname[schema.name].remove(schema)
if not self._schbyname[... | python | def unregister(self, uuid):
"""Unregister a schema registered with input uuid.
:raises: KeyError if uuid is not already registered.
"""
schema = self._schbyuuid.pop(uuid)
# clean schemas by name
self._schbyname[schema.name].remove(schema)
if not self._schbyname[... | [
"def",
"unregister",
"(",
"self",
",",
"uuid",
")",
":",
"schema",
"=",
"self",
".",
"_schbyuuid",
".",
"pop",
"(",
"uuid",
")",
"# clean schemas by name",
"self",
".",
"_schbyname",
"[",
"schema",
".",
"name",
"]",
".",
"remove",
"(",
"schema",
")",
"... | Unregister a schema registered with input uuid.
:raises: KeyError if uuid is not already registered. | [
"Unregister",
"a",
"schema",
"registered",
"with",
"input",
"uuid",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L122-L132 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.unregistercls | def unregistercls(self, schemacls=None, data_types=None):
"""Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister.
"""
if schemacls is not None:
# clean schemas by data type
... | python | def unregistercls(self, schemacls=None, data_types=None):
"""Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister.
"""
if schemacls is not None:
# clean schemas by data type
... | [
"def",
"unregistercls",
"(",
"self",
",",
"schemacls",
"=",
"None",
",",
"data_types",
"=",
"None",
")",
":",
"if",
"schemacls",
"is",
"not",
"None",
":",
"# clean schemas by data type",
"for",
"data_type",
"in",
"list",
"(",
"self",
".",
"_schbytype",
")",
... | Unregister schema class or associated data_types.
:param type schemacls: sub class of Schema.
:param list data_types: data_types to unregister. | [
"Unregister",
"schema",
"class",
"or",
"associated",
"data_types",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L134-L152 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.getbyuuid | def getbyuuid(self, uuid):
"""Get a schema by given uuid.
:param str uuid: schema uuid to retrieve.
:rtype: Schema
:raises: KeyError if uuid is not registered already.
"""
if uuid not in self._schbyuuid:
raise KeyError('uuid {0} not registered'.format(uuid))
... | python | def getbyuuid(self, uuid):
"""Get a schema by given uuid.
:param str uuid: schema uuid to retrieve.
:rtype: Schema
:raises: KeyError if uuid is not registered already.
"""
if uuid not in self._schbyuuid:
raise KeyError('uuid {0} not registered'.format(uuid))
... | [
"def",
"getbyuuid",
"(",
"self",
",",
"uuid",
")",
":",
"if",
"uuid",
"not",
"in",
"self",
".",
"_schbyuuid",
":",
"raise",
"KeyError",
"(",
"'uuid {0} not registered'",
".",
"format",
"(",
"uuid",
")",
")",
"return",
"self",
".",
"_schbyuuid",
"[",
"uui... | Get a schema by given uuid.
:param str uuid: schema uuid to retrieve.
:rtype: Schema
:raises: KeyError if uuid is not registered already. | [
"Get",
"a",
"schema",
"by",
"given",
"uuid",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L154-L164 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.getbyname | def getbyname(self, name):
"""Get schemas by given name.
:param str name: schema names to retrieve.
:rtype: list
:raises: KeyError if name is not registered already.
"""
if name not in self._schbyname:
raise KeyError('name {0} not registered'.format(name))
... | python | def getbyname(self, name):
"""Get schemas by given name.
:param str name: schema names to retrieve.
:rtype: list
:raises: KeyError if name is not registered already.
"""
if name not in self._schbyname:
raise KeyError('name {0} not registered'.format(name))
... | [
"def",
"getbyname",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_schbyname",
":",
"raise",
"KeyError",
"(",
"'name {0} not registered'",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_schbyname",
"[",
"nam... | Get schemas by given name.
:param str name: schema names to retrieve.
:rtype: list
:raises: KeyError if name is not registered already. | [
"Get",
"schemas",
"by",
"given",
"name",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L166-L176 |
b3j0f/schema | b3j0f/schema/registry.py | SchemaRegistry.getbydatatype | def getbydatatype(self, data_type, besteffort=True):
"""Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subcla... | python | def getbydatatype(self, data_type, besteffort=True):
"""Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subcla... | [
"def",
"getbydatatype",
"(",
"self",
",",
"data_type",
",",
"besteffort",
"=",
"True",
")",
":",
"result",
"=",
"None",
"if",
"data_type",
"in",
"self",
".",
"_schbytype",
":",
"result",
"=",
"self",
".",
"_schbytype",
"[",
"data_type",
"]",
"elif",
"bes... | Get schema class by data type.
:param type data_type: data type from where get schema class.
:param bool besteffort: if True and data_type not registered, parse all
registered data_types and stop when once data_type is a subclass of
input data_type.
:return: sub class of... | [
"Get",
"schema",
"class",
"by",
"data",
"type",
"."
] | train | https://github.com/b3j0f/schema/blob/1c88c23337f5fef50254e65bd407112c43396dd9/b3j0f/schema/registry.py#L178-L199 |
firstprayer/monsql | monsql/wrapper_sqlite3.py | SQLite3Database.truncate_table | def truncate_table(self, tablename):
"""
SQLite3 doesn't support direct truncate, so we just use delete here
"""
self.get(tablename).remove()
self.db.commit() | python | def truncate_table(self, tablename):
"""
SQLite3 doesn't support direct truncate, so we just use delete here
"""
self.get(tablename).remove()
self.db.commit() | [
"def",
"truncate_table",
"(",
"self",
",",
"tablename",
")",
":",
"self",
".",
"get",
"(",
"tablename",
")",
".",
"remove",
"(",
")",
"self",
".",
"db",
".",
"commit",
"(",
")"
] | SQLite3 doesn't support direct truncate, so we just use delete here | [
"SQLite3",
"doesn",
"t",
"support",
"direct",
"truncate",
"so",
"we",
"just",
"use",
"delete",
"here"
] | train | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/wrapper_sqlite3.py#L41-L46 |
vinu76jsr/pipsort | lib/pipsort/core/_logger.py | _Logger.start | def start(self, level="WARN"):
""" Start logging with this logger.
Until the logger is started, no messages will be emitted. This applies
to all loggers with the same name and any child loggers.
Messages less than the given priority level will be ignored. The
default level is '... | python | def start(self, level="WARN"):
""" Start logging with this logger.
Until the logger is started, no messages will be emitted. This applies
to all loggers with the same name and any child loggers.
Messages less than the given priority level will be ignored. The
default level is '... | [
"def",
"start",
"(",
"self",
",",
"level",
"=",
"\"WARN\"",
")",
":",
"if",
"self",
".",
"active",
":",
"return",
"handler",
"=",
"StreamHandler",
"(",
")",
"# stderr",
"handler",
".",
"setFormatter",
"(",
"Formatter",
"(",
"self",
".",
"LOGFMT",
")",
... | Start logging with this logger.
Until the logger is started, no messages will be emitted. This applies
to all loggers with the same name and any child loggers.
Messages less than the given priority level will be ignored. The
default level is 'WARN', which conforms to the *nix conventio... | [
"Start",
"logging",
"with",
"this",
"logger",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/lib/pipsort/core/_logger.py#L38-L63 |
vinu76jsr/pipsort | lib/pipsort/core/_logger.py | _Logger.stop | def stop(self):
""" Stop logging with this logger.
"""
if not self.active:
return
self.removeHandler(self.handlers[-1])
self.active = False
return | python | def stop(self):
""" Stop logging with this logger.
"""
if not self.active:
return
self.removeHandler(self.handlers[-1])
self.active = False
return | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"active",
":",
"return",
"self",
".",
"removeHandler",
"(",
"self",
".",
"handlers",
"[",
"-",
"1",
"]",
")",
"self",
".",
"active",
"=",
"False",
"return"
] | Stop logging with this logger. | [
"Stop",
"logging",
"with",
"this",
"logger",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/lib/pipsort/core/_logger.py#L65-L73 |
jalanb/pysyte | pysyte/tracebacks.py | parse_line | def parse_line(string):
"""Parse a single string as traceback line"""
match = line_regexp().match(string)
if match:
matches = match.groupdict()
line_number = matches['line_number']
path_to_python = matches['path_to_python']
spaceless_path_to_python = matches['spaceless_path_t... | python | def parse_line(string):
"""Parse a single string as traceback line"""
match = line_regexp().match(string)
if match:
matches = match.groupdict()
line_number = matches['line_number']
path_to_python = matches['path_to_python']
spaceless_path_to_python = matches['spaceless_path_t... | [
"def",
"parse_line",
"(",
"string",
")",
":",
"match",
"=",
"line_regexp",
"(",
")",
".",
"match",
"(",
"string",
")",
"if",
"match",
":",
"matches",
"=",
"match",
".",
"groupdict",
"(",
")",
"line_number",
"=",
"matches",
"[",
"'line_number'",
"]",
"p... | Parse a single string as traceback line | [
"Parse",
"a",
"single",
"string",
"as",
"traceback",
"line"
] | train | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/tracebacks.py#L25-L36 |
jashort/SmartFileSorter | smartfilesorter/actionplugins/moveto.py | MoveTo.do_action | def do_action(self, target, dry_run=False):
"""
:param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action.
:return: filename: Full path and filename after action completes
"""
# Get full path to the file in the desti... | python | def do_action(self, target, dry_run=False):
"""
:param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action.
:return: filename: Full path and filename after action completes
"""
# Get full path to the file in the desti... | [
"def",
"do_action",
"(",
"self",
",",
"target",
",",
"dry_run",
"=",
"False",
")",
":",
"# Get full path to the file in the destination directory",
"new_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"destination",
",",
"os",
".",
"path",
".... | :param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action.
:return: filename: Full path and filename after action completes | [
":",
"param",
"target",
":",
"Full",
"path",
"and",
"filename",
":",
"param",
"dry_run",
":",
"True",
"-",
"don",
"t",
"actually",
"perform",
"action",
".",
"False",
":",
"perform",
"action",
".",
":",
"return",
":",
"filename",
":",
"Full",
"path",
"a... | train | https://github.com/jashort/SmartFileSorter/blob/77faf09e5a737da93e16e71a64707366b8307910/smartfilesorter/actionplugins/moveto.py#L17-L62 |
timeyyy/apptools | peasoup/util.py | sftp_upload_window_size_set | def sftp_upload_window_size_set(srv,file, method_to_call='put'):
'''
sets config for uploading files with pysftp
'''
channel = srv.sftp_client.get_channel()
channel.lock.acquire()
channel.out_window_size += os.stat(file).st_size * 1.1 # bit more bytes incase packet loss
channel.out_buffer_... | python | def sftp_upload_window_size_set(srv,file, method_to_call='put'):
'''
sets config for uploading files with pysftp
'''
channel = srv.sftp_client.get_channel()
channel.lock.acquire()
channel.out_window_size += os.stat(file).st_size * 1.1 # bit more bytes incase packet loss
channel.out_buffer_... | [
"def",
"sftp_upload_window_size_set",
"(",
"srv",
",",
"file",
",",
"method_to_call",
"=",
"'put'",
")",
":",
"channel",
"=",
"srv",
".",
"sftp_client",
".",
"get_channel",
"(",
")",
"channel",
".",
"lock",
".",
"acquire",
"(",
")",
"channel",
".",
"out_wi... | sets config for uploading files with pysftp | [
"sets",
"config",
"for",
"uploading",
"files",
"with",
"pysftp"
] | train | https://github.com/timeyyy/apptools/blob/d3c0f324b0c2689c35f5601348276f4efd6cb240/peasoup/util.py#L76-L84 |
se-esss-litterbox/Pynac | Pynac/Plotting.py | PynPlt.plotit | def plotit(self):
'''
Produce the plots requested in the Dynac input file. This makes the same
plots as produced by the Dynac ``plotit`` command.
'''
[self._plot(i) for i in range(len(self.plots))] | python | def plotit(self):
'''
Produce the plots requested in the Dynac input file. This makes the same
plots as produced by the Dynac ``plotit`` command.
'''
[self._plot(i) for i in range(len(self.plots))] | [
"def",
"plotit",
"(",
"self",
")",
":",
"[",
"self",
".",
"_plot",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"plots",
")",
")",
"]"
] | Produce the plots requested in the Dynac input file. This makes the same
plots as produced by the Dynac ``plotit`` command. | [
"Produce",
"the",
"plots",
"requested",
"in",
"the",
"Dynac",
"input",
"file",
".",
"This",
"makes",
"the",
"same",
"plots",
"as",
"produced",
"by",
"the",
"Dynac",
"plotit",
"command",
"."
] | train | https://github.com/se-esss-litterbox/Pynac/blob/97e20aa85d20112cd114faa54a8197c5d0f61209/Pynac/Plotting.py#L109-L114 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | uncompress | def uncompress(pub):
'''
Input must be hex string, and a valid compressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 66.
'''
yp = int(pub[:2],16) - 2
x = int(pub[2:],16)
a = (pow_mod(x,3,P) + 7) % P
y =... | python | def uncompress(pub):
'''
Input must be hex string, and a valid compressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 66.
'''
yp = int(pub[:2],16) - 2
x = int(pub[2:],16)
a = (pow_mod(x,3,P) + 7) % P
y =... | [
"def",
"uncompress",
"(",
"pub",
")",
":",
"yp",
"=",
"int",
"(",
"pub",
"[",
":",
"2",
"]",
",",
"16",
")",
"-",
"2",
"x",
"=",
"int",
"(",
"pub",
"[",
"2",
":",
"]",
",",
"16",
")",
"a",
"=",
"(",
"pow_mod",
"(",
"x",
",",
"3",
",",
... | Input must be hex string, and a valid compressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 66. | [
"Input",
"must",
"be",
"hex",
"string",
"and",
"a",
"valid",
"compressed",
"public",
"key",
".",
"Check",
"if",
"it",
"s",
"a",
"valid",
"key",
"first",
"using",
"the",
"validatepubkey",
"()",
"function",
"below",
"and",
"then",
"verify",
"that",
"the",
... | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L32-L47 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | compress | def compress(pub):
'''
Input must be hex string, and a valid uncompressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 130.
'''
x = pub[2:66]
y = pub[66:]
if int(y,16) % 2:
o = str('03') + str(x)
... | python | def compress(pub):
'''
Input must be hex string, and a valid uncompressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 130.
'''
x = pub[2:66]
y = pub[66:]
if int(y,16) % 2:
o = str('03') + str(x)
... | [
"def",
"compress",
"(",
"pub",
")",
":",
"x",
"=",
"pub",
"[",
"2",
":",
"66",
"]",
"y",
"=",
"pub",
"[",
"66",
":",
"]",
"if",
"int",
"(",
"y",
",",
"16",
")",
"%",
"2",
":",
"o",
"=",
"str",
"(",
"'03'",
")",
"+",
"str",
"(",
"x",
"... | Input must be hex string, and a valid uncompressed public key.
Check if it's a valid key first, using the validatepubkey()
function below, and then verify that the str len is 130. | [
"Input",
"must",
"be",
"hex",
"string",
"and",
"a",
"valid",
"uncompressed",
"public",
"key",
".",
"Check",
"if",
"it",
"s",
"a",
"valid",
"key",
"first",
"using",
"the",
"validatepubkey",
"()",
"function",
"below",
"and",
"then",
"verify",
"that",
"the",
... | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L50-L63 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | privtopub | def privtopub(priv,outcompressed=True):
'''
Input must be 64-char hex string
'''
x, y = ecmultiply(Gx,Gy,int(priv,16))
x = dechex(x,32)
y = dechex(y,32)
o = '04' + x + y
if outcompressed:
return compress(o)
else:
return o | python | def privtopub(priv,outcompressed=True):
'''
Input must be 64-char hex string
'''
x, y = ecmultiply(Gx,Gy,int(priv,16))
x = dechex(x,32)
y = dechex(y,32)
o = '04' + x + y
if outcompressed:
return compress(o)
else:
return o | [
"def",
"privtopub",
"(",
"priv",
",",
"outcompressed",
"=",
"True",
")",
":",
"x",
",",
"y",
"=",
"ecmultiply",
"(",
"Gx",
",",
"Gy",
",",
"int",
"(",
"priv",
",",
"16",
")",
")",
"x",
"=",
"dechex",
"(",
"x",
",",
"32",
")",
"y",
"=",
"deche... | Input must be 64-char hex string | [
"Input",
"must",
"be",
"64",
"-",
"char",
"hex",
"string"
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L66-L78 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | subtractprivkeys | def subtractprivkeys(p1,p2):
'''
Input must be 64-char hex string
'''
return dechex(((int(p1,16) + (N - int(p2,16))) % N),32) | python | def subtractprivkeys(p1,p2):
'''
Input must be 64-char hex string
'''
return dechex(((int(p1,16) + (N - int(p2,16))) % N),32) | [
"def",
"subtractprivkeys",
"(",
"p1",
",",
"p2",
")",
":",
"return",
"dechex",
"(",
"(",
"(",
"int",
"(",
"p1",
",",
"16",
")",
"+",
"(",
"N",
"-",
"int",
"(",
"p2",
",",
"16",
")",
")",
")",
"%",
"N",
")",
",",
"32",
")"
] | Input must be 64-char hex string | [
"Input",
"must",
"be",
"64",
"-",
"char",
"hex",
"string"
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L89-L94 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | multiplypub | def multiplypub(pub,priv,outcompressed=True):
'''
Input pubkey must be hex string and valid pubkey.
Input privkey must be 64-char hex string.
Pubkey input can be compressed or uncompressed, as long as it's a
valid key and a hex string. Use the validatepubkey() function to
validate the public ke... | python | def multiplypub(pub,priv,outcompressed=True):
'''
Input pubkey must be hex string and valid pubkey.
Input privkey must be 64-char hex string.
Pubkey input can be compressed or uncompressed, as long as it's a
valid key and a hex string. Use the validatepubkey() function to
validate the public ke... | [
"def",
"multiplypub",
"(",
"pub",
",",
"priv",
",",
"outcompressed",
"=",
"True",
")",
":",
"if",
"len",
"(",
"pub",
")",
"==",
"66",
":",
"pub",
"=",
"uncompress",
"(",
"pub",
")",
"x",
",",
"y",
"=",
"ecmultiply",
"(",
"int",
"(",
"pub",
"[",
... | Input pubkey must be hex string and valid pubkey.
Input privkey must be 64-char hex string.
Pubkey input can be compressed or uncompressed, as long as it's a
valid key and a hex string. Use the validatepubkey() function to
validate the public key first. The compression of the input
public key does... | [
"Input",
"pubkey",
"must",
"be",
"hex",
"string",
"and",
"valid",
"pubkey",
".",
"Input",
"privkey",
"must",
"be",
"64",
"-",
"char",
"hex",
"string",
"."
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L105-L125 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | addpubs | def addpubs(p1,p2,outcompressed=True):
'''
Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompressed... | python | def addpubs(p1,p2,outcompressed=True):
'''
Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompressed... | [
"def",
"addpubs",
"(",
"p1",
",",
"p2",
",",
"outcompressed",
"=",
"True",
")",
":",
"if",
"len",
"(",
"p1",
")",
"==",
"66",
":",
"p1",
"=",
"uncompress",
"(",
"p1",
")",
"if",
"len",
"(",
"p2",
")",
"==",
"66",
":",
"p2",
"=",
"uncompress",
... | Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompressed bool dictates the compression of the output. | [
"Pubkey",
"inputs",
"can",
"be",
"compressed",
"or",
"uncompressed",
"as",
"long",
"as",
"they",
"re",
"valid",
"keys",
"and",
"hex",
"strings",
".",
"Use",
"the",
"validatepubkey",
"()",
"function",
"to",
"validate",
"them",
"first",
".",
"The",
"compressio... | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L128-L149 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | subtractpubs | def subtractpubs(p1,p2,outcompressed=True):
'''
Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompr... | python | def subtractpubs(p1,p2,outcompressed=True):
'''
Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompr... | [
"def",
"subtractpubs",
"(",
"p1",
",",
"p2",
",",
"outcompressed",
"=",
"True",
")",
":",
"if",
"len",
"(",
"p1",
")",
"==",
"66",
":",
"p1",
"=",
"uncompress",
"(",
"p1",
")",
"if",
"len",
"(",
"p2",
")",
"==",
"66",
":",
"p2",
"=",
"uncompres... | Pubkey inputs can be compressed or uncompressed, as long as
they're valid keys and hex strings. Use the validatepubkey()
function to validate them first. The compression of the input
keys does not do anything or matter in any way. Only the
outcompressed bool dictates the compression of the output. | [
"Pubkey",
"inputs",
"can",
"be",
"compressed",
"or",
"uncompressed",
"as",
"long",
"as",
"they",
"re",
"valid",
"keys",
"and",
"hex",
"strings",
".",
"Use",
"the",
"validatepubkey",
"()",
"function",
"to",
"validate",
"them",
"first",
".",
"The",
"compressio... | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L152-L173 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | validatepubkey | def validatepubkey(pub):
'''
Returns input key if it's a valid hex public key, or False
otherwise.
Input must be hex string, not bytes or integer/long or anything
else.
'''
try:
pub = hexstrlify(unhexlify(pub))
except:
return False
if len(pub) == 130:
if pub... | python | def validatepubkey(pub):
'''
Returns input key if it's a valid hex public key, or False
otherwise.
Input must be hex string, not bytes or integer/long or anything
else.
'''
try:
pub = hexstrlify(unhexlify(pub))
except:
return False
if len(pub) == 130:
if pub... | [
"def",
"validatepubkey",
"(",
"pub",
")",
":",
"try",
":",
"pub",
"=",
"hexstrlify",
"(",
"unhexlify",
"(",
"pub",
")",
")",
"except",
":",
"return",
"False",
"if",
"len",
"(",
"pub",
")",
"==",
"130",
":",
"if",
"pub",
"[",
":",
"2",
"]",
"!=",
... | Returns input key if it's a valid hex public key, or False
otherwise.
Input must be hex string, not bytes or integer/long or anything
else. | [
"Returns",
"input",
"key",
"if",
"it",
"s",
"a",
"valid",
"hex",
"public",
"key",
"or",
"False",
"otherwise",
"."
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L197-L220 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | wiftohex | def wiftohex(wifkey):
'''
Returns a tuple of:
(64-char hex key, 2-char hex prefix for key, if it was compressed)
'''
iscompressed = False
wifkey = normalize_input(wifkey)
assert len(wifkey) == 50 or len(wifkey) == 51 or len(wifkey) == 52
for c in wifkey:
if c not in b58_digits:
... | python | def wiftohex(wifkey):
'''
Returns a tuple of:
(64-char hex key, 2-char hex prefix for key, if it was compressed)
'''
iscompressed = False
wifkey = normalize_input(wifkey)
assert len(wifkey) == 50 or len(wifkey) == 51 or len(wifkey) == 52
for c in wifkey:
if c not in b58_digits:
... | [
"def",
"wiftohex",
"(",
"wifkey",
")",
":",
"iscompressed",
"=",
"False",
"wifkey",
"=",
"normalize_input",
"(",
"wifkey",
")",
"assert",
"len",
"(",
"wifkey",
")",
"==",
"50",
"or",
"len",
"(",
"wifkey",
")",
"==",
"51",
"or",
"len",
"(",
"wifkey",
... | Returns a tuple of:
(64-char hex key, 2-char hex prefix for key, if it was compressed) | [
"Returns",
"a",
"tuple",
"of",
":",
"(",
"64",
"-",
"char",
"hex",
"key",
"2",
"-",
"char",
"hex",
"prefix",
"for",
"key",
"if",
"it",
"was",
"compressed",
")"
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L223-L242 |
maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/bitcoin.py | privtohex | def privtohex(key):
'''
Used for getting unknown input type into a private key.
For example, if you ask a user to input a private key, and they
may input hex, WIF, integer, etc. Run it through this function to
get a standardized format.
Function either outputs private key hex string or raises ... | python | def privtohex(key):
'''
Used for getting unknown input type into a private key.
For example, if you ask a user to input a private key, and they
may input hex, WIF, integer, etc. Run it through this function to
get a standardized format.
Function either outputs private key hex string or raises ... | [
"def",
"privtohex",
"(",
"key",
")",
":",
"if",
"isitint",
"(",
"key",
")",
":",
"key",
"=",
"dechex",
"(",
"key",
",",
"32",
")",
"else",
":",
"try",
":",
"key",
",",
"z",
",",
"zz",
"=",
"wiftohex",
"(",
"key",
")",
"assert",
"len",
"(",
"k... | Used for getting unknown input type into a private key.
For example, if you ask a user to input a private key, and they
may input hex, WIF, integer, etc. Run it through this function to
get a standardized format.
Function either outputs private key hex string or raises an
exception. It's really go... | [
"Used",
"for",
"getting",
"unknown",
"input",
"type",
"into",
"a",
"private",
"key",
"."
] | train | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/bitcoin.py#L245-L287 |
olsoneric/pedemath | pedemath/quat.py | conjugate_quat | def conjugate_quat(quat):
"""Negate the vector part of the quaternion."""
return Quat(-quat.x, -quat.y, -quat.z, quat.w) | python | def conjugate_quat(quat):
"""Negate the vector part of the quaternion."""
return Quat(-quat.x, -quat.y, -quat.z, quat.w) | [
"def",
"conjugate_quat",
"(",
"quat",
")",
":",
"return",
"Quat",
"(",
"-",
"quat",
".",
"x",
",",
"-",
"quat",
".",
"y",
",",
"-",
"quat",
".",
"z",
",",
"quat",
".",
"w",
")"
] | Negate the vector part of the quaternion. | [
"Negate",
"the",
"vector",
"part",
"of",
"the",
"quaternion",
"."
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L17-L19 |
olsoneric/pedemath | pedemath/quat.py | lerp_quat | def lerp_quat(from_quat, to_quat, percent):
"""Return linear interpolation of two quaternions."""
# Check if signs need to be reversed.
if dot_quat(from_quat, to_quat) < 0.0:
to_sign = -1
else:
to_sign = 1
# Simple linear interpolation
percent_from = 1.0 - percent
percent_t... | python | def lerp_quat(from_quat, to_quat, percent):
"""Return linear interpolation of two quaternions."""
# Check if signs need to be reversed.
if dot_quat(from_quat, to_quat) < 0.0:
to_sign = -1
else:
to_sign = 1
# Simple linear interpolation
percent_from = 1.0 - percent
percent_t... | [
"def",
"lerp_quat",
"(",
"from_quat",
",",
"to_quat",
",",
"percent",
")",
":",
"# Check if signs need to be reversed.",
"if",
"dot_quat",
"(",
"from_quat",
",",
"to_quat",
")",
"<",
"0.0",
":",
"to_sign",
"=",
"-",
"1",
"else",
":",
"to_sign",
"=",
"1",
"... | Return linear interpolation of two quaternions. | [
"Return",
"linear",
"interpolation",
"of",
"two",
"quaternions",
"."
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L27-L46 |
olsoneric/pedemath | pedemath/quat.py | nlerp_quat | def nlerp_quat(from_quat, to_quat, percent):
"""Return normalized linear interpolation of two quaternions.
Less computationally expensive than slerp (which not implemented in this
lib yet), but does not maintain a constant velocity like slerp.
"""
result = lerp_quat(from_quat, to_quat, percent)
... | python | def nlerp_quat(from_quat, to_quat, percent):
"""Return normalized linear interpolation of two quaternions.
Less computationally expensive than slerp (which not implemented in this
lib yet), but does not maintain a constant velocity like slerp.
"""
result = lerp_quat(from_quat, to_quat, percent)
... | [
"def",
"nlerp_quat",
"(",
"from_quat",
",",
"to_quat",
",",
"percent",
")",
":",
"result",
"=",
"lerp_quat",
"(",
"from_quat",
",",
"to_quat",
",",
"percent",
")",
"result",
".",
"normalize",
"(",
")",
"return",
"result"
] | Return normalized linear interpolation of two quaternions.
Less computationally expensive than slerp (which not implemented in this
lib yet), but does not maintain a constant velocity like slerp. | [
"Return",
"normalized",
"linear",
"interpolation",
"of",
"two",
"quaternions",
"."
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L49-L58 |
olsoneric/pedemath | pedemath/quat.py | Quat.rotate_vec | def rotate_vec(self, vec):
"""
https://code.google.com/p/kri/wiki/Quaternions
v + 2.0*cross(q.xyz, cross(q.xyz,v) + q.w*v);
"""
xyz = Vec3(self.x, self.y, self.z)
return add_v3(vec, scale_v3(
xyz.cross(xyz.cross(vec) + scale_v3(vec, self.w)), 2.0)) | python | def rotate_vec(self, vec):
"""
https://code.google.com/p/kri/wiki/Quaternions
v + 2.0*cross(q.xyz, cross(q.xyz,v) + q.w*v);
"""
xyz = Vec3(self.x, self.y, self.z)
return add_v3(vec, scale_v3(
xyz.cross(xyz.cross(vec) + scale_v3(vec, self.w)), 2.0)) | [
"def",
"rotate_vec",
"(",
"self",
",",
"vec",
")",
":",
"xyz",
"=",
"Vec3",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"z",
")",
"return",
"add_v3",
"(",
"vec",
",",
"scale_v3",
"(",
"xyz",
".",
"cross",
"(",
"xyz",
".",
... | https://code.google.com/p/kri/wiki/Quaternions
v + 2.0*cross(q.xyz, cross(q.xyz,v) + q.w*v); | [
"https",
":",
"//",
"code",
".",
"google",
".",
"com",
"/",
"p",
"/",
"kri",
"/",
"wiki",
"/",
"Quaternions",
"v",
"+",
"2",
".",
"0",
"*",
"cross",
"(",
"q",
".",
"xyz",
"cross",
"(",
"q",
".",
"xyz",
"v",
")",
"+",
"q",
".",
"w",
"*",
"... | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L181-L188 |
olsoneric/pedemath | pedemath/quat.py | Quat.to_euler_rad | def to_euler_rad(self, dst_euler_vec3=None):
"""Returns euler angles
dst_euler_vec3 is an optional destination vector.
"""
euler_vec3 = dst_euler_vec3 or Vec3(0.0, 0.0, 0.0)
# TODO consolidated duplicated code in this function and to_euler_deg()
sqw = self.w * self.w
... | python | def to_euler_rad(self, dst_euler_vec3=None):
"""Returns euler angles
dst_euler_vec3 is an optional destination vector.
"""
euler_vec3 = dst_euler_vec3 or Vec3(0.0, 0.0, 0.0)
# TODO consolidated duplicated code in this function and to_euler_deg()
sqw = self.w * self.w
... | [
"def",
"to_euler_rad",
"(",
"self",
",",
"dst_euler_vec3",
"=",
"None",
")",
":",
"euler_vec3",
"=",
"dst_euler_vec3",
"or",
"Vec3",
"(",
"0.0",
",",
"0.0",
",",
"0.0",
")",
"# TODO consolidated duplicated code in this function and to_euler_deg()",
"sqw",
"=",
"self... | Returns euler angles
dst_euler_vec3 is an optional destination vector. | [
"Returns",
"euler",
"angles"
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L190-L209 |
olsoneric/pedemath | pedemath/quat.py | Quat.to_euler_deg | def to_euler_deg(self, euler_vec3):
"""Returns euler angles"""
sqw = self.w * self.w
sqx = self.x * self.x
sqy = self.y * self.y
sqz = self.z * self.z
euler_vec3.z = math.atan2(2.0 * (self.x * self.y + self.z * self.w),
(sqx - sqy - sqz ... | python | def to_euler_deg(self, euler_vec3):
"""Returns euler angles"""
sqw = self.w * self.w
sqx = self.x * self.x
sqy = self.y * self.y
sqz = self.z * self.z
euler_vec3.z = math.atan2(2.0 * (self.x * self.y + self.z * self.w),
(sqx - sqy - sqz ... | [
"def",
"to_euler_deg",
"(",
"self",
",",
"euler_vec3",
")",
":",
"sqw",
"=",
"self",
".",
"w",
"*",
"self",
".",
"w",
"sqx",
"=",
"self",
".",
"x",
"*",
"self",
".",
"x",
"sqy",
"=",
"self",
".",
"y",
"*",
"self",
".",
"y",
"sqz",
"=",
"self"... | Returns euler angles | [
"Returns",
"euler",
"angles"
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L211-L226 |
olsoneric/pedemath | pedemath/quat.py | Quat.set_from_matrix44 | def set_from_matrix44(self, mat):
"""Create a new Quat from a Matrix44.
Note that the matrix and indexes are column major.
"""
# Matrix trace
trace = mat.data[0][0] + mat.data[1][1] + mat.data[2][2] + 1.0
if trace > 0.00000001:
# n4 is norm of quaternion mu... | python | def set_from_matrix44(self, mat):
"""Create a new Quat from a Matrix44.
Note that the matrix and indexes are column major.
"""
# Matrix trace
trace = mat.data[0][0] + mat.data[1][1] + mat.data[2][2] + 1.0
if trace > 0.00000001:
# n4 is norm of quaternion mu... | [
"def",
"set_from_matrix44",
"(",
"self",
",",
"mat",
")",
":",
"# Matrix trace",
"trace",
"=",
"mat",
".",
"data",
"[",
"0",
"]",
"[",
"0",
"]",
"+",
"mat",
".",
"data",
"[",
"1",
"]",
"[",
"1",
"]",
"+",
"mat",
".",
"data",
"[",
"2",
"]",
"[... | Create a new Quat from a Matrix44.
Note that the matrix and indexes are column major. | [
"Create",
"a",
"new",
"Quat",
"from",
"a",
"Matrix44",
"."
] | train | https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/quat.py#L285-L329 |
PRIArobotics/HedgehogUtils | hedgehog/utils/asyncio.py | repeat_func | def repeat_func(func: Callable[[], Union[T, Awaitable[T]]], times: int=None, *, interval: float=0) -> AsyncIterator[T]:
"""
Repeats the result of a 0-ary function either indefinitely, or for a defined number of times.
`times` and `interval` behave exactly like with `aiostream.create.repeat`.
A useful i... | python | def repeat_func(func: Callable[[], Union[T, Awaitable[T]]], times: int=None, *, interval: float=0) -> AsyncIterator[T]:
"""
Repeats the result of a 0-ary function either indefinitely, or for a defined number of times.
`times` and `interval` behave exactly like with `aiostream.create.repeat`.
A useful i... | [
"def",
"repeat_func",
"(",
"func",
":",
"Callable",
"[",
"[",
"]",
",",
"Union",
"[",
"T",
",",
"Awaitable",
"[",
"T",
"]",
"]",
"]",
",",
"times",
":",
"int",
"=",
"None",
",",
"*",
",",
"interval",
":",
"float",
"=",
"0",
")",
"->",
"AsyncIte... | Repeats the result of a 0-ary function either indefinitely, or for a defined number of times.
`times` and `interval` behave exactly like with `aiostream.create.repeat`.
A useful idiom is to combine an indefinite `repeat_func` stream with `aiostream.select.takewhile`
to terminate the stream at some point. | [
"Repeats",
"the",
"result",
"of",
"a",
"0",
"-",
"ary",
"function",
"either",
"indefinitely",
"or",
"for",
"a",
"defined",
"number",
"of",
"times",
".",
"times",
"and",
"interval",
"behave",
"exactly",
"like",
"with",
"aiostream",
".",
"create",
".",
"repe... | train | https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/asyncio.py#L15-L24 |
PRIArobotics/HedgehogUtils | hedgehog/utils/asyncio.py | repeat_func_eof | def repeat_func_eof(func: Callable[[], Union[T, Awaitable[T]]], eof: Any, *, interval: float=0, use_is: bool=False) -> AsyncIterator[T]:
"""
Repeats the result of a 0-ary function until an `eof` item is reached.
The `eof` item itself is not part of the resulting stream; by setting `use_is` to true,
eof ... | python | def repeat_func_eof(func: Callable[[], Union[T, Awaitable[T]]], eof: Any, *, interval: float=0, use_is: bool=False) -> AsyncIterator[T]:
"""
Repeats the result of a 0-ary function until an `eof` item is reached.
The `eof` item itself is not part of the resulting stream; by setting `use_is` to true,
eof ... | [
"def",
"repeat_func_eof",
"(",
"func",
":",
"Callable",
"[",
"[",
"]",
",",
"Union",
"[",
"T",
",",
"Awaitable",
"[",
"T",
"]",
"]",
"]",
",",
"eof",
":",
"Any",
",",
"*",
",",
"interval",
":",
"float",
"=",
"0",
",",
"use_is",
":",
"bool",
"="... | Repeats the result of a 0-ary function until an `eof` item is reached.
The `eof` item itself is not part of the resulting stream; by setting `use_is` to true,
eof is checked by identity rather than equality.
`times` and `interval` behave exactly like with `aiostream.create.repeat`. | [
"Repeats",
"the",
"result",
"of",
"a",
"0",
"-",
"ary",
"function",
"until",
"an",
"eof",
"item",
"is",
"reached",
".",
"The",
"eof",
"item",
"itself",
"is",
"not",
"part",
"of",
"the",
"resulting",
"stream",
";",
"by",
"setting",
"use_is",
"to",
"true... | train | https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/asyncio.py#L28-L37 |
PRIArobotics/HedgehogUtils | hedgehog/utils/asyncio.py | stream_from_queue | def stream_from_queue(queue: asyncio.Queue, eof: Any=__DEFAULT, *, use_is: bool=False) -> AsyncIterator[Any]:
"""
Repeatedly gets an item from the given queue, until an item equal to `eof` (using `==` or `is`) is encountered.
If no `eof` is given, the stream does not stop.
"""
if eof is not __DEFAUL... | python | def stream_from_queue(queue: asyncio.Queue, eof: Any=__DEFAULT, *, use_is: bool=False) -> AsyncIterator[Any]:
"""
Repeatedly gets an item from the given queue, until an item equal to `eof` (using `==` or `is`) is encountered.
If no `eof` is given, the stream does not stop.
"""
if eof is not __DEFAUL... | [
"def",
"stream_from_queue",
"(",
"queue",
":",
"asyncio",
".",
"Queue",
",",
"eof",
":",
"Any",
"=",
"__DEFAULT",
",",
"*",
",",
"use_is",
":",
"bool",
"=",
"False",
")",
"->",
"AsyncIterator",
"[",
"Any",
"]",
":",
"if",
"eof",
"is",
"not",
"__DEFAU... | Repeatedly gets an item from the given queue, until an item equal to `eof` (using `==` or `is`) is encountered.
If no `eof` is given, the stream does not stop. | [
"Repeatedly",
"gets",
"an",
"item",
"from",
"the",
"given",
"queue",
"until",
"an",
"item",
"equal",
"to",
"eof",
"(",
"using",
"==",
"or",
"is",
")",
"is",
"encountered",
".",
"If",
"no",
"eof",
"is",
"given",
"the",
"stream",
"does",
"not",
"stop",
... | train | https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/asyncio.py#L40-L48 |
davidmiller/letter | letter/__init__.py | _stringlist | def _stringlist(*args):
"""
Take a lists of strings or strings and flatten these into
a list of strings.
Arguments:
- `*args`: "" or [""...]
Return: [""...]
Exceptions: None
"""
return list(itertools.chain.from_iterable(itertools.repeat(x,1) if stringy(x) else x for x in args if x)... | python | def _stringlist(*args):
"""
Take a lists of strings or strings and flatten these into
a list of strings.
Arguments:
- `*args`: "" or [""...]
Return: [""...]
Exceptions: None
"""
return list(itertools.chain.from_iterable(itertools.repeat(x,1) if stringy(x) else x for x in args if x)... | [
"def",
"_stringlist",
"(",
"*",
"args",
")",
":",
"return",
"list",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"itertools",
".",
"repeat",
"(",
"x",
",",
"1",
")",
"if",
"stringy",
"(",
"x",
")",
"else",
"x",
"for",
"x",
"in",
"args... | Take a lists of strings or strings and flatten these into
a list of strings.
Arguments:
- `*args`: "" or [""...]
Return: [""...]
Exceptions: None | [
"Take",
"a",
"lists",
"of",
"strings",
"or",
"strings",
"and",
"flatten",
"these",
"into",
"a",
"list",
"of",
"strings",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L51-L62 |
davidmiller/letter | letter/__init__.py | _parse_outgoing_mail | def _parse_outgoing_mail(sender, to, msgstring):
"""
Parse an outgoing mail and put it into the OUTBOX.
Arguments:
- `sender`: str
- `to`: str
- `msgstring`: str
Return: None
Exceptions: None
"""
global OUTBOX
OUTBOX.append(email.message_from_string(msgstring))
return | python | def _parse_outgoing_mail(sender, to, msgstring):
"""
Parse an outgoing mail and put it into the OUTBOX.
Arguments:
- `sender`: str
- `to`: str
- `msgstring`: str
Return: None
Exceptions: None
"""
global OUTBOX
OUTBOX.append(email.message_from_string(msgstring))
return | [
"def",
"_parse_outgoing_mail",
"(",
"sender",
",",
"to",
",",
"msgstring",
")",
":",
"global",
"OUTBOX",
"OUTBOX",
".",
"append",
"(",
"email",
".",
"message_from_string",
"(",
"msgstring",
")",
")",
"return"
] | Parse an outgoing mail and put it into the OUTBOX.
Arguments:
- `sender`: str
- `to`: str
- `msgstring`: str
Return: None
Exceptions: None | [
"Parse",
"an",
"outgoing",
"mail",
"and",
"put",
"it",
"into",
"the",
"OUTBOX",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L581-L596 |
davidmiller/letter | letter/__init__.py | Attachment.as_msg | def as_msg(self):
"""
Convert ourself to be a message part of the appropriate
MIME type.
Return: MIMEBase
Exceptions: None
"""
# Based upon http://docs.python.org/2/library/email-examples.html
# with minimal tweaking
# Guess the content type base... | python | def as_msg(self):
"""
Convert ourself to be a message part of the appropriate
MIME type.
Return: MIMEBase
Exceptions: None
"""
# Based upon http://docs.python.org/2/library/email-examples.html
# with minimal tweaking
# Guess the content type base... | [
"def",
"as_msg",
"(",
"self",
")",
":",
"# Based upon http://docs.python.org/2/library/email-examples.html",
"# with minimal tweaking",
"# Guess the content type based on the file's extension. Encoding",
"# will be ignored, although we should check for simple things like",
"# gzip'd or compress... | Convert ourself to be a message part of the appropriate
MIME type.
Return: MIMEBase
Exceptions: None | [
"Convert",
"ourself",
"to",
"be",
"a",
"message",
"part",
"of",
"the",
"appropriate",
"MIME",
"type",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L72-L113 |
davidmiller/letter | letter/__init__.py | BaseMailer.tolist | def tolist(self, to):
"""
Make sure that our addressees are a unicoded list
Arguments:
- `to`: str or list
Return: [u, ...]
Exceptions: None
"""
return ', '.join(isinstance(to, list) and [u(x) for x in to] or [u(to)]) | python | def tolist(self, to):
"""
Make sure that our addressees are a unicoded list
Arguments:
- `to`: str or list
Return: [u, ...]
Exceptions: None
"""
return ', '.join(isinstance(to, list) and [u(x) for x in to] or [u(to)]) | [
"def",
"tolist",
"(",
"self",
",",
"to",
")",
":",
"return",
"', '",
".",
"join",
"(",
"isinstance",
"(",
"to",
",",
"list",
")",
"and",
"[",
"u",
"(",
"x",
")",
"for",
"x",
"in",
"to",
"]",
"or",
"[",
"u",
"(",
"to",
")",
"]",
")"
] | Make sure that our addressees are a unicoded list
Arguments:
- `to`: str or list
Return: [u, ...]
Exceptions: None | [
"Make",
"sure",
"that",
"our",
"addressees",
"are",
"a",
"unicoded",
"list"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L122-L132 |
davidmiller/letter | letter/__init__.py | BaseMailer.sanity_check | def sanity_check(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None):
"""
Sanity check the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise NoContentError
... | python | def sanity_check(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None):
"""
Sanity check the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise NoContentError
... | [
"def",
"sanity_check",
"(",
"self",
",",
"sender",
",",
"to",
",",
"subject",
",",
"plain",
"=",
"None",
",",
"html",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
")",
":",
"if",
"not",
"plain",
"and",
"not",
"html",
":",
"raise"... | Sanity check the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise NoContentError
Arguments:
- `sender`: str
- `to`: list
- `subject`: str
- `plain`: str
... | [
"Sanity",
"check",
"the",
"message",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L134-L154 |
davidmiller/letter | letter/__init__.py | BaseSMTPMailer.send | def send(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None,
replyto=None, attach=None):
"""
Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise ... | python | def send(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None,
replyto=None, attach=None):
"""
Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise ... | [
"def",
"send",
"(",
"self",
",",
"sender",
",",
"to",
",",
"subject",
",",
"plain",
"=",
"None",
",",
"html",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"replyto",
"=",
"None",
",",
"attach",
"=",
"None",
")",
":",
"self... | Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise NoContentError
Arguments:
- `sender`: str
- `to`: list
- `subject`: str
- `plain`: str
- `... | [
"Send",
"the",
"message",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L162-L213 |
davidmiller/letter | letter/__init__.py | SMTPMailer.deliver | def deliver(self, message, to):
"""
Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None
"""
# Send the message via local SMTP server.
s = smtplib.SMTP(self.host, self.port)
# sendmail function takes 3 a... | python | def deliver(self, message, to):
"""
Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None
"""
# Send the message via local SMTP server.
s = smtplib.SMTP(self.host, self.port)
# sendmail function takes 3 a... | [
"def",
"deliver",
"(",
"self",
",",
"message",
",",
"to",
")",
":",
"# Send the message via local SMTP server.",
"s",
"=",
"smtplib",
".",
"SMTP",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
"# sendmail function takes 3 arguments: sender's address, reci... | Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None | [
"Deliver",
"our",
"message"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L228-L244 |
davidmiller/letter | letter/__init__.py | SMTPAuthenticatedMailer.deliver | def deliver(self, message, to):
"""
Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None
"""
# Send the message via local SMTP server.
s = smtplib.SMTP(self.host, self.port)
s.ehlo()
s.starttls()... | python | def deliver(self, message, to):
"""
Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None
"""
# Send the message via local SMTP server.
s = smtplib.SMTP(self.host, self.port)
s.ehlo()
s.starttls()... | [
"def",
"deliver",
"(",
"self",
",",
"message",
",",
"to",
")",
":",
"# Send the message via local SMTP server.",
"s",
"=",
"smtplib",
".",
"SMTP",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
"s",
".",
"ehlo",
"(",
")",
"s",
".",
"starttls"... | Deliver our message
Arguments:
- `message`: MIMEMultipart
Return: None
Exceptions: None | [
"Deliver",
"our",
"message"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L258-L277 |
davidmiller/letter | letter/__init__.py | DjangoMailer.send | def send(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None,
attach=None, replyto=None):
"""
Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise ... | python | def send(self, sender, to, subject, plain=None, html=None, cc=None, bcc=None,
attach=None, replyto=None):
"""
Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise ... | [
"def",
"send",
"(",
"self",
",",
"sender",
",",
"to",
",",
"subject",
",",
"plain",
"=",
"None",
",",
"html",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"attach",
"=",
"None",
",",
"replyto",
"=",
"None",
")",
":",
"head... | Send the message.
If we have PLAIN and HTML versions, send a multipart alternative
MIME message, else send whichever we do have.
If we have neither, raise NoContentError
Arguments:
- `sender`: str
- `to`: list
- `subject`: str
- `plain`: str
- `... | [
"Send",
"the",
"message",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L286-L336 |
davidmiller/letter | letter/__init__.py | BasePostman._find_tpl | def _find_tpl(self, name, extension='.jinja2'):
"""
Return a Path object representing the Template we're after,
searching SELF.tpls or None
Arguments:
- `name`: str
Return: Path or None
Exceptions: None
"""
found = None
for loc in self.tp... | python | def _find_tpl(self, name, extension='.jinja2'):
"""
Return a Path object representing the Template we're after,
searching SELF.tpls or None
Arguments:
- `name`: str
Return: Path or None
Exceptions: None
"""
found = None
for loc in self.tp... | [
"def",
"_find_tpl",
"(",
"self",
",",
"name",
",",
"extension",
"=",
"'.jinja2'",
")",
":",
"found",
"=",
"None",
"for",
"loc",
"in",
"self",
".",
"tpls",
":",
"if",
"not",
"loc",
":",
"continue",
"contents",
"=",
"[",
"f",
"for",
"f",
"in",
"loc",... | Return a Path object representing the Template we're after,
searching SELF.tpls or None
Arguments:
- `name`: str
Return: Path or None
Exceptions: None | [
"Return",
"a",
"Path",
"object",
"representing",
"the",
"Template",
"we",
"re",
"after",
"searching",
"SELF",
".",
"tpls",
"or",
"None"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L354-L376 |
davidmiller/letter | letter/__init__.py | BasePostman._find_tpls | def _find_tpls(self, name):
"""
Return plain, html templates for NAME
Arguments:
- `name`: str
Return: tuple
Exceptions: None
"""
return self._find_tpl(name, extension='.txt'), self._find_tpl(name, extension='.html') | python | def _find_tpls(self, name):
"""
Return plain, html templates for NAME
Arguments:
- `name`: str
Return: tuple
Exceptions: None
"""
return self._find_tpl(name, extension='.txt'), self._find_tpl(name, extension='.html') | [
"def",
"_find_tpls",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_find_tpl",
"(",
"name",
",",
"extension",
"=",
"'.txt'",
")",
",",
"self",
".",
"_find_tpl",
"(",
"name",
",",
"extension",
"=",
"'.html'",
")"
] | Return plain, html templates for NAME
Arguments:
- `name`: str
Return: tuple
Exceptions: None | [
"Return",
"plain",
"html",
"templates",
"for",
"NAME"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L378-L388 |
davidmiller/letter | letter/__init__.py | BasePostman._send | def _send(self, sender, to, subject, message, cc=None, bcc=None, attach=None, replyto=None):
"""
Send a Letter (MESSAGE) from SENDER to TO, with the subject SUBJECT
Arguments:
- `sender`: unicode
- `to`: unicode
- `subject`: unicode
- `message`: unicode
-... | python | def _send(self, sender, to, subject, message, cc=None, bcc=None, attach=None, replyto=None):
"""
Send a Letter (MESSAGE) from SENDER to TO, with the subject SUBJECT
Arguments:
- `sender`: unicode
- `to`: unicode
- `subject`: unicode
- `message`: unicode
-... | [
"def",
"_send",
"(",
"self",
",",
"sender",
",",
"to",
",",
"subject",
",",
"message",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"attach",
"=",
"None",
",",
"replyto",
"=",
"None",
")",
":",
"self",
".",
"mailer",
".",
"send",
"(",
... | Send a Letter (MESSAGE) from SENDER to TO, with the subject SUBJECT
Arguments:
- `sender`: unicode
- `to`: unicode
- `subject`: unicode
- `message`: unicode
- `cc`: str or [str]
- `bcc`: str or [str]
` `replyto`: str
Return: None
Exceptio... | [
"Send",
"a",
"Letter",
"(",
"MESSAGE",
")",
"from",
"SENDER",
"to",
"TO",
"with",
"the",
"subject",
"SUBJECT"
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L390-L407 |
davidmiller/letter | letter/__init__.py | BasePostman._sendtpl | def _sendtpl(self, sender, to, subject, cc=None, bcc=None, attach=None, replyto=None, **kwargs):
"""
Send a Letter from SENDER to TO, with the subject SUBJECT.
Use the current template, with KWARGS as the context.
Arguments:
- `sender`: unicode
- `to`: unicode
- ... | python | def _sendtpl(self, sender, to, subject, cc=None, bcc=None, attach=None, replyto=None, **kwargs):
"""
Send a Letter from SENDER to TO, with the subject SUBJECT.
Use the current template, with KWARGS as the context.
Arguments:
- `sender`: unicode
- `to`: unicode
- ... | [
"def",
"_sendtpl",
"(",
"self",
",",
"sender",
",",
"to",
",",
"subject",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"attach",
"=",
"None",
",",
"replyto",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"plain",
",",
"html",
"=",
"s... | Send a Letter from SENDER to TO, with the subject SUBJECT.
Use the current template, with KWARGS as the context.
Arguments:
- `sender`: unicode
- `to`: unicode
- `subject`: unicode
- `cc`: str or [str]
- `bcc`: str or [str]
- `replyto`: str
- `**k... | [
"Send",
"a",
"Letter",
"from",
"SENDER",
"to",
"TO",
"with",
"the",
"subject",
"SUBJECT",
".",
"Use",
"the",
"current",
"template",
"with",
"KWARGS",
"as",
"the",
"context",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L411-L431 |
davidmiller/letter | letter/__init__.py | BasePostman.body | def body(self, **kwargs):
"""
Return the plain and html versions of our contents.
Return: tuple
Exceptions: None
"""
text_content, html_content = None, None
if self.plain:
text_content = mold.cast(self.plain, **kwargs)
if self.html:
... | python | def body(self, **kwargs):
"""
Return the plain and html versions of our contents.
Return: tuple
Exceptions: None
"""
text_content, html_content = None, None
if self.plain:
text_content = mold.cast(self.plain, **kwargs)
if self.html:
... | [
"def",
"body",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"text_content",
",",
"html_content",
"=",
"None",
",",
"None",
"if",
"self",
".",
"plain",
":",
"text_content",
"=",
"mold",
".",
"cast",
"(",
"self",
".",
"plain",
",",
"*",
"*",
"kwar... | Return the plain and html versions of our contents.
Return: tuple
Exceptions: None | [
"Return",
"the",
"plain",
"and",
"html",
"versions",
"of",
"our",
"contents",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L433-L445 |
davidmiller/letter | letter/__init__.py | BasePostman.template | def template(self, name):
"""
Set an active template to use with our Postman.
This changes the call signature of send.
Arguments:
- `name`: str
Return: None
Exceptions: None
"""
self.plain, self.html = self._find_tpls(name)
if not self.p... | python | def template(self, name):
"""
Set an active template to use with our Postman.
This changes the call signature of send.
Arguments:
- `name`: str
Return: None
Exceptions: None
"""
self.plain, self.html = self._find_tpls(name)
if not self.p... | [
"def",
"template",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"plain",
",",
"self",
".",
"html",
"=",
"self",
".",
"_find_tpls",
"(",
"name",
")",
"if",
"not",
"self",
".",
"plain",
":",
"self",
".",
"plain",
"=",
"self",
".",
"_find_tpl",
... | Set an active template to use with our Postman.
This changes the call signature of send.
Arguments:
- `name`: str
Return: None
Exceptions: None | [
"Set",
"an",
"active",
"template",
"to",
"use",
"with",
"our",
"Postman",
"."
] | train | https://github.com/davidmiller/letter/blob/c0c66ae2c6a792106e9a8374a01421817c8a8ae0/letter/__init__.py#L448-L468 |
diffeo/rejester | rejester/_task_master.py | Worker.environment | def environment(self):
'''Get raw data about this worker.
This is recorded in the :meth:`heartbeat` info, and can be
retrieved by :meth:`TaskMaster.get_heartbeat`. The dictionary
includes keys ``worker_id``, ``host``, ``fqdn``, ``version``,
``working_set``, and ``memory``.
... | python | def environment(self):
'''Get raw data about this worker.
This is recorded in the :meth:`heartbeat` info, and can be
retrieved by :meth:`TaskMaster.get_heartbeat`. The dictionary
includes keys ``worker_id``, ``host``, ``fqdn``, ``version``,
``working_set``, and ``memory``.
... | [
"def",
"environment",
"(",
"self",
")",
":",
"hostname",
"=",
"socket",
".",
"gethostname",
"(",
")",
"aliases",
"=",
"(",
")",
"ipaddrs",
"=",
"(",
")",
"# This sequence isn't 100% reliable. We might try a socket()",
"# sequence like RedisBase._ipaddress(), or just deci... | Get raw data about this worker.
This is recorded in the :meth:`heartbeat` info, and can be
retrieved by :meth:`TaskMaster.get_heartbeat`. The dictionary
includes keys ``worker_id``, ``host``, ``fqdn``, ``version``,
``working_set``, and ``memory``. | [
"Get",
"raw",
"data",
"about",
"this",
"worker",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L107-L152 |
diffeo/rejester | rejester/_task_master.py | Worker.register | def register(self, parent=None):
'''Record the availability of this worker and get a unique identifer.
This sets :attr:`worker_id` and calls :meth:`heartbeat`. This
cannot be called multiple times without calling
:meth:`unregister` in between.
'''
if self.worker_id:
... | python | def register(self, parent=None):
'''Record the availability of this worker and get a unique identifer.
This sets :attr:`worker_id` and calls :meth:`heartbeat`. This
cannot be called multiple times without calling
:meth:`unregister` in between.
'''
if self.worker_id:
... | [
"def",
"register",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"if",
"self",
".",
"worker_id",
":",
"raise",
"ProgrammerError",
"(",
"'Worker.register cannot be called again without first calling unregister; it is not idempotent'",
")",
"self",
".",
"parent",
"="... | Record the availability of this worker and get a unique identifer.
This sets :attr:`worker_id` and calls :meth:`heartbeat`. This
cannot be called multiple times without calling
:meth:`unregister` in between. | [
"Record",
"the",
"availability",
"of",
"this",
"worker",
"and",
"get",
"a",
"unique",
"identifer",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L154-L168 |
diffeo/rejester | rejester/_task_master.py | Worker.unregister | def unregister(self):
'''Remove this worker from the list of available workers.
This requires the worker to already have been :meth:`register()`.
'''
self.task_master.worker_unregister(self.worker_id)
self.task_master.worker_id = None
self.worker_id = None | python | def unregister(self):
'''Remove this worker from the list of available workers.
This requires the worker to already have been :meth:`register()`.
'''
self.task_master.worker_unregister(self.worker_id)
self.task_master.worker_id = None
self.worker_id = None | [
"def",
"unregister",
"(",
"self",
")",
":",
"self",
".",
"task_master",
".",
"worker_unregister",
"(",
"self",
".",
"worker_id",
")",
"self",
".",
"task_master",
".",
"worker_id",
"=",
"None",
"self",
".",
"worker_id",
"=",
"None"
] | Remove this worker from the list of available workers.
This requires the worker to already have been :meth:`register()`. | [
"Remove",
"this",
"worker",
"from",
"the",
"list",
"of",
"available",
"workers",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L170-L178 |
diffeo/rejester | rejester/_task_master.py | Worker.heartbeat | def heartbeat(self):
'''Record the current worker state in the registry.
This records the worker's current mode, plus the contents of
:meth:`environment`, in the data store for inspection by others.
:returns mode: Current mode, as :meth:`TaskMaster.get_mode`
'''
mode =... | python | def heartbeat(self):
'''Record the current worker state in the registry.
This records the worker's current mode, plus the contents of
:meth:`environment`, in the data store for inspection by others.
:returns mode: Current mode, as :meth:`TaskMaster.get_mode`
'''
mode =... | [
"def",
"heartbeat",
"(",
"self",
")",
":",
"mode",
"=",
"self",
".",
"task_master",
".",
"get_mode",
"(",
")",
"self",
".",
"task_master",
".",
"worker_heartbeat",
"(",
"self",
".",
"worker_id",
",",
"mode",
",",
"self",
".",
"lifetime",
",",
"self",
"... | Record the current worker state in the registry.
This records the worker's current mode, plus the contents of
:meth:`environment`, in the data store for inspection by others.
:returns mode: Current mode, as :meth:`TaskMaster.get_mode` | [
"Record",
"the",
"current",
"worker",
"state",
"in",
"the",
"registry",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L180-L193 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.spec | def spec(self):
'''Actual work spec.
This is retrieved from the database on first use, and in some
cases a worker can be mildly more efficient if it avoids using
this.
'''
if self._spec_cache is None:
self._spec_cache = self.registry.get(
WOR... | python | def spec(self):
'''Actual work spec.
This is retrieved from the database on first use, and in some
cases a worker can be mildly more efficient if it avoids using
this.
'''
if self._spec_cache is None:
self._spec_cache = self.registry.get(
WOR... | [
"def",
"spec",
"(",
"self",
")",
":",
"if",
"self",
".",
"_spec_cache",
"is",
"None",
":",
"self",
".",
"_spec_cache",
"=",
"self",
".",
"registry",
".",
"get",
"(",
"WORK_SPECS",
",",
"self",
".",
"work_spec_name",
")",
"return",
"self",
".",
"_spec_c... | Actual work spec.
This is retrieved from the database on first use, and in some
cases a worker can be mildly more efficient if it avoids using
this. | [
"Actual",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L284-L295 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.module | def module(self):
'''Python module to run the job.
This is used by :func:`run` and the standard worker system.
If the work spec contains keys ``module``, ``run_function``,
and ``terminate_function``, then this contains the Python
module object named as ``module``; otherwise this... | python | def module(self):
'''Python module to run the job.
This is used by :func:`run` and the standard worker system.
If the work spec contains keys ``module``, ``run_function``,
and ``terminate_function``, then this contains the Python
module object named as ``module``; otherwise this... | [
"def",
"module",
"(",
"self",
")",
":",
"if",
"self",
".",
"_module_cache",
"is",
"None",
":",
"funclist",
"=",
"filter",
"(",
"None",
",",
"(",
"self",
".",
"spec",
".",
"get",
"(",
"'run_function'",
")",
",",
"self",
".",
"spec",
".",
"get",
"(",... | Python module to run the job.
This is used by :func:`run` and the standard worker system.
If the work spec contains keys ``module``, ``run_function``,
and ``terminate_function``, then this contains the Python
module object named as ``module``; otherwise this contains
:const:`Non... | [
"Python",
"module",
"to",
"run",
"the",
"job",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L298-L319 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.run | def run(self):
'''Actually runs the work unit.
This is called by the standard worker system, generally
once per work unit. It requires the work spec to contain
keys ``module``, ``run_function``, and ``terminate_function``.
It looks up ``run_function`` in :attr:`module` and call... | python | def run(self):
'''Actually runs the work unit.
This is called by the standard worker system, generally
once per work unit. It requires the work spec to contain
keys ``module``, ``run_function``, and ``terminate_function``.
It looks up ``run_function`` in :attr:`module` and call... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"logger",
".",
"info",
"(",
"'running work unit {0}'",
".",
"format",
"(",
"self",
".",
"key",
")",
")",
"run_function",
"=",
"getattr",
"(",
"self",
".",
"module",
",",
"self",
".",
"spec",
"[",
"'run... | Actually runs the work unit.
This is called by the standard worker system, generally
once per work unit. It requires the work spec to contain
keys ``module``, ``run_function``, and ``terminate_function``.
It looks up ``run_function`` in :attr:`module` and calls that
function wi... | [
"Actually",
"runs",
"the",
"work",
"unit",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L321-L344 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.terminate | def terminate(self):
'''Kills the work unit.
This is called by the standard worker system, but only in
response to an operating system signal. If the job does setup
such as creating a child process, its terminate function
should kill that child process. More specifically, this... | python | def terminate(self):
'''Kills the work unit.
This is called by the standard worker system, but only in
response to an operating system signal. If the job does setup
such as creating a child process, its terminate function
should kill that child process. More specifically, this... | [
"def",
"terminate",
"(",
"self",
")",
":",
"terminate_function_name",
"=",
"self",
".",
"spec",
".",
"get",
"(",
"'terminate_function'",
")",
"if",
"not",
"terminate_function_name",
":",
"logger",
".",
"error",
"(",
"'tried to terminate WorkUnit(%r) but no '",
"'fun... | Kills the work unit.
This is called by the standard worker system, but only in
response to an operating system signal. If the job does setup
such as creating a child process, its terminate function
should kill that child process. More specifically, this
function requires the w... | [
"Kills",
"the",
"work",
"unit",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L346-L376 |
diffeo/rejester | rejester/_task_master.py | WorkUnit._refresh | def _refresh(self, session, stopping=False):
'''Get this task's current state.
This must be called under the registry's lock. It updates
the :attr:`finished` and :attr:`failed` flags and the
:attr:`data` dictionary based on the current state in the
registry.
In the nor... | python | def _refresh(self, session, stopping=False):
'''Get this task's current state.
This must be called under the registry's lock. It updates
the :attr:`finished` and :attr:`failed` flags and the
:attr:`data` dictionary based on the current state in the
registry.
In the nor... | [
"def",
"_refresh",
"(",
"self",
",",
"session",
",",
"stopping",
"=",
"False",
")",
":",
"data",
"=",
"session",
".",
"get",
"(",
"WORK_UNITS_",
"+",
"self",
".",
"work_spec_name",
"+",
"_FINISHED",
",",
"self",
".",
"key",
")",
"if",
"data",
"is",
"... | Get this task's current state.
This must be called under the registry's lock. It updates
the :attr:`finished` and :attr:`failed` flags and the
:attr:`data` dictionary based on the current state in the
registry.
In the normal case, nothing will change and this function
... | [
"Get",
"this",
"task",
"s",
"current",
"state",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L378-L441 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.update | def update(self, lease_time=None):
'''Refresh this task's expiration time.
This tries to set the task's expiration time to the current
time, plus `lease_time` seconds. It requires the job to not
already be complete. If `lease_time` is negative, makes the
job immediately be ava... | python | def update(self, lease_time=None):
'''Refresh this task's expiration time.
This tries to set the task's expiration time to the current
time, plus `lease_time` seconds. It requires the job to not
already be complete. If `lease_time` is negative, makes the
job immediately be ava... | [
"def",
"update",
"(",
"self",
",",
"lease_time",
"=",
"None",
")",
":",
"if",
"lease_time",
"is",
"None",
":",
"lease_time",
"=",
"self",
".",
"default_lifetime",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_... | Refresh this task's expiration time.
This tries to set the task's expiration time to the current
time, plus `lease_time` seconds. It requires the job to not
already be complete. If `lease_time` is negative, makes the
job immediately be available for other workers to run.
:par... | [
"Refresh",
"this",
"task",
"s",
"expiration",
"time",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L443-L469 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.finish | def finish(self):
'''Move this work unit to a finished state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` returns successfully.
:raises rejester.exceptions.LostLease: if the lease has already
expired
'''
... | python | def finish(self):
'''Move this work unit to a finished state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` returns successfully.
:raises rejester.exceptions.LostLease: if the lease has already
expired
'''
... | [
"def",
"finish",
"(",
"self",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"self",
".",
"_refresh",
"(",
"session",
",",
"stopping",
"=",
"True",
")",
"if",
"self... | Move this work unit to a finished state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` returns successfully.
:raises rejester.exceptions.LostLease: if the lease has already
expired | [
"Move",
"this",
"work",
"unit",
"to",
"a",
"finished",
"state",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L471-L515 |
diffeo/rejester | rejester/_task_master.py | WorkUnit.fail | def fail(self, exc=None):
'''Move this work unit to a failed state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` ends with any exception:
.. code-block:: python
try:
work_unit.run()
work_... | python | def fail(self, exc=None):
'''Move this work unit to a failed state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` ends with any exception:
.. code-block:: python
try:
work_unit.run()
work_... | [
"def",
"fail",
"(",
"self",
",",
"exc",
"=",
"None",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"self",
".",
"_refresh",
"(",
"session",
",",
"stopping",
"=",
... | Move this work unit to a failed state.
In the standard worker system, the worker calls this on the job's
behalf when :meth:`run_function` ends with any exception:
.. code-block:: python
try:
work_unit.run()
work_unit.finish()
except Exce... | [
"Move",
"this",
"work",
"unit",
"to",
"a",
"failed",
"state",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L517-L586 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.set_mode | def set_mode(self, mode):
'''Set the global mode of the rejester system.
This must be one of the constants :attr:`TERMINATE`,
:attr:`RUN`, or :attr:`IDLE`. :attr:`TERMINATE` instructs any
running workers to do an orderly shutdown, completing current
jobs then exiting. :attr:`I... | python | def set_mode(self, mode):
'''Set the global mode of the rejester system.
This must be one of the constants :attr:`TERMINATE`,
:attr:`RUN`, or :attr:`IDLE`. :attr:`TERMINATE` instructs any
running workers to do an orderly shutdown, completing current
jobs then exiting. :attr:`I... | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
")",
":",
"if",
"mode",
"not",
"in",
"[",
"self",
".",
"TERMINATE",
",",
"self",
".",
"RUN",
",",
"self",
".",
"IDLE",
"]",
":",
"raise",
"ProgrammerError",
"(",
"'mode=%r is not recognized'",
"%",
"mode",
"... | Set the global mode of the rejester system.
This must be one of the constants :attr:`TERMINATE`,
:attr:`RUN`, or :attr:`IDLE`. :attr:`TERMINATE` instructs any
running workers to do an orderly shutdown, completing current
jobs then exiting. :attr:`IDLE` instructs workers to stay
... | [
"Set",
"the",
"global",
"mode",
"of",
"the",
"rejester",
"system",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L717-L735 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.idle_all_workers | def idle_all_workers(self):
'''Set the global mode to :attr:`IDLE` and wait for workers to stop.
This can wait arbitrarily long before returning. The worst
case in "normal" usage involves waiting five minutes for a
"lost" job to expire; a well-behaved but very-long-running job
... | python | def idle_all_workers(self):
'''Set the global mode to :attr:`IDLE` and wait for workers to stop.
This can wait arbitrarily long before returning. The worst
case in "normal" usage involves waiting five minutes for a
"lost" job to expire; a well-behaved but very-long-running job
... | [
"def",
"idle_all_workers",
"(",
"self",
")",
":",
"self",
".",
"set_mode",
"(",
"self",
".",
"IDLE",
")",
"while",
"1",
":",
"num_pending",
"=",
"dict",
"(",
")",
"for",
"work_spec_name",
"in",
"self",
".",
"registry",
".",
"pull",
"(",
"NICE_LEVELS",
... | Set the global mode to :attr:`IDLE` and wait for workers to stop.
This can wait arbitrarily long before returning. The worst
case in "normal" usage involves waiting five minutes for a
"lost" job to expire; a well-behaved but very-long-running job
can extend its own lease further, and t... | [
"Set",
"the",
"global",
"mode",
"to",
":",
"attr",
":",
"IDLE",
"and",
"wait",
"for",
"workers",
"to",
"stop",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L745-L771 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.mode_counts | def mode_counts(self):
'''Get the number of workers in each mode.
This returns a dictionary where the keys are mode constants
and the values are a simple integer count of the number of
workers in that mode.
'''
modes = {self.RUN: 0, self.IDLE: 0, self.TERMINATE: 0}
... | python | def mode_counts(self):
'''Get the number of workers in each mode.
This returns a dictionary where the keys are mode constants
and the values are a simple integer count of the number of
workers in that mode.
'''
modes = {self.RUN: 0, self.IDLE: 0, self.TERMINATE: 0}
... | [
"def",
"mode_counts",
"(",
"self",
")",
":",
"modes",
"=",
"{",
"self",
".",
"RUN",
":",
"0",
",",
"self",
".",
"IDLE",
":",
"0",
",",
"self",
".",
"TERMINATE",
":",
"0",
"}",
"for",
"worker_id",
",",
"mode",
"in",
"self",
".",
"workers",
"(",
... | Get the number of workers in each mode.
This returns a dictionary where the keys are mode constants
and the values are a simple integer count of the number of
workers in that mode. | [
"Get",
"the",
"number",
"of",
"workers",
"in",
"each",
"mode",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L773-L784 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.workers | def workers(self, alive=True):
'''Get a listing of all workers.
This returns a dictionary mapping worker ID to the mode
constant for their last observed mode.
:param bool alive: if true (default), only include workers
that have called :meth:`Worker.heartbeat` sufficiently rec... | python | def workers(self, alive=True):
'''Get a listing of all workers.
This returns a dictionary mapping worker ID to the mode
constant for their last observed mode.
:param bool alive: if true (default), only include workers
that have called :meth:`Worker.heartbeat` sufficiently rec... | [
"def",
"workers",
"(",
"self",
",",
"alive",
"=",
"True",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORKER_OBSERVED_MODE",
",",
"priority_min",
"=",
"alive",
"and",
"time",
".",
"time",
"(",
")",
"or",
"'-inf'",
")"
] | Get a listing of all workers.
This returns a dictionary mapping worker ID to the mode
constant for their last observed mode.
:param bool alive: if true (default), only include workers
that have called :meth:`Worker.heartbeat` sufficiently recently | [
"Get",
"a",
"listing",
"of",
"all",
"workers",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L786-L798 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.dump | def dump(self):
'''Print the entire contents of this to debug log messages.
This is really only intended for debugging. It could produce
a lot of data.
'''
with self.registry.lock(identifier=self.worker_id) as session:
for work_spec_name in self.registry.pull(NICE_... | python | def dump(self):
'''Print the entire contents of this to debug log messages.
This is really only intended for debugging. It could produce
a lot of data.
'''
with self.registry.lock(identifier=self.worker_id) as session:
for work_spec_name in self.registry.pull(NICE_... | [
"def",
"dump",
"(",
"self",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"for",
"work_spec_name",
"in",
"self",
".",
"registry",
".",
"pull",
"(",
"NICE_LEVELS",
")... | Print the entire contents of this to debug log messages.
This is really only intended for debugging. It could produce
a lot of data. | [
"Print",
"the",
"entire",
"contents",
"of",
"this",
"to",
"debug",
"log",
"messages",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L814-L841 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.validate_work_spec | def validate_work_spec(cls, work_spec):
'''Check that `work_spec` is valid.
It must at the very minimum contain a ``name`` and ``min_gb``.
:raise rejester.exceptions.ProgrammerError: if it isn't valid
'''
if 'name' not in work_spec:
raise ProgrammerError('work_spec... | python | def validate_work_spec(cls, work_spec):
'''Check that `work_spec` is valid.
It must at the very minimum contain a ``name`` and ``min_gb``.
:raise rejester.exceptions.ProgrammerError: if it isn't valid
'''
if 'name' not in work_spec:
raise ProgrammerError('work_spec... | [
"def",
"validate_work_spec",
"(",
"cls",
",",
"work_spec",
")",
":",
"if",
"'name'",
"not",
"in",
"work_spec",
":",
"raise",
"ProgrammerError",
"(",
"'work_spec lacks \"name\"'",
")",
"if",
"'min_gb'",
"not",
"in",
"work_spec",
"or",
"not",
"isinstance",
"(",
... | Check that `work_spec` is valid.
It must at the very minimum contain a ``name`` and ``min_gb``.
:raise rejester.exceptions.ProgrammerError: if it isn't valid | [
"Check",
"that",
"work_spec",
"is",
"valid",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L844-L856 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.num_available | def num_available(self, work_spec_name):
'''Get the number of available work units for some work spec.
These are work units that could be returned by :meth:`get_work`:
they are not complete, not currently executing, and not blocked
on some other work unit.
'''
return se... | python | def num_available(self, work_spec_name):
'''Get the number of available work units for some work spec.
These are work units that could be returned by :meth:`get_work`:
they are not complete, not currently executing, and not blocked
on some other work unit.
'''
return se... | [
"def",
"num_available",
"(",
"self",
",",
"work_spec_name",
")",
":",
"return",
"self",
".",
"registry",
".",
"len",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"priority_max",
"=",
"time",
".",
"time",
"(",
")",
")"
] | Get the number of available work units for some work spec.
These are work units that could be returned by :meth:`get_work`:
they are not complete, not currently executing, and not blocked
on some other work unit. | [
"Get",
"the",
"number",
"of",
"available",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L858-L867 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.num_pending | def num_pending(self, work_spec_name):
'''Get the number of pending work units for some work spec.
These are work units that some worker is currently working on
(hopefully; it could include work units assigned to workers that
died and that have not yet expired).
'''
ret... | python | def num_pending(self, work_spec_name):
'''Get the number of pending work units for some work spec.
These are work units that some worker is currently working on
(hopefully; it could include work units assigned to workers that
died and that have not yet expired).
'''
ret... | [
"def",
"num_pending",
"(",
"self",
",",
"work_spec_name",
")",
":",
"return",
"self",
".",
"registry",
".",
"len",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"priority_min",
"=",
"time",
".",
"time",
"(",
")",
")"
] | Get the number of pending work units for some work spec.
These are work units that some worker is currently working on
(hopefully; it could include work units assigned to workers that
died and that have not yet expired). | [
"Get",
"the",
"number",
"of",
"pending",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L869-L878 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.num_tasks | def num_tasks(self, work_spec_name):
'''Get the total number of work units for some work spec.'''
return self.num_finished(work_spec_name) + \
self.num_failed(work_spec_name) + \
self.registry.len(WORK_UNITS_ + work_spec_name) | python | def num_tasks(self, work_spec_name):
'''Get the total number of work units for some work spec.'''
return self.num_finished(work_spec_name) + \
self.num_failed(work_spec_name) + \
self.registry.len(WORK_UNITS_ + work_spec_name) | [
"def",
"num_tasks",
"(",
"self",
",",
"work_spec_name",
")",
":",
"return",
"self",
".",
"num_finished",
"(",
"work_spec_name",
")",
"+",
"self",
".",
"num_failed",
"(",
"work_spec_name",
")",
"+",
"self",
".",
"registry",
".",
"len",
"(",
"WORK_UNITS_",
"... | Get the total number of work units for some work spec. | [
"Get",
"the",
"total",
"number",
"of",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L906-L910 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.status | def status(self, work_spec_name):
'''Get a summary dictionary for some work spec.
The keys are the strings :meth:`num_available`, :meth:`num_pending`,
:meth:`num_blocked`, :meth:`num_finished`, :meth:`num_failed`,
and :meth:`num_tasks`, and the values are the values returned
fro... | python | def status(self, work_spec_name):
'''Get a summary dictionary for some work spec.
The keys are the strings :meth:`num_available`, :meth:`num_pending`,
:meth:`num_blocked`, :meth:`num_finished`, :meth:`num_failed`,
and :meth:`num_tasks`, and the values are the values returned
fro... | [
"def",
"status",
"(",
"self",
",",
"work_spec_name",
")",
":",
"return",
"dict",
"(",
"num_available",
"=",
"self",
".",
"num_available",
"(",
"work_spec_name",
")",
",",
"num_pending",
"=",
"self",
".",
"num_pending",
"(",
"work_spec_name",
")",
",",
"num_b... | Get a summary dictionary for some work spec.
The keys are the strings :meth:`num_available`, :meth:`num_pending`,
:meth:`num_blocked`, :meth:`num_finished`, :meth:`num_failed`,
and :meth:`num_tasks`, and the values are the values returned
from those functions. | [
"Get",
"a",
"summary",
"dictionary",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L912-L928 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.iter_work_specs | def iter_work_specs(self, limit=None, start=None):
'''
yield work spec dicts
'''
count = 0
ws_list, start = self.list_work_specs(limit, start)
while True:
for name_spec in ws_list:
yield name_spec[1]
count += 1
i... | python | def iter_work_specs(self, limit=None, start=None):
'''
yield work spec dicts
'''
count = 0
ws_list, start = self.list_work_specs(limit, start)
while True:
for name_spec in ws_list:
yield name_spec[1]
count += 1
i... | [
"def",
"iter_work_specs",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"start",
"=",
"None",
")",
":",
"count",
"=",
"0",
"ws_list",
",",
"start",
"=",
"self",
".",
"list_work_specs",
"(",
"limit",
",",
"start",
")",
"while",
"True",
":",
"for",
"nam... | yield work spec dicts | [
"yield",
"work",
"spec",
"dicts"
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L941-L957 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.get_work_spec | def get_work_spec(self, work_spec_name):
'''Get the dictionary defining some work spec.'''
with self.registry.lock(identifier=self.worker_id) as session:
return session.get(WORK_SPECS, work_spec_name) | python | def get_work_spec(self, work_spec_name):
'''Get the dictionary defining some work spec.'''
with self.registry.lock(identifier=self.worker_id) as session:
return session.get(WORK_SPECS, work_spec_name) | [
"def",
"get_work_spec",
"(",
"self",
",",
"work_spec_name",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"return",
"session",
".",
"get",
"(",
"WORK_SPECS",
",",
"wor... | Get the dictionary defining some work spec. | [
"Get",
"the",
"dictionary",
"defining",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L959-L962 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.get_work_units | def get_work_units(self, work_spec_name, work_unit_keys=None,
state=None, limit=None, start=None):
'''Get (key, value) pairs for work units.
If `state` is not :const:`None`, then it should be one of
the string state constants, and this function will return
a list ... | python | def get_work_units(self, work_spec_name, work_unit_keys=None,
state=None, limit=None, start=None):
'''Get (key, value) pairs for work units.
If `state` is not :const:`None`, then it should be one of
the string state constants, and this function will return
a list ... | [
"def",
"get_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_keys",
"=",
"None",
",",
"state",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"start",
"=",
"None",
")",
":",
"if",
"work_unit_keys",
"is",
"not",
"None",
":",
"raise",
"NotImp... | Get (key, value) pairs for work units.
If `state` is not :const:`None`, then it should be one of
the string state constants, and this function will return
a list of pairs of work unit key and value for work units
in that state. If `start` is not :const:`None`, then this
many wo... | [
"Get",
"(",
"key",
"value",
")",
"pairs",
"for",
"work",
"units",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L964-L1015 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_work_units | def list_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been completed ("available" or
"pending" work units) are included.
"... | python | def list_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been completed ("available" or
"pending" work units) are included.
"... | [
"def",
"list_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"start",
"=",
"start",
",",
"limi... | Get a dictionary of work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been completed ("available" or
"pending" work units) are included. | [
"Get",
"a",
"dictionary",
"of",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1017-L1026 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_available_work_units | def list_available_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of available work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been started, or units that were
started but did not comp... | python | def list_available_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of available work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been started, or units that were
started but did not comp... | [
"def",
"list_available_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"priority_max",
"=",
"time"... | Get a dictionary of available work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have not been started, or units that were
started but did not complete in a timely fashion, are
included. | [
"Get",
"a",
"dictionary",
"of",
"available",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1028-L1039 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_pending_work_units | def list_pending_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of in-progress work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Units listed here should be worked on by some worker.
"""
return self.registry... | python | def list_pending_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of in-progress work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Units listed here should be worked on by some worker.
"""
return self.registry... | [
"def",
"list_pending_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
",",
"priority_min",
"=",
"time",
... | Get a dictionary of in-progress work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Units listed here should be worked on by some worker. | [
"Get",
"a",
"dictionary",
"of",
"in",
"-",
"progress",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1041-L1050 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_blocked_work_units | def list_blocked_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of blocked work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Work units included in this list are blocked because they were
listed as the first work uni... | python | def list_blocked_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of blocked work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Work units included in this list are blocked because they were
listed as the first work uni... | [
"def",
"list_blocked_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
"+",
"_BLOCKED",
",",
"start",
"... | Get a dictionary of blocked work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Work units included in this list are blocked because they were
listed as the first work unit in
:func:`add_dependent_work_units`, and the work unit(s) they
de... | [
"Get",
"a",
"dictionary",
"of",
"blocked",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1052-L1065 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_finished_work_units | def list_finished_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of finished work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have been successfully completed are
included.
"""
... | python | def list_finished_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of finished work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have been successfully completed are
included.
"""
... | [
"def",
"list_finished_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
"+",
"_FINISHED",
",",
"start",
... | Get a dictionary of finished work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have been successfully completed are
included. | [
"Get",
"a",
"dictionary",
"of",
"finished",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1067-L1076 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.list_failed_work_units | def list_failed_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of failed work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have completed unsuccessfully are included.
"""
return self.reg... | python | def list_failed_work_units(self, work_spec_name, start=0, limit=None):
"""Get a dictionary of failed work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have completed unsuccessfully are included.
"""
return self.reg... | [
"def",
"list_failed_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"start",
"=",
"0",
",",
"limit",
"=",
"None",
")",
":",
"return",
"self",
".",
"registry",
".",
"filter",
"(",
"WORK_UNITS_",
"+",
"work_spec_name",
"+",
"_FAILED",
",",
"start",
"="... | Get a dictionary of failed work units for some work spec.
The dictionary is from work unit name to work unit definiton.
Only work units that have completed unsuccessfully are included. | [
"Get",
"a",
"dictionary",
"of",
"failed",
"work",
"units",
"for",
"some",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1078-L1086 |
diffeo/rejester | rejester/_task_master.py | TaskMaster._remove_some_work_units | def _remove_some_work_units(self, work_spec_name, work_unit_names,
suffix='', priority_min='-inf',
priority_max='+inf'):
'''Remove some units from somewhere.'''
now = time.time()
if work_unit_names is None:
count = 0
... | python | def _remove_some_work_units(self, work_spec_name, work_unit_names,
suffix='', priority_min='-inf',
priority_max='+inf'):
'''Remove some units from somewhere.'''
now = time.time()
if work_unit_names is None:
count = 0
... | [
"def",
"_remove_some_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
",",
"suffix",
"=",
"''",
",",
"priority_min",
"=",
"'-inf'",
",",
"priority_max",
"=",
"'+inf'",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"work... | Remove some units from somewhere. | [
"Remove",
"some",
"units",
"from",
"somewhere",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1088-L1111 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.del_work_units | def del_work_units(self, work_spec_name, work_unit_keys=None,
state=None, all=False):
'''Delete work units from a work spec.
The parameters are considered in order as follows:
* If `all` is :const:`True`, then all work units in
`work_spec_name` are deleted; oth... | python | def del_work_units(self, work_spec_name, work_unit_keys=None,
state=None, all=False):
'''Delete work units from a work spec.
The parameters are considered in order as follows:
* If `all` is :const:`True`, then all work units in
`work_spec_name` are deleted; oth... | [
"def",
"del_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_keys",
"=",
"None",
",",
"state",
"=",
"None",
",",
"all",
"=",
"False",
")",
":",
"count",
"=",
"0",
"if",
"(",
"state",
"is",
"None",
")",
"or",
"(",
"state",
"==",
"AVAIL... | Delete work units from a work spec.
The parameters are considered in order as follows:
* If `all` is :const:`True`, then all work units in
`work_spec_name` are deleted; otherwise
* If `state` is not :const:`None`, then all work units
in the named state are deleted; otherwis... | [
"Delete",
"work",
"units",
"from",
"a",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1113-L1146 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.remove_available_work_units | def remove_available_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the available queue.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all available work units in `work_spec_name` are
removed; otherwise only the specific named ... | python | def remove_available_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the available queue.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all available work units in `work_spec_name` are
removed; otherwise only the specific named ... | [
"def",
"remove_available_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
")",
":",
"return",
"self",
".",
"_remove_some_work_units",
"(",
"work_spec_name",
",",
"work_unit_names",
",",
"priority_max",
"=",
"time",
".",
"time",
"(",
")",
")... | Remove some work units in the available queue.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all available work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
:param str work_spec_name: name of the work spec
... | [
"Remove",
"some",
"work",
"units",
"in",
"the",
"available",
"queue",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1154-L1168 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.remove_pending_work_units | def remove_pending_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the pending list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work un... | python | def remove_pending_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the pending list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work un... | [
"def",
"remove_pending_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
")",
":",
"return",
"self",
".",
"_remove_some_work_units",
"(",
"work_spec_name",
",",
"work_unit_names",
",",
"priority_min",
"=",
"time",
".",
"time",
"(",
")",
")"
... | Remove some work units in the pending list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
Note that this function has the potential to confuse worker... | [
"Remove",
"some",
"work",
"units",
"in",
"the",
"pending",
"list",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1170-L1191 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.remove_blocked_work_units | def remove_blocked_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the blocked list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work un... | python | def remove_blocked_work_units(self, work_spec_name, work_unit_names):
'''Remove some work units in the blocked list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work un... | [
"def",
"remove_blocked_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
")",
":",
"return",
"self",
".",
"_remove_some_work_units",
"(",
"work_spec_name",
",",
"work_unit_names",
",",
"suffix",
"=",
"_BLOCKED",
")"
] | Remove some work units in the blocked list.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all pending work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
Note that none of the "remove" functions will restart block... | [
"Remove",
"some",
"work",
"units",
"in",
"the",
"blocked",
"list",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1193-L1212 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.remove_failed_work_units | def remove_failed_work_units(self, work_spec_name, work_unit_names):
'''Remove some failed work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all failed work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
... | python | def remove_failed_work_units(self, work_spec_name, work_unit_names):
'''Remove some failed work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all failed work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
... | [
"def",
"remove_failed_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
")",
":",
"return",
"self",
".",
"_remove_some_work_units",
"(",
"work_spec_name",
",",
"work_unit_names",
",",
"suffix",
"=",
"_FAILED",
")"
] | Remove some failed work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all failed work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
Also consider :meth:`retry` to move failed work units back into
t... | [
"Remove",
"some",
"failed",
"work",
"units",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1214-L1231 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.remove_finished_work_units | def remove_finished_work_units(self, work_spec_name, work_unit_names):
'''Remove some finished work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all finished work units in `work_spec_name` are
removed; otherwise only the specific named work units will ... | python | def remove_finished_work_units(self, work_spec_name, work_unit_names):
'''Remove some finished work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all finished work units in `work_spec_name` are
removed; otherwise only the specific named work units will ... | [
"def",
"remove_finished_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_names",
")",
":",
"return",
"self",
".",
"_remove_some_work_units",
"(",
"work_spec_name",
",",
"work_unit_names",
",",
"suffix",
"=",
"_FINISHED",
")"
] | Remove some finished work units.
If `work_unit_names` is :const:`None` (which must be passed
explicitly), all finished work units in `work_spec_name` are
removed; otherwise only the specific named work units will be.
:param str work_spec_name: name of the work spec
:param list ... | [
"Remove",
"some",
"finished",
"work",
"units",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1233-L1247 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.get_work_unit_status | def get_work_unit_status(self, work_spec_name, work_unit_key):
'''Get a high-level status for some work unit.
The return value is a dictionary. The only required key is
``status``, which could be any of:
``missing``
The work unit does not exist anywhere
``available``... | python | def get_work_unit_status(self, work_spec_name, work_unit_key):
'''Get a high-level status for some work unit.
The return value is a dictionary. The only required key is
``status``, which could be any of:
``missing``
The work unit does not exist anywhere
``available``... | [
"def",
"get_work_unit_status",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_key",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"# In the available list?",
"(",
"unit... | Get a high-level status for some work unit.
The return value is a dictionary. The only required key is
``status``, which could be any of:
``missing``
The work unit does not exist anywhere
``available``
The work unit is available for new workers; additional
... | [
"Get",
"a",
"high",
"-",
"level",
"status",
"for",
"some",
"work",
"unit",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1249-L1319 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.inspect_work_unit | def inspect_work_unit(self, work_spec_name, work_unit_key):
'''Get the data for some work unit.
Returns the data for that work unit, or `None` if it really
can't be found.
:param str work_spec_name: name of the work spec
:param str work_unit_key: name of the work unit
:... | python | def inspect_work_unit(self, work_spec_name, work_unit_key):
'''Get the data for some work unit.
Returns the data for that work unit, or `None` if it really
can't be found.
:param str work_spec_name: name of the work spec
:param str work_unit_key: name of the work unit
:... | [
"def",
"inspect_work_unit",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_key",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"work_unit_data",
"=",
"session",
".",
... | Get the data for some work unit.
Returns the data for that work unit, or `None` if it really
can't be found.
:param str work_spec_name: name of the work spec
:param str work_unit_key: name of the work unit
:return: definition of the work unit, or `None` | [
"Get",
"the",
"data",
"for",
"some",
"work",
"unit",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1321-L1343 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.reset_all | def reset_all(self, work_spec_name):
'''Restart a work spec.
This calls :meth:`idle_all_workers`, then moves all finished
jobs back into the available queue.
.. deprecated:: 0.4.5
See :meth:`idle_all_workers` for problems with that method.
This also ignores fail... | python | def reset_all(self, work_spec_name):
'''Restart a work spec.
This calls :meth:`idle_all_workers`, then moves all finished
jobs back into the available queue.
.. deprecated:: 0.4.5
See :meth:`idle_all_workers` for problems with that method.
This also ignores fail... | [
"def",
"reset_all",
"(",
"self",
",",
"work_spec_name",
")",
":",
"self",
".",
"idle_all_workers",
"(",
")",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"session",
".",
"move_... | Restart a work spec.
This calls :meth:`idle_all_workers`, then moves all finished
jobs back into the available queue.
.. deprecated:: 0.4.5
See :meth:`idle_all_workers` for problems with that method.
This also ignores failed jobs and work unit dependencies.
... | [
"Restart",
"a",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1349-L1366 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.update_bundle | def update_bundle(self, work_spec, work_units, nice=0):
'''Load a work spec and some work units into the task list.
update the work_spec and work_units. Overwrites any existing
work spec with the same ``work_spec['name']`` and similarly
overwrites any WorkUnit with the same ``w... | python | def update_bundle(self, work_spec, work_units, nice=0):
'''Load a work spec and some work units into the task list.
update the work_spec and work_units. Overwrites any existing
work spec with the same ``work_spec['name']`` and similarly
overwrites any WorkUnit with the same ``w... | [
"def",
"update_bundle",
"(",
"self",
",",
"work_spec",
",",
"work_units",
",",
"nice",
"=",
"0",
")",
":",
"self",
".",
"validate_work_spec",
"(",
"work_spec",
")",
"work_spec_name",
"=",
"work_spec",
"[",
"'name'",
"]",
"with",
"self",
".",
"registry",
".... | Load a work spec and some work units into the task list.
update the work_spec and work_units. Overwrites any existing
work spec with the same ``work_spec['name']`` and similarly
overwrites any WorkUnit with the same ``work_unit.key``
:param dict work_spec: Work spec dictionary... | [
"Load",
"a",
"work",
"spec",
"and",
"some",
"work",
"units",
"into",
"the",
"task",
"list",
".",
"update",
"the",
"work_spec",
"and",
"work_units",
".",
"Overwrites",
"any",
"existing",
"work",
"spec",
"with",
"the",
"same",
"work_spec",
"[",
"name",
"]",
... | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1368-L1396 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.set_work_spec | def set_work_spec(self, work_spec):
'''
work_spec is a dict()
work_spec['name'] is used as work_spec_name in other API calls
work_spec['nice'] is used for prioritization, if set.
'''
self.validate_work_spec(work_spec)
nice = int(work_spec.get('nice', 0))
... | python | def set_work_spec(self, work_spec):
'''
work_spec is a dict()
work_spec['name'] is used as work_spec_name in other API calls
work_spec['nice'] is used for prioritization, if set.
'''
self.validate_work_spec(work_spec)
nice = int(work_spec.get('nice', 0))
... | [
"def",
"set_work_spec",
"(",
"self",
",",
"work_spec",
")",
":",
"self",
".",
"validate_work_spec",
"(",
"work_spec",
")",
"nice",
"=",
"int",
"(",
"work_spec",
".",
"get",
"(",
"'nice'",
",",
"0",
")",
")",
"work_spec_name",
"=",
"work_spec",
"[",
"'nam... | work_spec is a dict()
work_spec['name'] is used as work_spec_name in other API calls
work_spec['nice'] is used for prioritization, if set. | [
"work_spec",
"is",
"a",
"dict",
"()",
"work_spec",
"[",
"name",
"]",
"is",
"used",
"as",
"work_spec_name",
"in",
"other",
"API",
"calls",
"work_spec",
"[",
"nice",
"]",
"is",
"used",
"for",
"prioritization",
"if",
"set",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1398-L1410 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.add_work_units | def add_work_units(self, work_spec_name, work_unit_key_vals):
'''
work_unit_key_vals list of (work_unit_key, work_unit_data)
'''
with self.registry.lock(identifier=self.worker_id) as session:
window_size = 10**4
for i in xrange(0, len(work_unit_key_vals), window_s... | python | def add_work_units(self, work_spec_name, work_unit_key_vals):
'''
work_unit_key_vals list of (work_unit_key, work_unit_data)
'''
with self.registry.lock(identifier=self.worker_id) as session:
window_size = 10**4
for i in xrange(0, len(work_unit_key_vals), window_s... | [
"def",
"add_work_units",
"(",
"self",
",",
"work_spec_name",
",",
"work_unit_key_vals",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"window_size",
"=",
"10",
"**",
"4"... | work_unit_key_vals list of (work_unit_key, work_unit_data) | [
"work_unit_key_vals",
"list",
"of",
"(",
"work_unit_key",
"work_unit_data",
")"
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1412-L1421 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.add_dependent_work_units | def add_dependent_work_units(self, work_unit, depends_on, hard=True):
"""Add work units, where one prevents execution of the other.
The two work units may be attached to different work specs,
but both must be in this task master's namespace. `work_unit`
and `depends_on` are both tuples... | python | def add_dependent_work_units(self, work_unit, depends_on, hard=True):
"""Add work units, where one prevents execution of the other.
The two work units may be attached to different work specs,
but both must be in this task master's namespace. `work_unit`
and `depends_on` are both tuples... | [
"def",
"add_dependent_work_units",
"(",
"self",
",",
"work_unit",
",",
"depends_on",
",",
"hard",
"=",
"True",
")",
":",
"# There's no good, not-confusing terminology here.",
"# I'll call work_unit \"later\" and depends_on \"earlier\"",
"# consistently, because that at least makes th... | Add work units, where one prevents execution of the other.
The two work units may be attached to different work specs,
but both must be in this task master's namespace. `work_unit`
and `depends_on` are both tuples of (work spec name, work unit
name, work unit dictionary). The work spe... | [
"Add",
"work",
"units",
"where",
"one",
"prevents",
"execution",
"of",
"the",
"other",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1423-L1557 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.retry | def retry(self, work_spec_name, *work_unit_names):
'''Move failed work unit(s) back into the "pending" queue.
The work unit will be available to execute immediately. If
other tasks had depended on it, those dependencies will not
be recreated.
:param str work_spec_name: name of... | python | def retry(self, work_spec_name, *work_unit_names):
'''Move failed work unit(s) back into the "pending" queue.
The work unit will be available to execute immediately. If
other tasks had depended on it, those dependencies will not
be recreated.
:param str work_spec_name: name of... | [
"def",
"retry",
"(",
"self",
",",
"work_spec_name",
",",
"*",
"work_unit_names",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"# This sequence is safe even if this system die... | Move failed work unit(s) back into the "pending" queue.
The work unit will be available to execute immediately. If
other tasks had depended on it, those dependencies will not
be recreated.
:param str work_spec_name: name of the (existing) work spec
:param str work_unit_names: ... | [
"Move",
"failed",
"work",
"unit",
"(",
"s",
")",
"back",
"into",
"the",
"pending",
"queue",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1559-L1594 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.nice | def nice(self, work_spec_name, nice):
'''Change the priority of an existing work spec.'''
with self.registry.lock(identifier=self.worker_id) as session:
session.update(NICE_LEVELS, dict(work_spec_name=nice)) | python | def nice(self, work_spec_name, nice):
'''Change the priority of an existing work spec.'''
with self.registry.lock(identifier=self.worker_id) as session:
session.update(NICE_LEVELS, dict(work_spec_name=nice)) | [
"def",
"nice",
"(",
"self",
",",
"work_spec_name",
",",
"nice",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"session",
".",
"update",
"(",
"NICE_LEVELS",
",",
"dic... | Change the priority of an existing work spec. | [
"Change",
"the",
"priority",
"of",
"an",
"existing",
"work",
"spec",
"."
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1596-L1599 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.get_work | def get_work(self, worker_id, available_gb=None, lease_time=None, work_spec_names=None, max_jobs=None):
'''obtain a WorkUnit instance based on available memory for the
worker process.
:param worker_id: unique identifier string for a worker to
which a WorkUnit will be assigne... | python | def get_work(self, worker_id, available_gb=None, lease_time=None, work_spec_names=None, max_jobs=None):
'''obtain a WorkUnit instance based on available memory for the
worker process.
:param worker_id: unique identifier string for a worker to
which a WorkUnit will be assigne... | [
"def",
"get_work",
"(",
"self",
",",
"worker_id",
",",
"available_gb",
"=",
"None",
",",
"lease_time",
"=",
"None",
",",
"work_spec_names",
"=",
"None",
",",
"max_jobs",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"available_gb",
",",
"(",
"in... | obtain a WorkUnit instance based on available memory for the
worker process.
:param worker_id: unique identifier string for a worker to
which a WorkUnit will be assigned, if available.
:param available_gb: number of gigabytes of RAM available to
this worker
... | [
"obtain",
"a",
"WorkUnit",
"instance",
"based",
"on",
"available",
"memory",
"for",
"the",
"worker",
"process",
".",
":",
"param",
"worker_id",
":",
"unique",
"identifier",
"string",
"for",
"a",
"worker",
"to",
"which",
"a",
"WorkUnit",
"will",
"be",
"assign... | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1601-L1693 |
diffeo/rejester | rejester/_task_master.py | TaskMaster.get_assigned_work_unit | def get_assigned_work_unit(self, worker_id, work_spec_name,
work_unit_key):
'''get a specific WorkUnit that has already been assigned to a
particular worker_id
'''
with self.registry.lock(identifier=self.worker_id) as session:
assigned_work_unit... | python | def get_assigned_work_unit(self, worker_id, work_spec_name,
work_unit_key):
'''get a specific WorkUnit that has already been assigned to a
particular worker_id
'''
with self.registry.lock(identifier=self.worker_id) as session:
assigned_work_unit... | [
"def",
"get_assigned_work_unit",
"(",
"self",
",",
"worker_id",
",",
"work_spec_name",
",",
"work_unit_key",
")",
":",
"with",
"self",
".",
"registry",
".",
"lock",
"(",
"identifier",
"=",
"self",
".",
"worker_id",
")",
"as",
"session",
":",
"assigned_work_uni... | get a specific WorkUnit that has already been assigned to a
particular worker_id | [
"get",
"a",
"specific",
"WorkUnit",
"that",
"has",
"already",
"been",
"assigned",
"to",
"a",
"particular",
"worker_id"
] | train | https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1695-L1718 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.