repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
akfullfo/taskforce | taskforce/utils.py | deltafmt | def deltafmt(delta, decimals = None):
"""
Returns a human readable representation of a time with the format:
[[[Ih]Jm]K[.L]s
For example: 6h5m23s
If "decimals" is specified, the seconds will be output with that many decimal places.
If not, there will be two places for times less than 1 minute, one place for ... | python | def deltafmt(delta, decimals = None):
"""
Returns a human readable representation of a time with the format:
[[[Ih]Jm]K[.L]s
For example: 6h5m23s
If "decimals" is specified, the seconds will be output with that many decimal places.
If not, there will be two places for times less than 1 minute, one place for ... | [
"def",
"deltafmt",
"(",
"delta",
",",
"decimals",
"=",
"None",
")",
":",
"try",
":",
"delta",
"=",
"float",
"(",
"delta",
")",
"except",
":",
"return",
"'(bad delta: %s)'",
"%",
"(",
"str",
"(",
"delta",
")",
",",
")",
"if",
"delta",
"<",
"60",
":"... | Returns a human readable representation of a time with the format:
[[[Ih]Jm]K[.L]s
For example: 6h5m23s
If "decimals" is specified, the seconds will be output with that many decimal places.
If not, there will be two places for times less than 1 minute, one place for times
less than 10 minutes, and zero places ot... | [
"Returns",
"a",
"human",
"readable",
"representation",
"of",
"a",
"time",
"with",
"the",
"format",
":"
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L186-L219 |
akfullfo/taskforce | taskforce/utils.py | setproctitle | def setproctitle(text):
"""
This is a wrapper for setproctitle.setproctitle(). The call sets
'text' as the new process title and returns the previous value.
The module is commonly not installed. If missing, nothing is changed,
and the call returns None.
The module is described here: https://... | python | def setproctitle(text):
"""
This is a wrapper for setproctitle.setproctitle(). The call sets
'text' as the new process title and returns the previous value.
The module is commonly not installed. If missing, nothing is changed,
and the call returns None.
The module is described here: https://... | [
"def",
"setproctitle",
"(",
"text",
")",
":",
"try",
":",
"import",
"setproctitle",
"except",
"Exception",
"as",
"e",
":",
"return",
"None",
"else",
":",
"# pragma: no cover",
"prev",
"=",
"setproctitle",
".",
"getproctitle",
"(",
")",
"setproctitle",
".",
"... | This is a wrapper for setproctitle.setproctitle(). The call sets
'text' as the new process title and returns the previous value.
The module is commonly not installed. If missing, nothing is changed,
and the call returns None.
The module is described here: https://pypi.python.org/pypi/setproctitle | [
"This",
"is",
"a",
"wrapper",
"for",
"setproctitle",
".",
"setproctitle",
"()",
".",
"The",
"call",
"sets",
"text",
"as",
"the",
"new",
"process",
"title",
"and",
"returns",
"the",
"previous",
"value",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L221-L238 |
akfullfo/taskforce | taskforce/utils.py | appname | def appname(path=None):
"""
Return a useful application name based on the program argument.
A special case maps 'mod_wsgi' to a more appropriate name so
web applications show up as our own.
"""
if path is None:
path = sys.argv[0]
name = os.path.basename(os.path.splitext(path)[0])
if name == 'mod... | python | def appname(path=None):
"""
Return a useful application name based on the program argument.
A special case maps 'mod_wsgi' to a more appropriate name so
web applications show up as our own.
"""
if path is None:
path = sys.argv[0]
name = os.path.basename(os.path.splitext(path)[0])
if name == 'mod... | [
"def",
"appname",
"(",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"sys",
".",
"argv",
"[",
"0",
"]",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
... | Return a useful application name based on the program argument.
A special case maps 'mod_wsgi' to a more appropriate name so
web applications show up as our own. | [
"Return",
"a",
"useful",
"application",
"name",
"based",
"on",
"the",
"program",
"argument",
".",
"A",
"special",
"case",
"maps",
"mod_wsgi",
"to",
"a",
"more",
"appropriate",
"name",
"so",
"web",
"applications",
"show",
"up",
"as",
"our",
"own",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L269-L280 |
akfullfo/taskforce | taskforce/utils.py | module_description | def module_description(module__name__, module__doc__, module__file__):
"""
Return formatted text that lists the module-level and class-level
embedded documentation. The function should be called exactly
as:
taskforce.utils.module_description(__name__, __doc__, __file__)
The most common us... | python | def module_description(module__name__, module__doc__, module__file__):
"""
Return formatted text that lists the module-level and class-level
embedded documentation. The function should be called exactly
as:
taskforce.utils.module_description(__name__, __doc__, __file__)
The most common us... | [
"def",
"module_description",
"(",
"module__name__",
",",
"module__doc__",
",",
"module__file__",
")",
":",
"mod_name",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"module__file__",
")",
")",
"[",
"0",
"]",
"mod_de... | Return formatted text that lists the module-level and class-level
embedded documentation. The function should be called exactly
as:
taskforce.utils.module_description(__name__, __doc__, __file__)
The most common use for this function is to produce the help
message for test code in a library m... | [
"Return",
"formatted",
"text",
"that",
"lists",
"the",
"module",
"-",
"level",
"and",
"class",
"-",
"level",
"embedded",
"documentation",
".",
"The",
"function",
"should",
"be",
"called",
"exactly",
"as",
":"
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L282-L307 |
akfullfo/taskforce | taskforce/utils.py | signum | def signum(signame):
"""
Determine the signal from its name. These forms are supported:
signal object (needed for python >= 3.5)
integer signal number
text signal number
SIGNAME (signal name in upper case)
signame (signal name in lower case)
NAME (name withou... | python | def signum(signame):
"""
Determine the signal from its name. These forms are supported:
signal object (needed for python >= 3.5)
integer signal number
text signal number
SIGNAME (signal name in upper case)
signame (signal name in lower case)
NAME (name withou... | [
"def",
"signum",
"(",
"signame",
")",
":",
"if",
"signum",
".",
"namemap",
"is",
"None",
":",
"# First time through, map evrything likely to its signal number",
"#",
"signum",
".",
"namemap",
"=",
"{",
"}",
"for",
"num",
",",
"nam",
"in",
"sigmap",
".",
"item... | Determine the signal from its name. These forms are supported:
signal object (needed for python >= 3.5)
integer signal number
text signal number
SIGNAME (signal name in upper case)
signame (signal name in lower case)
NAME (name without 'SIG' in upper case)
na... | [
"Determine",
"the",
"signal",
"from",
"its",
"name",
".",
"These",
"forms",
"are",
"supported",
":"
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L323-L354 |
akfullfo/taskforce | taskforce/utils.py | statusfmt | def statusfmt(status):
"""
Format an exit status as text.
"""
if status == 0:
msg = 'exited ok'
elif os.WIFSIGNALED(status):
msg = 'died on '+signame(os.WTERMSIG(status))
elif os.WIFEXITED(status) and os.WEXITSTATUS(status) > 0:
msg = 'exited '+str(os.WEXITSTATUS(status))
... | python | def statusfmt(status):
"""
Format an exit status as text.
"""
if status == 0:
msg = 'exited ok'
elif os.WIFSIGNALED(status):
msg = 'died on '+signame(os.WTERMSIG(status))
elif os.WIFEXITED(status) and os.WEXITSTATUS(status) > 0:
msg = 'exited '+str(os.WEXITSTATUS(status))
... | [
"def",
"statusfmt",
"(",
"status",
")",
":",
"if",
"status",
"==",
"0",
":",
"msg",
"=",
"'exited ok'",
"elif",
"os",
".",
"WIFSIGNALED",
"(",
"status",
")",
":",
"msg",
"=",
"'died on '",
"+",
"signame",
"(",
"os",
".",
"WTERMSIG",
"(",
"status",
")... | Format an exit status as text. | [
"Format",
"an",
"exit",
"status",
"as",
"text",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L357-L371 |
akfullfo/taskforce | taskforce/utils.py | sys_maxfd | def sys_maxfd():
"""
Returns the maximum file descriptor limit. This is guaranteed to
return a useful int value.
"""
maxfd = None
try:
maxfd = int(resource.getrlimit(resource.RLIMIT_NOFILE)[0])
if maxfd == resource.RLIM_INFINITY: #... | python | def sys_maxfd():
"""
Returns the maximum file descriptor limit. This is guaranteed to
return a useful int value.
"""
maxfd = None
try:
maxfd = int(resource.getrlimit(resource.RLIMIT_NOFILE)[0])
if maxfd == resource.RLIM_INFINITY: #... | [
"def",
"sys_maxfd",
"(",
")",
":",
"maxfd",
"=",
"None",
"try",
":",
"maxfd",
"=",
"int",
"(",
"resource",
".",
"getrlimit",
"(",
"resource",
".",
"RLIMIT_NOFILE",
")",
"[",
"0",
"]",
")",
"if",
"maxfd",
"==",
"resource",
".",
"RLIM_INFINITY",
":",
"... | Returns the maximum file descriptor limit. This is guaranteed to
return a useful int value. | [
"Returns",
"the",
"maximum",
"file",
"descriptor",
"limit",
".",
"This",
"is",
"guaranteed",
"to",
"return",
"a",
"useful",
"int",
"value",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L373-L386 |
akfullfo/taskforce | taskforce/utils.py | closeall | def closeall(**params):
"""
Close all file descriptors. This turns out to be harder than you'd
think. For example, here is a discussion:
http://stackoverflow.com/questions/899038/getting-the-highest-allocated-file-descriptor
The default algorithm here is to close until "closeall.beyond_last_fd"
... | python | def closeall(**params):
"""
Close all file descriptors. This turns out to be harder than you'd
think. For example, here is a discussion:
http://stackoverflow.com/questions/899038/getting-the-highest-allocated-file-descriptor
The default algorithm here is to close until "closeall.beyond_last_fd"
... | [
"def",
"closeall",
"(",
"*",
"*",
"params",
")",
":",
"exclude_list",
"=",
"params",
".",
"get",
"(",
"'exclude'",
")",
"beyond",
"=",
"params",
".",
"get",
"(",
"'beyond'",
")",
"maxfd",
"=",
"params",
".",
"get",
"(",
"'maxfd'",
")",
"if",
"maxfd",... | Close all file descriptors. This turns out to be harder than you'd
think. For example, here is a discussion:
http://stackoverflow.com/questions/899038/getting-the-highest-allocated-file-descriptor
The default algorithm here is to close until "closeall.beyond_last_fd"
close failures are registered. ... | [
"Close",
"all",
"file",
"descriptors",
".",
"This",
"turns",
"out",
"to",
"be",
"harder",
"than",
"you",
"d",
"think",
".",
"For",
"example",
"here",
"is",
"a",
"discussion",
":"
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L401-L477 |
akfullfo/taskforce | taskforce/utils.py | format_cmd | def format_cmd(args):
"""
Format the arg list appropriate for display as a command line with
individual arguments quoted appropriately. This is intended for logging
or display and not as input to a command interpreter (shell).
"""
if args is None:
return ''
out = ''
if not isinstanc... | python | def format_cmd(args):
"""
Format the arg list appropriate for display as a command line with
individual arguments quoted appropriately. This is intended for logging
or display and not as input to a command interpreter (shell).
"""
if args is None:
return ''
out = ''
if not isinstanc... | [
"def",
"format_cmd",
"(",
"args",
")",
":",
"if",
"args",
"is",
"None",
":",
"return",
"''",
"out",
"=",
"''",
"if",
"not",
"isinstance",
"(",
"args",
",",
"list",
")",
":",
"args",
"=",
"[",
"str",
"(",
"args",
")",
"]",
"for",
"arg",
"in",
"a... | Format the arg list appropriate for display as a command line with
individual arguments quoted appropriately. This is intended for logging
or display and not as input to a command interpreter (shell). | [
"Format",
"the",
"arg",
"list",
"appropriate",
"for",
"display",
"as",
"a",
"command",
"line",
"with",
"individual",
"arguments",
"quoted",
"appropriately",
".",
"This",
"is",
"intended",
"for",
"logging",
"or",
"display",
"and",
"not",
"as",
"input",
"to",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L480-L495 |
akfullfo/taskforce | taskforce/utils.py | daemonize | def daemonize(**params):
"""
This is a simple daemonization method. It just does a double fork() and the
parent exits after closing a good clump of possibly open file descriptors. The
child redirects stdin from /dev/null and sets a new process group and session.
If you need fancier, suggest you look at http://pyp... | python | def daemonize(**params):
"""
This is a simple daemonization method. It just does a double fork() and the
parent exits after closing a good clump of possibly open file descriptors. The
child redirects stdin from /dev/null and sets a new process group and session.
If you need fancier, suggest you look at http://pyp... | [
"def",
"daemonize",
"(",
"*",
"*",
"params",
")",
":",
"log",
"=",
"params",
".",
"get",
"(",
"'log'",
")",
"redir",
"=",
"params",
".",
"get",
"(",
"'redir'",
",",
"True",
")",
"try",
":",
"if",
"os",
".",
"fork",
"(",
")",
"!=",
"0",
":",
"... | This is a simple daemonization method. It just does a double fork() and the
parent exits after closing a good clump of possibly open file descriptors. The
child redirects stdin from /dev/null and sets a new process group and session.
If you need fancier, suggest you look at http://pypi.python.org/pypi/python-daemon/
... | [
"This",
"is",
"a",
"simple",
"daemonization",
"method",
".",
"It",
"just",
"does",
"a",
"double",
"fork",
"()",
"and",
"the",
"parent",
"exits",
"after",
"closing",
"a",
"good",
"clump",
"of",
"possibly",
"open",
"file",
"descriptors",
".",
"The",
"child",... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L497-L581 |
akfullfo/taskforce | taskforce/utils.py | log_filenos | def log_filenos(log, cloexec=True):
"""
Identify the filenos (unix file descriptors) of a logging object.
This is most commonly used to avoid closing the log file descriptors
after a fork so information can be logged before an exec().
To prevent conficts and potential hangs, the default is to set t... | python | def log_filenos(log, cloexec=True):
"""
Identify the filenos (unix file descriptors) of a logging object.
This is most commonly used to avoid closing the log file descriptors
after a fork so information can be logged before an exec().
To prevent conficts and potential hangs, the default is to set t... | [
"def",
"log_filenos",
"(",
"log",
",",
"cloexec",
"=",
"True",
")",
":",
"filenos",
"=",
"[",
"]",
"try",
":",
"for",
"handler",
"in",
"log",
".",
"handlers",
":",
"for",
"name",
"in",
"dir",
"(",
"handler",
")",
":",
"attr",
"=",
"getattr",
"(",
... | Identify the filenos (unix file descriptors) of a logging object.
This is most commonly used to avoid closing the log file descriptors
after a fork so information can be logged before an exec().
To prevent conficts and potential hangs, the default is to set the
fcntl.FD_CLOEXEC close-on-exec flag for t... | [
"Identify",
"the",
"filenos",
"(",
"unix",
"file",
"descriptors",
")",
"of",
"a",
"logging",
"object",
".",
"This",
"is",
"most",
"commonly",
"used",
"to",
"avoid",
"closing",
"the",
"log",
"file",
"descriptors",
"after",
"a",
"fork",
"so",
"information",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/utils.py#L583-L605 |
inveniosoftware/invenio-mail | invenio_mail/ext.py | print_email | def print_email(message, app):
"""Print mail to stream.
Signal handler for email_dispatched signal. Prints by default the output
to the stream specified in the constructor of InvenioMail.
:param message: Message object.
:param app: Flask application object.
"""
invenio_mail = app.extension... | python | def print_email(message, app):
"""Print mail to stream.
Signal handler for email_dispatched signal. Prints by default the output
to the stream specified in the constructor of InvenioMail.
:param message: Message object.
:param app: Flask application object.
"""
invenio_mail = app.extension... | [
"def",
"print_email",
"(",
"message",
",",
"app",
")",
":",
"invenio_mail",
"=",
"app",
".",
"extensions",
"[",
"'invenio-mail'",
"]",
"with",
"invenio_mail",
".",
"_lock",
":",
"invenio_mail",
".",
"stream",
".",
"write",
"(",
"'{0}\\n{1}\\n'",
".",
"format... | Print mail to stream.
Signal handler for email_dispatched signal. Prints by default the output
to the stream specified in the constructor of InvenioMail.
:param message: Message object.
:param app: Flask application object. | [
"Print",
"mail",
"to",
"stream",
"."
] | train | https://github.com/inveniosoftware/invenio-mail/blob/ebfc02637de3cf94d5c39c840e2958fdc0bd437a/invenio_mail/ext.py#L19-L32 |
inveniosoftware/invenio-mail | invenio_mail/ext.py | InvenioMail.init_app | def init_app(self, app):
"""Flask application initialization.
The initialization will:
* Set default values for the configuration variables.
* Initialise the Flask mail extension.
* Configure the extension to avoid the email sending in case of debug
or ``MAIL_SUPP... | python | def init_app(self, app):
"""Flask application initialization.
The initialization will:
* Set default values for the configuration variables.
* Initialise the Flask mail extension.
* Configure the extension to avoid the email sending in case of debug
or ``MAIL_SUPP... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"if",
"'mail'",
"not",
"in",
"app",
".",
"extensions",
":",
"Mail",
"(",
"app",
")",
"if",
"app",
".",
"config",
".",
"get",
"(",
"'MAIL_SUPPRESS_SEND'... | Flask application initialization.
The initialization will:
* Set default values for the configuration variables.
* Initialise the Flask mail extension.
* Configure the extension to avoid the email sending in case of debug
or ``MAIL_SUPPRESS_SEND`` config variable set. In ... | [
"Flask",
"application",
"initialization",
"."
] | train | https://github.com/inveniosoftware/invenio-mail/blob/ebfc02637de3cf94d5c39c840e2958fdc0bd437a/invenio_mail/ext.py#L52-L70 |
inveniosoftware/invenio-mail | invenio_mail/ext.py | InvenioMail.init_config | def init_config(app):
"""Initialize configuration.
:param app: Flask application object.
"""
app.config.setdefault('MAIL_DEBUG', app.debug)
app.config.setdefault('MAIL_SUPPRESS_SEND', app.debug or app.testing) | python | def init_config(app):
"""Initialize configuration.
:param app: Flask application object.
"""
app.config.setdefault('MAIL_DEBUG', app.debug)
app.config.setdefault('MAIL_SUPPRESS_SEND', app.debug or app.testing) | [
"def",
"init_config",
"(",
"app",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"'MAIL_DEBUG'",
",",
"app",
".",
"debug",
")",
"app",
".",
"config",
".",
"setdefault",
"(",
"'MAIL_SUPPRESS_SEND'",
",",
"app",
".",
"debug",
"or",
"app",
".",
"... | Initialize configuration.
:param app: Flask application object. | [
"Initialize",
"configuration",
"."
] | train | https://github.com/inveniosoftware/invenio-mail/blob/ebfc02637de3cf94d5c39c840e2958fdc0bd437a/invenio_mail/ext.py#L73-L79 |
PMBio/limix-backup | limix/ensemble/lmm_forest.py | Forest.fit | def fit(self, X, y, recycle=True, **grow_params):
"""Build a linear mixed forest of trees from the training set (X, y).
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples] or [n_sam... | python | def fit(self, X, y, recycle=True, **grow_params):
"""Build a linear mixed forest of trees from the training set (X, y).
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples] or [n_sam... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
",",
"recycle",
"=",
"True",
",",
"*",
"*",
"grow_params",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"kernel",
",",
"str",
")",
"and",
"self",
".",
"kernel",
"==",
"'data'",
":",
"self",
".",
... | Build a linear mixed forest of trees from the training set (X, y).
Parameters
----------
X : array-like of shape = [n_samples, n_features]
The training input samples.
y : array-like, shape = [n_samples] or [n_samples, 1]
The real valued targets
Returns
... | [
"Build",
"a",
"linear",
"mixed",
"forest",
"of",
"trees",
"from",
"the",
"training",
"set",
"(",
"X",
"y",
")",
"."
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/lmm_forest.py#L152-L251 |
PMBio/limix-backup | limix/ensemble/lmm_forest.py | Forest.predict | def predict(self, X, k=None, depth=None):
"""Predict response for X.
The response to an input sample is computed as the sum of
(1) the mean prediction of the trees in the forest (fixed effect) and
(2) the estimated random effect.
Parameters
----------
X : array-... | python | def predict(self, X, k=None, depth=None):
"""Predict response for X.
The response to an input sample is computed as the sum of
(1) the mean prediction of the trees in the forest (fixed effect) and
(2) the estimated random effect.
Parameters
----------
X : array-... | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"k",
"=",
"None",
",",
"depth",
"=",
"None",
")",
":",
"if",
"depth",
"is",
"None",
":",
"if",
"self",
".",
"opt_depth",
"is",
"not",
"None",
":",
"depth",
"=",
"self",
".",
"opt_depth",
"if",
"self",... | Predict response for X.
The response to an input sample is computed as the sum of
(1) the mean prediction of the trees in the forest (fixed effect) and
(2) the estimated random effect.
Parameters
----------
X : array-like of shape = [n_samples, n_features]
T... | [
"Predict",
"response",
"for",
"X",
"."
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/lmm_forest.py#L320-L353 |
PMBio/limix-backup | limix/ensemble/lmm_forest.py | MixedForestTree.clear_data | def clear_data(self):
'''
Free memory
If many trees are grown this is an useful options since it is saving a
lot of memory '''
if self.forest.verbose > 1:
print('clearing up stuff')
self.S = None
self.Uy = None
self.U = None | python | def clear_data(self):
'''
Free memory
If many trees are grown this is an useful options since it is saving a
lot of memory '''
if self.forest.verbose > 1:
print('clearing up stuff')
self.S = None
self.Uy = None
self.U = None | [
"def",
"clear_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"forest",
".",
"verbose",
">",
"1",
":",
"print",
"(",
"'clearing up stuff'",
")",
"self",
".",
"S",
"=",
"None",
"self",
".",
"Uy",
"=",
"None",
"self",
".",
"U",
"=",
"None"
] | Free memory
If many trees are grown this is an useful options since it is saving a
lot of memory | [
"Free",
"memory",
"If",
"many",
"trees",
"are",
"grown",
"this",
"is",
"an",
"useful",
"options",
"since",
"it",
"is",
"saving",
"a",
"lot",
"of",
"memory"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/lmm_forest.py#L592-L601 |
PMBio/limix-backup | limix/ensemble/lmm_forest.py | MixedForestTree.get_X_slice | def get_X_slice(self, rmind):
'''get X with slicing'''
if self.forest.optimize_memory_use:
return self.forest.X[:, rmind][self.subsample]
else:
return self.X[:, rmind] | python | def get_X_slice(self, rmind):
'''get X with slicing'''
if self.forest.optimize_memory_use:
return self.forest.X[:, rmind][self.subsample]
else:
return self.X[:, rmind] | [
"def",
"get_X_slice",
"(",
"self",
",",
"rmind",
")",
":",
"if",
"self",
".",
"forest",
".",
"optimize_memory_use",
":",
"return",
"self",
".",
"forest",
".",
"X",
"[",
":",
",",
"rmind",
"]",
"[",
"self",
".",
"subsample",
"]",
"else",
":",
"return"... | get X with slicing | [
"get",
"X",
"with",
"slicing"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/lmm_forest.py#L609-L614 |
tchx84/grestful | grestful/helpers.py | param_upload | def param_upload(field, path):
""" Pack upload metadata. """
if not path:
return None
param = {}
param['field'] = field
param['path'] = path
return param | python | def param_upload(field, path):
""" Pack upload metadata. """
if not path:
return None
param = {}
param['field'] = field
param['path'] = path
return param | [
"def",
"param_upload",
"(",
"field",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"return",
"None",
"param",
"=",
"{",
"}",
"param",
"[",
"'field'",
"]",
"=",
"field",
"param",
"[",
"'path'",
"]",
"=",
"path",
"return",
"param"
] | Pack upload metadata. | [
"Pack",
"upload",
"metadata",
"."
] | train | https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/helpers.py#L19-L26 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/cli.py | extract | def extract(filepath, taxonomy, output_mode, output_limit,
spires, match_mode, detect_author_keywords, extract_acronyms,
rebuild_cache, only_core_tags, no_cache):
"""Run keyword extraction on given PDF file for given taxonomy."""
if not filepath or not taxonomy:
print("No PDF fil... | python | def extract(filepath, taxonomy, output_mode, output_limit,
spires, match_mode, detect_author_keywords, extract_acronyms,
rebuild_cache, only_core_tags, no_cache):
"""Run keyword extraction on given PDF file for given taxonomy."""
if not filepath or not taxonomy:
print("No PDF fil... | [
"def",
"extract",
"(",
"filepath",
",",
"taxonomy",
",",
"output_mode",
",",
"output_limit",
",",
"spires",
",",
"match_mode",
",",
"detect_author_keywords",
",",
"extract_acronyms",
",",
"rebuild_cache",
",",
"only_core_tags",
",",
"no_cache",
")",
":",
"if",
"... | Run keyword extraction on given PDF file for given taxonomy. | [
"Run",
"keyword",
"extraction",
"on",
"given",
"PDF",
"file",
"for",
"given",
"taxonomy",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/cli.py#L63-L95 |
akfullfo/taskforce | taskforce/watch_modules.py | watch._build | def _build(self, name, **params):
"""
Rebuild operations by removing open modules that no longer need to be
watched, and adding new modules if they are not currently being watched.
This is done by comparing self.modules to watch_files.paths_open
"""
log = self._getparam('log... | python | def _build(self, name, **params):
"""
Rebuild operations by removing open modules that no longer need to be
watched, and adding new modules if they are not currently being watched.
This is done by comparing self.modules to watch_files.paths_open
"""
log = self._getparam('log... | [
"def",
"_build",
"(",
"self",
",",
"name",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"# Find all the modules that no longer need watching",
"#",
"rebu... | Rebuild operations by removing open modules that no longer need to be
watched, and adding new modules if they are not currently being watched.
This is done by comparing self.modules to watch_files.paths_open | [
"Rebuild",
"operations",
"by",
"removing",
"open",
"modules",
"that",
"no",
"longer",
"need",
"to",
"be",
"watched",
"and",
"adding",
"new",
"modules",
"if",
"they",
"are",
"not",
"currently",
"being",
"watched",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_modules.py#L67-L102 |
akfullfo/taskforce | taskforce/watch_modules.py | watch.get | def get(self, **params):
"""
Return a list of commands that where affected by a recent change
(following a poll() return for the controlling file descriptor).
Each list element is a tuple:
(name, command_path, module_list)
The event queue will be read multiple time... | python | def get(self, **params):
"""
Return a list of commands that where affected by a recent change
(following a poll() return for the controlling file descriptor).
Each list element is a tuple:
(name, command_path, module_list)
The event queue will be read multiple time... | [
"def",
"get",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"changes",
"=",
"{",
"}",
"paths",
"=",
"self",
".",
"_watch",
".",
"g... | Return a list of commands that where affected by a recent change
(following a poll() return for the controlling file descriptor).
Each list element is a tuple:
(name, command_path, module_list)
The event queue will be read multiple times and reads continue
until a timeout ... | [
"Return",
"a",
"list",
"of",
"commands",
"that",
"where",
"affected",
"by",
"a",
"recent",
"change",
"(",
"following",
"a",
"poll",
"()",
"return",
"for",
"the",
"controlling",
"file",
"descriptor",
")",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_modules.py#L104-L140 |
akfullfo/taskforce | taskforce/watch_modules.py | watch.add | def add(self, name, command_path=None, **params):
"""
Add a command to the list of commands being watched. "name"
should be a unique value that can be used as a dictionary
index. It is typically, but not necessarily, the command
name. The value is returned when the command or ... | python | def add(self, name, command_path=None, **params):
"""
Add a command to the list of commands being watched. "name"
should be a unique value that can be used as a dictionary
index. It is typically, but not necessarily, the command
name. The value is returned when the command or ... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"command_path",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"module_path",
"=",
"self",... | Add a command to the list of commands being watched. "name"
should be a unique value that can be used as a dictionary
index. It is typically, but not necessarily, the command
name. The value is returned when the command or modules for
the command change and is used with the remove() m... | [
"Add",
"a",
"command",
"to",
"the",
"list",
"of",
"commands",
"being",
"watched",
".",
"name",
"should",
"be",
"a",
"unique",
"value",
"that",
"can",
"be",
"used",
"as",
"a",
"dictionary",
"index",
".",
"It",
"is",
"typically",
"but",
"not",
"necessarily... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_modules.py#L142-L253 |
akfullfo/taskforce | taskforce/watch_modules.py | watch.remove | def remove(self, name, **params):
"""
Delete a command from the watched list. This involves removing
the command from the inverted watch list, then possibly
rebuilding the event set if any modules no longer need watching.
"""
log = self._getparam('log', self._discard, **para... | python | def remove(self, name, **params):
"""
Delete a command from the watched list. This involves removing
the command from the inverted watch list, then possibly
rebuilding the event set if any modules no longer need watching.
"""
log = self._getparam('log', self._discard, **para... | [
"def",
"remove",
"(",
"self",
",",
"name",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"if",
"name",
"not",
"in",
"self",
".",
"names",
":",
... | Delete a command from the watched list. This involves removing
the command from the inverted watch list, then possibly
rebuilding the event set if any modules no longer need watching. | [
"Delete",
"a",
"command",
"from",
"the",
"watched",
"list",
".",
"This",
"involves",
"removing",
"the",
"command",
"from",
"the",
"inverted",
"watch",
"list",
"then",
"possibly",
"rebuilding",
"the",
"event",
"set",
"if",
"any",
"modules",
"no",
"longer",
"n... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_modules.py#L255-L275 |
peterldowns/djoauth2 | example/djoauth2example/api/views.py | user_info | def user_info(access_token, request):
""" Return basic information about a user.
Limited to OAuth clients that have receieved authorization to the 'user_info'
scope.
"""
user = access_token.user
data = {
'username': user.username,
'first_name': user.first_name,
'last_name': user.last_name... | python | def user_info(access_token, request):
""" Return basic information about a user.
Limited to OAuth clients that have receieved authorization to the 'user_info'
scope.
"""
user = access_token.user
data = {
'username': user.username,
'first_name': user.first_name,
'last_name': user.last_name... | [
"def",
"user_info",
"(",
"access_token",
",",
"request",
")",
":",
"user",
"=",
"access_token",
".",
"user",
"data",
"=",
"{",
"'username'",
":",
"user",
".",
"username",
",",
"'first_name'",
":",
"user",
".",
"first_name",
",",
"'last_name'",
":",
"user",... | Return basic information about a user.
Limited to OAuth clients that have receieved authorization to the 'user_info'
scope. | [
"Return",
"basic",
"information",
"about",
"a",
"user",
"."
] | train | https://github.com/peterldowns/djoauth2/blob/151c7619d1d7a91d720397cfecf3a29fcc9747a9/example/djoauth2example/api/views.py#L12-L27 |
timofurrer/tag-expressions | tagexpressions/models.py | Or.evaluate | def evaluate(self, values):
"""Evaluate the "OR" expression
Check if the left "or" right expression
evaluate to True.
"""
return self.left.evaluate(values) or self.right.evaluate(values) | python | def evaluate(self, values):
"""Evaluate the "OR" expression
Check if the left "or" right expression
evaluate to True.
"""
return self.left.evaluate(values) or self.right.evaluate(values) | [
"def",
"evaluate",
"(",
"self",
",",
"values",
")",
":",
"return",
"self",
".",
"left",
".",
"evaluate",
"(",
"values",
")",
"or",
"self",
".",
"right",
".",
"evaluate",
"(",
"values",
")"
] | Evaluate the "OR" expression
Check if the left "or" right expression
evaluate to True. | [
"Evaluate",
"the",
"OR",
"expression"
] | train | https://github.com/timofurrer/tag-expressions/blob/9b58c34296b31530f31517ffefc8715516c73da3/tagexpressions/models.py#L34-L40 |
20c/munge | munge/codec/__init__.py | find_datafile | def find_datafile(name, search_path=('.'), codecs=get_codecs()):
"""
find all matching data files in search_path
search_path: path of directories to load from
codecs: allow to override from list of installed
returns array of tuples (codec_object, filename)
"""
rv = []
if isinstance(sear... | python | def find_datafile(name, search_path=('.'), codecs=get_codecs()):
"""
find all matching data files in search_path
search_path: path of directories to load from
codecs: allow to override from list of installed
returns array of tuples (codec_object, filename)
"""
rv = []
if isinstance(sear... | [
"def",
"find_datafile",
"(",
"name",
",",
"search_path",
"=",
"(",
"'.'",
")",
",",
"codecs",
"=",
"get_codecs",
"(",
")",
")",
":",
"rv",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"search_path",
",",
"basestring",
")",
":",
"search_path",
"=",
"(",
"s... | find all matching data files in search_path
search_path: path of directories to load from
codecs: allow to override from list of installed
returns array of tuples (codec_object, filename) | [
"find",
"all",
"matching",
"data",
"files",
"in",
"search_path",
"search_path",
":",
"path",
"of",
"directories",
"to",
"load",
"from",
"codecs",
":",
"allow",
"to",
"override",
"from",
"list",
"of",
"installed",
"returns",
"array",
"of",
"tuples",
"(",
"cod... | train | https://github.com/20c/munge/blob/e20fef8c24e48d4b0a5c387820fbb2b7bebb0af0/munge/codec/__init__.py#L33-L64 |
20c/munge | munge/codec/__init__.py | load_datafile | def load_datafile(name, search_path=('.'), codecs=get_codecs(), **kwargs):
"""
find datafile and load them from codec
TODO only does the first one
kwargs:
default = if passed will return that on failure instead of throwing
"""
mod = find_datafile(name, search_path, codecs)
if not mod:
... | python | def load_datafile(name, search_path=('.'), codecs=get_codecs(), **kwargs):
"""
find datafile and load them from codec
TODO only does the first one
kwargs:
default = if passed will return that on failure instead of throwing
"""
mod = find_datafile(name, search_path, codecs)
if not mod:
... | [
"def",
"load_datafile",
"(",
"name",
",",
"search_path",
"=",
"(",
"'.'",
")",
",",
"codecs",
"=",
"get_codecs",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"mod",
"=",
"find_datafile",
"(",
"name",
",",
"search_path",
",",
"codecs",
")",
"if",
"not... | find datafile and load them from codec
TODO only does the first one
kwargs:
default = if passed will return that on failure instead of throwing | [
"find",
"datafile",
"and",
"load",
"them",
"from",
"codec",
"TODO",
"only",
"does",
"the",
"first",
"one",
"kwargs",
":",
"default",
"=",
"if",
"passed",
"will",
"return",
"that",
"on",
"failure",
"instead",
"of",
"throwing"
] | train | https://github.com/20c/munge/blob/e20fef8c24e48d4b0a5c387820fbb2b7bebb0af0/munge/codec/__init__.py#L66-L80 |
KelSolaar/Foundations | foundations/shell.py | _set_ansi_escape_codes | def _set_ansi_escape_codes():
"""
Injects *ANSI* escape codes into :class:`AnsiEscapeCodes` class.
"""
AnsiEscapeCodes["reset"] = "\033[0m"
for foreground_code_name, foreground_code in FOREGROUND_ANSI_ESCAPE_CODES:
AnsiEscapeCodes[foreground_code_name] = "\033[{0}".format(foreground_code)
... | python | def _set_ansi_escape_codes():
"""
Injects *ANSI* escape codes into :class:`AnsiEscapeCodes` class.
"""
AnsiEscapeCodes["reset"] = "\033[0m"
for foreground_code_name, foreground_code in FOREGROUND_ANSI_ESCAPE_CODES:
AnsiEscapeCodes[foreground_code_name] = "\033[{0}".format(foreground_code)
... | [
"def",
"_set_ansi_escape_codes",
"(",
")",
":",
"AnsiEscapeCodes",
"[",
"\"reset\"",
"]",
"=",
"\"\\033[0m\"",
"for",
"foreground_code_name",
",",
"foreground_code",
"in",
"FOREGROUND_ANSI_ESCAPE_CODES",
":",
"AnsiEscapeCodes",
"[",
"foreground_code_name",
"]",
"=",
"\"... | Injects *ANSI* escape codes into :class:`AnsiEscapeCodes` class. | [
"Injects",
"*",
"ANSI",
"*",
"escape",
"codes",
"into",
":",
"class",
":",
"AnsiEscapeCodes",
"class",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/shell.py#L97-L115 |
KelSolaar/Foundations | foundations/shell.py | colorize | def colorize(text, color):
"""
Colorizes given text using given color.
:param text: Text to colorize.
:type text: unicode
:param color: *ANSI* escape code name.
:type color: unicode
:return: Colorized text.
:rtype: unicode
"""
escape_code = getattr(AnsiEscapeCodes, color, None)... | python | def colorize(text, color):
"""
Colorizes given text using given color.
:param text: Text to colorize.
:type text: unicode
:param color: *ANSI* escape code name.
:type color: unicode
:return: Colorized text.
:rtype: unicode
"""
escape_code = getattr(AnsiEscapeCodes, color, None)... | [
"def",
"colorize",
"(",
"text",
",",
"color",
")",
":",
"escape_code",
"=",
"getattr",
"(",
"AnsiEscapeCodes",
",",
"color",
",",
"None",
")",
"if",
"escape_code",
"is",
"None",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"AnsiEscapeCodeExistsError",
... | Colorizes given text using given color.
:param text: Text to colorize.
:type text: unicode
:param color: *ANSI* escape code name.
:type color: unicode
:return: Colorized text.
:rtype: unicode | [
"Colorizes",
"given",
"text",
"using",
"given",
"color",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/shell.py#L121-L139 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/ext.py | InvenioClassifier.init_app | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.cli.add_command(classifier_cmd)
app.extensions['invenio-classifier'] = self | python | def init_app(self, app):
"""Flask application initialization."""
self.init_config(app)
app.cli.add_command(classifier_cmd)
app.extensions['invenio-classifier'] = self | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"app",
".",
"cli",
".",
"add_command",
"(",
"classifier_cmd",
")",
"app",
".",
"extensions",
"[",
"'invenio-classifier'",
"]",
"=",
"self"
] | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/ext.py#L41-L45 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/ext.py | InvenioClassifier.init_config | def init_config(app):
"""Initialize configuration."""
for k in dir(config):
if k.startswith('CLASSIFIER_'):
app.config.setdefault(k, getattr(config, k)) | python | def init_config(app):
"""Initialize configuration."""
for k in dir(config):
if k.startswith('CLASSIFIER_'):
app.config.setdefault(k, getattr(config, k)) | [
"def",
"init_config",
"(",
"app",
")",
":",
"for",
"k",
"in",
"dir",
"(",
"config",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"'CLASSIFIER_'",
")",
":",
"app",
".",
"config",
".",
"setdefault",
"(",
"k",
",",
"getattr",
"(",
"config",
",",
"k",
... | Initialize configuration. | [
"Initialize",
"configuration",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/ext.py#L48-L52 |
akfullfo/taskforce | taskforce/task.py | legion_create_handler | def legion_create_handler(obj):
"""
Signal handlers can't be standard class methods because the signal
callback does not include the object reference (self). To work
around this we use a closure the carry the object reference.
"""
def _handler(sig, frame):
obj._sig_handler(sig, frame)
... | python | def legion_create_handler(obj):
"""
Signal handlers can't be standard class methods because the signal
callback does not include the object reference (self). To work
around this we use a closure the carry the object reference.
"""
def _handler(sig, frame):
obj._sig_handler(sig, frame)
... | [
"def",
"legion_create_handler",
"(",
"obj",
")",
":",
"def",
"_handler",
"(",
"sig",
",",
"frame",
")",
":",
"obj",
".",
"_sig_handler",
"(",
"sig",
",",
"frame",
")",
"if",
"'_sig_handler'",
"not",
"in",
"dir",
"(",
"obj",
")",
":",
"# pragma: no cover"... | Signal handlers can't be standard class methods because the signal
callback does not include the object reference (self). To work
around this we use a closure the carry the object reference. | [
"Signal",
"handlers",
"can",
"t",
"be",
"standard",
"class",
"methods",
"because",
"the",
"signal",
"callback",
"does",
"not",
"include",
"the",
"object",
"reference",
"(",
"self",
")",
".",
"To",
"work",
"around",
"this",
"we",
"use",
"a",
"closure",
"the... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L70-L81 |
akfullfo/taskforce | taskforce/task.py | _fmt_context | def _fmt_context(arg_list, context):
"""
Iterate on performing a format operation until the formatting makes no
further changes. This allows for the substitution of context values that
themselves have context values. To prevent infinite loops due to direct
or indirect self-reference, the total num... | python | def _fmt_context(arg_list, context):
"""
Iterate on performing a format operation until the formatting makes no
further changes. This allows for the substitution of context values that
themselves have context values. To prevent infinite loops due to direct
or indirect self-reference, the total num... | [
"def",
"_fmt_context",
"(",
"arg_list",
",",
"context",
")",
":",
"if",
"arg_list",
"is",
"None",
":",
"return",
"arg_list",
"just_one",
"=",
"False",
"if",
"not",
"isinstance",
"(",
"arg_list",
",",
"list",
")",
":",
"arg_list",
"=",
"[",
"arg_list",
"]... | Iterate on performing a format operation until the formatting makes no
further changes. This allows for the substitution of context values that
themselves have context values. To prevent infinite loops due to direct
or indirect self-reference, the total number of attempts is limited.
On any error, th... | [
"Iterate",
"on",
"performing",
"a",
"format",
"operation",
"until",
"the",
"formatting",
"makes",
"no",
"further",
"changes",
".",
"This",
"allows",
"for",
"the",
"substitution",
"of",
"context",
"values",
"that",
"themselves",
"have",
"context",
"values",
".",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L103-L148 |
akfullfo/taskforce | taskforce/task.py | _exec_process | def _exec_process(cmd_list, base_context, instance=0, log=None):
"""
Process execution tool.
The forks and execs a process with args formatted according to a context.
This is implemented as a module function to make it available to
event_targets, legion and tasks.
The args are:
cmd_list ... | python | def _exec_process(cmd_list, base_context, instance=0, log=None):
"""
Process execution tool.
The forks and execs a process with args formatted according to a context.
This is implemented as a module function to make it available to
event_targets, legion and tasks.
The args are:
cmd_list ... | [
"def",
"_exec_process",
"(",
"cmd_list",
",",
"base_context",
",",
"instance",
"=",
"0",
",",
"log",
"=",
"None",
")",
":",
"if",
"not",
"log",
":",
"# pragma: no cover",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"log",
".",
"addHand... | Process execution tool.
The forks and execs a process with args formatted according to a context.
This is implemented as a module function to make it available to
event_targets, legion and tasks.
The args are:
cmd_list - The path and arg vector
context - Task's context
instance ... | [
"Process",
"execution",
"tool",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L151-L369 |
akfullfo/taskforce | taskforce/task.py | event_target.command | def command(self, details):
"""
Handles executing a command-based event. This starts the command
as specified in the 'commands' section of the task config.
A separate event is registered to handle the command exit. This
simply logs the exit status.
"""
log = self._... | python | def command(self, details):
"""
Handles executing a command-based event. This starts the command
as specified in the 'commands' section of the task config.
A separate event is registered to handle the command exit. This
simply logs the exit status.
"""
log = self._... | [
"def",
"command",
"(",
"self",
",",
"details",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"'_config_running'",
"not",
"in",
"dir",
"(",
"self",
".",
"_parent",
")",
"or",
"'command... | Handles executing a command-based event. This starts the command
as specified in the 'commands' section of the task config.
A separate event is registered to handle the command exit. This
simply logs the exit status. | [
"Handles",
"executing",
"a",
"command",
"-",
"based",
"event",
".",
"This",
"starts",
"the",
"command",
"as",
"specified",
"in",
"the",
"commands",
"section",
"of",
"the",
"task",
"config",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L430-L455 |
akfullfo/taskforce | taskforce/task.py | event_target.command_exit | def command_exit(self, details):
"""
Handle the event when a utility command exits.
"""
log = self._params.get('log', self._discard)
pid = self._key
status = details
why = statusfmt(status)
if status:
log.warning("pid %d for %s(%s) %s", pid, self._... | python | def command_exit(self, details):
"""
Handle the event when a utility command exits.
"""
log = self._params.get('log', self._discard)
pid = self._key
status = details
why = statusfmt(status)
if status:
log.warning("pid %d for %s(%s) %s", pid, self._... | [
"def",
"command_exit",
"(",
"self",
",",
"details",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"pid",
"=",
"self",
".",
"_key",
"status",
"=",
"details",
"why",
"=",
"statusfmt",
"(",
... | Handle the event when a utility command exits. | [
"Handle",
"the",
"event",
"when",
"a",
"utility",
"command",
"exits",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L457-L468 |
akfullfo/taskforce | taskforce/task.py | event_target.proc_exit | def proc_exit(self, details):
"""
Handle the event when one of the task processes exits.
"""
log = self._params.get('log', self._discard)
pid = self._key
exit_code = details
why = statusfmt(exit_code)
proc = None
for p in self._parent._proc_state:
... | python | def proc_exit(self, details):
"""
Handle the event when one of the task processes exits.
"""
log = self._params.get('log', self._discard)
pid = self._key
exit_code = details
why = statusfmt(exit_code)
proc = None
for p in self._parent._proc_state:
... | [
"def",
"proc_exit",
"(",
"self",
",",
"details",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"pid",
"=",
"self",
".",
"_key",
"exit_code",
"=",
"details",
"why",
"=",
"statusfmt",
"(",
... | Handle the event when one of the task processes exits. | [
"Handle",
"the",
"event",
"when",
"one",
"of",
"the",
"task",
"processes",
"exits",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L470-L504 |
akfullfo/taskforce | taskforce/task.py | event_target.signal | def signal(self, details):
"""
Send a signal to all task processes.
"""
log = self._params.get('log', self._discard)
if '_signal' not in dir(self._parent) or not callable(getattr(self._parent, '_signal')):
log.error("Event parent '%s' has no '_signal' method", self._name)... | python | def signal(self, details):
"""
Send a signal to all task processes.
"""
log = self._params.get('log', self._discard)
if '_signal' not in dir(self._parent) or not callable(getattr(self._parent, '_signal')):
log.error("Event parent '%s' has no '_signal' method", self._name)... | [
"def",
"signal",
"(",
"self",
",",
"details",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"'_signal'",
"not",
"in",
"dir",
"(",
"self",
".",
"_parent",
")",
"or",
"not",
"callable... | Send a signal to all task processes. | [
"Send",
"a",
"signal",
"to",
"all",
"task",
"processes",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L506-L519 |
akfullfo/taskforce | taskforce/task.py | Context._context_defines | def _context_defines(self, context, conf):
"""
Apply any defines and role_defines from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defines value will override
a normal defines value.
"""
if conf an... | python | def _context_defines(self, context, conf):
"""
Apply any defines and role_defines from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defines value will override
a normal defines value.
"""
if conf an... | [
"def",
"_context_defines",
"(",
"self",
",",
"context",
",",
"conf",
")",
":",
"if",
"conf",
"and",
"'defines'",
"in",
"conf",
"and",
"isinstance",
"(",
"conf",
"[",
"'defines'",
"]",
",",
"dict",
")",
":",
"context",
".",
"update",
"(",
"conf",
"[",
... | Apply any defines and role_defines from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defines value will override
a normal defines value. | [
"Apply",
"any",
"defines",
"and",
"role_defines",
"from",
"the",
"current",
"config",
".",
"The",
"config",
"might",
"be",
"at",
"the",
"task",
"level",
"or",
"the",
"global",
"(",
"top",
")",
"level",
".",
"The",
"order",
"is",
"such",
"that",
"a",
"r... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L543-L559 |
akfullfo/taskforce | taskforce/task.py | Context._context_defaults | def _context_defaults(self, context, conf):
"""
Apply any defaults and role_defaults from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defaults value will be applied before
a normal defaults value so if present... | python | def _context_defaults(self, context, conf):
"""
Apply any defaults and role_defaults from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defaults value will be applied before
a normal defaults value so if present... | [
"def",
"_context_defaults",
"(",
"self",
",",
"context",
",",
"conf",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_legion'",
")",
":",
"roles",
"=",
"self",
".",
"_legion",
".",
"get_roles",
"(",
")",
"else",
":",
"roles",
"=",
"self",
".",
"get_r... | Apply any defaults and role_defaults from the current config.
The config might be at the task level or the global (top) level.
The order is such that a role_defaults value will be applied before
a normal defaults value so if present, the role_defaults is preferred. | [
"Apply",
"any",
"defaults",
"and",
"role_defaults",
"from",
"the",
"current",
"config",
".",
"The",
"config",
"might",
"be",
"at",
"the",
"task",
"level",
"or",
"the",
"global",
"(",
"top",
")",
"level",
".",
"The",
"order",
"is",
"such",
"that",
"a",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L561-L581 |
akfullfo/taskforce | taskforce/task.py | Context._get_list | def _get_list(self, value, context=None):
"""
Get a configuration value. The result is None if "value" is None,
otherwise the result is a list.
"value" may be a list, dict, or str value.
If a list, each element of the list may be a list, dict, or
str value, and the val... | python | def _get_list(self, value, context=None):
"""
Get a configuration value. The result is None if "value" is None,
otherwise the result is a list.
"value" may be a list, dict, or str value.
If a list, each element of the list may be a list, dict, or
str value, and the val... | [
"def",
"_get_list",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"res",
"=",
"[",
"]",
"if",
"value",
"is",
"None",
":",
"return... | Get a configuration value. The result is None if "value" is None,
otherwise the result is a list.
"value" may be a list, dict, or str value.
If a list, each element of the list may be a list, dict, or
str value, and the value extraction proceeds recursively.
During processing... | [
"Get",
"a",
"configuration",
"value",
".",
"The",
"result",
"is",
"None",
"if",
"value",
"is",
"None",
"otherwise",
"the",
"result",
"is",
"a",
"list",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L583-L620 |
akfullfo/taskforce | taskforce/task.py | Context._get | def _get(self, value, context=None, default=None):
"""
Similar to _get_list() except that the return value is required
to be a str. This calls _get_list() to retrieve the value,
but raises an exception unless the return is None or a
single-valued list when that value will be ret... | python | def _get(self, value, context=None, default=None):
"""
Similar to _get_list() except that the return value is required
to be a str. This calls _get_list() to retrieve the value,
but raises an exception unless the return is None or a
single-valued list when that value will be ret... | [
"def",
"_get",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"default",
"ret",
"=",
"self",
".",
"_get_list",
"(",
"value",
",",
"context",
"=",
"context",
... | Similar to _get_list() except that the return value is required
to be a str. This calls _get_list() to retrieve the value,
but raises an exception unless the return is None or a
single-valued list when that value will be returned.
If a default value is provided, it will be returned if ... | [
"Similar",
"to",
"_get_list",
"()",
"except",
"that",
"the",
"return",
"value",
"is",
"required",
"to",
"be",
"a",
"str",
".",
"This",
"calls",
"_get_list",
"()",
"to",
"retrieve",
"the",
"value",
"but",
"raises",
"an",
"exception",
"unless",
"the",
"retur... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L622-L648 |
akfullfo/taskforce | taskforce/task.py | legion._context_build | def _context_build(self, pending=False):
"""
Create a context dict from standard legion configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of p... | python | def _context_build(self, pending=False):
"""
Create a context dict from standard legion configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of p... | [
"def",
"_context_build",
"(",
"self",
",",
"pending",
"=",
"False",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"log",
".",
"debug",
"(",
"\"called with pending=%s\"",
",",
"pending",
")",
... | Create a context dict from standard legion configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of pre-defined values which have a common prefix from 'context_pr... | [
"Create",
"a",
"context",
"dict",
"from",
"standard",
"legion",
"configuration",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L914-L950 |
akfullfo/taskforce | taskforce/task.py | legion._get_http_services | def _get_http_services(self, http_list):
"""
Returns a list of httpd.HttpService instances which describe the HTTP
services that should be started.
The is built from the settings.http section of the configuration.
The first element of that section is adjusted according to parame... | python | def _get_http_services(self, http_list):
"""
Returns a list of httpd.HttpService instances which describe the HTTP
services that should be started.
The is built from the settings.http section of the configuration.
The first element of that section is adjusted according to parame... | [
"def",
"_get_http_services",
"(",
"self",
",",
"http_list",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"listen_param",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'http'",
")",
"service... | Returns a list of httpd.HttpService instances which describe the HTTP
services that should be started.
The is built from the settings.http section of the configuration.
The first element of that section is adjusted according to parameters
which have been passed into the legion. If sett... | [
"Returns",
"a",
"list",
"of",
"httpd",
".",
"HttpService",
"instances",
"which",
"describe",
"the",
"HTTP",
"services",
"that",
"should",
"be",
"started",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L952-L989 |
akfullfo/taskforce | taskforce/task.py | legion._manage_http_servers | def _manage_http_servers(self):
"""
Compares the running services with the current settings configuration
and adjusts the running services to match it if different.
The services are identified only by their postion in the server list,
so a change than only involves a position mo... | python | def _manage_http_servers(self):
"""
Compares the running services with the current settings configuration
and adjusts the running services to match it if different.
The services are identified only by their postion in the server list,
so a change than only involves a position mo... | [
"def",
"_manage_http_servers",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"not",
"self",
".",
"_config_running",
":",
"raise",
"Exception",
"(",
"'Attempt to create HTTP servi... | Compares the running services with the current settings configuration
and adjusts the running services to match it if different.
The services are identified only by their postion in the server list,
so a change than only involves a position move will cause a shuffle
in multiple services... | [
"Compares",
"the",
"running",
"services",
"with",
"the",
"current",
"settings",
"configuration",
"and",
"adjusts",
"the",
"running",
"services",
"to",
"match",
"it",
"if",
"different",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L991-L1071 |
akfullfo/taskforce | taskforce/task.py | legion._load_roles | def _load_roles(self):
"""
Load the roles, one per line, from the roles file. This is
called at startup and whenever the roles file changes.
Note that it is not strictly an error for the roles file to
be missing but a warning is logged in case that was not
intended.
... | python | def _load_roles(self):
"""
Load the roles, one per line, from the roles file. This is
called at startup and whenever the roles file changes.
Note that it is not strictly an error for the roles file to
be missing but a warning is logged in case that was not
intended.
... | [
"def",
"_load_roles",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"new_role_set",
"=",
"None",
"if",
"self",
".",
"_roles_file",
":",
"try",
":",
"with",
"open",
"(",
"self",... | Load the roles, one per line, from the roles file. This is
called at startup and whenever the roles file changes.
Note that it is not strictly an error for the roles file to
be missing but a warning is logged in case that was not
intended.
Returns True if there was a change in... | [
"Load",
"the",
"roles",
"one",
"per",
"line",
"from",
"the",
"roles",
"file",
".",
"This",
"is",
"called",
"at",
"startup",
"and",
"whenever",
"the",
"roles",
"file",
"changes",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1073-L1109 |
akfullfo/taskforce | taskforce/task.py | legion.set_roles_file | def set_roles_file(self, path):
"""
Load all roles from the roles file, and watch for future role
changes. When the roles file changes, it will be read and the
current configuration re-applied so that any role-induced
changes are processed.
Once loaded, the roles are pr... | python | def set_roles_file(self, path):
"""
Load all roles from the roles file, and watch for future role
changes. When the roles file changes, it will be read and the
current configuration re-applied so that any role-induced
changes are processed.
Once loaded, the roles are pr... | [
"def",
"set_roles_file",
"(",
"self",
",",
"path",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"path",
"!=",
"self",
".",
"_roles_file",
":",
"if",
"self",
".",
"_roles_file",
":",
... | Load all roles from the roles file, and watch for future role
changes. When the roles file changes, it will be read and the
current configuration re-applied so that any role-induced
changes are processed.
Once loaded, the roles are presented as a set. If there is
no role file,... | [
"Load",
"all",
"roles",
"from",
"the",
"roles",
"file",
"and",
"watch",
"for",
"future",
"role",
"changes",
".",
"When",
"the",
"roles",
"file",
"changes",
"it",
"will",
"be",
"read",
"and",
"the",
"current",
"configuration",
"re",
"-",
"applied",
"so",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1111-L1134 |
akfullfo/taskforce | taskforce/task.py | legion.set_config_file | def set_config_file(self, path):
"""
Set the config file. The contents must be valid YAML and there
must be a top-level element 'tasks'. The listed tasks will be
started according to their configuration, and the file will
be watched for future changes. The changes will be acti... | python | def set_config_file(self, path):
"""
Set the config file. The contents must be valid YAML and there
must be a top-level element 'tasks'. The listed tasks will be
started according to their configuration, and the file will
be watched for future changes. The changes will be acti... | [
"def",
"set_config_file",
"(",
"self",
",",
"path",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"path",
"!=",
"self",
".",
"_config_file",
":",
"if",
"self",
".",
"_config_file",
":... | Set the config file. The contents must be valid YAML and there
must be a top-level element 'tasks'. The listed tasks will be
started according to their configuration, and the file will
be watched for future changes. The changes will be activated
by appropriate changes to the running t... | [
"Set",
"the",
"config",
"file",
".",
"The",
"contents",
"must",
"be",
"valid",
"YAML",
"and",
"there",
"must",
"be",
"a",
"top",
"-",
"level",
"element",
"tasks",
".",
"The",
"listed",
"tasks",
"will",
"be",
"started",
"according",
"to",
"their",
"config... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1184-L1201 |
akfullfo/taskforce | taskforce/task.py | legion.set_own_module | def set_own_module(self, path):
"""
This is provided so the calling process can arrange for processing
to be stopped and a LegionReset exception raised when any part of
the program's own module tree changes.
"""
log = self._params.get('log', self._discard)
self._name ... | python | def set_own_module(self, path):
"""
This is provided so the calling process can arrange for processing
to be stopped and a LegionReset exception raised when any part of
the program's own module tree changes.
"""
log = self._params.get('log', self._discard)
self._name ... | [
"def",
"set_own_module",
"(",
"self",
",",
"path",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"self",
".",
"_name",
"=",
"path",
"self",
".",
"module_add",
"(",
"event_target",
"(",
"sel... | This is provided so the calling process can arrange for processing
to be stopped and a LegionReset exception raised when any part of
the program's own module tree changes. | [
"This",
"is",
"provided",
"so",
"the",
"calling",
"process",
"can",
"arrange",
"for",
"processing",
"to",
"be",
"stopped",
"and",
"a",
"LegionReset",
"exception",
"raised",
"when",
"any",
"part",
"of",
"the",
"program",
"s",
"own",
"module",
"tree",
"changes... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1203-L1211 |
akfullfo/taskforce | taskforce/task.py | legion.task_add | def task_add(self, t, periodic=None):
"""
Register a task in this legion. "periodic" should be None, or
a callback function which will be called periodically when the
legion is otherwise idle.
"""
name = t.get_name()
if name in self._tasknames:
raise Task... | python | def task_add(self, t, periodic=None):
"""
Register a task in this legion. "periodic" should be None, or
a callback function which will be called periodically when the
legion is otherwise idle.
"""
name = t.get_name()
if name in self._tasknames:
raise Task... | [
"def",
"task_add",
"(",
"self",
",",
"t",
",",
"periodic",
"=",
"None",
")",
":",
"name",
"=",
"t",
".",
"get_name",
"(",
")",
"if",
"name",
"in",
"self",
".",
"_tasknames",
":",
"raise",
"TaskError",
"(",
"name",
",",
"'Task already exists with %d daemo... | Register a task in this legion. "periodic" should be None, or
a callback function which will be called periodically when the
legion is otherwise idle. | [
"Register",
"a",
"task",
"in",
"this",
"legion",
".",
"periodic",
"should",
"be",
"None",
"or",
"a",
"callback",
"function",
"which",
"will",
"be",
"called",
"periodically",
"when",
"the",
"legion",
"is",
"otherwise",
"idle",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1220-L1231 |
akfullfo/taskforce | taskforce/task.py | legion.task_del | def task_del(self, t):
"""
Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted.
"""
name = t._name
if name in self._tasknames:
del self._tasknames[name]
self._tasks.discard(t)
... | python | def task_del(self, t):
"""
Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted.
"""
name = t._name
if name in self._tasknames:
del self._tasknames[name]
self._tasks.discard(t)
... | [
"def",
"task_del",
"(",
"self",
",",
"t",
")",
":",
"name",
"=",
"t",
".",
"_name",
"if",
"name",
"in",
"self",
".",
"_tasknames",
":",
"del",
"self",
".",
"_tasknames",
"[",
"name",
"]",
"self",
".",
"_tasks",
".",
"discard",
"(",
"t",
")",
"sel... | Remove a task in this legion.
If the task has active processes, an attempt is made to
stop them before the task is deleted. | [
"Remove",
"a",
"task",
"in",
"this",
"legion",
".",
"If",
"the",
"task",
"has",
"active",
"processes",
"an",
"attempt",
"is",
"made",
"to",
"stop",
"them",
"before",
"the",
"task",
"is",
"deleted",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1233-L1250 |
akfullfo/taskforce | taskforce/task.py | legion.task_list | def task_list(self, pending=True):
"""
Return the list of scoped tasks (ie tasks that have
appropriate roles set) in correct execution order.
The result is a list of task objects.
"""
log = self._params.get('log', self._discard)
tasks = [t for t in self._tasks if t.p... | python | def task_list(self, pending=True):
"""
Return the list of scoped tasks (ie tasks that have
appropriate roles set) in correct execution order.
The result is a list of task objects.
"""
log = self._params.get('log', self._discard)
tasks = [t for t in self._tasks if t.p... | [
"def",
"task_list",
"(",
"self",
",",
"pending",
"=",
"True",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"tasks",
"=",
"[",
"t",
"for",
"t",
"in",
"self",
".",
"_tasks",
"if",
"t",
... | Return the list of scoped tasks (ie tasks that have
appropriate roles set) in correct execution order.
The result is a list of task objects. | [
"Return",
"the",
"list",
"of",
"scoped",
"tasks",
"(",
"ie",
"tasks",
"that",
"have",
"appropriate",
"roles",
"set",
")",
"in",
"correct",
"execution",
"order",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1258-L1293 |
akfullfo/taskforce | taskforce/task.py | legion.proc_del | def proc_del(self, pid):
"""
Disassociate a process from the legion. Note that is is almost
always called by the task -- it doesn't attempt to stop the actual
process so a direct call is almost always wrong.
"""
if pid in self._procs:
del self._procs[pid]
... | python | def proc_del(self, pid):
"""
Disassociate a process from the legion. Note that is is almost
always called by the task -- it doesn't attempt to stop the actual
process so a direct call is almost always wrong.
"""
if pid in self._procs:
del self._procs[pid]
... | [
"def",
"proc_del",
"(",
"self",
",",
"pid",
")",
":",
"if",
"pid",
"in",
"self",
".",
"_procs",
":",
"del",
"self",
".",
"_procs",
"[",
"pid",
"]",
"else",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_d... | Disassociate a process from the legion. Note that is is almost
always called by the task -- it doesn't attempt to stop the actual
process so a direct call is almost always wrong. | [
"Disassociate",
"a",
"process",
"from",
"the",
"legion",
".",
"Note",
"that",
"is",
"is",
"almost",
"always",
"called",
"by",
"the",
"task",
"--",
"it",
"doesn",
"t",
"attempt",
"to",
"stop",
"the",
"actual",
"process",
"so",
"a",
"direct",
"call",
"is",... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1302-L1312 |
akfullfo/taskforce | taskforce/task.py | legion.module_add | def module_add(self, ev, path=None):
"""
Register for python module change events. If there is a module change, the
task will be notified with a call t.event(action).
"""
log = self._params.get('log', self._discard)
key = ev.get_key()
if key is None:
rais... | python | def module_add(self, ev, path=None):
"""
Register for python module change events. If there is a module change, the
task will be notified with a call t.event(action).
"""
log = self._params.get('log', self._discard)
key = ev.get_key()
if key is None:
rais... | [
"def",
"module_add",
"(",
"self",
",",
"ev",
",",
"path",
"=",
"None",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"key",
"=",
"ev",
".",
"get_key",
"(",
")",
"if",
"key",
"is",
"No... | Register for python module change events. If there is a module change, the
task will be notified with a call t.event(action). | [
"Register",
"for",
"python",
"module",
"change",
"events",
".",
"If",
"there",
"is",
"a",
"module",
"change",
"the",
"task",
"will",
"be",
"notified",
"with",
"a",
"call",
"t",
".",
"event",
"(",
"action",
")",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1314-L1325 |
akfullfo/taskforce | taskforce/task.py | legion.module_del | def module_del(self, key):
"""
Deregister from python module change events.
"""
if key in self._module_event_map:
del self._module_event_map[key]
if key in self._watch_modules.names:
self._watch_modules.remove(key) | python | def module_del(self, key):
"""
Deregister from python module change events.
"""
if key in self._module_event_map:
del self._module_event_map[key]
if key in self._watch_modules.names:
self._watch_modules.remove(key) | [
"def",
"module_del",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_module_event_map",
":",
"del",
"self",
".",
"_module_event_map",
"[",
"key",
"]",
"if",
"key",
"in",
"self",
".",
"_watch_modules",
".",
"names",
":",
"self",
"."... | Deregister from python module change events. | [
"Deregister",
"from",
"python",
"module",
"change",
"events",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1327-L1334 |
akfullfo/taskforce | taskforce/task.py | legion.file_add | def file_add(self, ev, paths):
"""
Register for file change events. If there is a change to the file, all
registered tasks will be notified with a call t.event(action).
Note that as multiple tasks might register an event on the same
path, each path is mapped to a dict of tasks ... | python | def file_add(self, ev, paths):
"""
Register for file change events. If there is a change to the file, all
registered tasks will be notified with a call t.event(action).
Note that as multiple tasks might register an event on the same
path, each path is mapped to a dict of tasks ... | [
"def",
"file_add",
"(",
"self",
",",
"ev",
",",
"paths",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"not",
"isinstance",
"(",
"paths",
",",
"list",
")",
":",
"paths",
"=",
"[",... | Register for file change events. If there is a change to the file, all
registered tasks will be notified with a call t.event(action).
Note that as multiple tasks might register an event on the same
path, each path is mapped to a dict of tasks pointing at actions.
A task can only regist... | [
"Register",
"for",
"file",
"change",
"events",
".",
"If",
"there",
"is",
"a",
"change",
"to",
"the",
"file",
"all",
"registered",
"tasks",
"will",
"be",
"notified",
"with",
"a",
"call",
"t",
".",
"event",
"(",
"action",
")",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1336-L1353 |
akfullfo/taskforce | taskforce/task.py | legion.file_del | def file_del(self, key, paths=None):
"""
Deregister a task for file event changes. If paths is None, all
paths assoicated with the task will be deregistered.
"""
if paths is None:
paths = []
for path in self._file_event_map:
if key in self._fi... | python | def file_del(self, key, paths=None):
"""
Deregister a task for file event changes. If paths is None, all
paths assoicated with the task will be deregistered.
"""
if paths is None:
paths = []
for path in self._file_event_map:
if key in self._fi... | [
"def",
"file_del",
"(",
"self",
",",
"key",
",",
"paths",
"=",
"None",
")",
":",
"if",
"paths",
"is",
"None",
":",
"paths",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"_file_event_map",
":",
"if",
"key",
"in",
"self",
".",
"_file_event_map",
... | Deregister a task for file event changes. If paths is None, all
paths assoicated with the task will be deregistered. | [
"Deregister",
"a",
"task",
"for",
"file",
"event",
"changes",
".",
"If",
"paths",
"is",
"None",
"all",
"paths",
"assoicated",
"with",
"the",
"task",
"will",
"be",
"deregistered",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1355-L1372 |
akfullfo/taskforce | taskforce/task.py | legion._reap | def _reap(self):
"""
Reap all processes that have exited. We try to reap bursts of
processes so that groups that cluster will tend to restart in the
configured order.
"""
log = self._params.get('log', self._discard)
try:
cnt = len(os.read(self._watch_chil... | python | def _reap(self):
"""
Reap all processes that have exited. We try to reap bursts of
processes so that groups that cluster will tend to restart in the
configured order.
"""
log = self._params.get('log', self._discard)
try:
cnt = len(os.read(self._watch_chil... | [
"def",
"_reap",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"try",
":",
"cnt",
"=",
"len",
"(",
"os",
".",
"read",
"(",
"self",
".",
"_watch_child",
",",
"102400",
")",
... | Reap all processes that have exited. We try to reap bursts of
processes so that groups that cluster will tend to restart in the
configured order. | [
"Reap",
"all",
"processes",
"that",
"have",
"exited",
".",
"We",
"try",
"to",
"reap",
"bursts",
"of",
"processes",
"so",
"that",
"groups",
"that",
"cluster",
"will",
"tend",
"to",
"restart",
"in",
"the",
"configured",
"order",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1374-L1409 |
akfullfo/taskforce | taskforce/task.py | task._reset_state | def _reset_state(self):
"""
State flags. These hold the time of the change in the particular state, or
None if there has been no such state change yet.
starting - Indicates the task is in the process of starting. This flag
inhibits further startup attempts.
... | python | def _reset_state(self):
"""
State flags. These hold the time of the change in the particular state, or
None if there has been no such state change yet.
starting - Indicates the task is in the process of starting. This flag
inhibits further startup attempts.
... | [
"def",
"_reset_state",
"(",
"self",
")",
":",
"self",
".",
"_starting",
"=",
"None",
"self",
".",
"_started",
"=",
"None",
"self",
".",
"_suspended",
"=",
"None",
"self",
".",
"_stopping",
"=",
"None",
"self",
".",
"_terminated",
"=",
"None",
"self",
"... | State flags. These hold the time of the change in the particular state, or
None if there has been no such state change yet.
starting - Indicates the task is in the process of starting. This flag
inhibits further startup attempts.
started - Indicates the task has bee... | [
"State",
"flags",
".",
"These",
"hold",
"the",
"time",
"of",
"the",
"change",
"in",
"the",
"particular",
"state",
"or",
"None",
"if",
"there",
"has",
"been",
"no",
"such",
"state",
"change",
"yet",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1703-L1741 |
akfullfo/taskforce | taskforce/task.py | task._context_build | def _context_build(self, pending=False):
"""
Create a context dict from standard task configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of pre... | python | def _context_build(self, pending=False):
"""
Create a context dict from standard task configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of pre... | [
"def",
"_context_build",
"(",
"self",
",",
"pending",
"=",
"False",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"log",
".",
"debug",
"(",
"\"called with pending=%s\"",
",",
"pending",
")",
... | Create a context dict from standard task configuration.
The context is constructed in a standard way and is passed to str.format() on configuration.
The context consists of the entire os.environ, the config 'defines', and a set
of pre-defined values which have a common prefix from 'context_pref... | [
"Create",
"a",
"context",
"dict",
"from",
"standard",
"task",
"configuration",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1746-L1800 |
akfullfo/taskforce | taskforce/task.py | task.participant | def participant(self):
"""
True if the tasks roles meet the legion's constraints,
False otherwise.
"""
log = self._params.get('log', self._discard)
context = self._context_build(pending=True)
conf = self._config_pending
if conf.get('control') == 'off':
... | python | def participant(self):
"""
True if the tasks roles meet the legion's constraints,
False otherwise.
"""
log = self._params.get('log', self._discard)
context = self._context_build(pending=True)
conf = self._config_pending
if conf.get('control') == 'off':
... | [
"def",
"participant",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"context",
"=",
"self",
".",
"_context_build",
"(",
"pending",
"=",
"True",
")",
"conf",
"=",
"self",
".",
... | True if the tasks roles meet the legion's constraints,
False otherwise. | [
"True",
"if",
"the",
"tasks",
"roles",
"meet",
"the",
"legion",
"s",
"constraints",
"False",
"otherwise",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1869-L1907 |
akfullfo/taskforce | taskforce/task.py | task._event_register | def _event_register(self, control):
"""
Do all necessary event registration with the legion for
events listed in the pending config. The default event
action is to stop the task.
"""
log = self._params.get('log', self._discard)
if 'events' not in self._config_running... | python | def _event_register(self, control):
"""
Do all necessary event registration with the legion for
events listed in the pending config. The default event
action is to stop the task.
"""
log = self._params.get('log', self._discard)
if 'events' not in self._config_running... | [
"def",
"_event_register",
"(",
"self",
",",
"control",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"'events'",
"not",
"in",
"self",
".",
"_config_running",
":",
"log",
".",
"debug",
... | Do all necessary event registration with the legion for
events listed in the pending config. The default event
action is to stop the task. | [
"Do",
"all",
"necessary",
"event",
"registration",
"with",
"the",
"legion",
"for",
"events",
"listed",
"in",
"the",
"pending",
"config",
".",
"The",
"default",
"event",
"action",
"is",
"to",
"stop",
"the",
"task",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1926-L1958 |
akfullfo/taskforce | taskforce/task.py | task._event_deregister | def _event_deregister(self):
"""
Deregister all legion events associated with this task
(or possibly those listed in the current config, but it
would be better to base deregistration on the task name).
"""
log = self._params.get('log', self._discard)
if 'events' not i... | python | def _event_deregister(self):
"""
Deregister all legion events associated with this task
(or possibly those listed in the current config, but it
would be better to base deregistration on the task name).
"""
log = self._params.get('log', self._discard)
if 'events' not i... | [
"def",
"_event_deregister",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"'events'",
"not",
"in",
"self",
".",
"_config_running",
":",
"log",
".",
"debug",
"(",
"\"No even... | Deregister all legion events associated with this task
(or possibly those listed in the current config, but it
would be better to base deregistration on the task name). | [
"Deregister",
"all",
"legion",
"events",
"associated",
"with",
"this",
"task",
"(",
"or",
"possibly",
"those",
"listed",
"in",
"the",
"current",
"config",
"but",
"it",
"would",
"be",
"better",
"to",
"base",
"deregistration",
"on",
"the",
"task",
"name",
")",... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1960-L1977 |
akfullfo/taskforce | taskforce/task.py | task._command_change | def _command_change(self):
"""
Returns True if the difference between the current and
pending configs represents a change to the command.
That comes down to these cases:
- No current config (startup case)
- No pending config (task deleted)
- Command... | python | def _command_change(self):
"""
Returns True if the difference between the current and
pending configs represents a change to the command.
That comes down to these cases:
- No current config (startup case)
- No pending config (task deleted)
- Command... | [
"def",
"_command_change",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"self",
".",
"_config_running",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"\"Task '%s' change - no ... | Returns True if the difference between the current and
pending configs represents a change to the command.
That comes down to these cases:
- No current config (startup case)
- No pending config (task deleted)
- Command changed (restart needed)
- Enviro... | [
"Returns",
"True",
"if",
"the",
"difference",
"between",
"the",
"current",
"and",
"pending",
"configs",
"represents",
"a",
"change",
"to",
"the",
"command",
".",
"That",
"comes",
"down",
"to",
"these",
"cases",
":",
"-",
"No",
"current",
"config",
"(",
"st... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L1979-L2013 |
akfullfo/taskforce | taskforce/task.py | task._task_periodic | def _task_periodic(self):
"""
This is a callback that is registered to be called periodically
from the legion. The legion chooses when it might be called,
typically when it is otherwise idle.
"""
log = self._params.get('log', self._discard)
log.debug("periodic")
... | python | def _task_periodic(self):
"""
This is a callback that is registered to be called periodically
from the legion. The legion chooses when it might be called,
typically when it is otherwise idle.
"""
log = self._params.get('log', self._discard)
log.debug("periodic")
... | [
"def",
"_task_periodic",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"log",
".",
"debug",
"(",
"\"periodic\"",
")",
"self",
".",
"manage",
"(",
")"
] | This is a callback that is registered to be called periodically
from the legion. The legion chooses when it might be called,
typically when it is otherwise idle. | [
"This",
"is",
"a",
"callback",
"that",
"is",
"registered",
"to",
"be",
"called",
"periodically",
"from",
"the",
"legion",
".",
"The",
"legion",
"chooses",
"when",
"it",
"might",
"be",
"called",
"typically",
"when",
"it",
"is",
"otherwise",
"idle",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2015-L2023 |
akfullfo/taskforce | taskforce/task.py | task._signal | def _signal(self, sig, pid=None):
"""
Send a signal to one or all pids associated with this task. Never fails, but logs
signalling faults as warnings.
"""
log = self._params.get('log', self._discard)
if pid is None:
pids = self.get_pids()
else:
... | python | def _signal(self, sig, pid=None):
"""
Send a signal to one or all pids associated with this task. Never fails, but logs
signalling faults as warnings.
"""
log = self._params.get('log', self._discard)
if pid is None:
pids = self.get_pids()
else:
... | [
"def",
"_signal",
"(",
"self",
",",
"sig",
",",
"pid",
"=",
"None",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"pid",
"is",
"None",
":",
"pids",
"=",
"self",
".",
"get_pids",
... | Send a signal to one or all pids associated with this task. Never fails, but logs
signalling faults as warnings. | [
"Send",
"a",
"signal",
"to",
"one",
"or",
"all",
"pids",
"associated",
"with",
"this",
"task",
".",
"Never",
"fails",
"but",
"logs",
"signalling",
"faults",
"as",
"warnings",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2025-L2040 |
akfullfo/taskforce | taskforce/task.py | task.onexit | def onexit(self):
"""
Runs any "onexit" functions present in the config. This will
normally be called from the proc_exit event handler after all
processes in a task have stopped.
Currently the following "onexit" types are supported:
'start': Set the specified task t... | python | def onexit(self):
"""
Runs any "onexit" functions present in the config. This will
normally be called from the proc_exit event handler after all
processes in a task have stopped.
Currently the following "onexit" types are supported:
'start': Set the specified task t... | [
"def",
"onexit",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"conf",
"=",
"self",
".",
"_config_running",
"if",
"'onexit'",
"not",
"in",
"conf",
":",
"log",
".",
"debug",
"... | Runs any "onexit" functions present in the config. This will
normally be called from the proc_exit event handler after all
processes in a task have stopped.
Currently the following "onexit" types are supported:
'start': Set the specified task to be started. It
norm... | [
"Runs",
"any",
"onexit",
"functions",
"present",
"in",
"the",
"config",
".",
"This",
"will",
"normally",
"be",
"called",
"from",
"the",
"proc_exit",
"event",
"handler",
"after",
"all",
"processes",
"in",
"a",
"task",
"have",
"stopped",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2042-L2098 |
akfullfo/taskforce | taskforce/task.py | task._shrink | def _shrink(self, needed, running):
"""
Shrink the process pool from the number currently running to
the needed number. The processes will be sent a SIGTERM at first
and if that doesn't clear the process, a SIGKILL. Errors will
be logged but otherwise ignored.
"""
l... | python | def _shrink(self, needed, running):
"""
Shrink the process pool from the number currently running to
the needed number. The processes will be sent a SIGTERM at first
and if that doesn't clear the process, a SIGKILL. Errors will
be logged but otherwise ignored.
"""
l... | [
"def",
"_shrink",
"(",
"self",
",",
"needed",
",",
"running",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"log",
".",
"info",
"(",
"\"%d process%s running, reducing to %d process%s\"",
",",
"ru... | Shrink the process pool from the number currently running to
the needed number. The processes will be sent a SIGTERM at first
and if that doesn't clear the process, a SIGKILL. Errors will
be logged but otherwise ignored. | [
"Shrink",
"the",
"process",
"pool",
"from",
"the",
"number",
"currently",
"running",
"to",
"the",
"needed",
"number",
".",
"The",
"processes",
"will",
"be",
"sent",
"a",
"SIGTERM",
"at",
"first",
"and",
"if",
"that",
"doesn",
"t",
"clear",
"the",
"process"... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2100-L2124 |
akfullfo/taskforce | taskforce/task.py | task._mark_started | def _mark_started(self):
"""
Set the state information for a task once it has completely started.
In particular, the time limit is applied as of this time (ie after
and start delay has been taking.
"""
log = self._params.get('log', self._discard)
now = time.time()
... | python | def _mark_started(self):
"""
Set the state information for a task once it has completely started.
In particular, the time limit is applied as of this time (ie after
and start delay has been taking.
"""
log = self._params.get('log', self._discard)
now = time.time()
... | [
"def",
"_mark_started",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"now",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_started",
"=",
"now",
"limit",
"=",
"self",
... | Set the state information for a task once it has completely started.
In particular, the time limit is applied as of this time (ie after
and start delay has been taking. | [
"Set",
"the",
"state",
"information",
"for",
"a",
"task",
"once",
"it",
"has",
"completely",
"started",
".",
"In",
"particular",
"the",
"time",
"limit",
"is",
"applied",
"as",
"of",
"this",
"time",
"(",
"ie",
"after",
"and",
"start",
"delay",
"has",
"bee... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2126-L2145 |
akfullfo/taskforce | taskforce/task.py | task._start | def _start(self):
"""
Start a task, which may involve starting zero or more processes.
This is indicated as an internal method because tasks are really
only ever marked as startable by the configuration. Any task
that should be running and is not will be started during regular
... | python | def _start(self):
"""
Start a task, which may involve starting zero or more processes.
This is indicated as an internal method because tasks are really
only ever marked as startable by the configuration. Any task
that should be running and is not will be started during regular
... | [
"def",
"_start",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"self",
".",
"_stopping",
":",
"log",
".",
"debug",
"(",
"\"%s task is stopping\"",
",",
"self",
".",
"_nam... | Start a task, which may involve starting zero or more processes.
This is indicated as an internal method because tasks are really
only ever marked as startable by the configuration. Any task
that should be running and is not will be started during regular
manage() calls. A task set to... | [
"Start",
"a",
"task",
"which",
"may",
"involve",
"starting",
"zero",
"or",
"more",
"processes",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2147-L2331 |
akfullfo/taskforce | taskforce/task.py | task.stop | def stop(self, task_is_resetting=False):
"""
Stop a task. This stops all processes for the task. The approach
is to mark the task as "stopping" , send a SIGTERM to each process,
and schedule a SIGKILL for some time later.
If the legion or task is resetting and a "restart" even... | python | def stop(self, task_is_resetting=False):
"""
Stop a task. This stops all processes for the task. The approach
is to mark the task as "stopping" , send a SIGTERM to each process,
and schedule a SIGKILL for some time later.
If the legion or task is resetting and a "restart" even... | [
"def",
"stop",
"(",
"self",
",",
"task_is_resetting",
"=",
"False",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"self",
".",
"_stopped",
":",
"log",
".",
"debug",
"(",
"\"'%s' is al... | Stop a task. This stops all processes for the task. The approach
is to mark the task as "stopping" , send a SIGTERM to each process,
and schedule a SIGKILL for some time later.
If the legion or task is resetting and a "restart" event is in scope,
that event will be fired rather than s... | [
"Stop",
"a",
"task",
".",
"This",
"stops",
"all",
"processes",
"for",
"the",
"task",
".",
"The",
"approach",
"is",
"to",
"mark",
"the",
"task",
"as",
"stopping",
"send",
"a",
"SIGTERM",
"to",
"each",
"process",
"and",
"schedule",
"a",
"SIGKILL",
"for",
... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2333-L2414 |
akfullfo/taskforce | taskforce/task.py | task.terminate | def terminate(self):
"""
Called when an existing task is removed from the configuration.
This sets a Do Not Resuscitate flag and then initiates a stop
sequence. Once all processes have stopped, the task will delete
itself.
"""
log = self._params.get('log', self._disc... | python | def terminate(self):
"""
Called when an existing task is removed from the configuration.
This sets a Do Not Resuscitate flag and then initiates a stop
sequence. Once all processes have stopped, the task will delete
itself.
"""
log = self._params.get('log', self._disc... | [
"def",
"terminate",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"self",
".",
"_dnr",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"stop",
"(",
")",
"log",
".",
"inf... | Called when an existing task is removed from the configuration.
This sets a Do Not Resuscitate flag and then initiates a stop
sequence. Once all processes have stopped, the task will delete
itself. | [
"Called",
"when",
"an",
"existing",
"task",
"is",
"removed",
"from",
"the",
"configuration",
".",
"This",
"sets",
"a",
"Do",
"Not",
"Resuscitate",
"flag",
"and",
"then",
"initiates",
"a",
"stop",
"sequence",
".",
"Once",
"all",
"processes",
"have",
"stopped"... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2416-L2426 |
akfullfo/taskforce | taskforce/task.py | task.apply | def apply(self):
"""
Make the pending config become the running config for this task
by triggering any necessary changes in the running task.
Returns True to request a shorter period before the next call,
False if nothing special is needed.
"""
log = self._params.get... | python | def apply(self):
"""
Make the pending config become the running config for this task
by triggering any necessary changes in the running task.
Returns True to request a shorter period before the next call,
False if nothing special is needed.
"""
log = self._params.get... | [
"def",
"apply",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"not",
"self",
".",
"_config_pending",
":",
"raise",
"TaskError",
"(",
"self",
".",
"_name",
",",
"\"No conf... | Make the pending config become the running config for this task
by triggering any necessary changes in the running task.
Returns True to request a shorter period before the next call,
False if nothing special is needed. | [
"Make",
"the",
"pending",
"config",
"become",
"the",
"running",
"config",
"for",
"this",
"task",
"by",
"triggering",
"any",
"necessary",
"changes",
"in",
"the",
"running",
"task",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2428-L2454 |
akfullfo/taskforce | taskforce/task.py | task.manage | def manage(self):
"""
Manage the task to handle restarts, reconfiguration, etc.
Returns True to request a shorter period before the next call,
False if nothing special is needed.
"""
log = self._params.get('log', self._discard)
if self._stopping:
log.debu... | python | def manage(self):
"""
Manage the task to handle restarts, reconfiguration, etc.
Returns True to request a shorter period before the next call,
False if nothing special is needed.
"""
log = self._params.get('log', self._discard)
if self._stopping:
log.debu... | [
"def",
"manage",
"(",
"self",
")",
":",
"log",
"=",
"self",
".",
"_params",
".",
"get",
"(",
"'log'",
",",
"self",
".",
"_discard",
")",
"if",
"self",
".",
"_stopping",
":",
"log",
".",
"debug",
"(",
"\"Task '%s', stopping, retrying stop()\"",
",",
"self... | Manage the task to handle restarts, reconfiguration, etc.
Returns True to request a shorter period before the next call,
False if nothing special is needed. | [
"Manage",
"the",
"task",
"to",
"handle",
"restarts",
"reconfiguration",
"etc",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L2456-L2478 |
KelSolaar/Foundations | foundations/data_structures.py | Structure.update | def update(self, *args, **kwargs):
"""
Reimplements the :meth:`Dict.update` method.
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\*
"""
dict.update(self, *args, **kwargs)
self.__dict__.upda... | python | def update(self, *args, **kwargs):
"""
Reimplements the :meth:`Dict.update` method.
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\*
"""
dict.update(self, *args, **kwargs)
self.__dict__.upda... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dict",
".",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"__dict__",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"k... | Reimplements the :meth:`Dict.update` method.
:param \*args: Arguments.
:type \*args: \*
:param \*\*kwargs: Keywords arguments.
:type \*\*kwargs: \*\* | [
"Reimplements",
"the",
":",
"meth",
":",
"Dict",
".",
"update",
"method",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/data_structures.py#L175-L186 |
KelSolaar/Foundations | foundations/data_structures.py | Lookup.get_first_key_from_value | def get_first_key_from_value(self, value):
"""
Gets the first key from given value.
:param value: Value.
:type value: object
:return: Key.
:rtype: object
"""
for key, data in self.iteritems():
if data == value:
return key | python | def get_first_key_from_value(self, value):
"""
Gets the first key from given value.
:param value: Value.
:type value: object
:return: Key.
:rtype: object
"""
for key, data in self.iteritems():
if data == value:
return key | [
"def",
"get_first_key_from_value",
"(",
"self",
",",
"value",
")",
":",
"for",
"key",
",",
"data",
"in",
"self",
".",
"iteritems",
"(",
")",
":",
"if",
"data",
"==",
"value",
":",
"return",
"key"
] | Gets the first key from given value.
:param value: Value.
:type value: object
:return: Key.
:rtype: object | [
"Gets",
"the",
"first",
"key",
"from",
"given",
"value",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/data_structures.py#L315-L327 |
KelSolaar/Foundations | foundations/data_structures.py | Lookup.get_keys_from_value | def get_keys_from_value(self, value):
"""
Gets the keys from given value.
:param value: Value.
:type value: object
:return: Keys.
:rtype: object
"""
return [key for key, data in self.iteritems() if data == value] | python | def get_keys_from_value(self, value):
"""
Gets the keys from given value.
:param value: Value.
:type value: object
:return: Keys.
:rtype: object
"""
return [key for key, data in self.iteritems() if data == value] | [
"def",
"get_keys_from_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"[",
"key",
"for",
"key",
",",
"data",
"in",
"self",
".",
"iteritems",
"(",
")",
"if",
"data",
"==",
"value",
"]"
] | Gets the keys from given value.
:param value: Value.
:type value: object
:return: Keys.
:rtype: object | [
"Gets",
"the",
"keys",
"from",
"given",
"value",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/data_structures.py#L329-L339 |
PMBio/limix-backup | limix/mtSet/iset_full.py | ISet_Full.setXr | def setXr(self, Xr):
""" set genotype data of the set component """
self.Xr = Xr
self.gp_block.covar.G = Xr | python | def setXr(self, Xr):
""" set genotype data of the set component """
self.Xr = Xr
self.gp_block.covar.G = Xr | [
"def",
"setXr",
"(",
"self",
",",
"Xr",
")",
":",
"self",
".",
"Xr",
"=",
"Xr",
"self",
".",
"gp_block",
".",
"covar",
".",
"G",
"=",
"Xr"
] | set genotype data of the set component | [
"set",
"genotype",
"data",
"of",
"the",
"set",
"component"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/iset_full.py#L43-L46 |
PMBio/limix-backup | limix/mtSet/iset_full.py | ISet_Full.fitNull | def fitNull(self, init_method='emp_cov'):
""" fit null model """
self.null = self.mtSet1.fitNull(cache=False, factr=self.factr, init_method=init_method)
self.null['NLL'] = self.null['NLL0']
self.mtSet2.null = copy.copy(self.null)
return self.null | python | def fitNull(self, init_method='emp_cov'):
""" fit null model """
self.null = self.mtSet1.fitNull(cache=False, factr=self.factr, init_method=init_method)
self.null['NLL'] = self.null['NLL0']
self.mtSet2.null = copy.copy(self.null)
return self.null | [
"def",
"fitNull",
"(",
"self",
",",
"init_method",
"=",
"'emp_cov'",
")",
":",
"self",
".",
"null",
"=",
"self",
".",
"mtSet1",
".",
"fitNull",
"(",
"cache",
"=",
"False",
",",
"factr",
"=",
"self",
".",
"factr",
",",
"init_method",
"=",
"init_method",... | fit null model | [
"fit",
"null",
"model"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/iset_full.py#L48-L53 |
PMBio/limix-backup | limix/mtSet/iset_full.py | ISet_Full.getVC | def getVC(self):
"""
Variance componenrs
"""
_Cr = decompose_GxE(self.fr['Cr'])
RV = {}
for key in list(_Cr.keys()):
RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
RV['var_g'] = sp.array([var_CoXX(self.fr['Cg'], self.XXh)])
RV['va... | python | def getVC(self):
"""
Variance componenrs
"""
_Cr = decompose_GxE(self.fr['Cr'])
RV = {}
for key in list(_Cr.keys()):
RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
RV['var_g'] = sp.array([var_CoXX(self.fr['Cg'], self.XXh)])
RV['va... | [
"def",
"getVC",
"(",
"self",
")",
":",
"_Cr",
"=",
"decompose_GxE",
"(",
"self",
".",
"fr",
"[",
"'Cr'",
"]",
")",
"RV",
"=",
"{",
"}",
"for",
"key",
"in",
"list",
"(",
"_Cr",
".",
"keys",
"(",
")",
")",
":",
"RV",
"[",
"'var_%s'",
"%",
"key"... | Variance componenrs | [
"Variance",
"componenrs"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/iset_full.py#L156-L166 |
PMBio/limix-backup | limix/stats/chi2mixture.py | Chi2mixture.estimate_chi2mixture | def estimate_chi2mixture(self, lrt):
"""
estimates the parameters of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d
(1-mixture)*chi2(0) + (mixture)*scale*chi2(dof),
where
scale is the scaling paramet... | python | def estimate_chi2mixture(self, lrt):
"""
estimates the parameters of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d
(1-mixture)*chi2(0) + (mixture)*scale*chi2(dof),
where
scale is the scaling paramet... | [
"def",
"estimate_chi2mixture",
"(",
"self",
",",
"lrt",
")",
":",
"\"\"\"\n step 1: estimate the probability of being in component one\n \"\"\"",
"self",
".",
"mixture",
"=",
"1",
"-",
"(",
"lrt",
"<=",
"self",
".",
"tol",
")",
".",
"mean",
"(",
")",
... | estimates the parameters of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d
(1-mixture)*chi2(0) + (mixture)*scale*chi2(dof),
where
scale is the scaling parameter for the scales chi-square distribution
dof ... | [
"estimates",
"the",
"parameters",
"of",
"a",
"mixture",
"of",
"a",
"chi",
"-",
"squared",
"random",
"variable",
"of",
"degree",
"0",
"and",
"a",
"scaled",
"chi",
"-",
"squared",
"random",
"variable",
"of",
"degree",
"d",
"(",
"1",
"-",
"mixture",
")",
... | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/chi2mixture.py#L36-L83 |
PMBio/limix-backup | limix/stats/chi2mixture.py | Chi2mixture.sf | def sf(self,lrt):
"""
computes the survival function of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d
"""
_lrt = SP.copy(lrt)
_lrt[lrt<self.tol] = 0
pv = self.mixture*STATS.chi2.sf(_lrt/self.scale,self.... | python | def sf(self,lrt):
"""
computes the survival function of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d
"""
_lrt = SP.copy(lrt)
_lrt[lrt<self.tol] = 0
pv = self.mixture*STATS.chi2.sf(_lrt/self.scale,self.... | [
"def",
"sf",
"(",
"self",
",",
"lrt",
")",
":",
"_lrt",
"=",
"SP",
".",
"copy",
"(",
"lrt",
")",
"_lrt",
"[",
"lrt",
"<",
"self",
".",
"tol",
"]",
"=",
"0",
"pv",
"=",
"self",
".",
"mixture",
"*",
"STATS",
".",
"chi2",
".",
"sf",
"(",
"_lrt... | computes the survival function of a mixture of a chi-squared random variable of degree
0 and a scaled chi-squared random variable of degree d | [
"computes",
"the",
"survival",
"function",
"of",
"a",
"mixture",
"of",
"a",
"chi",
"-",
"squared",
"random",
"variable",
"of",
"degree",
"0",
"and",
"a",
"scaled",
"chi",
"-",
"squared",
"random",
"variable",
"of",
"degree",
"d"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/chi2mixture.py#L87-L95 |
theonion/djes | djes/management/commands/sync_es.py | stringify | def stringify(data):
"""Turns all dictionary values into strings"""
if isinstance(data, dict):
for key, value in data.items():
data[key] = stringify(value)
elif isinstance(data, list):
return [stringify(item) for item in data]
else:
return smart_text(data)
return... | python | def stringify(data):
"""Turns all dictionary values into strings"""
if isinstance(data, dict):
for key, value in data.items():
data[key] = stringify(value)
elif isinstance(data, list):
return [stringify(item) for item in data]
else:
return smart_text(data)
return... | [
"def",
"stringify",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"data",
"[",
"key",
"]",
"=",
"stringify",
"(",
"value",
")",
"elif",
"isins... | Turns all dictionary values into strings | [
"Turns",
"all",
"dictionary",
"values",
"into",
"strings"
] | train | https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/management/commands/sync_es.py#L71-L81 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient.init_app | def init_app(self, app, client_id=None):
"""Initialize the Micropub extension if it was not given app
in the constructor.
Args:
app (flask.Flask): the flask application to extend.
client_id (string, optional): the IndieAuth client id, will be
displayed when the u... | python | def init_app(self, app, client_id=None):
"""Initialize the Micropub extension if it was not given app
in the constructor.
Args:
app (flask.Flask): the flask application to extend.
client_id (string, optional): the IndieAuth client id, will be
displayed when the u... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"client_id",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"client_id",
":",
"if",
"client_id",
":",
"self",
".",
"client_id",
"=",
"client_id",
"else",
":",
"self",
".",
"client_id",
"=",
"app",
".... | Initialize the Micropub extension if it was not given app
in the constructor.
Args:
app (flask.Flask): the flask application to extend.
client_id (string, optional): the IndieAuth client id, will be
displayed when the user is asked to authorize this client. If not
... | [
"Initialize",
"the",
"Micropub",
"extension",
"if",
"it",
"was",
"not",
"given",
"app",
"in",
"the",
"constructor",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L45-L59 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient.authenticate | def authenticate(self, me, state=None, next_url=None):
"""Authenticate a user via IndieAuth.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,
... | python | def authenticate(self, me, state=None, next_url=None):
"""Authenticate a user via IndieAuth.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,
... | [
"def",
"authenticate",
"(",
"self",
",",
"me",
",",
"state",
"=",
"None",
",",
"next_url",
"=",
"None",
")",
":",
"redirect_url",
"=",
"flask",
".",
"url_for",
"(",
"self",
".",
"flask_endpoint_for_function",
"(",
"self",
".",
"_authenticated_handler",
")",
... | Authenticate a user via IndieAuth.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,
useful if you want to maintain some state, e.g. the starting... | [
"Authenticate",
"a",
"user",
"via",
"IndieAuth",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L61-L80 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient.authorize | def authorize(self, me, state=None, next_url=None, scope='read'):
"""Authorize a user via Micropub.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,... | python | def authorize(self, me, state=None, next_url=None, scope='read'):
"""Authorize a user via Micropub.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,... | [
"def",
"authorize",
"(",
"self",
",",
"me",
",",
"state",
"=",
"None",
",",
"next_url",
"=",
"None",
",",
"scope",
"=",
"'read'",
")",
":",
"redirect_url",
"=",
"flask",
".",
"url_for",
"(",
"self",
".",
"flask_endpoint_for_function",
"(",
"self",
".",
... | Authorize a user via Micropub.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
state (string, optional): passed through the whole auth process,
useful if you want to maintain some state, e.g. the starting pag... | [
"Authorize",
"a",
"user",
"via",
"Micropub",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L82-L104 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient._start_indieauth | def _start_indieauth(self, me, redirect_url, state, scope):
"""Helper for both authentication and authorization. Kicks off
IndieAuth by fetching the authorization endpoint from the user's
homepage and redirecting to it.
Args:
me (string): the authing user's URL. if it does not... | python | def _start_indieauth(self, me, redirect_url, state, scope):
"""Helper for both authentication and authorization. Kicks off
IndieAuth by fetching the authorization endpoint from the user's
homepage and redirecting to it.
Args:
me (string): the authing user's URL. if it does not... | [
"def",
"_start_indieauth",
"(",
"self",
",",
"me",
",",
"redirect_url",
",",
"state",
",",
"scope",
")",
":",
"if",
"not",
"me",
".",
"startswith",
"(",
"'http://'",
")",
"and",
"not",
"me",
".",
"startswith",
"(",
"'https://'",
")",
":",
"me",
"=",
... | Helper for both authentication and authorization. Kicks off
IndieAuth by fetching the authorization endpoint from the user's
homepage and redirecting to it.
Args:
me (string): the authing user's URL. if it does not begin with
https?://, http:// will be prepended.
... | [
"Helper",
"for",
"both",
"authentication",
"and",
"authorization",
".",
"Kicks",
"off",
"IndieAuth",
"by",
"fetching",
"the",
"authorization",
"endpoint",
"from",
"the",
"user",
"s",
"homepage",
"and",
"redirecting",
"to",
"it",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L106-L147 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient.authenticated_handler | def authenticated_handler(self, f):
"""Decorates the authentication callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse.
"""
@functools.wraps(f)
def decorated():
resp = self._handle_authenticate_response()
return f(r... | python | def authenticated_handler(self, f):
"""Decorates the authentication callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse.
"""
@functools.wraps(f)
def decorated():
resp = self._handle_authenticate_response()
return f(r... | [
"def",
"authenticated_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
")",
":",
"resp",
"=",
"self",
".",
"_handle_authenticate_response",
"(",
")",
"return",
"f",
"(",
"resp",
")",
"se... | Decorates the authentication callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse. | [
"Decorates",
"the",
"authentication",
"callback",
"endpoint",
".",
"The",
"endpoint",
"should",
"take",
"one",
"argument",
"a",
"flask",
".",
"ext",
".",
"micropub",
".",
"AuthResponse",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L149-L158 |
kylewm/flask-micropub | flask_micropub.py | MicropubClient.authorized_handler | def authorized_handler(self, f):
"""Decorates the authorization callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse.
"""
@functools.wraps(f)
def decorated():
resp = self._handle_authorize_response()
return f(resp)
... | python | def authorized_handler(self, f):
"""Decorates the authorization callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse.
"""
@functools.wraps(f)
def decorated():
resp = self._handle_authorize_response()
return f(resp)
... | [
"def",
"authorized_handler",
"(",
"self",
",",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"decorated",
"(",
")",
":",
"resp",
"=",
"self",
".",
"_handle_authorize_response",
"(",
")",
"return",
"f",
"(",
"resp",
")",
"self",
... | Decorates the authorization callback endpoint. The endpoint should
take one argument, a flask.ext.micropub.AuthResponse. | [
"Decorates",
"the",
"authorization",
"callback",
"endpoint",
".",
"The",
"endpoint",
"should",
"take",
"one",
"argument",
"a",
"flask",
".",
"ext",
".",
"micropub",
".",
"AuthResponse",
"."
] | train | https://github.com/kylewm/flask-micropub/blob/897c75848c441758d61c11e36c02ae9c1f786950/flask_micropub.py#L160-L169 |
PMBio/limix-backup | limix/deprecated/archive/util.py | getPosNew | def getPosNew(data):
"""
get Fixed position
"""
pos = data.geno['col_header']['pos'][:]
chrom= data.geno['col_header']['chrom'][:]
n_chroms = chrom.max()
pos_new = []
for chrom_i in range(1,n_chroms+1):
I = chrom==chrom_i
_pos = pos[I]
for i in range(1,_pos.shape[... | python | def getPosNew(data):
"""
get Fixed position
"""
pos = data.geno['col_header']['pos'][:]
chrom= data.geno['col_header']['chrom'][:]
n_chroms = chrom.max()
pos_new = []
for chrom_i in range(1,n_chroms+1):
I = chrom==chrom_i
_pos = pos[I]
for i in range(1,_pos.shape[... | [
"def",
"getPosNew",
"(",
"data",
")",
":",
"pos",
"=",
"data",
".",
"geno",
"[",
"'col_header'",
"]",
"[",
"'pos'",
"]",
"[",
":",
"]",
"chrom",
"=",
"data",
".",
"geno",
"[",
"'col_header'",
"]",
"[",
"'chrom'",
"]",
"[",
":",
"]",
"n_chroms",
"... | get Fixed position | [
"get",
"Fixed",
"position"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/util.py#L37-L53 |
PMBio/limix-backup | limix/deprecated/archive/util.py | getCumPos | def getCumPos(data):
"""
getCumulativePosition
"""
pos = getPosNew(data)
chrom= data.geno['col_header']['chrom'][:]
n_chroms = int(chrom.max())
x = 0
for chrom_i in range(1,n_chroms+1):
I = chrom==chrom_i
pos[I]+=x
x=pos[I].max()
return pos | python | def getCumPos(data):
"""
getCumulativePosition
"""
pos = getPosNew(data)
chrom= data.geno['col_header']['chrom'][:]
n_chroms = int(chrom.max())
x = 0
for chrom_i in range(1,n_chroms+1):
I = chrom==chrom_i
pos[I]+=x
x=pos[I].max()
return pos | [
"def",
"getCumPos",
"(",
"data",
")",
":",
"pos",
"=",
"getPosNew",
"(",
"data",
")",
"chrom",
"=",
"data",
".",
"geno",
"[",
"'col_header'",
"]",
"[",
"'chrom'",
"]",
"[",
":",
"]",
"n_chroms",
"=",
"int",
"(",
"chrom",
".",
"max",
"(",
")",
")"... | getCumulativePosition | [
"getCumulativePosition"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/util.py#L55-L67 |
PMBio/limix-backup | limix/deprecated/archive/util.py | getChromBounds | def getChromBounds(data):
"""
getChromBounds
"""
chrom= data.geno['col_header']['chrom'][:]
posCum = getCumPos(data)
n_chroms = int(chrom.max())
chrom_bounds = []
for chrom_i in range(2,n_chroms+1):
I1 = chrom==chrom_i
I0 = chrom==chrom_i-1
_cb = 0.5*(posCum[I0].m... | python | def getChromBounds(data):
"""
getChromBounds
"""
chrom= data.geno['col_header']['chrom'][:]
posCum = getCumPos(data)
n_chroms = int(chrom.max())
chrom_bounds = []
for chrom_i in range(2,n_chroms+1):
I1 = chrom==chrom_i
I0 = chrom==chrom_i-1
_cb = 0.5*(posCum[I0].m... | [
"def",
"getChromBounds",
"(",
"data",
")",
":",
"chrom",
"=",
"data",
".",
"geno",
"[",
"'col_header'",
"]",
"[",
"'chrom'",
"]",
"[",
":",
"]",
"posCum",
"=",
"getCumPos",
"(",
"data",
")",
"n_chroms",
"=",
"int",
"(",
"chrom",
".",
"max",
"(",
")... | getChromBounds | [
"getChromBounds"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/util.py#L69-L82 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.add_field | def add_field(self, fieldname, fieldspec=whoosh_module_fields.TEXT):
"""Add a field in the index of the model.
Args:
fieldname (Text): This parameters register a new field in specified model.
fieldspec (Name, optional): This option adds various options as were described before.
Returns:
... | python | def add_field(self, fieldname, fieldspec=whoosh_module_fields.TEXT):
"""Add a field in the index of the model.
Args:
fieldname (Text): This parameters register a new field in specified model.
fieldspec (Name, optional): This option adds various options as were described before.
Returns:
... | [
"def",
"add_field",
"(",
"self",
",",
"fieldname",
",",
"fieldspec",
"=",
"whoosh_module_fields",
".",
"TEXT",
")",
":",
"self",
".",
"_whoosh",
".",
"add_field",
"(",
"fieldname",
",",
"fieldspec",
")",
"return",
"self",
".",
"_whoosh",
".",
"schema"
] | Add a field in the index of the model.
Args:
fieldname (Text): This parameters register a new field in specified model.
fieldspec (Name, optional): This option adds various options as were described before.
Returns:
TYPE: The new schema after deleted is returned. | [
"Add",
"a",
"field",
"in",
"the",
"index",
"of",
"the",
"model",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L66-L77 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.delete_field | def delete_field(self, field_name):
"""This function deletes one determined field using the command MODEL.pw.delete_field(FIELD)
Args:
field_name (string): This argument let you delete some field for some model registered in the index.
Returns:
(WhooshSchema): The new schema after deleted ... | python | def delete_field(self, field_name):
"""This function deletes one determined field using the command MODEL.pw.delete_field(FIELD)
Args:
field_name (string): This argument let you delete some field for some model registered in the index.
Returns:
(WhooshSchema): The new schema after deleted ... | [
"def",
"delete_field",
"(",
"self",
",",
"field_name",
")",
":",
"self",
".",
"_whoosh",
".",
"remove_field",
"(",
"field_name",
".",
"strip",
"(",
")",
")",
"return",
"self",
".",
"_whoosh",
".",
"schema"
] | This function deletes one determined field using the command MODEL.pw.delete_field(FIELD)
Args:
field_name (string): This argument let you delete some field for some model registered in the index.
Returns:
(WhooshSchema): The new schema after deleted is returned. | [
"This",
"function",
"deletes",
"one",
"determined",
"field",
"using",
"the",
"command",
"MODEL",
".",
"pw",
".",
"delete_field",
"(",
"FIELD",
")"
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L79-L89 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.delete_documents | def delete_documents(self):
"""Deletes all the documents using the pk associated to them.
"""
pk = str(self._primary_key)
for doc in self._whoosh.searcher().documents():
if pk in doc:
doc_pk = str(doc[pk])
self._whoosh.delete_by_term(pk, doc_pk) | python | def delete_documents(self):
"""Deletes all the documents using the pk associated to them.
"""
pk = str(self._primary_key)
for doc in self._whoosh.searcher().documents():
if pk in doc:
doc_pk = str(doc[pk])
self._whoosh.delete_by_term(pk, doc_pk) | [
"def",
"delete_documents",
"(",
"self",
")",
":",
"pk",
"=",
"str",
"(",
"self",
".",
"_primary_key",
")",
"for",
"doc",
"in",
"self",
".",
"_whoosh",
".",
"searcher",
"(",
")",
".",
"documents",
"(",
")",
":",
"if",
"pk",
"in",
"doc",
":",
"doc_pk... | Deletes all the documents using the pk associated to them. | [
"Deletes",
"all",
"the",
"documents",
"using",
"the",
"pk",
"associated",
"to",
"them",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L91-L98 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.charge_documents | def charge_documents(self):
"""
This method allow you to charge documents you already have
in your database. In this way an Index would be created according to
the model and fields registered.
"""
doc_count = self._whoosh.doc_count()
objs = orm.count(e for e in self._model)... | python | def charge_documents(self):
"""
This method allow you to charge documents you already have
in your database. In this way an Index would be created according to
the model and fields registered.
"""
doc_count = self._whoosh.doc_count()
objs = orm.count(e for e in self._model)... | [
"def",
"charge_documents",
"(",
"self",
")",
":",
"doc_count",
"=",
"self",
".",
"_whoosh",
".",
"doc_count",
"(",
")",
"objs",
"=",
"orm",
".",
"count",
"(",
"e",
"for",
"e",
"in",
"self",
".",
"_model",
")",
"field_names",
"=",
"set",
"(",
"self",
... | This method allow you to charge documents you already have
in your database. In this way an Index would be created according to
the model and fields registered. | [
"This",
"method",
"allow",
"you",
"to",
"charge",
"documents",
"you",
"already",
"have",
"in",
"your",
"database",
".",
"In",
"this",
"way",
"an",
"Index",
"would",
"be",
"created",
"according",
"to",
"the",
"model",
"and",
"fields",
"registered",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L117-L140 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.search | def search(self, search_string, **opt):
"""The core function of the package. These are the arguments we consider.
Args:
search_string (str): This is what you are looking for in your pony database.
Optional Args:
opt: The following opts are available for the search function:
* add_w... | python | def search(self, search_string, **opt):
"""The core function of the package. These are the arguments we consider.
Args:
search_string (str): This is what you are looking for in your pony database.
Optional Args:
opt: The following opts are available for the search function:
* add_w... | [
"def",
"search",
"(",
"self",
",",
"search_string",
",",
"*",
"*",
"opt",
")",
":",
"prepped_string",
"=",
"self",
".",
"prep_search_string",
"(",
"search_string",
",",
"self",
".",
"to_bool",
"(",
"opt",
".",
"get",
"(",
"'add_wildcards'",
",",
"False",
... | The core function of the package. These are the arguments we consider.
Args:
search_string (str): This is what you are looking for in your pony database.
Optional Args:
opt: The following opts are available for the search function:
* add_wildcars(bool): This opt allows you to search no... | [
"The",
"core",
"function",
"of",
"the",
"package",
".",
"These",
"are",
"the",
"arguments",
"we",
"consider",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L149-L248 |
jonaprieto/ponywhoosh | ponywhoosh/index.py | Index.prep_search_string | def prep_search_string(self, search_string, add_wildcards=False):
"""Prepares search string as a proper whoosh search string.
Args:
search_string (str): it prepares the search string and see if
the lenght is correct.
Optional Args:
add_wildcards (bool): It runs a query for inexact quer... | python | def prep_search_string(self, search_string, add_wildcards=False):
"""Prepares search string as a proper whoosh search string.
Args:
search_string (str): it prepares the search string and see if
the lenght is correct.
Optional Args:
add_wildcards (bool): It runs a query for inexact quer... | [
"def",
"prep_search_string",
"(",
"self",
",",
"search_string",
",",
"add_wildcards",
"=",
"False",
")",
":",
"s",
"=",
"search_string",
".",
"strip",
"(",
")",
"try",
":",
"s",
"=",
"str",
"(",
"s",
")",
"except",
":",
"pass",
"s",
"=",
"s",
".",
... | Prepares search string as a proper whoosh search string.
Args:
search_string (str): it prepares the search string and see if
the lenght is correct.
Optional Args:
add_wildcards (bool): It runs a query for inexact queries.
Raises:
ValueError: When the search string does not have ... | [
"Prepares",
"search",
"string",
"as",
"a",
"proper",
"whoosh",
"search",
"string",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/index.py#L250-L277 |
PMBio/limix-backup | limix/mtSet/core/preprocessCore.py | computeCovarianceMatrixPlink | def computeCovarianceMatrixPlink(plink_path,out_dir,bfile,cfile,sim_type='RRM'):
"""
computing the covariance matrix via plink
"""
print("Using plink to create covariance matrix")
cmd = '%s --bfile %s '%(plink_path,bfile)
if sim_type=='RRM':
# using variance standardization
cmd... | python | def computeCovarianceMatrixPlink(plink_path,out_dir,bfile,cfile,sim_type='RRM'):
"""
computing the covariance matrix via plink
"""
print("Using plink to create covariance matrix")
cmd = '%s --bfile %s '%(plink_path,bfile)
if sim_type=='RRM':
# using variance standardization
cmd... | [
"def",
"computeCovarianceMatrixPlink",
"(",
"plink_path",
",",
"out_dir",
",",
"bfile",
",",
"cfile",
",",
"sim_type",
"=",
"'RRM'",
")",
":",
"print",
"(",
"\"Using plink to create covariance matrix\"",
")",
"cmd",
"=",
"'%s --bfile %s '",
"%",
"(",
"plink_path",
... | computing the covariance matrix via plink | [
"computing",
"the",
"covariance",
"matrix",
"via",
"plink"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/core/preprocessCore.py#L23-L54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.