repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
raiden-network/raiden | raiden/utils/filters.py | get_filter_args_for_all_events_from_channel | def get_filter_args_for_all_events_from_channel(
token_network_address: TokenNetworkAddress,
channel_identifier: ChannelID,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> Dict:
""" Return... | python | def get_filter_args_for_all_events_from_channel(
token_network_address: TokenNetworkAddress,
channel_identifier: ChannelID,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> Dict:
""" Return... | [
"def",
"get_filter_args_for_all_events_from_channel",
"(",
"token_network_address",
":",
"TokenNetworkAddress",
",",
"channel_identifier",
":",
"ChannelID",
",",
"contract_manager",
":",
"ContractManager",
",",
"from_block",
":",
"BlockSpecification",
"=",
"GENESIS_BLOCK_NUMBER... | Return the filter params for all events of a given channel. | [
"Return",
"the",
"filter",
"params",
"for",
"all",
"events",
"of",
"a",
"given",
"channel",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/filters.py#L62-L85 | train |
pytorch/tnt | torchnet/meter/confusionmeter.py | ConfusionMeter.add | def add(self, predicted, target):
"""Computes the confusion matrix of K x K size where K is no of classes
Args:
predicted (tensor): Can be an N x K tensor of predicted scores obtained from
the model for N examples and K classes or an N-tensor of
integer value... | python | def add(self, predicted, target):
"""Computes the confusion matrix of K x K size where K is no of classes
Args:
predicted (tensor): Can be an N x K tensor of predicted scores obtained from
the model for N examples and K classes or an N-tensor of
integer value... | [
"def",
"add",
"(",
"self",
",",
"predicted",
",",
"target",
")",
":",
"predicted",
"=",
"predicted",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
"target",
"=",
"target",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
"assert",
"predicted",
".",
... | Computes the confusion matrix of K x K size where K is no of classes
Args:
predicted (tensor): Can be an N x K tensor of predicted scores obtained from
the model for N examples and K classes or an N-tensor of
integer values between 0 and K-1.
target (tens... | [
"Computes",
"the",
"confusion",
"matrix",
"of",
"K",
"x",
"K",
"size",
"where",
"K",
"is",
"no",
"of",
"classes"
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/meter/confusionmeter.py#L29-L75 | train |
pytorch/tnt | torchnet/dataset/shuffledataset.py | ShuffleDataset.resample | def resample(self, seed=None):
"""Resample the dataset.
Args:
seed (int, optional): Seed for resampling. By default no seed is
used.
"""
if seed is not None:
gen = torch.manual_seed(seed)
else:
gen = torch.default_generator
... | python | def resample(self, seed=None):
"""Resample the dataset.
Args:
seed (int, optional): Seed for resampling. By default no seed is
used.
"""
if seed is not None:
gen = torch.manual_seed(seed)
else:
gen = torch.default_generator
... | [
"def",
"resample",
"(",
"self",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"not",
"None",
":",
"gen",
"=",
"torch",
".",
"manual_seed",
"(",
"seed",
")",
"else",
":",
"gen",
"=",
"torch",
".",
"default_generator",
"if",
"self",
".",
"r... | Resample the dataset.
Args:
seed (int, optional): Seed for resampling. By default no seed is
used. | [
"Resample",
"the",
"dataset",
"."
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/dataset/shuffledataset.py#L44-L61 | train |
pytorch/tnt | torchnet/meter/apmeter.py | APMeter.reset | def reset(self):
"""Resets the meter with empty member variables"""
self.scores = torch.FloatTensor(torch.FloatStorage())
self.targets = torch.LongTensor(torch.LongStorage())
self.weights = torch.FloatTensor(torch.FloatStorage()) | python | def reset(self):
"""Resets the meter with empty member variables"""
self.scores = torch.FloatTensor(torch.FloatStorage())
self.targets = torch.LongTensor(torch.LongStorage())
self.weights = torch.FloatTensor(torch.FloatStorage()) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"scores",
"=",
"torch",
".",
"FloatTensor",
"(",
"torch",
".",
"FloatStorage",
"(",
")",
")",
"self",
".",
"targets",
"=",
"torch",
".",
"LongTensor",
"(",
"torch",
".",
"LongStorage",
"(",
")",
")"... | Resets the meter with empty member variables | [
"Resets",
"the",
"meter",
"with",
"empty",
"member",
"variables"
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/meter/apmeter.py#L26-L30 | train |
pytorch/tnt | torchnet/meter/apmeter.py | APMeter.value | def value(self):
"""Returns the model's average precision for each class
Return:
ap (FloatTensor): 1xK tensor, with avg precision for each class k
"""
if self.scores.numel() == 0:
return 0
ap = torch.zeros(self.scores.size(1))
if hasattr(torch, ... | python | def value(self):
"""Returns the model's average precision for each class
Return:
ap (FloatTensor): 1xK tensor, with avg precision for each class k
"""
if self.scores.numel() == 0:
return 0
ap = torch.zeros(self.scores.size(1))
if hasattr(torch, ... | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"scores",
".",
"numel",
"(",
")",
"==",
"0",
":",
"return",
"0",
"ap",
"=",
"torch",
".",
"zeros",
"(",
"self",
".",
"scores",
".",
"size",
"(",
"1",
")",
")",
"if",
"hasattr",
"(",
"t... | Returns the model's average precision for each class
Return:
ap (FloatTensor): 1xK tensor, with avg precision for each class k | [
"Returns",
"the",
"model",
"s",
"average",
"precision",
"for",
"each",
"class"
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/meter/apmeter.py#L100-L142 | train |
pytorch/tnt | torchnet/engine/engine.py | Engine.hook | def hook(self, name, state):
r"""Registers a backward hook.
The hook will be called every time a gradient with respect to the
Tensor is computed. The hook should have the following signature::
hook (grad) -> Tensor or None
The hook should not modify its argument, but it ca... | python | def hook(self, name, state):
r"""Registers a backward hook.
The hook will be called every time a gradient with respect to the
Tensor is computed. The hook should have the following signature::
hook (grad) -> Tensor or None
The hook should not modify its argument, but it ca... | [
"def",
"hook",
"(",
"self",
",",
"name",
",",
"state",
")",
":",
"if",
"name",
"in",
"self",
".",
"hooks",
":",
"self",
".",
"hooks",
"[",
"name",
"]",
"(",
"state",
")"
] | r"""Registers a backward hook.
The hook will be called every time a gradient with respect to the
Tensor is computed. The hook should have the following signature::
hook (grad) -> Tensor or None
The hook should not modify its argument, but it can optionally return
a new gra... | [
"r",
"Registers",
"a",
"backward",
"hook",
"."
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/engine/engine.py#L5-L31 | train |
pytorch/tnt | torchnet/logger/visdomlogger.py | BaseVisdomLogger._viz_prototype | def _viz_prototype(self, vis_fn):
''' Outputs a function which will log the arguments to Visdom in an appropriate way.
Args:
vis_fn: A function, such as self.vis.image
'''
def _viz_logger(*args, **kwargs):
self.win = vis_fn(*args,
... | python | def _viz_prototype(self, vis_fn):
''' Outputs a function which will log the arguments to Visdom in an appropriate way.
Args:
vis_fn: A function, such as self.vis.image
'''
def _viz_logger(*args, **kwargs):
self.win = vis_fn(*args,
... | [
"def",
"_viz_prototype",
"(",
"self",
",",
"vis_fn",
")",
":",
"def",
"_viz_logger",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"win",
"=",
"vis_fn",
"(",
"*",
"args",
",",
"win",
"=",
"self",
".",
"win",
",",
"env",
"=",
... | Outputs a function which will log the arguments to Visdom in an appropriate way.
Args:
vis_fn: A function, such as self.vis.image | [
"Outputs",
"a",
"function",
"which",
"will",
"log",
"the",
"arguments",
"to",
"Visdom",
"in",
"an",
"appropriate",
"way",
"."
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/logger/visdomlogger.py#L36-L48 | train |
pytorch/tnt | torchnet/logger/visdomlogger.py | BaseVisdomLogger.log_state | def log_state(self, state):
""" Gathers the stats from self.trainer.stats and passes them into
self.log, as a list """
results = []
for field_idx, field in enumerate(self.fields):
parent, stat = None, state
for f in field:
parent, stat = stat, ... | python | def log_state(self, state):
""" Gathers the stats from self.trainer.stats and passes them into
self.log, as a list """
results = []
for field_idx, field in enumerate(self.fields):
parent, stat = None, state
for f in field:
parent, stat = stat, ... | [
"def",
"log_state",
"(",
"self",
",",
"state",
")",
":",
"results",
"=",
"[",
"]",
"for",
"field_idx",
",",
"field",
"in",
"enumerate",
"(",
"self",
".",
"fields",
")",
":",
"parent",
",",
"stat",
"=",
"None",
",",
"state",
"for",
"f",
"in",
"field... | Gathers the stats from self.trainer.stats and passes them into
self.log, as a list | [
"Gathers",
"the",
"stats",
"from",
"self",
".",
"trainer",
".",
"stats",
"and",
"passes",
"them",
"into",
"self",
".",
"log",
"as",
"a",
"list"
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/logger/visdomlogger.py#L50-L59 | train |
pytorch/tnt | torchnet/logger/meterlogger.py | MeterLogger.peek_meter | def peek_meter(self):
'''Returns a dict of all meters and their values.'''
result = {}
for key in self.meter.keys():
val = self.meter[key].value()
val = val[0] if isinstance(val, (list, tuple)) else val
result[key] = val
return result | python | def peek_meter(self):
'''Returns a dict of all meters and their values.'''
result = {}
for key in self.meter.keys():
val = self.meter[key].value()
val = val[0] if isinstance(val, (list, tuple)) else val
result[key] = val
return result | [
"def",
"peek_meter",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"meter",
".",
"keys",
"(",
")",
":",
"val",
"=",
"self",
".",
"meter",
"[",
"key",
"]",
".",
"value",
"(",
")",
"val",
"=",
"val",
"[",
"0",... | Returns a dict of all meters and their values. | [
"Returns",
"a",
"dict",
"of",
"all",
"meters",
"and",
"their",
"values",
"."
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/logger/meterlogger.py#L103-L110 | train |
pytorch/tnt | torchnet/utils/resultswriter.py | ResultsWriter.update | def update(self, task_name, result):
''' Update the results file with new information.
Args:
task_name (str): Name of the currently running task. A previously unseen
``task_name`` will create a new entry in both :attr:`tasks`
and :attr:`results`.
... | python | def update(self, task_name, result):
''' Update the results file with new information.
Args:
task_name (str): Name of the currently running task. A previously unseen
``task_name`` will create a new entry in both :attr:`tasks`
and :attr:`results`.
... | [
"def",
"update",
"(",
"self",
",",
"task_name",
",",
"result",
")",
":",
"with",
"open",
"(",
"self",
".",
"filepath",
",",
"'rb'",
")",
"as",
"f",
":",
"existing_results",
"=",
"pickle",
".",
"load",
"(",
"f",
")",
"if",
"task_name",
"not",
"in",
... | Update the results file with new information.
Args:
task_name (str): Name of the currently running task. A previously unseen
``task_name`` will create a new entry in both :attr:`tasks`
and :attr:`results`.
result: This will be appended to the list in :att... | [
"Update",
"the",
"results",
"file",
"with",
"new",
"information",
"."
] | 3ed904b2cbed16d3bab368bb9ca5adc876d3ce69 | https://github.com/pytorch/tnt/blob/3ed904b2cbed16d3bab368bb9ca5adc876d3ce69/torchnet/utils/resultswriter.py#L49-L70 | train |
onelogin/python3-saml | src/onelogin/saml2/xml_utils.py | OneLogin_Saml2_XML.query | def query(dom, query, context=None, tagid=None):
"""
Extracts nodes that match the query from the Element
:param dom: The root of the lxml objet
:type: Element
:param query: Xpath Expresion
:type: string
:param context: Context Node
:type: DOMElement
... | python | def query(dom, query, context=None, tagid=None):
"""
Extracts nodes that match the query from the Element
:param dom: The root of the lxml objet
:type: Element
:param query: Xpath Expresion
:type: string
:param context: Context Node
:type: DOMElement
... | [
"def",
"query",
"(",
"dom",
",",
"query",
",",
"context",
"=",
"None",
",",
"tagid",
"=",
"None",
")",
":",
"if",
"context",
"is",
"None",
":",
"source",
"=",
"dom",
"else",
":",
"source",
"=",
"context",
"if",
"tagid",
"is",
"None",
":",
"return",... | Extracts nodes that match the query from the Element
:param dom: The root of the lxml objet
:type: Element
:param query: Xpath Expresion
:type: string
:param context: Context Node
:type: DOMElement
:param tagid: Tag ID
:type query: String
:ret... | [
"Extracts",
"nodes",
"that",
"match",
"the",
"query",
"from",
"the",
"Element"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/xml_utils.py#L107-L134 | train |
onelogin/python3-saml | src/onelogin/saml2/idp_metadata_parser.py | dict_deep_merge | def dict_deep_merge(a, b, path=None):
"""Deep-merge dictionary `b` into dictionary `a`.
Kudos to http://stackoverflow.com/a/7205107/145400
"""
if path is None:
path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
... | python | def dict_deep_merge(a, b, path=None):
"""Deep-merge dictionary `b` into dictionary `a`.
Kudos to http://stackoverflow.com/a/7205107/145400
"""
if path is None:
path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
... | [
"def",
"dict_deep_merge",
"(",
"a",
",",
"b",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"[",
"]",
"for",
"key",
"in",
"b",
":",
"if",
"key",
"in",
"a",
":",
"if",
"isinstance",
"(",
"a",
"[",
"key",
"]"... | Deep-merge dictionary `b` into dictionary `a`.
Kudos to http://stackoverflow.com/a/7205107/145400 | [
"Deep",
"-",
"merge",
"dictionary",
"b",
"into",
"dictionary",
"a",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/idp_metadata_parser.py#L248-L267 | train |
onelogin/python3-saml | src/onelogin/saml2/settings.py | OneLogin_Saml2_Settings.__load_paths | def __load_paths(self, base_path=None):
"""
Set the paths of the different folders
"""
if base_path is None:
base_path = dirname(dirname(dirname(__file__)))
if not base_path.endswith(sep):
base_path += sep
self.__paths = {
'base': base_... | python | def __load_paths(self, base_path=None):
"""
Set the paths of the different folders
"""
if base_path is None:
base_path = dirname(dirname(dirname(__file__)))
if not base_path.endswith(sep):
base_path += sep
self.__paths = {
'base': base_... | [
"def",
"__load_paths",
"(",
"self",
",",
"base_path",
"=",
"None",
")",
":",
"if",
"base_path",
"is",
"None",
":",
"base_path",
"=",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"__file__",
")",
")",
")",
"if",
"not",
"base_path",
".",
"endswith",
"... | Set the paths of the different folders | [
"Set",
"the",
"paths",
"of",
"the",
"different",
"folders"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L130-L143 | train |
onelogin/python3-saml | src/onelogin/saml2/settings.py | OneLogin_Saml2_Settings.__update_paths | def __update_paths(self, settings):
"""
Set custom paths if necessary
"""
if not isinstance(settings, dict):
return
if 'custom_base_path' in settings:
base_path = settings['custom_base_path']
base_path = join(dirname(__file__), base_path)
... | python | def __update_paths(self, settings):
"""
Set custom paths if necessary
"""
if not isinstance(settings, dict):
return
if 'custom_base_path' in settings:
base_path = settings['custom_base_path']
base_path = join(dirname(__file__), base_path)
... | [
"def",
"__update_paths",
"(",
"self",
",",
"settings",
")",
":",
"if",
"not",
"isinstance",
"(",
"settings",
",",
"dict",
")",
":",
"return",
"if",
"'custom_base_path'",
"in",
"settings",
":",
"base_path",
"=",
"settings",
"[",
"'custom_base_path'",
"]",
"ba... | Set custom paths if necessary | [
"Set",
"custom",
"paths",
"if",
"necessary"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L145-L155 | train |
onelogin/python3-saml | src/onelogin/saml2/settings.py | OneLogin_Saml2_Settings.__load_settings_from_dict | def __load_settings_from_dict(self, settings):
"""
Loads settings info from a settings Dict
:param settings: SAML Toolkit Settings
:type settings: dict
:returns: True if the settings info is valid
:rtype: boolean
"""
errors = self.check_settings(settings... | python | def __load_settings_from_dict(self, settings):
"""
Loads settings info from a settings Dict
:param settings: SAML Toolkit Settings
:type settings: dict
:returns: True if the settings info is valid
:rtype: boolean
"""
errors = self.check_settings(settings... | [
"def",
"__load_settings_from_dict",
"(",
"self",
",",
"settings",
")",
":",
"errors",
"=",
"self",
".",
"check_settings",
"(",
"settings",
")",
"if",
"len",
"(",
"errors",
")",
"==",
"0",
":",
"self",
".",
"__errors",
"=",
"[",
"]",
"self",
".",
"__sp"... | Loads settings info from a settings Dict
:param settings: SAML Toolkit Settings
:type settings: dict
:returns: True if the settings info is valid
:rtype: boolean | [
"Loads",
"settings",
"info",
"from",
"a",
"settings",
"Dict"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L202-L227 | train |
onelogin/python3-saml | src/onelogin/saml2/settings.py | OneLogin_Saml2_Settings.check_settings | def check_settings(self, settings):
"""
Checks the settings info.
:param settings: Dict with settings data
:type settings: dict
:returns: Errors found on the settings data
:rtype: list
"""
assert isinstance(settings, dict)
errors = []
if... | python | def check_settings(self, settings):
"""
Checks the settings info.
:param settings: Dict with settings data
:type settings: dict
:returns: Errors found on the settings data
:rtype: list
"""
assert isinstance(settings, dict)
errors = []
if... | [
"def",
"check_settings",
"(",
"self",
",",
"settings",
")",
":",
"assert",
"isinstance",
"(",
"settings",
",",
"dict",
")",
"errors",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"settings",
",",
"dict",
")",
"or",
"len",
"(",
"settings",
")",
"==",
... | Checks the settings info.
:param settings: Dict with settings data
:type settings: dict
:returns: Errors found on the settings data
:rtype: list | [
"Checks",
"the",
"settings",
"info",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L315-L336 | train |
onelogin/python3-saml | src/onelogin/saml2/settings.py | OneLogin_Saml2_Settings.format_idp_cert_multi | def format_idp_cert_multi(self):
"""
Formats the Multple IdP certs.
"""
if 'x509certMulti' in self.__idp:
if 'signing' in self.__idp['x509certMulti']:
for idx in range(len(self.__idp['x509certMulti']['signing'])):
self.__idp['x509certMulti'... | python | def format_idp_cert_multi(self):
"""
Formats the Multple IdP certs.
"""
if 'x509certMulti' in self.__idp:
if 'signing' in self.__idp['x509certMulti']:
for idx in range(len(self.__idp['x509certMulti']['signing'])):
self.__idp['x509certMulti'... | [
"def",
"format_idp_cert_multi",
"(",
"self",
")",
":",
"if",
"'x509certMulti'",
"in",
"self",
".",
"__idp",
":",
"if",
"'signing'",
"in",
"self",
".",
"__idp",
"[",
"'x509certMulti'",
"]",
":",
"for",
"idx",
"in",
"range",
"(",
"len",
"(",
"self",
".",
... | Formats the Multple IdP certs. | [
"Formats",
"the",
"Multple",
"IdP",
"certs",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L730-L741 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | return_false_on_exception | def return_false_on_exception(func):
"""
Decorator. When applied to a function, it will, by default, suppress any exceptions
raised by that function and return False. It may be overridden by passing a
"raise_exceptions" keyword argument when calling the wrapped function.
"""
@wraps(func)
def... | python | def return_false_on_exception(func):
"""
Decorator. When applied to a function, it will, by default, suppress any exceptions
raised by that function and return False. It may be overridden by passing a
"raise_exceptions" keyword argument when calling the wrapped function.
"""
@wraps(func)
def... | [
"def",
"return_false_on_exception",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"exceptfalse",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"pop",
"(",
"'raise_exceptions'",
",",
"False",
")",
":",
... | Decorator. When applied to a function, it will, by default, suppress any exceptions
raised by that function and return False. It may be overridden by passing a
"raise_exceptions" keyword argument when calling the wrapped function. | [
"Decorator",
".",
"When",
"applied",
"to",
"a",
"function",
"it",
"will",
"by",
"default",
"suppress",
"any",
"exceptions",
"raised",
"by",
"that",
"function",
"and",
"return",
"False",
".",
"It",
"may",
"be",
"overridden",
"by",
"passing",
"a",
"raise_excep... | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L39-L54 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.is_https | def is_https(request_data):
"""
Checks if https or http.
:param request_data: The request as a dict
:type: dict
:return: False if https is not active
:rtype: boolean
"""
is_https = 'https' in request_data and request_data['https'] != 'off'
is_htt... | python | def is_https(request_data):
"""
Checks if https or http.
:param request_data: The request as a dict
:type: dict
:return: False if https is not active
:rtype: boolean
"""
is_https = 'https' in request_data and request_data['https'] != 'off'
is_htt... | [
"def",
"is_https",
"(",
"request_data",
")",
":",
"is_https",
"=",
"'https'",
"in",
"request_data",
"and",
"request_data",
"[",
"'https'",
"]",
"!=",
"'off'",
"is_https",
"=",
"is_https",
"or",
"(",
"'server_port'",
"in",
"request_data",
"and",
"str",
"(",
"... | Checks if https or http.
:param request_data: The request as a dict
:type: dict
:return: False if https is not active
:rtype: boolean | [
"Checks",
"if",
"https",
"or",
"http",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L300-L312 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.get_self_url_no_query | def get_self_url_no_query(request_data):
"""
Returns the URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string
"""
self_url_host = OneLogin_Saml2_Util... | python | def get_self_url_no_query(request_data):
"""
Returns the URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string
"""
self_url_host = OneLogin_Saml2_Util... | [
"def",
"get_self_url_no_query",
"(",
"request_data",
")",
":",
"self_url_host",
"=",
"OneLogin_Saml2_Utils",
".",
"get_self_url_host",
"(",
"request_data",
")",
"script_name",
"=",
"request_data",
"[",
"'script_name'",
"]",
"if",
"script_name",
":",
"if",
"script_name... | Returns the URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string | [
"Returns",
"the",
"URL",
"of",
"the",
"current",
"host",
"+",
"current",
"view",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L315-L336 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.get_self_routed_url_no_query | def get_self_routed_url_no_query(request_data):
"""
Returns the routed URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string
"""
self_url_host = OneLo... | python | def get_self_routed_url_no_query(request_data):
"""
Returns the routed URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string
"""
self_url_host = OneLo... | [
"def",
"get_self_routed_url_no_query",
"(",
"request_data",
")",
":",
"self_url_host",
"=",
"OneLogin_Saml2_Utils",
".",
"get_self_url_host",
"(",
"request_data",
")",
"route",
"=",
"''",
"if",
"'request_uri'",
"in",
"request_data",
"and",
"request_data",
"[",
"'reque... | Returns the routed URL of the current host + current view.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view
:rtype: string | [
"Returns",
"the",
"routed",
"URL",
"of",
"the",
"current",
"host",
"+",
"current",
"view",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L339-L356 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.get_self_url | def get_self_url(request_data):
"""
Returns the URL of the current host + current view + query.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view + query
:rtype: string
"""
self_url_host = OneLogin_Sam... | python | def get_self_url(request_data):
"""
Returns the URL of the current host + current view + query.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view + query
:rtype: string
"""
self_url_host = OneLogin_Sam... | [
"def",
"get_self_url",
"(",
"request_data",
")",
":",
"self_url_host",
"=",
"OneLogin_Saml2_Utils",
".",
"get_self_url_host",
"(",
"request_data",
")",
"request_uri",
"=",
"''",
"if",
"'request_uri'",
"in",
"request_data",
":",
"request_uri",
"=",
"request_data",
"[... | Returns the URL of the current host + current view + query.
:param request_data: The request as a dict
:type: dict
:return: The url of current host + current view + query
:rtype: string | [
"Returns",
"the",
"URL",
"of",
"the",
"current",
"host",
"+",
"current",
"view",
"+",
"query",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L359-L379 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.get_expire_time | def get_expire_time(cache_duration=None, valid_until=None):
"""
Compares 2 dates and returns the earliest.
:param cache_duration: The duration, as a string.
:type: string
:param valid_until: The valid until date, as a string or as a timestamp
:type: string
:ret... | python | def get_expire_time(cache_duration=None, valid_until=None):
"""
Compares 2 dates and returns the earliest.
:param cache_duration: The duration, as a string.
:type: string
:param valid_until: The valid until date, as a string or as a timestamp
:type: string
:ret... | [
"def",
"get_expire_time",
"(",
"cache_duration",
"=",
"None",
",",
"valid_until",
"=",
"None",
")",
":",
"expire_time",
"=",
"None",
"if",
"cache_duration",
"is",
"not",
"None",
":",
"expire_time",
"=",
"OneLogin_Saml2_Utils",
".",
"parse_duration",
"(",
"cache_... | Compares 2 dates and returns the earliest.
:param cache_duration: The duration, as a string.
:type: string
:param valid_until: The valid until date, as a string or as a timestamp
:type: string
:return: The expiration time.
:rtype: int | [
"Compares",
"2",
"dates",
"and",
"returns",
"the",
"earliest",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L458-L486 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.calculate_x509_fingerprint | def calculate_x509_fingerprint(x509_cert, alg='sha1'):
"""
Calculates the fingerprint of a formatted x509cert.
:param x509_cert: x509 cert formatted
:type: string
:param alg: The algorithm to build the fingerprint
:type: string
:returns: fingerprint
:rt... | python | def calculate_x509_fingerprint(x509_cert, alg='sha1'):
"""
Calculates the fingerprint of a formatted x509cert.
:param x509_cert: x509 cert formatted
:type: string
:param alg: The algorithm to build the fingerprint
:type: string
:returns: fingerprint
:rt... | [
"def",
"calculate_x509_fingerprint",
"(",
"x509_cert",
",",
"alg",
"=",
"'sha1'",
")",
":",
"assert",
"isinstance",
"(",
"x509_cert",
",",
"compat",
".",
"str_type",
")",
"lines",
"=",
"x509_cert",
".",
"split",
"(",
"'\\n'",
")",
"data",
"=",
"''",
"inDat... | Calculates the fingerprint of a formatted x509cert.
:param x509_cert: x509 cert formatted
:type: string
:param alg: The algorithm to build the fingerprint
:type: string
:returns: fingerprint
:rtype: string | [
"Calculates",
"the",
"fingerprint",
"of",
"a",
"formatted",
"x509cert",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L498-L547 | train |
onelogin/python3-saml | src/onelogin/saml2/utils.py | OneLogin_Saml2_Utils.sign_binary | def sign_binary(msg, key, algorithm=xmlsec.Transform.RSA_SHA1, debug=False):
"""
Sign binary message
:param msg: The element we should validate
:type: bytes
:param key: The private key
:type: string
:param debug: Activate the xmlsec debug
:type: bool
... | python | def sign_binary(msg, key, algorithm=xmlsec.Transform.RSA_SHA1, debug=False):
"""
Sign binary message
:param msg: The element we should validate
:type: bytes
:param key: The private key
:type: string
:param debug: Activate the xmlsec debug
:type: bool
... | [
"def",
"sign_binary",
"(",
"msg",
",",
"key",
",",
"algorithm",
"=",
"xmlsec",
".",
"Transform",
".",
"RSA_SHA1",
",",
"debug",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"msg",
",",
"str",
")",
":",
"msg",
"=",
"msg",
".",
"encode",
"(",
"'u... | Sign binary message
:param msg: The element we should validate
:type: bytes
:param key: The private key
:type: string
:param debug: Activate the xmlsec debug
:type: bool
:return signed message
:rtype str | [
"Sign",
"binary",
"message"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/utils.py#L986-L1009 | train |
onelogin/python3-saml | src/onelogin/saml2/auth.py | OneLogin_Saml2_Auth.process_response | def process_response(self, request_id=None):
"""
Process the SAML Response sent by the IdP.
:param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP.
:type request_id: string
:raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when... | python | def process_response(self, request_id=None):
"""
Process the SAML Response sent by the IdP.
:param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP.
:type request_id: string
:raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when... | [
"def",
"process_response",
"(",
"self",
",",
"request_id",
"=",
"None",
")",
":",
"self",
".",
"__errors",
"=",
"[",
"]",
"self",
".",
"__error_reason",
"=",
"None",
"if",
"'post_data'",
"in",
"self",
".",
"__request_data",
"and",
"'SAMLResponse'",
"in",
"... | Process the SAML Response sent by the IdP.
:param request_id: Is an optional argument. Is the ID of the AuthNRequest sent by this SP to the IdP.
:type request_id: string
:raises: OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND, when a POST with a SAMLResponse is not found | [
"Process",
"the",
"SAML",
"Response",
"sent",
"by",
"the",
"IdP",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/auth.py#L89-L127 | train |
onelogin/python3-saml | src/onelogin/saml2/auth.py | OneLogin_Saml2_Auth.redirect_to | def redirect_to(self, url=None, parameters={}):
"""
Redirects the user to the URL passed by parameter or to the URL that we defined in our SSO Request.
:param url: The target URL to redirect the user
:type url: string
:param parameters: Extra parameters to be passed as part of t... | python | def redirect_to(self, url=None, parameters={}):
"""
Redirects the user to the URL passed by parameter or to the URL that we defined in our SSO Request.
:param url: The target URL to redirect the user
:type url: string
:param parameters: Extra parameters to be passed as part of t... | [
"def",
"redirect_to",
"(",
"self",
",",
"url",
"=",
"None",
",",
"parameters",
"=",
"{",
"}",
")",
":",
"if",
"url",
"is",
"None",
"and",
"'RelayState'",
"in",
"self",
".",
"__request_data",
"[",
"'get_data'",
"]",
":",
"url",
"=",
"self",
".",
"__re... | Redirects the user to the URL passed by parameter or to the URL that we defined in our SSO Request.
:param url: The target URL to redirect the user
:type url: string
:param parameters: Extra parameters to be passed as part of the URL
:type parameters: dict
:returns: Redirection... | [
"Redirects",
"the",
"user",
"to",
"the",
"URL",
"passed",
"by",
"parameter",
"or",
"to",
"the",
"URL",
"that",
"we",
"defined",
"in",
"our",
"SSO",
"Request",
"."
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/auth.py#L197-L210 | train |
onelogin/python3-saml | src/onelogin/saml2/auth.py | OneLogin_Saml2_Auth.__build_sign_query | def __build_sign_query(saml_data, relay_state, algorithm, saml_type, lowercase_urlencoding=False):
"""
Build sign query
:param saml_data: The Request data
:type saml_data: str
:param relay_state: The Relay State
:type relay_state: str
:param algorithm: The Sign... | python | def __build_sign_query(saml_data, relay_state, algorithm, saml_type, lowercase_urlencoding=False):
"""
Build sign query
:param saml_data: The Request data
:type saml_data: str
:param relay_state: The Relay State
:type relay_state: str
:param algorithm: The Sign... | [
"def",
"__build_sign_query",
"(",
"saml_data",
",",
"relay_state",
",",
"algorithm",
",",
"saml_type",
",",
"lowercase_urlencoding",
"=",
"False",
")",
":",
"sign_data",
"=",
"[",
"'%s=%s'",
"%",
"(",
"saml_type",
",",
"OneLogin_Saml2_Utils",
".",
"escape_url",
... | Build sign query
:param saml_data: The Request data
:type saml_data: str
:param relay_state: The Relay State
:type relay_state: str
:param algorithm: The Signature Algorithm
:type algorithm: str
:param saml_type: The target URL the user should be redirected to... | [
"Build",
"sign",
"query"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/auth.py#L469-L492 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.check_status | def check_status(self):
"""
Check if the status of the response is success or not
:raises: Exception. If the status is not success
"""
status = OneLogin_Saml2_Utils.get_status(self.document)
code = status.get('code', None)
if code and code != OneLogin_Saml2_Const... | python | def check_status(self):
"""
Check if the status of the response is success or not
:raises: Exception. If the status is not success
"""
status = OneLogin_Saml2_Utils.get_status(self.document)
code = status.get('code', None)
if code and code != OneLogin_Saml2_Const... | [
"def",
"check_status",
"(",
"self",
")",
":",
"status",
"=",
"OneLogin_Saml2_Utils",
".",
"get_status",
"(",
"self",
".",
"document",
")",
"code",
"=",
"status",
".",
"get",
"(",
"'code'",
",",
"None",
")",
"if",
"code",
"and",
"code",
"!=",
"OneLogin_Sa... | Check if the status of the response is success or not
:raises: Exception. If the status is not success | [
"Check",
"if",
"the",
"status",
"of",
"the",
"response",
"is",
"success",
"or",
"not"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L330-L348 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_authn_contexts | def get_authn_contexts(self):
"""
Gets the authentication contexts
:returns: The authentication classes for the SAML Response
:rtype: list
"""
authn_context_nodes = self.__query_assertion('/saml:AuthnStatement/saml:AuthnContext/saml:AuthnContextClassRef')
return ... | python | def get_authn_contexts(self):
"""
Gets the authentication contexts
:returns: The authentication classes for the SAML Response
:rtype: list
"""
authn_context_nodes = self.__query_assertion('/saml:AuthnStatement/saml:AuthnContext/saml:AuthnContextClassRef')
return ... | [
"def",
"get_authn_contexts",
"(",
"self",
")",
":",
"authn_context_nodes",
"=",
"self",
".",
"__query_assertion",
"(",
"'/saml:AuthnStatement/saml:AuthnContext/saml:AuthnContextClassRef'",
")",
"return",
"[",
"OneLogin_Saml2_XML",
".",
"element_text",
"(",
"node",
")",
"f... | Gets the authentication contexts
:returns: The authentication classes for the SAML Response
:rtype: list | [
"Gets",
"the",
"authentication",
"contexts"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L380-L388 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_nameid | def get_nameid(self):
"""
Gets the NameID provided by the SAML Response from the IdP
:returns: NameID (value)
:rtype: string|None
"""
nameid_value = None
nameid_data = self.get_nameid_data()
if nameid_data and 'Value' in nameid_data.keys():
na... | python | def get_nameid(self):
"""
Gets the NameID provided by the SAML Response from the IdP
:returns: NameID (value)
:rtype: string|None
"""
nameid_value = None
nameid_data = self.get_nameid_data()
if nameid_data and 'Value' in nameid_data.keys():
na... | [
"def",
"get_nameid",
"(",
"self",
")",
":",
"nameid_value",
"=",
"None",
"nameid_data",
"=",
"self",
".",
"get_nameid_data",
"(",
")",
"if",
"nameid_data",
"and",
"'Value'",
"in",
"nameid_data",
".",
"keys",
"(",
")",
":",
"nameid_value",
"=",
"nameid_data",... | Gets the NameID provided by the SAML Response from the IdP
:returns: NameID (value)
:rtype: string|None | [
"Gets",
"the",
"NameID",
"provided",
"by",
"the",
"SAML",
"Response",
"from",
"the",
"IdP"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L475-L486 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_nameid_format | def get_nameid_format(self):
"""
Gets the NameID Format provided by the SAML Response from the IdP
:returns: NameID Format
:rtype: string|None
"""
nameid_format = None
nameid_data = self.get_nameid_data()
if nameid_data and 'Format' in nameid_data.keys():... | python | def get_nameid_format(self):
"""
Gets the NameID Format provided by the SAML Response from the IdP
:returns: NameID Format
:rtype: string|None
"""
nameid_format = None
nameid_data = self.get_nameid_data()
if nameid_data and 'Format' in nameid_data.keys():... | [
"def",
"get_nameid_format",
"(",
"self",
")",
":",
"nameid_format",
"=",
"None",
"nameid_data",
"=",
"self",
".",
"get_nameid_data",
"(",
")",
"if",
"nameid_data",
"and",
"'Format'",
"in",
"nameid_data",
".",
"keys",
"(",
")",
":",
"nameid_format",
"=",
"nam... | Gets the NameID Format provided by the SAML Response from the IdP
:returns: NameID Format
:rtype: string|None | [
"Gets",
"the",
"NameID",
"Format",
"provided",
"by",
"the",
"SAML",
"Response",
"from",
"the",
"IdP"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L488-L499 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_session_not_on_or_after | def get_session_not_on_or_after(self):
"""
Gets the SessionNotOnOrAfter from the AuthnStatement
Could be used to set the local session expiration
:returns: The SessionNotOnOrAfter value
:rtype: time|None
"""
not_on_or_after = None
authn_statement_nodes = ... | python | def get_session_not_on_or_after(self):
"""
Gets the SessionNotOnOrAfter from the AuthnStatement
Could be used to set the local session expiration
:returns: The SessionNotOnOrAfter value
:rtype: time|None
"""
not_on_or_after = None
authn_statement_nodes = ... | [
"def",
"get_session_not_on_or_after",
"(",
"self",
")",
":",
"not_on_or_after",
"=",
"None",
"authn_statement_nodes",
"=",
"self",
".",
"__query_assertion",
"(",
"'/saml:AuthnStatement[@SessionNotOnOrAfter]'",
")",
"if",
"authn_statement_nodes",
":",
"not_on_or_after",
"=",... | Gets the SessionNotOnOrAfter from the AuthnStatement
Could be used to set the local session expiration
:returns: The SessionNotOnOrAfter value
:rtype: time|None | [
"Gets",
"the",
"SessionNotOnOrAfter",
"from",
"the",
"AuthnStatement",
"Could",
"be",
"used",
"to",
"set",
"the",
"local",
"session",
"expiration"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L501-L513 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_session_index | def get_session_index(self):
"""
Gets the SessionIndex from the AuthnStatement
Could be used to be stored in the local session in order
to be used in a future Logout Request that the SP could
send to the SP, to set what specific session must be deleted
:returns: The Sess... | python | def get_session_index(self):
"""
Gets the SessionIndex from the AuthnStatement
Could be used to be stored in the local session in order
to be used in a future Logout Request that the SP could
send to the SP, to set what specific session must be deleted
:returns: The Sess... | [
"def",
"get_session_index",
"(",
"self",
")",
":",
"session_index",
"=",
"None",
"authn_statement_nodes",
"=",
"self",
".",
"__query_assertion",
"(",
"'/saml:AuthnStatement[@SessionIndex]'",
")",
"if",
"authn_statement_nodes",
":",
"session_index",
"=",
"authn_statement_n... | Gets the SessionIndex from the AuthnStatement
Could be used to be stored in the local session in order
to be used in a future Logout Request that the SP could
send to the SP, to set what specific session must be deleted
:returns: The SessionIndex value
:rtype: string|None | [
"Gets",
"the",
"SessionIndex",
"from",
"the",
"AuthnStatement",
"Could",
"be",
"used",
"to",
"be",
"stored",
"in",
"the",
"local",
"session",
"in",
"order",
"to",
"be",
"used",
"in",
"a",
"future",
"Logout",
"Request",
"that",
"the",
"SP",
"could",
"send",... | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L521-L535 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.get_attributes | def get_attributes(self):
"""
Gets the Attributes from the AttributeStatement element.
EncryptedAttributes are not supported
"""
attributes = {}
attribute_nodes = self.__query_assertion('/saml:AttributeStatement/saml:Attribute')
for attribute_node in attribute_nod... | python | def get_attributes(self):
"""
Gets the Attributes from the AttributeStatement element.
EncryptedAttributes are not supported
"""
attributes = {}
attribute_nodes = self.__query_assertion('/saml:AttributeStatement/saml:Attribute')
for attribute_node in attribute_nod... | [
"def",
"get_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"}",
"attribute_nodes",
"=",
"self",
".",
"__query_assertion",
"(",
"'/saml:AttributeStatement/saml:Attribute'",
")",
"for",
"attribute_node",
"in",
"attribute_nodes",
":",
"attr_name",
"=",
"at... | Gets the Attributes from the AttributeStatement element.
EncryptedAttributes are not supported | [
"Gets",
"the",
"Attributes",
"from",
"the",
"AttributeStatement",
"element",
".",
"EncryptedAttributes",
"are",
"not",
"supported"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L537-L570 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.validate_timestamps | def validate_timestamps(self):
"""
Verifies that the document is valid according to Conditions Element
:returns: True if the condition is valid, False otherwise
:rtype: bool
"""
conditions_nodes = self.__query_assertion('/saml:Conditions')
for conditions_node in... | python | def validate_timestamps(self):
"""
Verifies that the document is valid according to Conditions Element
:returns: True if the condition is valid, False otherwise
:rtype: bool
"""
conditions_nodes = self.__query_assertion('/saml:Conditions')
for conditions_node in... | [
"def",
"validate_timestamps",
"(",
"self",
")",
":",
"conditions_nodes",
"=",
"self",
".",
"__query_assertion",
"(",
"'/saml:Conditions'",
")",
"for",
"conditions_node",
"in",
"conditions_nodes",
":",
"nb_attr",
"=",
"conditions_node",
".",
"get",
"(",
"'NotBefore'"... | Verifies that the document is valid according to Conditions Element
:returns: True if the condition is valid, False otherwise
:rtype: bool | [
"Verifies",
"that",
"the",
"document",
"is",
"valid",
"according",
"to",
"Conditions",
"Element"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L701-L723 | train |
onelogin/python3-saml | src/onelogin/saml2/response.py | OneLogin_Saml2_Response.__query_assertion | def __query_assertion(self, xpath_expr):
"""
Extracts nodes that match the query from the Assertion
:param xpath_expr: Xpath Expresion
:type xpath_expr: String
:returns: The queried nodes
:rtype: list
"""
assertion_expr = '/saml:Assertion'
signa... | python | def __query_assertion(self, xpath_expr):
"""
Extracts nodes that match the query from the Assertion
:param xpath_expr: Xpath Expresion
:type xpath_expr: String
:returns: The queried nodes
:rtype: list
"""
assertion_expr = '/saml:Assertion'
signa... | [
"def",
"__query_assertion",
"(",
"self",
",",
"xpath_expr",
")",
":",
"assertion_expr",
"=",
"'/saml:Assertion'",
"signature_expr",
"=",
"'/ds:Signature/ds:SignedInfo/ds:Reference'",
"signed_assertion_query",
"=",
"'/samlp:Response'",
"+",
"assertion_expr",
"+",
"signature_ex... | Extracts nodes that match the query from the Assertion
:param xpath_expr: Xpath Expresion
:type xpath_expr: String
:returns: The queried nodes
:rtype: list | [
"Extracts",
"nodes",
"that",
"match",
"the",
"query",
"from",
"the",
"Assertion"
] | 064b7275fba1e5f39a9116ba1cdcc5d01fc34daa | https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L725-L758 | train |
automl/HpBandSter | hpbandster/optimizers/kde/mvkde.py | MultivariateKDE.pdf | def pdf(self, x_test):
"""
Computes the probability density function at all x_test
"""
N,D = self.data.shape
x_test = np.asfortranarray(x_test)
x_test = x_test.reshape([-1, D])
pdfs = self._individual_pdfs(x_test)
#import pdb; pdb.set_trace()
# combine values based on fully_dimensional!
if self.... | python | def pdf(self, x_test):
"""
Computes the probability density function at all x_test
"""
N,D = self.data.shape
x_test = np.asfortranarray(x_test)
x_test = x_test.reshape([-1, D])
pdfs = self._individual_pdfs(x_test)
#import pdb; pdb.set_trace()
# combine values based on fully_dimensional!
if self.... | [
"def",
"pdf",
"(",
"self",
",",
"x_test",
")",
":",
"N",
",",
"D",
"=",
"self",
".",
"data",
".",
"shape",
"x_test",
"=",
"np",
".",
"asfortranarray",
"(",
"x_test",
")",
"x_test",
"=",
"x_test",
".",
"reshape",
"(",
"[",
"-",
"1",
",",
"D",
"]... | Computes the probability density function at all x_test | [
"Computes",
"the",
"probability",
"density",
"function",
"at",
"all",
"x_test"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/kde/mvkde.py#L172-L189 | train |
automl/HpBandSter | hpbandster/examples/plot_example_7_interactive_plot.py | realtime_learning_curves | def realtime_learning_curves(runs):
"""
example how to extract a different kind of learning curve.
The x values are now the time the runs finished, not the budget anymore.
We no longer plot the validation loss on the y axis, but now the test accuracy.
This is just to show how to get different information into ... | python | def realtime_learning_curves(runs):
"""
example how to extract a different kind of learning curve.
The x values are now the time the runs finished, not the budget anymore.
We no longer plot the validation loss on the y axis, but now the test accuracy.
This is just to show how to get different information into ... | [
"def",
"realtime_learning_curves",
"(",
"runs",
")",
":",
"sr",
"=",
"sorted",
"(",
"runs",
",",
"key",
"=",
"lambda",
"r",
":",
"r",
".",
"budget",
")",
"lc",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"t",
":",
"not",
"t",
"[",
"1",
"]",
"is",
... | example how to extract a different kind of learning curve.
The x values are now the time the runs finished, not the budget anymore.
We no longer plot the validation loss on the y axis, but now the test accuracy.
This is just to show how to get different information into the interactive plot. | [
"example",
"how",
"to",
"extract",
"a",
"different",
"kind",
"of",
"learning",
"curve",
".",
"The",
"x",
"values",
"are",
"now",
"the",
"time",
"the",
"runs",
"finished",
"not",
"the",
"budget",
"anymore",
".",
"We",
"no",
"longer",
"plot",
"the",
"valid... | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/examples/plot_example_7_interactive_plot.py#L39-L51 | train |
automl/HpBandSter | hpbandster/core/worker.py | Worker.load_nameserver_credentials | def load_nameserver_credentials(self, working_directory, num_tries=60, interval=1):
"""
loads the nameserver credentials in cases where master and workers share a filesystem
Parameters
----------
working_directory: str
the working directory for the HPB run (see master)
num_tries: int
number of at... | python | def load_nameserver_credentials(self, working_directory, num_tries=60, interval=1):
"""
loads the nameserver credentials in cases where master and workers share a filesystem
Parameters
----------
working_directory: str
the working directory for the HPB run (see master)
num_tries: int
number of at... | [
"def",
"load_nameserver_credentials",
"(",
"self",
",",
"working_directory",
",",
"num_tries",
"=",
"60",
",",
"interval",
"=",
"1",
")",
":",
"fn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_directory",
",",
"'HPB_run_%s_pyro.pkl'",
"%",
"self",
"."... | loads the nameserver credentials in cases where master and workers share a filesystem
Parameters
----------
working_directory: str
the working directory for the HPB run (see master)
num_tries: int
number of attempts to find the file (default 60)
interval: float
waiting period between the attem... | [
"loads",
"the",
"nameserver",
"credentials",
"in",
"cases",
"where",
"master",
"and",
"workers",
"share",
"a",
"filesystem"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/worker.py#L70-L95 | train |
automl/HpBandSter | hpbandster/core/master.py | Master.wait_for_workers | def wait_for_workers(self, min_n_workers=1):
"""
helper function to hold execution until some workers are active
Parameters
----------
min_n_workers: int
minimum number of workers present before the run starts
"""
self.logger.debug('wait_for_workers trying to get the condition')
with self.thread... | python | def wait_for_workers(self, min_n_workers=1):
"""
helper function to hold execution until some workers are active
Parameters
----------
min_n_workers: int
minimum number of workers present before the run starts
"""
self.logger.debug('wait_for_workers trying to get the condition')
with self.thread... | [
"def",
"wait_for_workers",
"(",
"self",
",",
"min_n_workers",
"=",
"1",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'wait_for_workers trying to get the condition'",
")",
"with",
"self",
".",
"thread_cond",
":",
"while",
"(",
"self",
".",
"dispatcher",
... | helper function to hold execution until some workers are active
Parameters
----------
min_n_workers: int
minimum number of workers present before the run starts | [
"helper",
"function",
"to",
"hold",
"execution",
"until",
"some",
"workers",
"are",
"active"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/master.py#L135-L152 | train |
automl/HpBandSter | hpbandster/core/master.py | Master.run | def run(self, n_iterations=1, min_n_workers=1, iteration_kwargs = {},):
"""
run n_iterations of SuccessiveHalving
Parameters
----------
n_iterations: int
number of iterations to be performed in this run
min_n_workers: int
minimum number of workers before starting the run
"""
self.wait_for_worke... | python | def run(self, n_iterations=1, min_n_workers=1, iteration_kwargs = {},):
"""
run n_iterations of SuccessiveHalving
Parameters
----------
n_iterations: int
number of iterations to be performed in this run
min_n_workers: int
minimum number of workers before starting the run
"""
self.wait_for_worke... | [
"def",
"run",
"(",
"self",
",",
"n_iterations",
"=",
"1",
",",
"min_n_workers",
"=",
"1",
",",
"iteration_kwargs",
"=",
"{",
"}",
",",
")",
":",
"self",
".",
"wait_for_workers",
"(",
"min_n_workers",
")",
"iteration_kwargs",
".",
"update",
"(",
"{",
"'re... | run n_iterations of SuccessiveHalving
Parameters
----------
n_iterations: int
number of iterations to be performed in this run
min_n_workers: int
minimum number of workers before starting the run | [
"run",
"n_iterations",
"of",
"SuccessiveHalving"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/master.py#L176-L233 | train |
automl/HpBandSter | hpbandster/core/master.py | Master.job_callback | def job_callback(self, job):
"""
method to be called when a job has finished
this will do some book keeping and call the user defined
new_result_callback if one was specified
"""
self.logger.debug('job_callback for %s started'%str(job.id))
with self.thread_cond:
self.logger.debug('job_callback for %s ... | python | def job_callback(self, job):
"""
method to be called when a job has finished
this will do some book keeping and call the user defined
new_result_callback if one was specified
"""
self.logger.debug('job_callback for %s started'%str(job.id))
with self.thread_cond:
self.logger.debug('job_callback for %s ... | [
"def",
"job_callback",
"(",
"self",
",",
"job",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'job_callback for %s started'",
"%",
"str",
"(",
"job",
".",
"id",
")",
")",
"with",
"self",
".",
"thread_cond",
":",
"self",
".",
"logger",
".",
"debu... | method to be called when a job has finished
this will do some book keeping and call the user defined
new_result_callback if one was specified | [
"method",
"to",
"be",
"called",
"when",
"a",
"job",
"has",
"finished"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/master.py#L248-L269 | train |
automl/HpBandSter | hpbandster/core/master.py | Master._submit_job | def _submit_job(self, config_id, config, budget):
"""
hidden function to submit a new job to the dispatcher
This function handles the actual submission in a
(hopefully) thread save way
"""
self.logger.debug('HBMASTER: trying submitting job %s to dispatcher'%str(config_id))
with self.thread_cond:
self.... | python | def _submit_job(self, config_id, config, budget):
"""
hidden function to submit a new job to the dispatcher
This function handles the actual submission in a
(hopefully) thread save way
"""
self.logger.debug('HBMASTER: trying submitting job %s to dispatcher'%str(config_id))
with self.thread_cond:
self.... | [
"def",
"_submit_job",
"(",
"self",
",",
"config_id",
",",
"config",
",",
"budget",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'HBMASTER: trying submitting job %s to dispatcher'",
"%",
"str",
"(",
"config_id",
")",
")",
"with",
"self",
".",
"thread_co... | hidden function to submit a new job to the dispatcher
This function handles the actual submission in a
(hopefully) thread save way | [
"hidden",
"function",
"to",
"submit",
"a",
"new",
"job",
"to",
"the",
"dispatcher"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/master.py#L281-L295 | train |
automl/HpBandSter | hpbandster/optimizers/learning_curve_models/lcnet.py | LCNetWrapper.fit | def fit(self, times, losses, configs=None):
"""
function to train the model on the observed data
Parameters:
-----------
times: list
list of numpy arrays of the timesteps for each curve
losses: list
list of numpy array... | python | def fit(self, times, losses, configs=None):
"""
function to train the model on the observed data
Parameters:
-----------
times: list
list of numpy arrays of the timesteps for each curve
losses: list
list of numpy array... | [
"def",
"fit",
"(",
"self",
",",
"times",
",",
"losses",
",",
"configs",
"=",
"None",
")",
":",
"assert",
"np",
".",
"all",
"(",
"times",
">",
"0",
")",
"and",
"np",
".",
"all",
"(",
"times",
"<=",
"self",
".",
"max_num_epochs",
")",
"train",
"=",... | function to train the model on the observed data
Parameters:
-----------
times: list
list of numpy arrays of the timesteps for each curve
losses: list
list of numpy arrays of the loss (the actual learning curve)
configs: list ... | [
"function",
"to",
"train",
"the",
"model",
"on",
"the",
"observed",
"data"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/learning_curve_models/lcnet.py#L24-L63 | train |
automl/HpBandSter | hpbandster/optimizers/learning_curve_models/lcnet.py | LCNetWrapper.predict_unseen | def predict_unseen(self, times, config):
"""
predict the loss of an unseen configuration
Parameters:
-----------
times: numpy array
times where to predict the loss
config: numpy array
the numerical representation of th... | python | def predict_unseen(self, times, config):
"""
predict the loss of an unseen configuration
Parameters:
-----------
times: numpy array
times where to predict the loss
config: numpy array
the numerical representation of th... | [
"def",
"predict_unseen",
"(",
"self",
",",
"times",
",",
"config",
")",
":",
"assert",
"np",
".",
"all",
"(",
"times",
">",
"0",
")",
"and",
"np",
".",
"all",
"(",
"times",
"<=",
"self",
".",
"max_num_epochs",
")",
"x",
"=",
"np",
".",
"array",
"... | predict the loss of an unseen configuration
Parameters:
-----------
times: numpy array
times where to predict the loss
config: numpy array
the numerical representation of the config
Returns:
--------
... | [
"predict",
"the",
"loss",
"of",
"an",
"unseen",
"configuration"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/learning_curve_models/lcnet.py#L65-L93 | train |
automl/HpBandSter | hpbandster/optimizers/learning_curve_models/lcnet.py | LCNetWrapper.extend_partial | def extend_partial(self, times, obs_times, obs_losses, config=None):
"""
extends a partially observed curve
Parameters:
-----------
times: numpy array
times where to predict the loss
obs_times: numpy array
times where ... | python | def extend_partial(self, times, obs_times, obs_losses, config=None):
"""
extends a partially observed curve
Parameters:
-----------
times: numpy array
times where to predict the loss
obs_times: numpy array
times where ... | [
"def",
"extend_partial",
"(",
"self",
",",
"times",
",",
"obs_times",
",",
"obs_losses",
",",
"config",
"=",
"None",
")",
":",
"return",
"self",
".",
"predict_unseen",
"(",
"times",
",",
"config",
")"
] | extends a partially observed curve
Parameters:
-----------
times: numpy array
times where to predict the loss
obs_times: numpy array
times where the curve has already been observed
obs_losses: numpy array
corre... | [
"extends",
"a",
"partially",
"observed",
"curve"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/learning_curve_models/lcnet.py#L95-L119 | train |
automl/HpBandSter | hpbandster/core/base_config_generator.py | base_config_generator.new_result | def new_result(self, job, update_model=True):
"""
registers finished runs
Every time a run has finished, this function should be called
to register it with the result logger. If overwritten, make
sure to call this method from the base class to ensure proper
logging.
Parameters
----------
job: insta... | python | def new_result(self, job, update_model=True):
"""
registers finished runs
Every time a run has finished, this function should be called
to register it with the result logger. If overwritten, make
sure to call this method from the base class to ensure proper
logging.
Parameters
----------
job: insta... | [
"def",
"new_result",
"(",
"self",
",",
"job",
",",
"update_model",
"=",
"True",
")",
":",
"if",
"not",
"job",
".",
"exception",
"is",
"None",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"job {} failed with exception\\n{}\"",
".",
"format",
"(",
"job... | registers finished runs
Every time a run has finished, this function should be called
to register it with the result logger. If overwritten, make
sure to call this method from the base class to ensure proper
logging.
Parameters
----------
job: instance of hpbandster.distributed.dispatcher.Job
contai... | [
"registers",
"finished",
"runs"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_config_generator.py#L47-L65 | train |
automl/HpBandSter | hpbandster/optimizers/learning_curve_models/arif.py | ARIF.invert_differencing | def invert_differencing(self, initial_part, differenced_rest, order=None):
"""
function to invert the differencing
"""
if order is None: order = self.diff_order
# compute the differenced values of the initial part:
starting_points = [ self.apply_differencing(initial... | python | def invert_differencing(self, initial_part, differenced_rest, order=None):
"""
function to invert the differencing
"""
if order is None: order = self.diff_order
# compute the differenced values of the initial part:
starting_points = [ self.apply_differencing(initial... | [
"def",
"invert_differencing",
"(",
"self",
",",
"initial_part",
",",
"differenced_rest",
",",
"order",
"=",
"None",
")",
":",
"if",
"order",
"is",
"None",
":",
"order",
"=",
"self",
".",
"diff_order",
"# compute the differenced values of the initial part:",
"startin... | function to invert the differencing | [
"function",
"to",
"invert",
"the",
"differencing"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/learning_curve_models/arif.py#L38-L54 | train |
automl/HpBandSter | hpbandster/core/nameserver.py | nic_name_to_host | def nic_name_to_host(nic_name):
""" helper function to translate the name of a network card into a valid host name"""
from netifaces import ifaddresses, AF_INET
host = ifaddresses(nic_name).setdefault(AF_INET, [{'addr': 'No IP addr'}] )[0]['addr']
return(host) | python | def nic_name_to_host(nic_name):
""" helper function to translate the name of a network card into a valid host name"""
from netifaces import ifaddresses, AF_INET
host = ifaddresses(nic_name).setdefault(AF_INET, [{'addr': 'No IP addr'}] )[0]['addr']
return(host) | [
"def",
"nic_name_to_host",
"(",
"nic_name",
")",
":",
"from",
"netifaces",
"import",
"ifaddresses",
",",
"AF_INET",
"host",
"=",
"ifaddresses",
"(",
"nic_name",
")",
".",
"setdefault",
"(",
"AF_INET",
",",
"[",
"{",
"'addr'",
":",
"'No IP addr'",
"}",
"]",
... | helper function to translate the name of a network card into a valid host name | [
"helper",
"function",
"to",
"translate",
"the",
"name",
"of",
"a",
"network",
"card",
"into",
"a",
"valid",
"host",
"name"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/nameserver.py#L9-L13 | train |
automl/HpBandSter | hpbandster/core/base_iteration.py | BaseIteration.register_result | def register_result(self, job, skip_sanity_checks=False):
"""
function to register the result of a job
This function is called from HB_master, don't call this from
your script.
"""
if self.is_finished:
raise RuntimeError("This HB iteration is finished, you can't register more results!")
config_id = ... | python | def register_result(self, job, skip_sanity_checks=False):
"""
function to register the result of a job
This function is called from HB_master, don't call this from
your script.
"""
if self.is_finished:
raise RuntimeError("This HB iteration is finished, you can't register more results!")
config_id = ... | [
"def",
"register_result",
"(",
"self",
",",
"job",
",",
"skip_sanity_checks",
"=",
"False",
")",
":",
"if",
"self",
".",
"is_finished",
":",
"raise",
"RuntimeError",
"(",
"\"This HB iteration is finished, you can't register more results!\"",
")",
"config_id",
"=",
"jo... | function to register the result of a job
This function is called from HB_master, don't call this from
your script. | [
"function",
"to",
"register",
"the",
"result",
"of",
"a",
"job"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L105-L139 | train |
automl/HpBandSter | hpbandster/core/base_iteration.py | BaseIteration.get_next_run | def get_next_run(self):
"""
function to return the next configuration and budget to run.
This function is called from HB_master, don't call this from
your script.
It returns None if this run of SH is finished or there are
pending jobs that need to finish to progress to the next stage.
If there are empt... | python | def get_next_run(self):
"""
function to return the next configuration and budget to run.
This function is called from HB_master, don't call this from
your script.
It returns None if this run of SH is finished or there are
pending jobs that need to finish to progress to the next stage.
If there are empt... | [
"def",
"get_next_run",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_finished",
":",
"return",
"(",
"None",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"if",
"v",
".",
"status",
"==",
"'QUEUED'",
":",
"asser... | function to return the next configuration and budget to run.
This function is called from HB_master, don't call this from
your script.
It returns None if this run of SH is finished or there are
pending jobs that need to finish to progress to the next stage.
If there are empty slots to be filled in the curr... | [
"function",
"to",
"return",
"the",
"next",
"configuration",
"and",
"budget",
"to",
"run",
"."
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L141-L176 | train |
automl/HpBandSter | hpbandster/core/base_iteration.py | BaseIteration.process_results | def process_results(self):
"""
function that is called when a stage is completed and
needs to be analyzed befor further computations.
The code here implements the original SH algorithms by
advancing the k-best (lowest loss) configurations at the current
budget. k is defined by the num_configs list (see __i... | python | def process_results(self):
"""
function that is called when a stage is completed and
needs to be analyzed befor further computations.
The code here implements the original SH algorithms by
advancing the k-best (lowest loss) configurations at the current
budget. k is defined by the num_configs list (see __i... | [
"def",
"process_results",
"(",
"self",
")",
":",
"self",
".",
"stage",
"+=",
"1",
"# collect all config_ids that need to be compared",
"config_ids",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"cid",
":",
"self",
".",
"data",
"[",
"cid",
"]",
".",
"status",
"... | function that is called when a stage is completed and
needs to be analyzed befor further computations.
The code here implements the original SH algorithms by
advancing the k-best (lowest loss) configurations at the current
budget. k is defined by the num_configs list (see __init__)
and the current stage valu... | [
"function",
"that",
"is",
"called",
"when",
"a",
"stage",
"is",
"completed",
"and",
"needs",
"to",
"be",
"analyzed",
"befor",
"further",
"computations",
"."
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L201-L242 | train |
automl/HpBandSter | hpbandster/core/base_iteration.py | WarmStartIteration.fix_timestamps | def fix_timestamps(self, time_ref):
"""
manipulates internal time stamps such that the last run ends at time 0
"""
for k,v in self.data.items():
for kk, vv in v.time_stamps.items():
for kkk,vvv in vv.items():
self.data[k].time_stamps[kk][kkk] += time_ref | python | def fix_timestamps(self, time_ref):
"""
manipulates internal time stamps such that the last run ends at time 0
"""
for k,v in self.data.items():
for kk, vv in v.time_stamps.items():
for kkk,vvv in vv.items():
self.data[k].time_stamps[kk][kkk] += time_ref | [
"def",
"fix_timestamps",
"(",
"self",
",",
"time_ref",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"for",
"kk",
",",
"vv",
"in",
"v",
".",
"time_stamps",
".",
"items",
"(",
")",
":",
"for",
"kkk",
","... | manipulates internal time stamps such that the last run ends at time 0 | [
"manipulates",
"internal",
"time",
"stamps",
"such",
"that",
"the",
"last",
"run",
"ends",
"at",
"time",
"0"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/base_iteration.py#L290-L298 | train |
automl/HpBandSter | hpbandster/optimizers/config_generators/lcnet.py | LCNetWrapper.get_config | def get_config(self, budget):
"""
function to sample a new configuration
This function is called inside Hyperband to query a new configuration
Parameters:
-----------
budget: float
the budget for which this configuration is scheduled... | python | def get_config(self, budget):
"""
function to sample a new configuration
This function is called inside Hyperband to query a new configuration
Parameters:
-----------
budget: float
the budget for which this configuration is scheduled... | [
"def",
"get_config",
"(",
"self",
",",
"budget",
")",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"if",
"not",
"self",
".",
"is_trained",
":",
"c",
"=",
"self",
".",
"config_space",
".",
"sample_configuration",
"(",
")",
".",
"get_array",
"(",
... | function to sample a new configuration
This function is called inside Hyperband to query a new configuration
Parameters:
-----------
budget: float
the budget for which this configuration is scheduled
returns: config
should r... | [
"function",
"to",
"sample",
"a",
"new",
"configuration"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/optimizers/config_generators/lcnet.py#L63-L103 | train |
automl/HpBandSter | hpbandster/core/result.py | extract_HBS_learning_curves | def extract_HBS_learning_curves(runs):
"""
function to get the hyperband learning curves
This is an example function showing the interface to use the
HB_result.get_learning_curves method.
Parameters
----------
runs: list of HB_result.run objects
the performed runs for an unspecified config
Returns
------... | python | def extract_HBS_learning_curves(runs):
"""
function to get the hyperband learning curves
This is an example function showing the interface to use the
HB_result.get_learning_curves method.
Parameters
----------
runs: list of HB_result.run objects
the performed runs for an unspecified config
Returns
------... | [
"def",
"extract_HBS_learning_curves",
"(",
"runs",
")",
":",
"sr",
"=",
"sorted",
"(",
"runs",
",",
"key",
"=",
"lambda",
"r",
":",
"r",
".",
"budget",
")",
"lc",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"t",
":",
"not",
"t",
"[",
"1",
"]",
"is... | function to get the hyperband learning curves
This is an example function showing the interface to use the
HB_result.get_learning_curves method.
Parameters
----------
runs: list of HB_result.run objects
the performed runs for an unspecified config
Returns
-------
list of learning curves: list of lists of... | [
"function",
"to",
"get",
"the",
"hyperband",
"learning",
"curves"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L35-L61 | train |
automl/HpBandSter | hpbandster/core/result.py | logged_results_to_HBS_result | def logged_results_to_HBS_result(directory):
"""
function to import logged 'live-results' and return a HB_result object
You can load live run results with this function and the returned
HB_result object gives you access to the results the same way
a finished run would.
Parameters
----------
directory: str
... | python | def logged_results_to_HBS_result(directory):
"""
function to import logged 'live-results' and return a HB_result object
You can load live run results with this function and the returned
HB_result object gives you access to the results the same way
a finished run would.
Parameters
----------
directory: str
... | [
"def",
"logged_results_to_HBS_result",
"(",
"directory",
")",
":",
"data",
"=",
"{",
"}",
"time_ref",
"=",
"float",
"(",
"'inf'",
")",
"budget_set",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'con... | function to import logged 'live-results' and return a HB_result object
You can load live run results with this function and the returned
HB_result object gives you access to the results the same way
a finished run would.
Parameters
----------
directory: str
the directory containing the results.json and confi... | [
"function",
"to",
"import",
"logged",
"live",
"-",
"results",
"and",
"return",
"a",
"HB_result",
"object"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L139-L200 | train |
automl/HpBandSter | hpbandster/core/result.py | Result.get_incumbent_id | def get_incumbent_id(self):
"""
Find the config_id of the incumbent.
The incumbent here is the configuration with the smallest loss
among all runs on the maximum budget! If no run finishes on the
maximum budget, None is returned!
"""
tmp_list = []
for k,v in self.data.items():
try:
# only things... | python | def get_incumbent_id(self):
"""
Find the config_id of the incumbent.
The incumbent here is the configuration with the smallest loss
among all runs on the maximum budget! If no run finishes on the
maximum budget, None is returned!
"""
tmp_list = []
for k,v in self.data.items():
try:
# only things... | [
"def",
"get_incumbent_id",
"(",
"self",
")",
":",
"tmp_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"try",
":",
"# only things run for the max budget are considered",
"res",
"=",
"v",
".",
"results",
... | Find the config_id of the incumbent.
The incumbent here is the configuration with the smallest loss
among all runs on the maximum budget! If no run finishes on the
maximum budget, None is returned! | [
"Find",
"the",
"config_id",
"of",
"the",
"incumbent",
"."
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L219-L241 | train |
automl/HpBandSter | hpbandster/core/result.py | Result.get_runs_by_id | def get_runs_by_id(self, config_id):
"""
returns a list of runs for a given config id
The runs are sorted by ascending budget, so '-1' will give
the longest run for this config.
"""
d = self.data[config_id]
runs = []
for b in d.results.keys():
try:
err_logs = d.exceptions.get(b, None)
if d... | python | def get_runs_by_id(self, config_id):
"""
returns a list of runs for a given config id
The runs are sorted by ascending budget, so '-1' will give
the longest run for this config.
"""
d = self.data[config_id]
runs = []
for b in d.results.keys():
try:
err_logs = d.exceptions.get(b, None)
if d... | [
"def",
"get_runs_by_id",
"(",
"self",
",",
"config_id",
")",
":",
"d",
"=",
"self",
".",
"data",
"[",
"config_id",
"]",
"runs",
"=",
"[",
"]",
"for",
"b",
"in",
"d",
".",
"results",
".",
"keys",
"(",
")",
":",
"try",
":",
"err_logs",
"=",
"d",
... | returns a list of runs for a given config id
The runs are sorted by ascending budget, so '-1' will give
the longest run for this config. | [
"returns",
"a",
"list",
"of",
"runs",
"for",
"a",
"given",
"config",
"id"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L319-L341 | train |
automl/HpBandSter | hpbandster/core/result.py | Result.get_learning_curves | def get_learning_curves(self, lc_extractor=extract_HBS_learning_curves, config_ids=None):
"""
extracts all learning curves from all run configurations
Parameters
----------
lc_extractor: callable
a function to return a list of learning_curves.
defaults to hpbanster.HB_result.extract_HP_learning_curv... | python | def get_learning_curves(self, lc_extractor=extract_HBS_learning_curves, config_ids=None):
"""
extracts all learning curves from all run configurations
Parameters
----------
lc_extractor: callable
a function to return a list of learning_curves.
defaults to hpbanster.HB_result.extract_HP_learning_curv... | [
"def",
"get_learning_curves",
"(",
"self",
",",
"lc_extractor",
"=",
"extract_HBS_learning_curves",
",",
"config_ids",
"=",
"None",
")",
":",
"config_ids",
"=",
"self",
".",
"data",
".",
"keys",
"(",
")",
"if",
"config_ids",
"is",
"None",
"else",
"config_ids",... | extracts all learning curves from all run configurations
Parameters
----------
lc_extractor: callable
a function to return a list of learning_curves.
defaults to hpbanster.HB_result.extract_HP_learning_curves
config_ids: list of valid config ids
if only a subset of the config ids is wanted
Ret... | [
"extracts",
"all",
"learning",
"curves",
"from",
"all",
"run",
"configurations"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L344-L371 | train |
automl/HpBandSter | hpbandster/core/result.py | Result.get_all_runs | def get_all_runs(self, only_largest_budget=False):
"""
returns all runs performed
Parameters
----------
only_largest_budget: boolean
if True, only the largest budget for each configuration
is returned. This makes sense if the runs are continued
across budgets and the info field contains the info... | python | def get_all_runs(self, only_largest_budget=False):
"""
returns all runs performed
Parameters
----------
only_largest_budget: boolean
if True, only the largest budget for each configuration
is returned. This makes sense if the runs are continued
across budgets and the info field contains the info... | [
"def",
"get_all_runs",
"(",
"self",
",",
"only_largest_budget",
"=",
"False",
")",
":",
"all_runs",
"=",
"[",
"]",
"for",
"k",
"in",
"self",
".",
"data",
".",
"keys",
"(",
")",
":",
"runs",
"=",
"self",
".",
"get_runs_by_id",
"(",
"k",
")",
"if",
"... | returns all runs performed
Parameters
----------
only_largest_budget: boolean
if True, only the largest budget for each configuration
is returned. This makes sense if the runs are continued
across budgets and the info field contains the information
you care about. If False, all runs of a configu... | [
"returns",
"all",
"runs",
"performed"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L374-L398 | train |
automl/HpBandSter | hpbandster/core/result.py | Result.get_id2config_mapping | def get_id2config_mapping(self):
"""
returns a dict where the keys are the config_ids and the values
are the actual configurations
"""
new_dict = {}
for k, v in self.data.items():
new_dict[k] = {}
new_dict[k]['config'] = copy.deepcopy(v.config)
try:
new_dict[k]['config_info'] = copy.deepcopy(v.... | python | def get_id2config_mapping(self):
"""
returns a dict where the keys are the config_ids and the values
are the actual configurations
"""
new_dict = {}
for k, v in self.data.items():
new_dict[k] = {}
new_dict[k]['config'] = copy.deepcopy(v.config)
try:
new_dict[k]['config_info'] = copy.deepcopy(v.... | [
"def",
"get_id2config_mapping",
"(",
"self",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"new_dict",
"[",
"k",
"]",
"=",
"{",
"}",
"new_dict",
"[",
"k",
"]",
"[",
"'config'",
... | returns a dict where the keys are the config_ids and the values
are the actual configurations | [
"returns",
"a",
"dict",
"where",
"the",
"keys",
"are",
"the",
"config_ids",
"and",
"the",
"values",
"are",
"the",
"actual",
"configurations"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L400-L413 | train |
automl/HpBandSter | hpbandster/core/result.py | Result._merge_results | def _merge_results(self):
"""
hidden function to merge the list of results into one
dictionary and 'normalize' the time stamps
"""
new_dict = {}
for it in self.data:
new_dict.update(it)
for k,v in new_dict.items():
for kk, vv in v.time_stamps.items():
for kkk,vvv in vv.items():
new_dict[k]... | python | def _merge_results(self):
"""
hidden function to merge the list of results into one
dictionary and 'normalize' the time stamps
"""
new_dict = {}
for it in self.data:
new_dict.update(it)
for k,v in new_dict.items():
for kk, vv in v.time_stamps.items():
for kkk,vvv in vv.items():
new_dict[k]... | [
"def",
"_merge_results",
"(",
"self",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"it",
"in",
"self",
".",
"data",
":",
"new_dict",
".",
"update",
"(",
"it",
")",
"for",
"k",
",",
"v",
"in",
"new_dict",
".",
"items",
"(",
")",
":",
"for",
"kk",
... | hidden function to merge the list of results into one
dictionary and 'normalize' the time stamps | [
"hidden",
"function",
"to",
"merge",
"the",
"list",
"of",
"results",
"into",
"one",
"dictionary",
"and",
"normalize",
"the",
"time",
"stamps"
] | 841db4b827f342e5eb7f725723ea6461ac52d45a | https://github.com/automl/HpBandSter/blob/841db4b827f342e5eb7f725723ea6461ac52d45a/hpbandster/core/result.py#L415-L429 | train |
Koed00/django-q | django_q/core_signing.py | TimestampSigner.unsign | def unsign(self, value, max_age=None):
"""
Retrieve original value and check it wasn't signed more
than max_age seconds ago.
"""
result = super(TimestampSigner, self).unsign(value)
value, timestamp = result.rsplit(self.sep, 1)
timestamp = baseconv.base62.decode(ti... | python | def unsign(self, value, max_age=None):
"""
Retrieve original value and check it wasn't signed more
than max_age seconds ago.
"""
result = super(TimestampSigner, self).unsign(value)
value, timestamp = result.rsplit(self.sep, 1)
timestamp = baseconv.base62.decode(ti... | [
"def",
"unsign",
"(",
"self",
",",
"value",
",",
"max_age",
"=",
"None",
")",
":",
"result",
"=",
"super",
"(",
"TimestampSigner",
",",
"self",
")",
".",
"unsign",
"(",
"value",
")",
"value",
",",
"timestamp",
"=",
"result",
".",
"rsplit",
"(",
"self... | Retrieve original value and check it wasn't signed more
than max_age seconds ago. | [
"Retrieve",
"original",
"value",
"and",
"check",
"it",
"wasn",
"t",
"signed",
"more",
"than",
"max_age",
"seconds",
"ago",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/core_signing.py#L63-L79 | train |
Koed00/django-q | django_q/humanhash.py | HumanHasher.humanize | def humanize(self, hexdigest, words=4, separator='-'):
"""
Humanize a given hexadecimal digest.
Change the number of words output by specifying `words`. Change the
word separator with `separator`.
>>> digest = '60ad8d0d871b6095808297'
>>> HumanHasher().humanize... | python | def humanize(self, hexdigest, words=4, separator='-'):
"""
Humanize a given hexadecimal digest.
Change the number of words output by specifying `words`. Change the
word separator with `separator`.
>>> digest = '60ad8d0d871b6095808297'
>>> HumanHasher().humanize... | [
"def",
"humanize",
"(",
"self",
",",
"hexdigest",
",",
"words",
"=",
"4",
",",
"separator",
"=",
"'-'",
")",
":",
"# Gets a list of byte values between 0-255.",
"bytes",
"=",
"[",
"int",
"(",
"x",
",",
"16",
")",
"for",
"x",
"in",
"list",
"(",
"map",
"... | Humanize a given hexadecimal digest.
Change the number of words output by specifying `words`. Change the
word separator with `separator`.
>>> digest = '60ad8d0d871b6095808297'
>>> HumanHasher().humanize(digest)
'sodium-magnesium-nineteen-hydrogen' | [
"Humanize",
"a",
"given",
"hexadecimal",
"digest",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L73-L91 | train |
Koed00/django-q | django_q/humanhash.py | HumanHasher.compress | def compress(bytes, target):
"""
Compress a list of byte values to a fixed target length.
>>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151]
>>> HumanHasher.compress(bytes, 4)
[205, 128, 156, 96]
Attempting to compress a smaller number of bytes... | python | def compress(bytes, target):
"""
Compress a list of byte values to a fixed target length.
>>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151]
>>> HumanHasher.compress(bytes, 4)
[205, 128, 156, 96]
Attempting to compress a smaller number of bytes... | [
"def",
"compress",
"(",
"bytes",
",",
"target",
")",
":",
"length",
"=",
"len",
"(",
"bytes",
")",
"if",
"target",
">",
"length",
":",
"raise",
"ValueError",
"(",
"\"Fewer input bytes than requested output\"",
")",
"# Split `bytes` into `target` segments.",
"seg_siz... | Compress a list of byte values to a fixed target length.
>>> bytes = [96, 173, 141, 13, 135, 27, 96, 149, 128, 130, 151]
>>> HumanHasher.compress(bytes, 4)
[205, 128, 156, 96]
Attempting to compress a smaller number of bytes to a larger number is
an error:
... | [
"Compress",
"a",
"list",
"of",
"byte",
"values",
"to",
"a",
"fixed",
"target",
"length",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L94-L126 | train |
Koed00/django-q | django_q/humanhash.py | HumanHasher.uuid | def uuid(self, **params):
"""
Generate a UUID with a human-readable representation.
Returns `(human_repr, full_digest)`. Accepts the same keyword arguments
as :meth:`humanize` (they'll be passed straight through).
"""
digest = str(uuidlib.uuid4()).replace('-', '')
... | python | def uuid(self, **params):
"""
Generate a UUID with a human-readable representation.
Returns `(human_repr, full_digest)`. Accepts the same keyword arguments
as :meth:`humanize` (they'll be passed straight through).
"""
digest = str(uuidlib.uuid4()).replace('-', '')
... | [
"def",
"uuid",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"digest",
"=",
"str",
"(",
"uuidlib",
".",
"uuid4",
"(",
")",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
"return",
"self",
".",
"humanize",
"(",
"digest",
",",
"*",
"*",
"para... | Generate a UUID with a human-readable representation.
Returns `(human_repr, full_digest)`. Accepts the same keyword arguments
as :meth:`humanize` (they'll be passed straight through). | [
"Generate",
"a",
"UUID",
"with",
"a",
"human",
"-",
"readable",
"representation",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/humanhash.py#L128-L138 | train |
Koed00/django-q | django_q/tasks.py | async_task | def async_task(func, *args, **kwargs):
"""Queue a task for the cluster."""
keywords = kwargs.copy()
opt_keys = (
'hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker')
q_options = keywords.pop('q_options', {})
# get an id
tag = uuid()
# ... | python | def async_task(func, *args, **kwargs):
"""Queue a task for the cluster."""
keywords = kwargs.copy()
opt_keys = (
'hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker')
q_options = keywords.pop('q_options', {})
# get an id
tag = uuid()
# ... | [
"def",
"async_task",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"keywords",
"=",
"kwargs",
".",
"copy",
"(",
")",
"opt_keys",
"=",
"(",
"'hook'",
",",
"'group'",
",",
"'save'",
",",
"'sync'",
",",
"'cached'",
",",
"'ack_failure... | Queue a task for the cluster. | [
"Queue",
"a",
"task",
"for",
"the",
"cluster",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L21-L62 | train |
Koed00/django-q | django_q/tasks.py | schedule | def schedule(func, *args, **kwargs):
"""
Create a schedule.
:param func: function to schedule.
:param args: function arguments.
:param name: optional name for the schedule.
:param hook: optional result hook function.
:type schedule_type: Schedule.TYPE
:param repeats: how many times to r... | python | def schedule(func, *args, **kwargs):
"""
Create a schedule.
:param func: function to schedule.
:param args: function arguments.
:param name: optional name for the schedule.
:param hook: optional result hook function.
:type schedule_type: Schedule.TYPE
:param repeats: how many times to r... | [
"def",
"schedule",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
",",
"None",
")",
"hook",
"=",
"kwargs",
".",
"pop",
"(",
"'hook'",
",",
"None",
")",
"schedule_type",
"=",
"kw... | Create a schedule.
:param func: function to schedule.
:param args: function arguments.
:param name: optional name for the schedule.
:param hook: optional result hook function.
:type schedule_type: Schedule.TYPE
:param repeats: how many times to repeat. 0=never, -1=always.
:param next_run: N... | [
"Create",
"a",
"schedule",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L65-L102 | train |
Koed00/django-q | django_q/tasks.py | result | def result(task_id, wait=0, cached=Conf.CACHED):
"""
Return the result of the named task.
:type task_id: str or uuid
:param task_id: the task name or uuid
:type wait: int
:param wait: number of milliseconds to wait for a result
:param bool cached: run this against the cache backend
:ret... | python | def result(task_id, wait=0, cached=Conf.CACHED):
"""
Return the result of the named task.
:type task_id: str or uuid
:param task_id: the task name or uuid
:type wait: int
:param wait: number of milliseconds to wait for a result
:param bool cached: run this against the cache backend
:ret... | [
"def",
"result",
"(",
"task_id",
",",
"wait",
"=",
"0",
",",
"cached",
"=",
"Conf",
".",
"CACHED",
")",
":",
"if",
"cached",
":",
"return",
"result_cached",
"(",
"task_id",
",",
"wait",
")",
"start",
"=",
"time",
"(",
")",
"while",
"True",
":",
"r"... | Return the result of the named task.
:type task_id: str or uuid
:param task_id: the task name or uuid
:type wait: int
:param wait: number of milliseconds to wait for a result
:param bool cached: run this against the cache backend
:return: the result object of this task
:rtype: object | [
"Return",
"the",
"result",
"of",
"the",
"named",
"task",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L105-L126 | train |
Koed00/django-q | django_q/tasks.py | result_cached | def result_cached(task_id, wait=0, broker=None):
"""
Return the result from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
while True:
r = broker.cache.get('{}:{}'.format(broker.list_key, task_id))
if r:
return SignedPackage.loads(r... | python | def result_cached(task_id, wait=0, broker=None):
"""
Return the result from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
while True:
r = broker.cache.get('{}:{}'.format(broker.list_key, task_id))
if r:
return SignedPackage.loads(r... | [
"def",
"result_cached",
"(",
"task_id",
",",
"wait",
"=",
"0",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"start",
"=",
"time",
"(",
")",
"while",
"True",
":",
"r",
"=",
"broker",
".",
... | Return the result from the cache backend | [
"Return",
"the",
"result",
"from",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L129-L142 | train |
Koed00/django-q | django_q/tasks.py | result_group | def result_group(group_id, failures=False, wait=0, count=None, cached=Conf.CACHED):
"""
Return a list of results for a task group.
:param str group_id: the group id
:param bool failures: set to True to include failures
:param int count: Block until there are this many results in the group
:para... | python | def result_group(group_id, failures=False, wait=0, count=None, cached=Conf.CACHED):
"""
Return a list of results for a task group.
:param str group_id: the group id
:param bool failures: set to True to include failures
:param int count: Block until there are this many results in the group
:para... | [
"def",
"result_group",
"(",
"group_id",
",",
"failures",
"=",
"False",
",",
"wait",
"=",
"0",
",",
"count",
"=",
"None",
",",
"cached",
"=",
"Conf",
".",
"CACHED",
")",
":",
"if",
"cached",
":",
"return",
"result_group_cached",
"(",
"group_id",
",",
"f... | Return a list of results for a task group.
:param str group_id: the group id
:param bool failures: set to True to include failures
:param int count: Block until there are this many results in the group
:param bool cached: run this against the cache backend
:return: list or results | [
"Return",
"a",
"list",
"of",
"results",
"for",
"a",
"task",
"group",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L145-L169 | train |
Koed00/django-q | django_q/tasks.py | result_group_cached | def result_group_cached(group_id, failures=False, wait=0, count=None, broker=None):
"""
Return a list of results for a task group from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
if count:
while True:
if count_group_cached(group_id) == co... | python | def result_group_cached(group_id, failures=False, wait=0, count=None, broker=None):
"""
Return a list of results for a task group from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
if count:
while True:
if count_group_cached(group_id) == co... | [
"def",
"result_group_cached",
"(",
"group_id",
",",
"failures",
"=",
"False",
",",
"wait",
"=",
"0",
",",
"count",
"=",
"None",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"start",
"=",
"ti... | Return a list of results for a task group from the cache backend | [
"Return",
"a",
"list",
"of",
"results",
"for",
"a",
"task",
"group",
"from",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L172-L195 | train |
Koed00/django-q | django_q/tasks.py | fetch | def fetch(task_id, wait=0, cached=Conf.CACHED):
"""
Return the processed task.
:param task_id: the task name or uuid
:type task_id: str or uuid
:param wait: the number of milliseconds to wait for a result
:type wait: int
:param bool cached: run this against the cache backend
:return: th... | python | def fetch(task_id, wait=0, cached=Conf.CACHED):
"""
Return the processed task.
:param task_id: the task name or uuid
:type task_id: str or uuid
:param wait: the number of milliseconds to wait for a result
:type wait: int
:param bool cached: run this against the cache backend
:return: th... | [
"def",
"fetch",
"(",
"task_id",
",",
"wait",
"=",
"0",
",",
"cached",
"=",
"Conf",
".",
"CACHED",
")",
":",
"if",
"cached",
":",
"return",
"fetch_cached",
"(",
"task_id",
",",
"wait",
")",
"start",
"=",
"time",
"(",
")",
"while",
"True",
":",
"t",
... | Return the processed task.
:param task_id: the task name or uuid
:type task_id: str or uuid
:param wait: the number of milliseconds to wait for a result
:type wait: int
:param bool cached: run this against the cache backend
:return: the full task object
:rtype: Task | [
"Return",
"the",
"processed",
"task",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L198-L219 | train |
Koed00/django-q | django_q/tasks.py | fetch_cached | def fetch_cached(task_id, wait=0, broker=None):
"""
Return the processed task from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
while True:
r = broker.cache.get('{}:{}'.format(broker.list_key, task_id))
if r:
task = SignedPackage.l... | python | def fetch_cached(task_id, wait=0, broker=None):
"""
Return the processed task from the cache backend
"""
if not broker:
broker = get_broker()
start = time()
while True:
r = broker.cache.get('{}:{}'.format(broker.list_key, task_id))
if r:
task = SignedPackage.l... | [
"def",
"fetch_cached",
"(",
"task_id",
",",
"wait",
"=",
"0",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"start",
"=",
"time",
"(",
")",
"while",
"True",
":",
"r",
"=",
"broker",
".",
... | Return the processed task from the cache backend | [
"Return",
"the",
"processed",
"task",
"from",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L222-L246 | train |
Koed00/django-q | django_q/tasks.py | fetch_group | def fetch_group(group_id, failures=True, wait=0, count=None, cached=Conf.CACHED):
"""
Return a list of Tasks for a task group.
:param str group_id: the group id
:param bool failures: set to False to exclude failures
:param bool cached: run this against the cache backend
:return: list of Tasks
... | python | def fetch_group(group_id, failures=True, wait=0, count=None, cached=Conf.CACHED):
"""
Return a list of Tasks for a task group.
:param str group_id: the group id
:param bool failures: set to False to exclude failures
:param bool cached: run this against the cache backend
:return: list of Tasks
... | [
"def",
"fetch_group",
"(",
"group_id",
",",
"failures",
"=",
"True",
",",
"wait",
"=",
"0",
",",
"count",
"=",
"None",
",",
"cached",
"=",
"Conf",
".",
"CACHED",
")",
":",
"if",
"cached",
":",
"return",
"fetch_group_cached",
"(",
"group_id",
",",
"fail... | Return a list of Tasks for a task group.
:param str group_id: the group id
:param bool failures: set to False to exclude failures
:param bool cached: run this against the cache backend
:return: list of Tasks | [
"Return",
"a",
"list",
"of",
"Tasks",
"for",
"a",
"task",
"group",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L249-L272 | train |
Koed00/django-q | django_q/tasks.py | fetch_group_cached | def fetch_group_cached(group_id, failures=True, wait=0, count=None, broker=None):
"""
Return a list of Tasks for a task group in the cache backend
"""
if not broker:
broker = get_broker()
start = time()
if count:
while True:
if count_group_cached(group_id) == count or... | python | def fetch_group_cached(group_id, failures=True, wait=0, count=None, broker=None):
"""
Return a list of Tasks for a task group in the cache backend
"""
if not broker:
broker = get_broker()
start = time()
if count:
while True:
if count_group_cached(group_id) == count or... | [
"def",
"fetch_group_cached",
"(",
"group_id",
",",
"failures",
"=",
"True",
",",
"wait",
"=",
"0",
",",
"count",
"=",
"None",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"start",
"=",
"time... | Return a list of Tasks for a task group in the cache backend | [
"Return",
"a",
"list",
"of",
"Tasks",
"for",
"a",
"task",
"group",
"in",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L275-L309 | train |
Koed00/django-q | django_q/tasks.py | count_group | def count_group(group_id, failures=False, cached=Conf.CACHED):
"""
Count the results in a group.
:param str group_id: the group id
:param bool failures: Returns failure count if True
:param bool cached: run this against the cache backend
:return: the number of tasks/results in a group
:rtyp... | python | def count_group(group_id, failures=False, cached=Conf.CACHED):
"""
Count the results in a group.
:param str group_id: the group id
:param bool failures: Returns failure count if True
:param bool cached: run this against the cache backend
:return: the number of tasks/results in a group
:rtyp... | [
"def",
"count_group",
"(",
"group_id",
",",
"failures",
"=",
"False",
",",
"cached",
"=",
"Conf",
".",
"CACHED",
")",
":",
"if",
"cached",
":",
"return",
"count_group_cached",
"(",
"group_id",
",",
"failures",
")",
"return",
"Task",
".",
"get_group_count",
... | Count the results in a group.
:param str group_id: the group id
:param bool failures: Returns failure count if True
:param bool cached: run this against the cache backend
:return: the number of tasks/results in a group
:rtype: int | [
"Count",
"the",
"results",
"in",
"a",
"group",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L312-L324 | train |
Koed00/django-q | django_q/tasks.py | count_group_cached | def count_group_cached(group_id, failures=False, broker=None):
"""
Count the results in a group in the cache backend
"""
if not broker:
broker = get_broker()
group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id))
if group_list:
if not failures:
... | python | def count_group_cached(group_id, failures=False, broker=None):
"""
Count the results in a group in the cache backend
"""
if not broker:
broker = get_broker()
group_list = broker.cache.get('{}:{}:keys'.format(broker.list_key, group_id))
if group_list:
if not failures:
... | [
"def",
"count_group_cached",
"(",
"group_id",
",",
"failures",
"=",
"False",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"group_list",
"=",
"broker",
".",
"cache",
".",
"get",
"(",
"'{}:{}:keys... | Count the results in a group in the cache backend | [
"Count",
"the",
"results",
"in",
"a",
"group",
"in",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L327-L342 | train |
Koed00/django-q | django_q/tasks.py | delete_group_cached | def delete_group_cached(group_id, broker=None):
"""
Delete a group from the cache backend
"""
if not broker:
broker = get_broker()
group_key = '{}:{}:keys'.format(broker.list_key, group_id)
group_list = broker.cache.get(group_key)
broker.cache.delete_many(group_list)
broker.cache... | python | def delete_group_cached(group_id, broker=None):
"""
Delete a group from the cache backend
"""
if not broker:
broker = get_broker()
group_key = '{}:{}:keys'.format(broker.list_key, group_id)
group_list = broker.cache.get(group_key)
broker.cache.delete_many(group_list)
broker.cache... | [
"def",
"delete_group_cached",
"(",
"group_id",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"group_key",
"=",
"'{}:{}:keys'",
".",
"format",
"(",
"broker",
".",
"list_key",
",",
"group_id",
")",
... | Delete a group from the cache backend | [
"Delete",
"a",
"group",
"from",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L360-L369 | train |
Koed00/django-q | django_q/tasks.py | delete_cached | def delete_cached(task_id, broker=None):
"""
Delete a task from the cache backend
"""
if not broker:
broker = get_broker()
return broker.cache.delete('{}:{}'.format(broker.list_key, task_id)) | python | def delete_cached(task_id, broker=None):
"""
Delete a task from the cache backend
"""
if not broker:
broker = get_broker()
return broker.cache.delete('{}:{}'.format(broker.list_key, task_id)) | [
"def",
"delete_cached",
"(",
"task_id",
",",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"return",
"broker",
".",
"cache",
".",
"delete",
"(",
"'{}:{}'",
".",
"format",
"(",
"broker",
".",
"list_k... | Delete a task from the cache backend | [
"Delete",
"a",
"task",
"from",
"the",
"cache",
"backend"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L372-L378 | train |
Koed00/django-q | django_q/tasks.py | async_iter | def async_iter(func, args_iter, **kwargs):
"""
enqueues a function with iterable arguments
"""
iter_count = len(args_iter)
iter_group = uuid()[1]
# clean up the kwargs
options = kwargs.get('q_options', kwargs)
options.pop('hook', None)
options['broker'] = options.get('broker', get_br... | python | def async_iter(func, args_iter, **kwargs):
"""
enqueues a function with iterable arguments
"""
iter_count = len(args_iter)
iter_group = uuid()[1]
# clean up the kwargs
options = kwargs.get('q_options', kwargs)
options.pop('hook', None)
options['broker'] = options.get('broker', get_br... | [
"def",
"async_iter",
"(",
"func",
",",
"args_iter",
",",
"*",
"*",
"kwargs",
")",
":",
"iter_count",
"=",
"len",
"(",
"args_iter",
")",
"iter_group",
"=",
"uuid",
"(",
")",
"[",
"1",
"]",
"# clean up the kwargs",
"options",
"=",
"kwargs",
".",
"get",
"... | enqueues a function with iterable arguments | [
"enqueues",
"a",
"function",
"with",
"iterable",
"arguments"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L395-L417 | train |
Koed00/django-q | django_q/tasks.py | _sync | def _sync(pack):
"""Simulate a package travelling through the cluster."""
task_queue = Queue()
result_queue = Queue()
task = SignedPackage.loads(pack)
task_queue.put(task)
task_queue.put('STOP')
worker(task_queue, result_queue, Value('f', -1))
result_queue.put('STOP')
monitor(result_... | python | def _sync(pack):
"""Simulate a package travelling through the cluster."""
task_queue = Queue()
result_queue = Queue()
task = SignedPackage.loads(pack)
task_queue.put(task)
task_queue.put('STOP')
worker(task_queue, result_queue, Value('f', -1))
result_queue.put('STOP')
monitor(result_... | [
"def",
"_sync",
"(",
"pack",
")",
":",
"task_queue",
"=",
"Queue",
"(",
")",
"result_queue",
"=",
"Queue",
"(",
")",
"task",
"=",
"SignedPackage",
".",
"loads",
"(",
"pack",
")",
"task_queue",
".",
"put",
"(",
"task",
")",
"task_queue",
".",
"put",
"... | Simulate a package travelling through the cluster. | [
"Simulate",
"a",
"package",
"travelling",
"through",
"the",
"cluster",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L677-L691 | train |
Koed00/django-q | django_q/tasks.py | Iter.append | def append(self, *args):
"""
add arguments to the set
"""
self.args.append(args)
if self.started:
self.started = False
return self.length() | python | def append(self, *args):
"""
add arguments to the set
"""
self.args.append(args)
if self.started:
self.started = False
return self.length() | [
"def",
"append",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"args",
".",
"append",
"(",
"args",
")",
"if",
"self",
".",
"started",
":",
"self",
".",
"started",
"=",
"False",
"return",
"self",
".",
"length",
"(",
")"
] | add arguments to the set | [
"add",
"arguments",
"to",
"the",
"set"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L460-L467 | train |
Koed00/django-q | django_q/admin.py | retry_failed | def retry_failed(FailAdmin, request, queryset):
"""Submit selected tasks back to the queue."""
for task in queryset:
async_task(task.func, *task.args or (), hook=task.hook, **task.kwargs or {})
task.delete() | python | def retry_failed(FailAdmin, request, queryset):
"""Submit selected tasks back to the queue."""
for task in queryset:
async_task(task.func, *task.args or (), hook=task.hook, **task.kwargs or {})
task.delete() | [
"def",
"retry_failed",
"(",
"FailAdmin",
",",
"request",
",",
"queryset",
")",
":",
"for",
"task",
"in",
"queryset",
":",
"async_task",
"(",
"task",
".",
"func",
",",
"*",
"task",
".",
"args",
"or",
"(",
")",
",",
"hook",
"=",
"task",
".",
"hook",
... | Submit selected tasks back to the queue. | [
"Submit",
"selected",
"tasks",
"back",
"to",
"the",
"queue",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L40-L44 | train |
Koed00/django-q | django_q/admin.py | TaskAdmin.get_queryset | def get_queryset(self, request):
"""Only show successes."""
qs = super(TaskAdmin, self).get_queryset(request)
return qs.filter(success=True) | python | def get_queryset(self, request):
"""Only show successes."""
qs = super(TaskAdmin, self).get_queryset(request)
return qs.filter(success=True) | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"TaskAdmin",
",",
"self",
")",
".",
"get_queryset",
"(",
"request",
")",
"return",
"qs",
".",
"filter",
"(",
"success",
"=",
"True",
")"
] | Only show successes. | [
"Only",
"show",
"successes",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L26-L29 | train |
Koed00/django-q | django_q/admin.py | TaskAdmin.get_readonly_fields | def get_readonly_fields(self, request, obj=None):
"""Set all fields readonly."""
return list(self.readonly_fields) + [field.name for field in obj._meta.fields] | python | def get_readonly_fields(self, request, obj=None):
"""Set all fields readonly."""
return list(self.readonly_fields) + [field.name for field in obj._meta.fields] | [
"def",
"get_readonly_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"list",
"(",
"self",
".",
"readonly_fields",
")",
"+",
"[",
"field",
".",
"name",
"for",
"field",
"in",
"obj",
".",
"_meta",
".",
"fields",
"]"
] | Set all fields readonly. | [
"Set",
"all",
"fields",
"readonly",
"."
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/admin.py#L35-L37 | train |
Koed00/django-q | django_q/cluster.py | save_task | def save_task(task, broker):
"""
Saves the task package to Django or the cache
"""
# SAVE LIMIT < 0 : Don't save success
if not task.get('save', Conf.SAVE_LIMIT >= 0) and task['success']:
return
# enqueues next in a chain
if task.get('chain', None):
django_q.tasks.async_chain... | python | def save_task(task, broker):
"""
Saves the task package to Django or the cache
"""
# SAVE LIMIT < 0 : Don't save success
if not task.get('save', Conf.SAVE_LIMIT >= 0) and task['success']:
return
# enqueues next in a chain
if task.get('chain', None):
django_q.tasks.async_chain... | [
"def",
"save_task",
"(",
"task",
",",
"broker",
")",
":",
"# SAVE LIMIT < 0 : Don't save success",
"if",
"not",
"task",
".",
"get",
"(",
"'save'",
",",
"Conf",
".",
"SAVE_LIMIT",
">=",
"0",
")",
"and",
"task",
"[",
"'success'",
"]",
":",
"return",
"# enque... | Saves the task package to Django or the cache | [
"Saves",
"the",
"task",
"package",
"to",
"Django",
"or",
"the",
"cache"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/cluster.py#L400-L438 | train |
Koed00/django-q | django_q/cluster.py | scheduler | def scheduler(broker=None):
"""
Creates a task from a schedule at the scheduled time and schedules next run
"""
if not broker:
broker = get_broker()
db.close_old_connections()
try:
for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()):
args ... | python | def scheduler(broker=None):
"""
Creates a task from a schedule at the scheduled time and schedules next run
"""
if not broker:
broker = get_broker()
db.close_old_connections()
try:
for s in Schedule.objects.exclude(repeats=0).filter(next_run__lt=timezone.now()):
args ... | [
"def",
"scheduler",
"(",
"broker",
"=",
"None",
")",
":",
"if",
"not",
"broker",
":",
"broker",
"=",
"get_broker",
"(",
")",
"db",
".",
"close_old_connections",
"(",
")",
"try",
":",
"for",
"s",
"in",
"Schedule",
".",
"objects",
".",
"exclude",
"(",
... | Creates a task from a schedule at the scheduled time and schedules next run | [
"Creates",
"a",
"task",
"from",
"a",
"schedule",
"at",
"the",
"scheduled",
"time",
"and",
"schedules",
"next",
"run"
] | c84fd11a67c9a47d821786dfcdc189bb258c6f54 | https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/cluster.py#L486-L557 | train |
google/python-adb | adb/adb_commands.py | AdbCommands._get_service_connection | def _get_service_connection(self, service, service_command=None, create=True, timeout_ms=None):
"""
Based on the service, get the AdbConnection for that service or create one if it doesnt exist
:param service:
:param service_command: Additional service parameters to append
:para... | python | def _get_service_connection(self, service, service_command=None, create=True, timeout_ms=None):
"""
Based on the service, get the AdbConnection for that service or create one if it doesnt exist
:param service:
:param service_command: Additional service parameters to append
:para... | [
"def",
"_get_service_connection",
"(",
"self",
",",
"service",
",",
"service_command",
"=",
"None",
",",
"create",
"=",
"True",
",",
"timeout_ms",
"=",
"None",
")",
":",
"connection",
"=",
"self",
".",
"_service_connections",
".",
"get",
"(",
"service",
",",... | Based on the service, get the AdbConnection for that service or create one if it doesnt exist
:param service:
:param service_command: Additional service parameters to append
:param create: If False, dont create a connection if it does not exist
:return: | [
"Based",
"on",
"the",
"service",
"get",
"the",
"AdbConnection",
"for",
"that",
"service",
"or",
"create",
"one",
"if",
"it",
"doesnt",
"exist"
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L71-L99 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.ConnectDevice | def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, **kwargs):
"""Convenience function to setup a transport handle for the adb device from
usb path or serial then connect to it.
Args:
port_path: The filename of usb port to use.
serial: The seri... | python | def ConnectDevice(self, port_path=None, serial=None, default_timeout_ms=None, **kwargs):
"""Convenience function to setup a transport handle for the adb device from
usb path or serial then connect to it.
Args:
port_path: The filename of usb port to use.
serial: The seri... | [
"def",
"ConnectDevice",
"(",
"self",
",",
"port_path",
"=",
"None",
",",
"serial",
"=",
"None",
",",
"default_timeout_ms",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# If there isnt a handle override (used by tests), build one here",
"if",
"'handle'",
"in",
... | Convenience function to setup a transport handle for the adb device from
usb path or serial then connect to it.
Args:
port_path: The filename of usb port to use.
serial: The serial number of the device to use.
default_timeout_ms: The default timeout in milliseconds to... | [
"Convenience",
"function",
"to",
"setup",
"a",
"transport",
"handle",
"for",
"the",
"adb",
"device",
"from",
"usb",
"path",
"or",
"serial",
"then",
"connect",
"to",
"it",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L101-L144 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.Install | def Install(self, apk_path, destination_dir='', replace_existing=True,
grant_permissions=False, timeout_ms=None, transfer_progress_callback=None):
"""Install an apk to the device.
Doesn't support verifier file, instead allows destination directory to be
overridden.
Args... | python | def Install(self, apk_path, destination_dir='', replace_existing=True,
grant_permissions=False, timeout_ms=None, transfer_progress_callback=None):
"""Install an apk to the device.
Doesn't support verifier file, instead allows destination directory to be
overridden.
Args... | [
"def",
"Install",
"(",
"self",
",",
"apk_path",
",",
"destination_dir",
"=",
"''",
",",
"replace_existing",
"=",
"True",
",",
"grant_permissions",
"=",
"False",
",",
"timeout_ms",
"=",
"None",
",",
"transfer_progress_callback",
"=",
"None",
")",
":",
"if",
"... | Install an apk to the device.
Doesn't support verifier file, instead allows destination directory to be
overridden.
Args:
apk_path: Local path to apk to install.
destination_dir: Optional destination directory. Use /system/app/ for
persistent applications.
... | [
"Install",
"an",
"apk",
"to",
"the",
"device",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L192-L230 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.Uninstall | def Uninstall(self, package_name, keep_data=False, timeout_ms=None):
"""Removes a package from the device.
Args:
package_name: Package name of target package.
keep_data: whether to keep the data and cache directories
timeout_ms: Expected timeout for pushing and installing.... | python | def Uninstall(self, package_name, keep_data=False, timeout_ms=None):
"""Removes a package from the device.
Args:
package_name: Package name of target package.
keep_data: whether to keep the data and cache directories
timeout_ms: Expected timeout for pushing and installing.... | [
"def",
"Uninstall",
"(",
"self",
",",
"package_name",
",",
"keep_data",
"=",
"False",
",",
"timeout_ms",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pm uninstall'",
"]",
"if",
"keep_data",
":",
"cmd",
".",
"append",
"(",
"'-k'",
")",
"cmd",
".",
"append"... | Removes a package from the device.
Args:
package_name: Package name of target package.
keep_data: whether to keep the data and cache directories
timeout_ms: Expected timeout for pushing and installing.
Returns:
The pm uninstall output. | [
"Removes",
"a",
"package",
"from",
"the",
"device",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L232-L248 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.Push | def Push(self, source_file, device_filename, mtime='0', timeout_ms=None, progress_callback=None, st_mode=None):
"""Push a file or directory to the device.
Args:
source_file: Either a filename, a directory or file-like object to push to
the device.
device_filen... | python | def Push(self, source_file, device_filename, mtime='0', timeout_ms=None, progress_callback=None, st_mode=None):
"""Push a file or directory to the device.
Args:
source_file: Either a filename, a directory or file-like object to push to
the device.
device_filen... | [
"def",
"Push",
"(",
"self",
",",
"source_file",
",",
"device_filename",
",",
"mtime",
"=",
"'0'",
",",
"timeout_ms",
"=",
"None",
",",
"progress_callback",
"=",
"None",
",",
"st_mode",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"source_file",
",",
"... | Push a file or directory to the device.
Args:
source_file: Either a filename, a directory or file-like object to push to
the device.
device_filename: Destination on the device to write to.
mtime: Optional, modification time to set on the file.
time... | [
"Push",
"a",
"file",
"or",
"directory",
"to",
"the",
"device",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L250-L281 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.Pull | def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callback=None):
"""Pull a file from the device.
Args:
device_filename: Filename on the device to pull.
dest_file: If set, a filename or writable file-like object.
timeout_ms: Expected timeout for any... | python | def Pull(self, device_filename, dest_file=None, timeout_ms=None, progress_callback=None):
"""Pull a file from the device.
Args:
device_filename: Filename on the device to pull.
dest_file: If set, a filename or writable file-like object.
timeout_ms: Expected timeout for any... | [
"def",
"Pull",
"(",
"self",
",",
"device_filename",
",",
"dest_file",
"=",
"None",
",",
"timeout_ms",
"=",
"None",
",",
"progress_callback",
"=",
"None",
")",
":",
"if",
"not",
"dest_file",
":",
"dest_file",
"=",
"io",
".",
"BytesIO",
"(",
")",
"elif",
... | Pull a file from the device.
Args:
device_filename: Filename on the device to pull.
dest_file: If set, a filename or writable file-like object.
timeout_ms: Expected timeout for any part of the pull.
progress_callback: callback method that accepts filename, bytes_written ... | [
"Pull",
"a",
"file",
"from",
"the",
"device",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L283-L318 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.List | def List(self, device_path):
"""Return a directory listing of the given path.
Args:
device_path: Directory to list.
"""
connection = self.protocol_handler.Open(self._handle, destination=b'sync:')
listing = self.filesync_handler.List(connection, device_path)
con... | python | def List(self, device_path):
"""Return a directory listing of the given path.
Args:
device_path: Directory to list.
"""
connection = self.protocol_handler.Open(self._handle, destination=b'sync:')
listing = self.filesync_handler.List(connection, device_path)
con... | [
"def",
"List",
"(",
"self",
",",
"device_path",
")",
":",
"connection",
"=",
"self",
".",
"protocol_handler",
".",
"Open",
"(",
"self",
".",
"_handle",
",",
"destination",
"=",
"b'sync:'",
")",
"listing",
"=",
"self",
".",
"filesync_handler",
".",
"List",
... | Return a directory listing of the given path.
Args:
device_path: Directory to list. | [
"Return",
"a",
"directory",
"listing",
"of",
"the",
"given",
"path",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L328-L337 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.Shell | def Shell(self, command, timeout_ms=None):
"""Run command on the device, returning the output.
Args:
command: Shell command to run
timeout_ms: Maximum time to allow the command to run.
"""
return self.protocol_handler.Command(
self._handle, service=b'shel... | python | def Shell(self, command, timeout_ms=None):
"""Run command on the device, returning the output.
Args:
command: Shell command to run
timeout_ms: Maximum time to allow the command to run.
"""
return self.protocol_handler.Command(
self._handle, service=b'shel... | [
"def",
"Shell",
"(",
"self",
",",
"command",
",",
"timeout_ms",
"=",
"None",
")",
":",
"return",
"self",
".",
"protocol_handler",
".",
"Command",
"(",
"self",
".",
"_handle",
",",
"service",
"=",
"b'shell'",
",",
"command",
"=",
"command",
",",
"timeout_... | Run command on the device, returning the output.
Args:
command: Shell command to run
timeout_ms: Maximum time to allow the command to run. | [
"Run",
"command",
"on",
"the",
"device",
"returning",
"the",
"output",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L367-L376 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.StreamingShell | def StreamingShell(self, command, timeout_ms=None):
"""Run command on the device, yielding each line of output.
Args:
command: Command to run on the target.
timeout_ms: Maximum time to allow the command to run.
Yields:
The responses from the shell command.
... | python | def StreamingShell(self, command, timeout_ms=None):
"""Run command on the device, yielding each line of output.
Args:
command: Command to run on the target.
timeout_ms: Maximum time to allow the command to run.
Yields:
The responses from the shell command.
... | [
"def",
"StreamingShell",
"(",
"self",
",",
"command",
",",
"timeout_ms",
"=",
"None",
")",
":",
"return",
"self",
".",
"protocol_handler",
".",
"StreamingCommand",
"(",
"self",
".",
"_handle",
",",
"service",
"=",
"b'shell'",
",",
"command",
"=",
"command",
... | Run command on the device, yielding each line of output.
Args:
command: Command to run on the target.
timeout_ms: Maximum time to allow the command to run.
Yields:
The responses from the shell command. | [
"Run",
"command",
"on",
"the",
"device",
"yielding",
"each",
"line",
"of",
"output",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L378-L390 | train |
google/python-adb | adb/adb_commands.py | AdbCommands.InteractiveShell | def InteractiveShell(self, cmd=None, strip_cmd=True, delim=None, strip_delim=True):
"""Get stdout from the currently open interactive shell and optionally run a command
on the device, returning all output.
Args:
cmd: Optional. Command to run on the target.
strip_cmd: Opt... | python | def InteractiveShell(self, cmd=None, strip_cmd=True, delim=None, strip_delim=True):
"""Get stdout from the currently open interactive shell and optionally run a command
on the device, returning all output.
Args:
cmd: Optional. Command to run on the target.
strip_cmd: Opt... | [
"def",
"InteractiveShell",
"(",
"self",
",",
"cmd",
"=",
"None",
",",
"strip_cmd",
"=",
"True",
",",
"delim",
"=",
"None",
",",
"strip_delim",
"=",
"True",
")",
":",
"conn",
"=",
"self",
".",
"_get_service_connection",
"(",
"b'shell:'",
")",
"return",
"s... | Get stdout from the currently open interactive shell and optionally run a command
on the device, returning all output.
Args:
cmd: Optional. Command to run on the target.
strip_cmd: Optional (default True). Strip command name from stdout.
delim: Optional. Delimiter to l... | [
"Get",
"stdout",
"from",
"the",
"currently",
"open",
"interactive",
"shell",
"and",
"optionally",
"run",
"a",
"command",
"on",
"the",
"device",
"returning",
"all",
"output",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/adb_commands.py#L401-L419 | train |
google/python-adb | adb/common.py | InterfaceMatcher | def InterfaceMatcher(clazz, subclass, protocol):
"""Returns a matcher that returns the setting with the given interface."""
interface = (clazz, subclass, protocol)
def Matcher(device):
for setting in device.iterSettings():
if GetInterface(setting) == interface:
return se... | python | def InterfaceMatcher(clazz, subclass, protocol):
"""Returns a matcher that returns the setting with the given interface."""
interface = (clazz, subclass, protocol)
def Matcher(device):
for setting in device.iterSettings():
if GetInterface(setting) == interface:
return se... | [
"def",
"InterfaceMatcher",
"(",
"clazz",
",",
"subclass",
",",
"protocol",
")",
":",
"interface",
"=",
"(",
"clazz",
",",
"subclass",
",",
"protocol",
")",
"def",
"Matcher",
"(",
"device",
")",
":",
"for",
"setting",
"in",
"device",
".",
"iterSettings",
... | Returns a matcher that returns the setting with the given interface. | [
"Returns",
"a",
"matcher",
"that",
"returns",
"the",
"setting",
"with",
"the",
"given",
"interface",
"."
] | d9b94b2dda555c14674c19806debb8449c0e9652 | https://github.com/google/python-adb/blob/d9b94b2dda555c14674c19806debb8449c0e9652/adb/common.py#L40-L49 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.