id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
221,800 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | make_client | def make_client(servers: Sequence[str], *args, **kwargs) -> GMatrixClient:
"""Given a list of possible servers, chooses the closest available and create a GMatrixClient
Params:
servers: list of servers urls, with scheme (http or https)
Rest of args and kwargs are forwarded to GMatrixClient cons... | python | def make_client(servers: Sequence[str], *args, **kwargs) -> GMatrixClient:
"""Given a list of possible servers, chooses the closest available and create a GMatrixClient
Params:
servers: list of servers urls, with scheme (http or https)
Rest of args and kwargs are forwarded to GMatrixClient cons... | [
"def",
"make_client",
"(",
"servers",
":",
"Sequence",
"[",
"str",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"GMatrixClient",
":",
"if",
"len",
"(",
"servers",
")",
">",
"1",
":",
"sorted_servers",
"=",
"[",
"server_url",
"for",
"(",... | Given a list of possible servers, chooses the closest available and create a GMatrixClient
Params:
servers: list of servers urls, with scheme (http or https)
Rest of args and kwargs are forwarded to GMatrixClient constructor
Returns:
GMatrixClient instance for one of the available serve... | [
"Given",
"a",
"list",
"of",
"possible",
"servers",
"chooses",
"the",
"closest",
"available",
"and",
"create",
"a",
"GMatrixClient"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L494-L532 |
221,801 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.add_userid_for_address | def add_userid_for_address(self, address: Address, user_id: str):
""" Add a ``user_id`` for the given ``address``.
Implicitly adds the address if it was unknown before.
"""
self._address_to_userids[address].add(user_id) | python | def add_userid_for_address(self, address: Address, user_id: str):
""" Add a ``user_id`` for the given ``address``.
Implicitly adds the address if it was unknown before.
"""
self._address_to_userids[address].add(user_id) | [
"def",
"add_userid_for_address",
"(",
"self",
",",
"address",
":",
"Address",
",",
"user_id",
":",
"str",
")",
":",
"self",
".",
"_address_to_userids",
"[",
"address",
"]",
".",
"add",
"(",
"user_id",
")"
] | Add a ``user_id`` for the given ``address``.
Implicitly adds the address if it was unknown before. | [
"Add",
"a",
"user_id",
"for",
"the",
"given",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L122-L127 |
221,802 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.add_userids_for_address | def add_userids_for_address(self, address: Address, user_ids: Iterable[str]):
""" Add multiple ``user_ids`` for the given ``address``.
Implicitly adds any addresses if they were unknown before.
"""
self._address_to_userids[address].update(user_ids) | python | def add_userids_for_address(self, address: Address, user_ids: Iterable[str]):
""" Add multiple ``user_ids`` for the given ``address``.
Implicitly adds any addresses if they were unknown before.
"""
self._address_to_userids[address].update(user_ids) | [
"def",
"add_userids_for_address",
"(",
"self",
",",
"address",
":",
"Address",
",",
"user_ids",
":",
"Iterable",
"[",
"str",
"]",
")",
":",
"self",
".",
"_address_to_userids",
"[",
"address",
"]",
".",
"update",
"(",
"user_ids",
")"
] | Add multiple ``user_ids`` for the given ``address``.
Implicitly adds any addresses if they were unknown before. | [
"Add",
"multiple",
"user_ids",
"for",
"the",
"given",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L129-L134 |
221,803 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.get_userids_for_address | def get_userids_for_address(self, address: Address) -> Set[str]:
""" Return all known user ids for the given ``address``. """
if not self.is_address_known(address):
return set()
return self._address_to_userids[address] | python | def get_userids_for_address(self, address: Address) -> Set[str]:
""" Return all known user ids for the given ``address``. """
if not self.is_address_known(address):
return set()
return self._address_to_userids[address] | [
"def",
"get_userids_for_address",
"(",
"self",
",",
"address",
":",
"Address",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"is_address_known",
"(",
"address",
")",
":",
"return",
"set",
"(",
")",
"return",
"self",
".",
"_address_to_... | Return all known user ids for the given ``address``. | [
"Return",
"all",
"known",
"user",
"ids",
"for",
"the",
"given",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L136-L140 |
221,804 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.get_userid_presence | def get_userid_presence(self, user_id: str) -> UserPresence:
""" Return the current presence state of ``user_id``. """
return self._userid_to_presence.get(user_id, UserPresence.UNKNOWN) | python | def get_userid_presence(self, user_id: str) -> UserPresence:
""" Return the current presence state of ``user_id``. """
return self._userid_to_presence.get(user_id, UserPresence.UNKNOWN) | [
"def",
"get_userid_presence",
"(",
"self",
",",
"user_id",
":",
"str",
")",
"->",
"UserPresence",
":",
"return",
"self",
".",
"_userid_to_presence",
".",
"get",
"(",
"user_id",
",",
"UserPresence",
".",
"UNKNOWN",
")"
] | Return the current presence state of ``user_id``. | [
"Return",
"the",
"current",
"presence",
"state",
"of",
"user_id",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L142-L144 |
221,805 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.get_address_reachability | def get_address_reachability(self, address: Address) -> AddressReachability:
""" Return the current reachability state for ``address``. """
return self._address_to_reachability.get(address, AddressReachability.UNKNOWN) | python | def get_address_reachability(self, address: Address) -> AddressReachability:
""" Return the current reachability state for ``address``. """
return self._address_to_reachability.get(address, AddressReachability.UNKNOWN) | [
"def",
"get_address_reachability",
"(",
"self",
",",
"address",
":",
"Address",
")",
"->",
"AddressReachability",
":",
"return",
"self",
".",
"_address_to_reachability",
".",
"get",
"(",
"address",
",",
"AddressReachability",
".",
"UNKNOWN",
")"
] | Return the current reachability state for ``address``. | [
"Return",
"the",
"current",
"reachability",
"state",
"for",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L146-L148 |
221,806 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.force_user_presence | def force_user_presence(self, user: User, presence: UserPresence):
""" Forcibly set the ``user`` presence to ``presence``.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should **not** generally be used.
"""
self._userid_to_presence[user... | python | def force_user_presence(self, user: User, presence: UserPresence):
""" Forcibly set the ``user`` presence to ``presence``.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should **not** generally be used.
"""
self._userid_to_presence[user... | [
"def",
"force_user_presence",
"(",
"self",
",",
"user",
":",
"User",
",",
"presence",
":",
"UserPresence",
")",
":",
"self",
".",
"_userid_to_presence",
"[",
"user",
".",
"user_id",
"]",
"=",
"presence"
] | Forcibly set the ``user`` presence to ``presence``.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should **not** generally be used. | [
"Forcibly",
"set",
"the",
"user",
"presence",
"to",
"presence",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L150-L156 |
221,807 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager.refresh_address_presence | def refresh_address_presence(self, address):
"""
Update synthesized address presence state from cached user presence states.
Triggers callback (if any) in case the state has changed.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should... | python | def refresh_address_presence(self, address):
"""
Update synthesized address presence state from cached user presence states.
Triggers callback (if any) in case the state has changed.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should... | [
"def",
"refresh_address_presence",
"(",
"self",
",",
"address",
")",
":",
"composite_presence",
"=",
"{",
"self",
".",
"_fetch_user_presence",
"(",
"uid",
")",
"for",
"uid",
"in",
"self",
".",
"_address_to_userids",
"[",
"address",
"]",
"}",
"# Iterate over User... | Update synthesized address presence state from cached user presence states.
Triggers callback (if any) in case the state has changed.
This method is only provided to cover an edge case in our use of the Matrix protocol and
should **not** generally be used. | [
"Update",
"synthesized",
"address",
"presence",
"state",
"from",
"cached",
"user",
"presence",
"states",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L158-L194 |
221,808 | raiden-network/raiden | raiden/network/transport/matrix/utils.py | UserAddressManager._presence_listener | def _presence_listener(self, event: Dict[str, Any]):
"""
Update cached user presence state from Matrix presence events.
Due to the possibility of nodes using accounts on multiple homeservers a composite
address state is synthesised from the cached individual user presence states.
... | python | def _presence_listener(self, event: Dict[str, Any]):
"""
Update cached user presence state from Matrix presence events.
Due to the possibility of nodes using accounts on multiple homeservers a composite
address state is synthesised from the cached individual user presence states.
... | [
"def",
"_presence_listener",
"(",
"self",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"if",
"self",
".",
"_stop_event",
".",
"ready",
"(",
")",
":",
"return",
"user_id",
"=",
"event",
"[",
"'sender'",
"]",
"if",
"event",
"[",
... | Update cached user presence state from Matrix presence events.
Due to the possibility of nodes using accounts on multiple homeservers a composite
address state is synthesised from the cached individual user presence states. | [
"Update",
"cached",
"user",
"presence",
"state",
"from",
"Matrix",
"presence",
"events",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/utils.py#L196-L230 |
221,809 | raiden-network/raiden | raiden/tasks.py | check_version | def check_version(current_version: str):
""" Check periodically for a new release """
app_version = parse_version(current_version)
while True:
try:
_do_check_version(app_version)
except requests.exceptions.HTTPError as herr:
click.secho('Error while checking for versi... | python | def check_version(current_version: str):
""" Check periodically for a new release """
app_version = parse_version(current_version)
while True:
try:
_do_check_version(app_version)
except requests.exceptions.HTTPError as herr:
click.secho('Error while checking for versi... | [
"def",
"check_version",
"(",
"current_version",
":",
"str",
")",
":",
"app_version",
"=",
"parse_version",
"(",
"current_version",
")",
"while",
"True",
":",
"try",
":",
"_do_check_version",
"(",
"app_version",
")",
"except",
"requests",
".",
"exceptions",
".",
... | Check periodically for a new release | [
"Check",
"periodically",
"for",
"a",
"new",
"release"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L59-L73 |
221,810 | raiden-network/raiden | raiden/tasks.py | check_gas_reserve | def check_gas_reserve(raiden):
""" Check periodically for gas reserve in the account """
while True:
has_enough_balance, estimated_required_balance = gas_reserve.has_enough_gas_reserve(
raiden,
channels_to_open=1,
)
estimated_required_balance_eth = Web3.fromWei(es... | python | def check_gas_reserve(raiden):
""" Check periodically for gas reserve in the account """
while True:
has_enough_balance, estimated_required_balance = gas_reserve.has_enough_gas_reserve(
raiden,
channels_to_open=1,
)
estimated_required_balance_eth = Web3.fromWei(es... | [
"def",
"check_gas_reserve",
"(",
"raiden",
")",
":",
"while",
"True",
":",
"has_enough_balance",
",",
"estimated_required_balance",
"=",
"gas_reserve",
".",
"has_enough_gas_reserve",
"(",
"raiden",
",",
"channels_to_open",
"=",
"1",
",",
")",
"estimated_required_balan... | Check periodically for gas reserve in the account | [
"Check",
"periodically",
"for",
"gas",
"reserve",
"in",
"the",
"account"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L76-L98 |
221,811 | raiden-network/raiden | raiden/tasks.py | check_rdn_deposits | def check_rdn_deposits(raiden, user_deposit_proxy: UserDeposit):
""" Check periodically for RDN deposits in the user-deposits contract """
while True:
rei_balance = user_deposit_proxy.effective_balance(raiden.address, "latest")
rdn_balance = to_rdn(rei_balance)
if rei_balance < MIN_REI_T... | python | def check_rdn_deposits(raiden, user_deposit_proxy: UserDeposit):
""" Check periodically for RDN deposits in the user-deposits contract """
while True:
rei_balance = user_deposit_proxy.effective_balance(raiden.address, "latest")
rdn_balance = to_rdn(rei_balance)
if rei_balance < MIN_REI_T... | [
"def",
"check_rdn_deposits",
"(",
"raiden",
",",
"user_deposit_proxy",
":",
"UserDeposit",
")",
":",
"while",
"True",
":",
"rei_balance",
"=",
"user_deposit_proxy",
".",
"effective_balance",
"(",
"raiden",
".",
"address",
",",
"\"latest\"",
")",
"rdn_balance",
"="... | Check periodically for RDN deposits in the user-deposits contract | [
"Check",
"periodically",
"for",
"RDN",
"deposits",
"in",
"the",
"user",
"-",
"deposits",
"contract"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L101-L119 |
221,812 | raiden-network/raiden | raiden/tasks.py | check_network_id | def check_network_id(network_id, web3: Web3):
""" Check periodically if the underlying ethereum client's network id has changed"""
while True:
current_id = int(web3.version.network)
if network_id != current_id:
raise RuntimeError(
f'Raiden was running on network with ... | python | def check_network_id(network_id, web3: Web3):
""" Check periodically if the underlying ethereum client's network id has changed"""
while True:
current_id = int(web3.version.network)
if network_id != current_id:
raise RuntimeError(
f'Raiden was running on network with ... | [
"def",
"check_network_id",
"(",
"network_id",
",",
"web3",
":",
"Web3",
")",
":",
"while",
"True",
":",
"current_id",
"=",
"int",
"(",
"web3",
".",
"version",
".",
"network",
")",
"if",
"network_id",
"!=",
"current_id",
":",
"raise",
"RuntimeError",
"(",
... | Check periodically if the underlying ethereum client's network id has changed | [
"Check",
"periodically",
"if",
"the",
"underlying",
"ethereum",
"client",
"s",
"network",
"id",
"has",
"changed"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L122-L133 |
221,813 | raiden-network/raiden | raiden/tasks.py | AlarmTask.register_callback | def register_callback(self, callback):
""" Register a new callback.
Note:
The callback will be executed in the AlarmTask context and for
this reason it should not block, otherwise we can miss block
changes.
"""
if not callable(callback):
r... | python | def register_callback(self, callback):
""" Register a new callback.
Note:
The callback will be executed in the AlarmTask context and for
this reason it should not block, otherwise we can miss block
changes.
"""
if not callable(callback):
r... | [
"def",
"register_callback",
"(",
"self",
",",
"callback",
")",
":",
"if",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"ValueError",
"(",
"'callback is not a callable'",
")",
"self",
".",
"callbacks",
".",
"append",
"(",
"callback",
")"
] | Register a new callback.
Note:
The callback will be executed in the AlarmTask context and for
this reason it should not block, otherwise we can miss block
changes. | [
"Register",
"a",
"new",
"callback",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L171-L182 |
221,814 | raiden-network/raiden | raiden/tasks.py | AlarmTask.remove_callback | def remove_callback(self, callback):
"""Remove callback from the list of callbacks if it exists"""
if callback in self.callbacks:
self.callbacks.remove(callback) | python | def remove_callback(self, callback):
"""Remove callback from the list of callbacks if it exists"""
if callback in self.callbacks:
self.callbacks.remove(callback) | [
"def",
"remove_callback",
"(",
"self",
",",
"callback",
")",
":",
"if",
"callback",
"in",
"self",
".",
"callbacks",
":",
"self",
".",
"callbacks",
".",
"remove",
"(",
"callback",
")"
] | Remove callback from the list of callbacks if it exists | [
"Remove",
"callback",
"from",
"the",
"list",
"of",
"callbacks",
"if",
"it",
"exists"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L184-L187 |
221,815 | raiden-network/raiden | raiden/tasks.py | AlarmTask.first_run | def first_run(self, known_block_number):
""" Blocking call to update the local state, if necessary. """
assert self.callbacks, 'callbacks not set'
latest_block = self.chain.get_block(block_identifier='latest')
log.debug(
'Alarm task first run',
known_block_number... | python | def first_run(self, known_block_number):
""" Blocking call to update the local state, if necessary. """
assert self.callbacks, 'callbacks not set'
latest_block = self.chain.get_block(block_identifier='latest')
log.debug(
'Alarm task first run',
known_block_number... | [
"def",
"first_run",
"(",
"self",
",",
"known_block_number",
")",
":",
"assert",
"self",
".",
"callbacks",
",",
"'callbacks not set'",
"latest_block",
"=",
"self",
".",
"chain",
".",
"get_block",
"(",
"block_identifier",
"=",
"'latest'",
")",
"log",
".",
"debug... | Blocking call to update the local state, if necessary. | [
"Blocking",
"call",
"to",
"update",
"the",
"local",
"state",
"if",
"necessary",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L207-L222 |
221,816 | raiden-network/raiden | raiden/tasks.py | AlarmTask._maybe_run_callbacks | def _maybe_run_callbacks(self, latest_block):
""" Run the callbacks if there is at least one new block.
The callbacks are executed only if there is a new block, otherwise the
filters may try to poll for an inexisting block number and the Ethereum
client can return an JSON-RPC error.
... | python | def _maybe_run_callbacks(self, latest_block):
""" Run the callbacks if there is at least one new block.
The callbacks are executed only if there is a new block, otherwise the
filters may try to poll for an inexisting block number and the Ethereum
client can return an JSON-RPC error.
... | [
"def",
"_maybe_run_callbacks",
"(",
"self",
",",
"latest_block",
")",
":",
"assert",
"self",
".",
"known_block_number",
"is",
"not",
"None",
",",
"'known_block_number not set'",
"latest_block_number",
"=",
"latest_block",
"[",
"'number'",
"]",
"missed_blocks",
"=",
... | Run the callbacks if there is at least one new block.
The callbacks are executed only if there is a new block, otherwise the
filters may try to poll for an inexisting block number and the Ethereum
client can return an JSON-RPC error. | [
"Run",
"the",
"callbacks",
"if",
"there",
"is",
"at",
"least",
"one",
"new",
"block",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/tasks.py#L224-L269 |
221,817 | raiden-network/raiden | raiden/storage/restore.py | channel_state_until_state_change | def channel_state_until_state_change(
raiden,
canonical_identifier: CanonicalIdentifier,
state_change_identifier: int,
) -> typing.Optional[NettingChannelState]:
""" Go through WAL state changes until a certain balance hash is found. """
wal = restore_to_state_change(
transition_... | python | def channel_state_until_state_change(
raiden,
canonical_identifier: CanonicalIdentifier,
state_change_identifier: int,
) -> typing.Optional[NettingChannelState]:
""" Go through WAL state changes until a certain balance hash is found. """
wal = restore_to_state_change(
transition_... | [
"def",
"channel_state_until_state_change",
"(",
"raiden",
",",
"canonical_identifier",
":",
"CanonicalIdentifier",
",",
"state_change_identifier",
":",
"int",
",",
")",
"->",
"typing",
".",
"Optional",
"[",
"NettingChannelState",
"]",
":",
"wal",
"=",
"restore_to_stat... | Go through WAL state changes until a certain balance hash is found. | [
"Go",
"through",
"WAL",
"state",
"changes",
"until",
"a",
"certain",
"balance",
"hash",
"is",
"found",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/restore.py#L10-L36 |
221,818 | raiden-network/raiden | raiden/utils/signing.py | pack_data | def pack_data(abi_types, values) -> bytes:
"""Normalize data and pack them into a byte array"""
if len(abi_types) != len(values):
raise ValueError(
"Length mismatch between provided abi types and values. Got "
"{0} types and {1} values.".format(len(abi_types), len(values)),
... | python | def pack_data(abi_types, values) -> bytes:
"""Normalize data and pack them into a byte array"""
if len(abi_types) != len(values):
raise ValueError(
"Length mismatch between provided abi types and values. Got "
"{0} types and {1} values.".format(len(abi_types), len(values)),
... | [
"def",
"pack_data",
"(",
"abi_types",
",",
"values",
")",
"->",
"bytes",
":",
"if",
"len",
"(",
"abi_types",
")",
"!=",
"len",
"(",
"values",
")",
":",
"raise",
"ValueError",
"(",
"\"Length mismatch between provided abi types and values. Got \"",
"\"{0} types and {... | Normalize data and pack them into a byte array | [
"Normalize",
"data",
"and",
"pack",
"them",
"into",
"a",
"byte",
"array"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/signing.py#L9-L23 |
221,819 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | _RetryQueue._expiration_generator | def _expiration_generator(
timeout_generator: Iterable[float],
now: Callable[[], float] = time.time,
) -> Iterator[bool]:
"""Stateful generator that yields True if more than timeout has passed since previous True,
False otherwise.
Helper method to tell when a message... | python | def _expiration_generator(
timeout_generator: Iterable[float],
now: Callable[[], float] = time.time,
) -> Iterator[bool]:
"""Stateful generator that yields True if more than timeout has passed since previous True,
False otherwise.
Helper method to tell when a message... | [
"def",
"_expiration_generator",
"(",
"timeout_generator",
":",
"Iterable",
"[",
"float",
"]",
",",
"now",
":",
"Callable",
"[",
"[",
"]",
",",
"float",
"]",
"=",
"time",
".",
"time",
",",
")",
"->",
"Iterator",
"[",
"bool",
"]",
":",
"for",
"timeout",
... | Stateful generator that yields True if more than timeout has passed since previous True,
False otherwise.
Helper method to tell when a message needs to be retried (more than timeout seconds
passed since last time it was sent).
timeout is iteratively fetched from timeout_generator
... | [
"Stateful",
"generator",
"that",
"yields",
"True",
"if",
"more",
"than",
"timeout",
"has",
"passed",
"since",
"previous",
"True",
"False",
"otherwise",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L117-L133 |
221,820 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | _RetryQueue.enqueue | def enqueue(self, queue_identifier: QueueIdentifier, message: Message):
""" Enqueue a message to be sent, and notify main loop """
assert queue_identifier.recipient == self.receiver
with self._lock:
already_queued = any(
queue_identifier == data.queue_identifier and m... | python | def enqueue(self, queue_identifier: QueueIdentifier, message: Message):
""" Enqueue a message to be sent, and notify main loop """
assert queue_identifier.recipient == self.receiver
with self._lock:
already_queued = any(
queue_identifier == data.queue_identifier and m... | [
"def",
"enqueue",
"(",
"self",
",",
"queue_identifier",
":",
"QueueIdentifier",
",",
"message",
":",
"Message",
")",
":",
"assert",
"queue_identifier",
".",
"recipient",
"==",
"self",
".",
"receiver",
"with",
"self",
".",
"_lock",
":",
"already_queued",
"=",
... | Enqueue a message to be sent, and notify main loop | [
"Enqueue",
"a",
"message",
"to",
"be",
"sent",
"and",
"notify",
"main",
"loop"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L135-L163 |
221,821 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport.stop | def stop(self):
""" Try to gracefully stop the greenlet synchronously
Stop isn't expected to re-raise greenlet _run exception
(use self.greenlet.get() for that),
but it should raise any stop-time exception """
if self._stop_event.ready():
return
self._stop_ev... | python | def stop(self):
""" Try to gracefully stop the greenlet synchronously
Stop isn't expected to re-raise greenlet _run exception
(use self.greenlet.get() for that),
but it should raise any stop-time exception """
if self._stop_event.ready():
return
self._stop_ev... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stop_event",
".",
"ready",
"(",
")",
":",
"return",
"self",
".",
"_stop_event",
".",
"set",
"(",
")",
"self",
".",
"_global_send_event",
".",
"set",
"(",
")",
"for",
"retrier",
"in",
"self",
... | Try to gracefully stop the greenlet synchronously
Stop isn't expected to re-raise greenlet _run exception
(use self.greenlet.get() for that),
but it should raise any stop-time exception | [
"Try",
"to",
"gracefully",
"stop",
"the",
"greenlet",
"synchronously"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L434-L459 |
221,822 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport.whitelist | def whitelist(self, address: Address):
"""Whitelist peer address to receive communications from
This may be called before transport is started, to ensure events generated during
start are handled properly.
"""
self.log.debug('Whitelist', address=to_normalized_address(address))
... | python | def whitelist(self, address: Address):
"""Whitelist peer address to receive communications from
This may be called before transport is started, to ensure events generated during
start are handled properly.
"""
self.log.debug('Whitelist', address=to_normalized_address(address))
... | [
"def",
"whitelist",
"(",
"self",
",",
"address",
":",
"Address",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Whitelist'",
",",
"address",
"=",
"to_normalized_address",
"(",
"address",
")",
")",
"self",
".",
"_address_mgr",
".",
"add_address",
"(",
... | Whitelist peer address to receive communications from
This may be called before transport is started, to ensure events generated during
start are handled properly. | [
"Whitelist",
"peer",
"address",
"to",
"receive",
"communications",
"from"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L476-L483 |
221,823 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport.send_async | def send_async(
self,
queue_identifier: QueueIdentifier,
message: Message,
):
"""Queue the message for sending to recipient in the queue_identifier
It may be called before transport is started, to initialize message queues
The actual sending is started on... | python | def send_async(
self,
queue_identifier: QueueIdentifier,
message: Message,
):
"""Queue the message for sending to recipient in the queue_identifier
It may be called before transport is started, to initialize message queues
The actual sending is started on... | [
"def",
"send_async",
"(",
"self",
",",
"queue_identifier",
":",
"QueueIdentifier",
",",
"message",
":",
"Message",
",",
")",
":",
"# even if transport is not started, can run to enqueue messages to send when it starts",
"receiver_address",
"=",
"queue_identifier",
".",
"recip... | Queue the message for sending to recipient in the queue_identifier
It may be called before transport is started, to initialize message queues
The actual sending is started only when the transport is started | [
"Queue",
"the",
"message",
"for",
"sending",
"to",
"recipient",
"in",
"the",
"queue_identifier"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L516-L545 |
221,824 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport.send_global | def send_global(self, room: str, message: Message) -> None:
"""Sends a message to one of the global rooms
These rooms aren't being listened on and therefore no reply could be heard, so these
messages are sent in a send-and-forget async way.
The actual room name is composed from the suff... | python | def send_global(self, room: str, message: Message) -> None:
"""Sends a message to one of the global rooms
These rooms aren't being listened on and therefore no reply could be heard, so these
messages are sent in a send-and-forget async way.
The actual room name is composed from the suff... | [
"def",
"send_global",
"(",
"self",
",",
"room",
":",
"str",
",",
"message",
":",
"Message",
")",
"->",
"None",
":",
"self",
".",
"_global_send_queue",
".",
"put",
"(",
"(",
"room",
",",
"message",
")",
")",
"self",
".",
"_global_send_event",
".",
"set"... | Sends a message to one of the global rooms
These rooms aren't being listened on and therefore no reply could be heard, so these
messages are sent in a send-and-forget async way.
The actual room name is composed from the suffix given as parameter and chain name or id
e.g.: raiden_ropsten... | [
"Sends",
"a",
"message",
"to",
"one",
"of",
"the",
"global",
"rooms"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L547-L559 |
221,825 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._handle_invite | def _handle_invite(self, room_id: _RoomID, state: dict):
""" Join rooms invited by whitelisted partners """
if self._stop_event.ready():
return
self.log.debug('Got invite', room_id=room_id)
invite_events = [
event
for event in state['events']
... | python | def _handle_invite(self, room_id: _RoomID, state: dict):
""" Join rooms invited by whitelisted partners """
if self._stop_event.ready():
return
self.log.debug('Got invite', room_id=room_id)
invite_events = [
event
for event in state['events']
... | [
"def",
"_handle_invite",
"(",
"self",
",",
"room_id",
":",
"_RoomID",
",",
"state",
":",
"dict",
")",
":",
"if",
"self",
".",
"_stop_event",
".",
"ready",
"(",
")",
":",
"return",
"self",
".",
"log",
".",
"debug",
"(",
"'Got invite'",
",",
"room_id",
... | Join rooms invited by whitelisted partners | [
"Join",
"rooms",
"invited",
"by",
"whitelisted",
"partners"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L644-L739 |
221,826 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._get_retrier | def _get_retrier(self, receiver: Address) -> _RetryQueue:
""" Construct and return a _RetryQueue for receiver """
if receiver not in self._address_to_retrier:
retrier = _RetryQueue(transport=self, receiver=receiver)
self._address_to_retrier[receiver] = retrier
# Alway... | python | def _get_retrier(self, receiver: Address) -> _RetryQueue:
""" Construct and return a _RetryQueue for receiver """
if receiver not in self._address_to_retrier:
retrier = _RetryQueue(transport=self, receiver=receiver)
self._address_to_retrier[receiver] = retrier
# Alway... | [
"def",
"_get_retrier",
"(",
"self",
",",
"receiver",
":",
"Address",
")",
"->",
"_RetryQueue",
":",
"if",
"receiver",
"not",
"in",
"self",
".",
"_address_to_retrier",
":",
"retrier",
"=",
"_RetryQueue",
"(",
"transport",
"=",
"self",
",",
"receiver",
"=",
... | Construct and return a _RetryQueue for receiver | [
"Construct",
"and",
"return",
"a",
"_RetryQueue",
"for",
"receiver"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L951-L961 |
221,827 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._get_private_room | def _get_private_room(self, invitees: List[User]):
""" Create an anonymous, private room and invite peers """
return self._client.create_room(
None,
invitees=[user.user_id for user in invitees],
is_public=False,
) | python | def _get_private_room(self, invitees: List[User]):
""" Create an anonymous, private room and invite peers """
return self._client.create_room(
None,
invitees=[user.user_id for user in invitees],
is_public=False,
) | [
"def",
"_get_private_room",
"(",
"self",
",",
"invitees",
":",
"List",
"[",
"User",
"]",
")",
":",
"return",
"self",
".",
"_client",
".",
"create_room",
"(",
"None",
",",
"invitees",
"=",
"[",
"user",
".",
"user_id",
"for",
"user",
"in",
"invitees",
"]... | Create an anonymous, private room and invite peers | [
"Create",
"an",
"anonymous",
"private",
"room",
"and",
"invite",
"peers"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1078-L1084 |
221,828 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._sign | def _sign(self, data: bytes) -> bytes:
""" Use eth_sign compatible hasher to sign matrix data """
assert self._raiden_service is not None
return self._raiden_service.signer.sign(data=data) | python | def _sign(self, data: bytes) -> bytes:
""" Use eth_sign compatible hasher to sign matrix data """
assert self._raiden_service is not None
return self._raiden_service.signer.sign(data=data) | [
"def",
"_sign",
"(",
"self",
",",
"data",
":",
"bytes",
")",
"->",
"bytes",
":",
"assert",
"self",
".",
"_raiden_service",
"is",
"not",
"None",
"return",
"self",
".",
"_raiden_service",
".",
"signer",
".",
"sign",
"(",
"data",
"=",
"data",
")"
] | Use eth_sign compatible hasher to sign matrix data | [
"Use",
"eth_sign",
"compatible",
"hasher",
"to",
"sign",
"matrix",
"data"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1207-L1210 |
221,829 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._get_user | def _get_user(self, user: Union[User, str]) -> User:
"""Creates an User from an user_id, if none, or fetch a cached User
As all users are supposed to be in discovery room, its members dict is used for caching"""
user_id: str = getattr(user, 'user_id', user)
discovery_room = self._global... | python | def _get_user(self, user: Union[User, str]) -> User:
"""Creates an User from an user_id, if none, or fetch a cached User
As all users are supposed to be in discovery room, its members dict is used for caching"""
user_id: str = getattr(user, 'user_id', user)
discovery_room = self._global... | [
"def",
"_get_user",
"(",
"self",
",",
"user",
":",
"Union",
"[",
"User",
",",
"str",
"]",
")",
"->",
"User",
":",
"user_id",
":",
"str",
"=",
"getattr",
"(",
"user",
",",
"'user_id'",
",",
"user",
")",
"discovery_room",
"=",
"self",
".",
"_global_roo... | Creates an User from an user_id, if none, or fetch a cached User
As all users are supposed to be in discovery room, its members dict is used for caching | [
"Creates",
"an",
"User",
"from",
"an",
"user_id",
"if",
"none",
"or",
"fetch",
"a",
"cached",
"User"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1212-L1229 |
221,830 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._set_room_id_for_address | def _set_room_id_for_address(self, address: Address, room_id: Optional[_RoomID] = None):
""" Uses GMatrixClient.set_account_data to keep updated mapping of addresses->rooms
If room_id is falsy, clean list of rooms. Else, push room_id to front of the list """
assert not room_id or room_id in se... | python | def _set_room_id_for_address(self, address: Address, room_id: Optional[_RoomID] = None):
""" Uses GMatrixClient.set_account_data to keep updated mapping of addresses->rooms
If room_id is falsy, clean list of rooms. Else, push room_id to front of the list """
assert not room_id or room_id in se... | [
"def",
"_set_room_id_for_address",
"(",
"self",
",",
"address",
":",
"Address",
",",
"room_id",
":",
"Optional",
"[",
"_RoomID",
"]",
"=",
"None",
")",
":",
"assert",
"not",
"room_id",
"or",
"room_id",
"in",
"self",
".",
"_client",
".",
"rooms",
",",
"'I... | Uses GMatrixClient.set_account_data to keep updated mapping of addresses->rooms
If room_id is falsy, clean list of rooms. Else, push room_id to front of the list | [
"Uses",
"GMatrixClient",
".",
"set_account_data",
"to",
"keep",
"updated",
"mapping",
"of",
"addresses",
"-",
">",
"rooms"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1231-L1262 |
221,831 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._get_room_ids_for_address | def _get_room_ids_for_address(
self,
address: Address,
filter_private: bool = None,
) -> List[_RoomID]:
""" Uses GMatrixClient.get_account_data to get updated mapping of address->rooms
It'll filter only existing rooms.
If filter_private=True, also filter ... | python | def _get_room_ids_for_address(
self,
address: Address,
filter_private: bool = None,
) -> List[_RoomID]:
""" Uses GMatrixClient.get_account_data to get updated mapping of address->rooms
It'll filter only existing rooms.
If filter_private=True, also filter ... | [
"def",
"_get_room_ids_for_address",
"(",
"self",
",",
"address",
":",
"Address",
",",
"filter_private",
":",
"bool",
"=",
"None",
",",
")",
"->",
"List",
"[",
"_RoomID",
"]",
":",
"address_hex",
":",
"AddressHex",
"=",
"to_checksum_address",
"(",
"address",
... | Uses GMatrixClient.get_account_data to get updated mapping of address->rooms
It'll filter only existing rooms.
If filter_private=True, also filter out public rooms.
If filter_private=None, filter according to self._private_rooms | [
"Uses",
"GMatrixClient",
".",
"get_account_data",
"to",
"get",
"updated",
"mapping",
"of",
"address",
"-",
">",
"rooms"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1264-L1304 |
221,832 | raiden-network/raiden | raiden/network/transport/matrix/transport.py | MatrixTransport._leave_unused_rooms | def _leave_unused_rooms(self, _address_to_room_ids: Dict[AddressHex, List[_RoomID]]):
"""
Checks for rooms we've joined and which partner isn't health-checked and leave.
**MUST** be called from a context that holds the `_account_data_lock`.
"""
_msg = '_leave_unused_rooms called... | python | def _leave_unused_rooms(self, _address_to_room_ids: Dict[AddressHex, List[_RoomID]]):
"""
Checks for rooms we've joined and which partner isn't health-checked and leave.
**MUST** be called from a context that holds the `_account_data_lock`.
"""
_msg = '_leave_unused_rooms called... | [
"def",
"_leave_unused_rooms",
"(",
"self",
",",
"_address_to_room_ids",
":",
"Dict",
"[",
"AddressHex",
",",
"List",
"[",
"_RoomID",
"]",
"]",
")",
":",
"_msg",
"=",
"'_leave_unused_rooms called without account data lock'",
"assert",
"self",
".",
"_account_data_lock",... | Checks for rooms we've joined and which partner isn't health-checked and leave.
**MUST** be called from a context that holds the `_account_data_lock`. | [
"Checks",
"for",
"rooms",
"we",
"ve",
"joined",
"and",
"which",
"partner",
"isn",
"t",
"health",
"-",
"checked",
"and",
"leave",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/matrix/transport.py#L1306-L1386 |
221,833 | raiden-network/raiden | tools/scenario-player/scenario_player/scenario.py | NodesConfig.nodes | def nodes(self) -> List[str]:
"""Return the list of nodes configured in the scenario's yaml.
Should the scenario use version 1, we check if there is a 'setting'.
If so, we derive the list of nodes from this dictionary, using its
'first', 'last' and 'template' keys. Should any of these k... | python | def nodes(self) -> List[str]:
"""Return the list of nodes configured in the scenario's yaml.
Should the scenario use version 1, we check if there is a 'setting'.
If so, we derive the list of nodes from this dictionary, using its
'first', 'last' and 'template' keys. Should any of these k... | [
"def",
"nodes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"self",
".",
"_scenario_version",
"==",
"1",
"and",
"'range'",
"in",
"self",
".",
"_config",
":",
"range_config",
"=",
"self",
".",
"_config",
"[",
"'range'",
"]",
"try",
":"... | Return the list of nodes configured in the scenario's yaml.
Should the scenario use version 1, we check if there is a 'setting'.
If so, we derive the list of nodes from this dictionary, using its
'first', 'last' and 'template' keys. Should any of these keys be
missing, we throw an appro... | [
"Return",
"the",
"list",
"of",
"nodes",
"configured",
"in",
"the",
"scenario",
"s",
"yaml",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/scenario.py#L82-L121 |
221,834 | raiden-network/raiden | tools/scenario-player/scenario_player/scenario.py | Scenario.version | def version(self) -> int:
"""Return the scenario's version.
If this is not present, we default to version 1.
:raises InvalidScenarioVersion:
if the supplied version is not present in :var:`SUPPORTED_SCENARIO_VERSIONS`.
"""
version = self._config.get('version', 1)
... | python | def version(self) -> int:
"""Return the scenario's version.
If this is not present, we default to version 1.
:raises InvalidScenarioVersion:
if the supplied version is not present in :var:`SUPPORTED_SCENARIO_VERSIONS`.
"""
version = self._config.get('version', 1)
... | [
"def",
"version",
"(",
"self",
")",
"->",
"int",
":",
"version",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'version'",
",",
"1",
")",
"if",
"version",
"not",
"in",
"SUPPORTED_SCENARIO_VERSIONS",
":",
"raise",
"InvalidScenarioVersion",
"(",
"f'Unexpected... | Return the scenario's version.
If this is not present, we default to version 1.
:raises InvalidScenarioVersion:
if the supplied version is not present in :var:`SUPPORTED_SCENARIO_VERSIONS`. | [
"Return",
"the",
"scenario",
"s",
"version",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/scenario.py#L155-L167 |
221,835 | raiden-network/raiden | tools/scenario-player/scenario_player/scenario.py | Scenario.protocol | def protocol(self) -> str:
"""Return the designated protocol of the scenario.
If the node's mode is :attr:`NodeMode.MANAGED`, we always choose `http` and
display a warning if there was a 'protocol' set explicitly in the
scenario's yaml.
Otherwise we simply access the 'protocol'... | python | def protocol(self) -> str:
"""Return the designated protocol of the scenario.
If the node's mode is :attr:`NodeMode.MANAGED`, we always choose `http` and
display a warning if there was a 'protocol' set explicitly in the
scenario's yaml.
Otherwise we simply access the 'protocol'... | [
"def",
"protocol",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"nodes",
".",
"mode",
"is",
"NodeMode",
".",
"MANAGED",
":",
"if",
"'protocol'",
"in",
"self",
".",
"_config",
":",
"log",
".",
"warning",
"(",
"'The \"protocol\" setting is not supp... | Return the designated protocol of the scenario.
If the node's mode is :attr:`NodeMode.MANAGED`, we always choose `http` and
display a warning if there was a 'protocol' set explicitly in the
scenario's yaml.
Otherwise we simply access the 'protocol' key of the yaml, defaulting to
... | [
"Return",
"the",
"designated",
"protocol",
"of",
"the",
"scenario",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/scenario.py#L180-L194 |
221,836 | raiden-network/raiden | tools/scenario-player/scenario_player/scenario.py | Scenario.task | def task(self) -> Tuple[str, Any]:
"""Return the scenario's task configuration as a tuple.
:raises MultipleTaskDefinitions:
if there is more than one task config under the 'scenario' key.
"""
try:
items, = self.configuration.items()
except ValueError:
... | python | def task(self) -> Tuple[str, Any]:
"""Return the scenario's task configuration as a tuple.
:raises MultipleTaskDefinitions:
if there is more than one task config under the 'scenario' key.
"""
try:
items, = self.configuration.items()
except ValueError:
... | [
"def",
"task",
"(",
"self",
")",
"->",
"Tuple",
"[",
"str",
",",
"Any",
"]",
":",
"try",
":",
"items",
",",
"=",
"self",
".",
"configuration",
".",
"items",
"(",
")",
"except",
"ValueError",
":",
"raise",
"MultipleTaskDefinitions",
"(",
"'Multiple tasks ... | Return the scenario's task configuration as a tuple.
:raises MultipleTaskDefinitions:
if there is more than one task config under the 'scenario' key. | [
"Return",
"the",
"scenario",
"s",
"task",
"configuration",
"as",
"a",
"tuple",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/scenario.py#L250-L262 |
221,837 | raiden-network/raiden | tools/scenario-player/scenario_player/scenario.py | Scenario.task_class | def task_class(self):
"""Return the Task class type configured for the scenario."""
from scenario_player.tasks.base import get_task_class_for_type
root_task_type, _ = self.task
task_class = get_task_class_for_type(root_task_type)
return task_class | python | def task_class(self):
"""Return the Task class type configured for the scenario."""
from scenario_player.tasks.base import get_task_class_for_type
root_task_type, _ = self.task
task_class = get_task_class_for_type(root_task_type)
return task_class | [
"def",
"task_class",
"(",
"self",
")",
":",
"from",
"scenario_player",
".",
"tasks",
".",
"base",
"import",
"get_task_class_for_type",
"root_task_type",
",",
"_",
"=",
"self",
".",
"task",
"task_class",
"=",
"get_task_class_for_type",
"(",
"root_task_type",
")",
... | Return the Task class type configured for the scenario. | [
"Return",
"the",
"Task",
"class",
"type",
"configured",
"for",
"the",
"scenario",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/scenario.py#L271-L278 |
221,838 | raiden-network/raiden | tools/check_circleci_config.py | _check_workflows_align | def _check_workflows_align(config):
"""
Ensure that the common shared jobs in the `raiden-default` and `nightly` workflows are
identical.
"""
jobs_default = config['workflows']['raiden-default']['jobs']
jobs_nightly = config['workflows']['nightly']['jobs']
if jobs_default == jobs_nightly[:... | python | def _check_workflows_align(config):
"""
Ensure that the common shared jobs in the `raiden-default` and `nightly` workflows are
identical.
"""
jobs_default = config['workflows']['raiden-default']['jobs']
jobs_nightly = config['workflows']['nightly']['jobs']
if jobs_default == jobs_nightly[:... | [
"def",
"_check_workflows_align",
"(",
"config",
")",
":",
"jobs_default",
"=",
"config",
"[",
"'workflows'",
"]",
"[",
"'raiden-default'",
"]",
"[",
"'jobs'",
"]",
"jobs_nightly",
"=",
"config",
"[",
"'workflows'",
"]",
"[",
"'nightly'",
"]",
"[",
"'jobs'",
... | Ensure that the common shared jobs in the `raiden-default` and `nightly` workflows are
identical. | [
"Ensure",
"that",
"the",
"common",
"shared",
"jobs",
"in",
"the",
"raiden",
"-",
"default",
"and",
"nightly",
"workflows",
"are",
"identical",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/check_circleci_config.py#L26-L58 |
221,839 | raiden-network/raiden | raiden/network/rpc/smartcontract_proxy.py | ContractProxy.get_transaction_data | def get_transaction_data(
abi: Dict,
function_name: str,
args: Any = None,
kwargs: Any = None,
):
"""Get encoded transaction data"""
args = args or list()
fn_abi = find_matching_fn_abi(
abi,
function_name,
ar... | python | def get_transaction_data(
abi: Dict,
function_name: str,
args: Any = None,
kwargs: Any = None,
):
"""Get encoded transaction data"""
args = args or list()
fn_abi = find_matching_fn_abi(
abi,
function_name,
ar... | [
"def",
"get_transaction_data",
"(",
"abi",
":",
"Dict",
",",
"function_name",
":",
"str",
",",
"args",
":",
"Any",
"=",
"None",
",",
"kwargs",
":",
"Any",
"=",
"None",
",",
")",
":",
"args",
"=",
"args",
"or",
"list",
"(",
")",
"fn_abi",
"=",
"find... | Get encoded transaction data | [
"Get",
"encoded",
"transaction",
"data"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/smartcontract_proxy.py#L140-L161 |
221,840 | raiden-network/raiden | raiden/network/rpc/smartcontract_proxy.py | ContractProxy.decode_transaction_input | def decode_transaction_input(self, transaction_hash: bytes) -> Dict:
"""Return inputs of a method call"""
transaction = self.contract.web3.eth.getTransaction(
transaction_hash,
)
return self.contract.decode_function_input(
transaction['input'],
) | python | def decode_transaction_input(self, transaction_hash: bytes) -> Dict:
"""Return inputs of a method call"""
transaction = self.contract.web3.eth.getTransaction(
transaction_hash,
)
return self.contract.decode_function_input(
transaction['input'],
) | [
"def",
"decode_transaction_input",
"(",
"self",
",",
"transaction_hash",
":",
"bytes",
")",
"->",
"Dict",
":",
"transaction",
"=",
"self",
".",
"contract",
".",
"web3",
".",
"eth",
".",
"getTransaction",
"(",
"transaction_hash",
",",
")",
"return",
"self",
"... | Return inputs of a method call | [
"Return",
"inputs",
"of",
"a",
"method",
"call"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/smartcontract_proxy.py#L163-L171 |
221,841 | raiden-network/raiden | raiden/network/rpc/smartcontract_proxy.py | ContractProxy.estimate_gas | def estimate_gas(
self,
block_identifier,
function: str,
*args,
**kwargs,
) -> typing.Optional[int]:
"""Returns a gas estimate for the function with the given arguments or
None if the function call will fail due to Insufficient funds or
... | python | def estimate_gas(
self,
block_identifier,
function: str,
*args,
**kwargs,
) -> typing.Optional[int]:
"""Returns a gas estimate for the function with the given arguments or
None if the function call will fail due to Insufficient funds or
... | [
"def",
"estimate_gas",
"(",
"self",
",",
"block_identifier",
",",
"function",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
",",
")",
"->",
"typing",
".",
"Optional",
"[",
"int",
"]",
":",
"fn",
"=",
"getattr",
"(",
"self",
".",
"contract",
... | Returns a gas estimate for the function with the given arguments or
None if the function call will fail due to Insufficient funds or
the logic in the called function. | [
"Returns",
"a",
"gas",
"estimate",
"for",
"the",
"function",
"with",
"the",
"given",
"arguments",
"or",
"None",
"if",
"the",
"function",
"call",
"will",
"fail",
"due",
"to",
"Insufficient",
"funds",
"or",
"the",
"logic",
"in",
"the",
"called",
"function",
... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/smartcontract_proxy.py#L179-L218 |
221,842 | raiden-network/raiden | raiden/messages.py | SignedMessage.sign | def sign(self, signer: Signer):
""" Sign message using signer. """
message_data = self._data_to_sign()
self.signature = signer.sign(data=message_data) | python | def sign(self, signer: Signer):
""" Sign message using signer. """
message_data = self._data_to_sign()
self.signature = signer.sign(data=message_data) | [
"def",
"sign",
"(",
"self",
",",
"signer",
":",
"Signer",
")",
":",
"message_data",
"=",
"self",
".",
"_data_to_sign",
"(",
")",
"self",
".",
"signature",
"=",
"signer",
".",
"sign",
"(",
"data",
"=",
"message_data",
")"
] | Sign message using signer. | [
"Sign",
"message",
"using",
"signer",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/messages.py#L282-L285 |
221,843 | raiden-network/raiden | raiden/messages.py | SignedBlindedBalanceProof._sign | def _sign(self, signer: Signer) -> Signature:
"""Internal function for the overall `sign` function of `RequestMonitoring`.
"""
# Important: we don't write the signature to `.signature`
data = self._data_to_sign()
return signer.sign(data) | python | def _sign(self, signer: Signer) -> Signature:
"""Internal function for the overall `sign` function of `RequestMonitoring`.
"""
# Important: we don't write the signature to `.signature`
data = self._data_to_sign()
return signer.sign(data) | [
"def",
"_sign",
"(",
"self",
",",
"signer",
":",
"Signer",
")",
"->",
"Signature",
":",
"# Important: we don't write the signature to `.signature`",
"data",
"=",
"self",
".",
"_data_to_sign",
"(",
")",
"return",
"signer",
".",
"sign",
"(",
"data",
")"
] | Internal function for the overall `sign` function of `RequestMonitoring`. | [
"Internal",
"function",
"for",
"the",
"overall",
"sign",
"function",
"of",
"RequestMonitoring",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/messages.py#L1590-L1595 |
221,844 | raiden-network/raiden | raiden/messages.py | RequestMonitoring.verify_request_monitoring | def verify_request_monitoring(
self,
partner_address: Address,
requesting_address: Address,
) -> bool:
""" One should only use this method to verify integrity and signatures of a
RequestMonitoring message. """
if not self.non_closing_signature:
... | python | def verify_request_monitoring(
self,
partner_address: Address,
requesting_address: Address,
) -> bool:
""" One should only use this method to verify integrity and signatures of a
RequestMonitoring message. """
if not self.non_closing_signature:
... | [
"def",
"verify_request_monitoring",
"(",
"self",
",",
"partner_address",
":",
"Address",
",",
"requesting_address",
":",
"Address",
",",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"non_closing_signature",
":",
"return",
"False",
"balance_proof_data",
"=",
... | One should only use this method to verify integrity and signatures of a
RequestMonitoring message. | [
"One",
"should",
"only",
"use",
"this",
"method",
"to",
"verify",
"integrity",
"and",
"signatures",
"of",
"a",
"RequestMonitoring",
"message",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/messages.py#L1780-L1824 |
221,845 | raiden-network/raiden | raiden/utils/filters.py | get_filter_args_for_specific_event_from_channel | def get_filter_args_for_specific_event_from_channel(
token_network_address: TokenNetworkAddress,
channel_identifier: ChannelID,
event_name: str,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'lates... | python | def get_filter_args_for_specific_event_from_channel(
token_network_address: TokenNetworkAddress,
channel_identifier: ChannelID,
event_name: str,
contract_manager: ContractManager,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'lates... | [
"def",
"get_filter_args_for_specific_event_from_channel",
"(",
"token_network_address",
":",
"TokenNetworkAddress",
",",
"channel_identifier",
":",
"ChannelID",
",",
"event_name",
":",
"str",
",",
"contract_manager",
":",
"ContractManager",
",",
"from_block",
":",
"BlockSpe... | Return the filter params for a specific event of a given channel. | [
"Return",
"the",
"filter",
"params",
"for",
"a",
"specific",
"event",
"of",
"a",
"given",
"channel",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/filters.py#L32-L59 |
221,846 | 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 |
221,847 | 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 |
221,848 | 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 |
221,849 | 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 |
221,850 | 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 |
221,851 | 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 |
221,852 | 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 |
221,853 | 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 |
221,854 | 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 |
221,855 | 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 |
221,856 | 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 |
221,857 | 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 |
221,858 | 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 |
221,859 | 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 |
221,860 | 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 |
221,861 | 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 |
221,862 | 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 |
221,863 | 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 |
221,864 | 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 |
221,865 | 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 |
221,866 | 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 |
221,867 | 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 |
221,868 | 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 |
221,869 | 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 |
221,870 | 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 |
221,871 | 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 |
221,872 | 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 |
221,873 | 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 |
221,874 | 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 |
221,875 | 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 |
221,876 | 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 |
221,877 | 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 |
221,878 | 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 |
221,879 | 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 |
221,880 | 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 |
221,881 | 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 |
221,882 | 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 |
221,883 | 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 |
221,884 | 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 |
221,885 | 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 |
221,886 | 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 |
221,887 | 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 |
221,888 | 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 |
221,889 | 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 |
221,890 | 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 |
221,891 | 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 |
221,892 | 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 |
221,893 | 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 |
221,894 | 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 |
221,895 | 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 |
221,896 | 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 |
221,897 | 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 |
221,898 | 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 |
221,899 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.