hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5dcbfa6c61cfc50797f0b8d79391fad7decc5c29 | tianyikillua/ratpmetro | ratpmetro/main.py | [
"MIT"
] | Python | _define_incidents | null | def _define_incidents(self):
"""
Define some keywords for identifying incidents from RATP tweets
"""
# Keywords for operational incidents
self.incident_words = ["perturbé", "interrompu", "ralenti"]
# Incident causes and their keywords
# Question: incident voie -... |
Define some keywords for identifying incidents from RATP tweets
| Define some keywords for identifying incidents from RATP tweets | [
"Define",
"some",
"keywords",
"for",
"identifying",
"incidents",
"from",
"RATP",
"tweets"
] | def _define_incidents(self):
self.incident_words = ["perturbé", "interrompu", "ralenti"]
self.incident_causes = {
"colis": ["colis", "bagage"],
"technique": [
"technique",
"panne",
"exploitation",
"fumée",
... | [
"def",
"_define_incidents",
"(",
"self",
")",
":",
"self",
".",
"incident_words",
"=",
"[",
"\"perturbé\",",
" ",
"interrompu\",",
" ",
"ralenti\"]",
"",
"self",
".",
"incident_causes",
"=",
"{",
"\"colis\"",
":",
"[",
"\"colis\"",
",",
"\"bagage\"",
"]",
",... | Define some keywords for identifying incidents from RATP tweets | [
"Define",
"some",
"keywords",
"for",
"identifying",
"incidents",
"from",
"RATP",
"tweets"
] | [
"\"\"\"\n Define some keywords for identifying incidents from RATP tweets\n \"\"\"",
"# Keywords for operational incidents",
"# Incident causes and their keywords",
"# Question: incident voie -> autre ?",
"# diver incident -> autre ?",
"# Some tweets are incomplete (thank you Twit... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f4d413d9fb0d2dca478e13f79473b2d11f95983 | Wecros/aoc-2021 | day15/part1.py | [
"MIT"
] | Python | dijkstra | <not_specific> | def dijkstra(grid, start, end):
"""Dijsktra algorithm to find the shortest path.
Returns map with visited nodes as keys and the shortest path possible to them.
"""
unvisited = {(x, y): math.inf for x in range(WIDTH) for y in range(HEIGHT)}
visited = {}
current = start
current_risk = 0
... | Dijsktra algorithm to find the shortest path.
Returns map with visited nodes as keys and the shortest path possible to them.
| Dijsktra algorithm to find the shortest path.
Returns map with visited nodes as keys and the shortest path possible to them. | [
"Dijsktra",
"algorithm",
"to",
"find",
"the",
"shortest",
"path",
".",
"Returns",
"map",
"with",
"visited",
"nodes",
"as",
"keys",
"and",
"the",
"shortest",
"path",
"possible",
"to",
"them",
"."
] | def dijkstra(grid, start, end):
unvisited = {(x, y): math.inf for x in range(WIDTH) for y in range(HEIGHT)}
visited = {}
current = start
current_risk = 0
while True:
x, y = current
for x2, y2 in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
if (x2, y2) not in unvisite... | [
"def",
"dijkstra",
"(",
"grid",
",",
"start",
",",
"end",
")",
":",
"unvisited",
"=",
"{",
"(",
"x",
",",
"y",
")",
":",
"math",
".",
"inf",
"for",
"x",
"in",
"range",
"(",
"WIDTH",
")",
"for",
"y",
"in",
"range",
"(",
"HEIGHT",
")",
"}",
"vi... | Dijsktra algorithm to find the shortest path. | [
"Dijsktra",
"algorithm",
"to",
"find",
"the",
"shortest",
"path",
"."
] | [
"\"\"\"Dijsktra algorithm to find the shortest path.\n\n Returns map with visited nodes as keys and the shortest path possible to them.\n \"\"\""
] | [
{
"param": "grid",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "grid",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start",
"type": null,
"docstring": null,
"docstring_tokens": ... |
163051f6561fac820ebccefa227603cee55ee3d0 | Wecros/aoc-2021 | day6/part2.py | [
"MIT"
] | Python | start_spawning | <not_specific> | def start_spawning(days, day_keys):
"""Calculate every day key for "1" fish number. Other fishes are then get by offsetting
day keys dictionary."""
day_keys[0] = 1
days_fish_count = {0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
for day in range(1, days + 1):
day_keys[day] = da... | Calculate every day key for "1" fish number. Other fishes are then get by offsetting
day keys dictionary. | Calculate every day key for "1" fish number. Other fishes are then get by offsetting
day keys dictionary. | [
"Calculate",
"every",
"day",
"key",
"for",
"\"",
"1",
"\"",
"fish",
"number",
".",
"Other",
"fishes",
"are",
"then",
"get",
"by",
"offsetting",
"day",
"keys",
"dictionary",
"."
] | def start_spawning(days, day_keys):
day_keys[0] = 1
days_fish_count = {0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
for day in range(1, days + 1):
day_keys[day] = days_fish_count[0]
days_fish_count[OLD_FISH + 1] += days_fish_count[0]
days_fish_count[NEW_FISH + 1] += da... | [
"def",
"start_spawning",
"(",
"days",
",",
"day_keys",
")",
":",
"day_keys",
"[",
"0",
"]",
"=",
"1",
"days_fish_count",
"=",
"{",
"0",
":",
"0",
",",
"1",
":",
"1",
",",
"2",
":",
"0",
",",
"3",
":",
"0",
",",
"4",
":",
"0",
",",
"5",
":",... | Calculate every day key for "1" fish number. | [
"Calculate",
"every",
"day",
"key",
"for",
"\"",
"1",
"\"",
"fish",
"number",
"."
] | [
"\"\"\"Calculate every day key for \"1\" fish number. Other fishes are then get by offsetting\n day keys dictionary.\"\"\""
] | [
{
"param": "days",
"type": null
},
{
"param": "day_keys",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "days",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "day_keys",
"type": null,
"docstring": null,
"docstring_tokens... |
a9a6178a27a18877fd641bf9499157bc1e306f51 | fossabot/ironic-inspector | ironic_inspector/plugins/local_link_connection.py | [
"Apache-2.0"
] | Python | before_update | null | def before_update(self, introspection_data, node_info, **kwargs):
"""Process LLDP data and patch Ironic port local link connection"""
inventory = utils.get_inventory(introspection_data)
ironic_ports = node_info.ports()
for iface in inventory['interfaces']:
if iface['name'] ... | Process LLDP data and patch Ironic port local link connection | Process LLDP data and patch Ironic port local link connection | [
"Process",
"LLDP",
"data",
"and",
"patch",
"Ironic",
"port",
"local",
"link",
"connection"
] | def before_update(self, introspection_data, node_info, **kwargs):
inventory = utils.get_inventory(introspection_data)
ironic_ports = node_info.ports()
for iface in inventory['interfaces']:
if iface['name'] not in introspection_data['all_interfaces']:
continue
... | [
"def",
"before_update",
"(",
"self",
",",
"introspection_data",
",",
"node_info",
",",
"**",
"kwargs",
")",
":",
"inventory",
"=",
"utils",
".",
"get_inventory",
"(",
"introspection_data",
")",
"ironic_ports",
"=",
"node_info",
".",
"ports",
"(",
")",
"for",
... | Process LLDP data and patch Ironic port local link connection | [
"Process",
"LLDP",
"data",
"and",
"patch",
"Ironic",
"port",
"local",
"link",
"connection"
] | [
"\"\"\"Process LLDP data and patch Ironic port local link connection\"\"\"",
"# First check if lldp data was already processed by lldp_basic",
"# plugin which stores data in 'all_interfaces'",
"# If no processed lldp data was available then parse raw lldp data"
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
},
{
"param": "node_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | _process_root_device_hints | <not_specific> | def _process_root_device_hints(self, introspection_data, node_info,
inventory):
"""Detect root disk from root device hints and IPA inventory."""
hints = node_info.node().properties.get('root_device')
if not hints:
LOG.debug('Root device hints are no... | Detect root disk from root device hints and IPA inventory. | Detect root disk from root device hints and IPA inventory. | [
"Detect",
"root",
"disk",
"from",
"root",
"device",
"hints",
"and",
"IPA",
"inventory",
"."
] | def _process_root_device_hints(self, introspection_data, node_info,
inventory):
hints = node_info.node().properties.get('root_device')
if not hints:
LOG.debug('Root device hints are not provided',
node_info=node_info, data=introspectio... | [
"def",
"_process_root_device_hints",
"(",
"self",
",",
"introspection_data",
",",
"node_info",
",",
"inventory",
")",
":",
"hints",
"=",
"node_info",
".",
"node",
"(",
")",
".",
"properties",
".",
"get",
"(",
"'root_device'",
")",
"if",
"not",
"hints",
":",
... | Detect root disk from root device hints and IPA inventory. | [
"Detect",
"root",
"disk",
"from",
"root",
"device",
"hints",
"and",
"IPA",
"inventory",
"."
] | [
"\"\"\"Detect root disk from root device hints and IPA inventory.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
},
{
"param": "node_info",
"type": null
},
{
"param": "inventory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | before_update | null | def before_update(self, introspection_data, node_info, **kwargs):
"""Update node with scheduler properties."""
inventory = utils.get_inventory(introspection_data,
node_info=node_info)
try:
introspection_data['cpus'] = int(inventory['cpu']['coun... | Update node with scheduler properties. | Update node with scheduler properties. | [
"Update",
"node",
"with",
"scheduler",
"properties",
"."
] | def before_update(self, introspection_data, node_info, **kwargs):
inventory = utils.get_inventory(introspection_data,
node_info=node_info)
try:
introspection_data['cpus'] = int(inventory['cpu']['count'])
introspection_data['cpu_arch'] = str... | [
"def",
"before_update",
"(",
"self",
",",
"introspection_data",
",",
"node_info",
",",
"**",
"kwargs",
")",
":",
"inventory",
"=",
"utils",
".",
"get_inventory",
"(",
"introspection_data",
",",
"node_info",
"=",
"node_info",
")",
"try",
":",
"introspection_data"... | Update node with scheduler properties. | [
"Update",
"node",
"with",
"scheduler",
"properties",
"."
] | [
"\"\"\"Update node with scheduler properties.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
},
{
"param": "node_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | _get_interfaces | <not_specific> | def _get_interfaces(self, data=None):
"""Convert inventory to a dict with interfaces.
:return: dict interface name -> dict with keys 'mac' and 'ip'
"""
result = {}
inventory = utils.get_inventory(data)
pxe_mac = utils.get_pxe_mac(data)
for iface in inventory['i... | Convert inventory to a dict with interfaces.
:return: dict interface name -> dict with keys 'mac' and 'ip'
| Convert inventory to a dict with interfaces. | [
"Convert",
"inventory",
"to",
"a",
"dict",
"with",
"interfaces",
"."
] | def _get_interfaces(self, data=None):
result = {}
inventory = utils.get_inventory(data)
pxe_mac = utils.get_pxe_mac(data)
for iface in inventory['interfaces']:
name = iface.get('name')
mac = iface.get('mac_address')
ipv4_address = iface.get('ipv4_addre... | [
"def",
"_get_interfaces",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"result",
"=",
"{",
"}",
"inventory",
"=",
"utils",
".",
"get_inventory",
"(",
"data",
")",
"pxe_mac",
"=",
"utils",
".",
"get_pxe_mac",
"(",
"data",
")",
"for",
"iface",
"in",
... | Convert inventory to a dict with interfaces. | [
"Convert",
"inventory",
"to",
"a",
"dict",
"with",
"interfaces",
"."
] | [
"\"\"\"Convert inventory to a dict with interfaces.\n\n :return: dict interface name -> dict with keys 'mac' and 'ip'\n \"\"\"",
"# NOTE(kaifeng) ipv6 address may in the form of fd00::1%enp2s0,",
"# which is not supported by netaddr, remove the suffix if exists."
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [
{
"docstring": "dict interface name -> dict with keys 'mac' and 'ip'",
"docstring_tokens": [
"dict",
"interface",
"name",
"-",
">",
"dict",
"with",
"keys",
"'",
"mac",
"'",
"and",
"'"... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | _validate_interfaces | <not_specific> | def _validate_interfaces(self, interfaces, data=None):
"""Validate interfaces on correctness and suitability.
:return: dict interface name -> dict with keys 'mac' and 'ip'
"""
if not interfaces:
raise utils.Error(_('No interfaces supplied by the ramdisk'),
... | Validate interfaces on correctness and suitability.
:return: dict interface name -> dict with keys 'mac' and 'ip'
| Validate interfaces on correctness and suitability. | [
"Validate",
"interfaces",
"on",
"correctness",
"and",
"suitability",
"."
] | def _validate_interfaces(self, interfaces, data=None):
if not interfaces:
raise utils.Error(_('No interfaces supplied by the ramdisk'),
data=data)
pxe_mac = utils.get_pxe_mac(data)
if not pxe_mac and CONF.processing.add_ports == 'pxe':
LOG.wa... | [
"def",
"_validate_interfaces",
"(",
"self",
",",
"interfaces",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"interfaces",
":",
"raise",
"utils",
".",
"Error",
"(",
"_",
"(",
"'No interfaces supplied by the ramdisk'",
")",
",",
"data",
"=",
"data",
")",
... | Validate interfaces on correctness and suitability. | [
"Validate",
"interfaces",
"on",
"correctness",
"and",
"suitability",
"."
] | [
"\"\"\"Validate interfaces on correctness and suitability.\n\n :return: dict interface name -> dict with keys 'mac' and 'ip'\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "interfaces",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [
{
"docstring": "dict interface name -> dict with keys 'mac' and 'ip'",
"docstring_tokens": [
"dict",
"interface",
"name",
"-",
">",
"dict",
"with",
"keys",
"'",
"mac",
"'",
"and",
"'"... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | before_processing | null | def before_processing(self, introspection_data, **kwargs):
"""Validate information about network interfaces."""
bmc_address = utils.get_ipmi_address_from_data(introspection_data)
bmc_v6address = utils.get_ipmi_v6address_from_data(introspection_data)
# Overwrite the old ipmi_address fiel... | Validate information about network interfaces. | Validate information about network interfaces. | [
"Validate",
"information",
"about",
"network",
"interfaces",
"."
] | def before_processing(self, introspection_data, **kwargs):
bmc_address = utils.get_ipmi_address_from_data(introspection_data)
bmc_v6address = utils.get_ipmi_v6address_from_data(introspection_data)
introspection_data['ipmi_address'] = bmc_address
introspection_data['ipmi_v6address'] = bmc... | [
"def",
"before_processing",
"(",
"self",
",",
"introspection_data",
",",
"**",
"kwargs",
")",
":",
"bmc_address",
"=",
"utils",
".",
"get_ipmi_address_from_data",
"(",
"introspection_data",
")",
"bmc_v6address",
"=",
"utils",
".",
"get_ipmi_v6address_from_data",
"(",
... | Validate information about network interfaces. | [
"Validate",
"information",
"about",
"network",
"interfaces",
"."
] | [
"\"\"\"Validate information about network interfaces.\"\"\"",
"# Overwrite the old ipmi_address field to avoid inconsistency"
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
47078da698aab59327aaac34f72d0c2db636455c | fossabot/ironic-inspector | ironic_inspector/plugins/standard.py | [
"Apache-2.0"
] | Python | before_update | <not_specific> | def before_update(self, introspection_data, node_info, **kwargs):
"""Create new ports and drop ports that are not present in the data."""
interfaces = introspection_data.get('interfaces')
if CONF.processing.add_ports != 'disabled':
node_info.create_ports(list(interfaces.values()))
... | Create new ports and drop ports that are not present in the data. | Create new ports and drop ports that are not present in the data. | [
"Create",
"new",
"ports",
"and",
"drop",
"ports",
"that",
"are",
"not",
"present",
"in",
"the",
"data",
"."
] | def before_update(self, introspection_data, node_info, **kwargs):
interfaces = introspection_data.get('interfaces')
if CONF.processing.add_ports != 'disabled':
node_info.create_ports(list(interfaces.values()))
if CONF.processing.keep_ports == 'present':
expected_macs = {
... | [
"def",
"before_update",
"(",
"self",
",",
"introspection_data",
",",
"node_info",
",",
"**",
"kwargs",
")",
":",
"interfaces",
"=",
"introspection_data",
".",
"get",
"(",
"'interfaces'",
")",
"if",
"CONF",
".",
"processing",
".",
"add_ports",
"!=",
"'disabled'... | Create new ports and drop ports that are not present in the data. | [
"Create",
"new",
"ports",
"and",
"drop",
"ports",
"that",
"are",
"not",
"present",
"in",
"the",
"data",
"."
] | [
"\"\"\"Create new ports and drop ports that are not present in the data.\"\"\"",
"# list is required as we modify underlying dict",
"# Make sure is_pxe_enabled is up-to-date"
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
},
{
"param": "node_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
8548fca9ea65c55e990d6190c467c812aa9f7d45 | fossabot/ironic-inspector | ironic_inspector/plugins/base_physnet.py | [
"Apache-2.0"
] | Python | _get_physnet_patch | <not_specific> | def _get_physnet_patch(self, physnet, port):
"""Return a patch to update the port's physical network.
:param physnet: The physical network to set.
:param port: The ironic port to patch.
:returns: A dict to be used as a patch for the port, or None.
"""
if (not CONF.proces... | Return a patch to update the port's physical network.
:param physnet: The physical network to set.
:param port: The ironic port to patch.
:returns: A dict to be used as a patch for the port, or None.
| Return a patch to update the port's physical network. | [
"Return",
"a",
"patch",
"to",
"update",
"the",
"port",
"'",
"s",
"physical",
"network",
"."
] | def _get_physnet_patch(self, physnet, port):
if (not CONF.processing.overwrite_existing
or port.physical_network == physnet):
return
return {'op': 'add', 'path': '/physical_network', 'value': physnet} | [
"def",
"_get_physnet_patch",
"(",
"self",
",",
"physnet",
",",
"port",
")",
":",
"if",
"(",
"not",
"CONF",
".",
"processing",
".",
"overwrite_existing",
"or",
"port",
".",
"physical_network",
"==",
"physnet",
")",
":",
"return",
"return",
"{",
"'op'",
":",... | Return a patch to update the port's physical network. | [
"Return",
"a",
"patch",
"to",
"update",
"the",
"port",
"'",
"s",
"physical",
"network",
"."
] | [
"\"\"\"Return a patch to update the port's physical network.\n\n :param physnet: The physical network to set.\n :param port: The ironic port to patch.\n :returns: A dict to be used as a patch for the port, or None.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "physnet",
"type": null
},
{
"param": "port",
"type": null
}
] | {
"returns": [
{
"docstring": "A dict to be used as a patch for the port, or None.",
"docstring_tokens": [
"A",
"dict",
"to",
"be",
"used",
"as",
"a",
"patch",
"for",
"the",
"port",
"or",
"None",
... |
8548fca9ea65c55e990d6190c467c812aa9f7d45 | fossabot/ironic-inspector | ironic_inspector/plugins/base_physnet.py | [
"Apache-2.0"
] | Python | before_update | null | def before_update(self, introspection_data, node_info, **kwargs):
"""Process introspection data and patch port physical network."""
inventory = utils.get_inventory(introspection_data)
ironic_ports = node_info.ports()
for iface in inventory['interfaces']:
if iface['name'] no... | Process introspection data and patch port physical network. | Process introspection data and patch port physical network. | [
"Process",
"introspection",
"data",
"and",
"patch",
"port",
"physical",
"network",
"."
] | def before_update(self, introspection_data, node_info, **kwargs):
inventory = utils.get_inventory(introspection_data)
ironic_ports = node_info.ports()
for iface in inventory['interfaces']:
if iface['name'] not in introspection_data['all_interfaces']:
continue
... | [
"def",
"before_update",
"(",
"self",
",",
"introspection_data",
",",
"node_info",
",",
"**",
"kwargs",
")",
":",
"inventory",
"=",
"utils",
".",
"get_inventory",
"(",
"introspection_data",
")",
"ironic_ports",
"=",
"node_info",
".",
"ports",
"(",
")",
"for",
... | Process introspection data and patch port physical network. | [
"Process",
"introspection",
"data",
"and",
"patch",
"port",
"physical",
"network",
"."
] | [
"\"\"\"Process introspection data and patch port physical network.\"\"\"",
"# Determine the physical network for this port.",
"# Port not touched in here."
] | [
{
"param": "self",
"type": null
},
{
"param": "introspection_data",
"type": null
},
{
"param": "node_info",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "introspection_data",
"type": null,
"docstring": null,
"docstr... |
4c55f365b824a331f30dc47da16ffdf0cc8b51cd | tthero/file-qrcode-makeread | main.py | [
"Unlicense"
] | Python | text_input_check | null | def text_input_check(self, target):
'''
For self.maker_text_box:
Check if it is empty or not to deactivate self.
'''
if target == MAKER_TARGET:
if self.maker_text_box.get():
self.maker_start_button.configure(state=ACTIVE)
else:
... |
For self.maker_text_box:
Check if it is empty or not to deactivate self.
| For self.maker_text_box:
Check if it is empty or not to deactivate self. | [
"For",
"self",
".",
"maker_text_box",
":",
"Check",
"if",
"it",
"is",
"empty",
"or",
"not",
"to",
"deactivate",
"self",
"."
] | def text_input_check(self, target):
if target == MAKER_TARGET:
if self.maker_text_box.get():
self.maker_start_button.configure(state=ACTIVE)
else:
self.maker_start_button.configure(state=DISABLED)
elif target == READER_TARGET:
if self.r... | [
"def",
"text_input_check",
"(",
"self",
",",
"target",
")",
":",
"if",
"target",
"==",
"MAKER_TARGET",
":",
"if",
"self",
".",
"maker_text_box",
".",
"get",
"(",
")",
":",
"self",
".",
"maker_start_button",
".",
"configure",
"(",
"state",
"=",
"ACTIVE",
... | For self.maker_text_box:
Check if it is empty or not to deactivate self. | [
"For",
"self",
".",
"maker_text_box",
":",
"Check",
"if",
"it",
"is",
"empty",
"or",
"not",
"to",
"deactivate",
"self",
"."
] | [
"'''\n For self.maker_text_box:\n Check if it is empty or not to deactivate self.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "target",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens":... |
4c55f365b824a331f30dc47da16ffdf0cc8b51cd | tthero/file-qrcode-makeread | main.py | [
"Unlicense"
] | Python | code_maker_engine | null | def code_maker_engine(self):
'''
Dealing with the main components of QR code making
'''
make_status_msg = "----- QR Code Maker -----"
self.log_msg_entry(make_status_msg)
file_names = self.maker_text_box.get()
file_names = [file_name.strip() for file_name in file_... |
Dealing with the main components of QR code making
| Dealing with the main components of QR code making | [
"Dealing",
"with",
"the",
"main",
"components",
"of",
"QR",
"code",
"making"
] | def code_maker_engine(self):
make_status_msg = "----- QR Code Maker -----"
self.log_msg_entry(make_status_msg)
file_names = self.maker_text_box.get()
file_names = [file_name.strip() for file_name in file_names.split(",")]
for file_path in file_names:
if os.path.isdir(... | [
"def",
"code_maker_engine",
"(",
"self",
")",
":",
"make_status_msg",
"=",
"\"----- QR Code Maker -----\"",
"self",
".",
"log_msg_entry",
"(",
"make_status_msg",
")",
"file_names",
"=",
"self",
".",
"maker_text_box",
".",
"get",
"(",
")",
"file_names",
"=",
"[",
... | Dealing with the main components of QR code making | [
"Dealing",
"with",
"the",
"main",
"components",
"of",
"QR",
"code",
"making"
] | [
"'''\n Dealing with the main components of QR code making\n '''",
"# IF: The file path is a directory",
"# Only accounts for files in the current folder, not subfolders",
"# print(file_path, file_name)",
"# ELSE: The file path is a file",
"# Making QR code for that particular file path",
"... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4c55f365b824a331f30dc47da16ffdf0cc8b51cd | tthero/file-qrcode-makeread | main.py | [
"Unlicense"
] | Python | code_reader_engine | null | def code_reader_engine(self):
'''
Dealing with the main components of QR code reading
'''
make_status_msg = "----- QR Code Reader -----"
self.log_msg_entry(make_status_msg)
file_names = self.reader_text_box.get()
file_names = [file_name.strip() for file_name in f... |
Dealing with the main components of QR code reading
| Dealing with the main components of QR code reading | [
"Dealing",
"with",
"the",
"main",
"components",
"of",
"QR",
"code",
"reading"
] | def code_reader_engine(self):
make_status_msg = "----- QR Code Reader -----"
self.log_msg_entry(make_status_msg)
file_names = self.reader_text_box.get()
file_names = [file_name.strip() for file_name in file_names.split(",")]
for file_path in file_names:
if not os.path... | [
"def",
"code_reader_engine",
"(",
"self",
")",
":",
"make_status_msg",
"=",
"\"----- QR Code Reader -----\"",
"self",
".",
"log_msg_entry",
"(",
"make_status_msg",
")",
"file_names",
"=",
"self",
".",
"reader_text_box",
".",
"get",
"(",
")",
"file_names",
"=",
"["... | Dealing with the main components of QR code reading | [
"Dealing",
"with",
"the",
"main",
"components",
"of",
"QR",
"code",
"reading"
] | [
"'''\n Dealing with the main components of QR code reading\n '''",
"# Reading QR code using pyzbar",
"# print(file_path)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
450d71736f634ce9cfbdd7614f76037d1b069247 | saadtony/modified_equation_code_test | src/MOIRA.py | [
"MIT"
] | Python | __independent_vars | null | def __independent_vars(self):
'''
Defines the symbols for the independent variables, differential elements, wave number variables, and indices
'''
self.vars = {}
self.t = {}
num = 1
for var, index in zip(self.__independentVars, self.__indices):
self.va... |
Defines the symbols for the independent variables, differential elements, wave number variables, and indices
| Defines the symbols for the independent variables, differential elements, wave number variables, and indices | [
"Defines",
"the",
"symbols",
"for",
"the",
"independent",
"variables",
"differential",
"elements",
"wave",
"number",
"variables",
"and",
"indices"
] | def __independent_vars(self):
self.vars = {}
self.t = {}
num = 1
for var, index in zip(self.__independentVars, self.__indices):
self.vars[var] = {}
varName = 'indepVar{}'.format(num)
setattr(self, varName, symbols(var))
self.vars[var]['sym'... | [
"def",
"__independent_vars",
"(",
"self",
")",
":",
"self",
".",
"vars",
"=",
"{",
"}",
"self",
".",
"t",
"=",
"{",
"}",
"num",
"=",
"1",
"for",
"var",
",",
"index",
"in",
"zip",
"(",
"self",
".",
"__independentVars",
",",
"self",
".",
"__indices",... | Defines the symbols for the independent variables, differential elements, wave number variables, and indices | [
"Defines",
"the",
"symbols",
"for",
"the",
"independent",
"variables",
"differential",
"elements",
"wave",
"number",
"variables",
"and",
"indices"
] | [
"'''\n Defines the symbols for the independent variables, differential elements, wave number variables, and indices\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
450d71736f634ce9cfbdd7614f76037d1b069247 | saadtony/modified_equation_code_test | src/MOIRA.py | [
"MIT"
] | Python | function | <not_specific> | def function(self, time, **kwargs):
'''
The function assigned to the dependent variable name. It has the following form exp(alpha tn) exp(ikx) exp(iky) ...
Parameters:
time (symbolic expression): time step at which we are applying this function ex: n, n+1, n-1, ..., <timeIndex\> + n... |
The function assigned to the dependent variable name. It has the following form exp(alpha tn) exp(ikx) exp(iky) ...
Parameters:
time (symbolic expression): time step at which we are applying this function ex: n, n+1, n-1, ..., <timeIndex\> + number.
kwargs (symbolic expression)... | The function assigned to the dependent variable name. | [
"The",
"function",
"assigned",
"to",
"the",
"dependent",
"variable",
"name",
"."
] | def function(self, time, **kwargs):
keys = list(kwargs.keys())
expression = exp(self.t['ampFactor'] * (self.t['sym'] + (time - self.t['index']) * self.t['variation']))
for var in keys:
expression *= exp(1j * self.vars[var]['waveNum'] * (
self.vars[var]['sym'] + (k... | [
"def",
"function",
"(",
"self",
",",
"time",
",",
"**",
"kwargs",
")",
":",
"keys",
"=",
"list",
"(",
"kwargs",
".",
"keys",
"(",
")",
")",
"expression",
"=",
"exp",
"(",
"self",
".",
"t",
"[",
"'ampFactor'",
"]",
"*",
"(",
"self",
".",
"t",
"[... | The function assigned to the dependent variable name. | [
"The",
"function",
"assigned",
"to",
"the",
"dependent",
"variable",
"name",
"."
] | [
"'''\n The function assigned to the dependent variable name. It has the following form exp(alpha tn) exp(ikx) exp(iky) ...\n\n Parameters:\n time (symbolic expression): time step at which we are applying this function ex: n, n+1, n-1, ..., <timeIndex\\> + number.\n kwargs (symbol... | [
{
"param": "self",
"type": null
},
{
"param": "time",
"type": null
}
] | {
"returns": [
{
"docstring": "symbolic expression of this function applied at time index and points",
"docstring_tokens": [
"symbolic",
"expression",
"of",
"this",
"function",
"applied",
"at",
"time",
"index",
"and",
... |
450d71736f634ce9cfbdd7614f76037d1b069247 | saadtony/modified_equation_code_test | src/MOIRA.py | [
"MIT"
] | Python | stencil_gen | <not_specific> | def stencil_gen(self, points, order):
'''
Generates finite difference equation based on the location of sampled points and derivative order
Parameters:
points (list int): stencil of length N needed ex: [-1,0,1] stencil around 0
order (int > 0): the order of derivatives d... |
Generates finite difference equation based on the location of sampled points and derivative order
Parameters:
points (list int): stencil of length N needed ex: [-1,0,1] stencil around 0
order (int > 0): the order of derivatives d, d<N
Returns:
the finite d... | Generates finite difference equation based on the location of sampled points and derivative order | [
"Generates",
"finite",
"difference",
"equation",
"based",
"on",
"the",
"location",
"of",
"sampled",
"points",
"and",
"derivative",
"order"
] | def stencil_gen(self, points, order):
numPts = len(points)
M = []
for i in range(numPts):
M.append([s ** i for s in points])
M = Matrix(M)
b = Matrix([factorial(order) * 1 if j == order else 0 for j in range(numPts)])
coefs = list(M.inv() * b)
return {... | [
"def",
"stencil_gen",
"(",
"self",
",",
"points",
",",
"order",
")",
":",
"numPts",
"=",
"len",
"(",
"points",
")",
"M",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"numPts",
")",
":",
"M",
".",
"append",
"(",
"[",
"s",
"**",
"i",
"for",
"... | Generates finite difference equation based on the location of sampled points and derivative order | [
"Generates",
"finite",
"difference",
"equation",
"based",
"on",
"the",
"location",
"of",
"sampled",
"points",
"and",
"derivative",
"order"
] | [
"'''\n Generates finite difference equation based on the location of sampled points and derivative order\n\n Parameters:\n points (list int): stencil of length N needed ex: [-1,0,1] stencil around 0\n order (int > 0): the order of derivatives d, d<N\n\n Returns:\n ... | [
{
"param": "self",
"type": null
},
{
"param": "points",
"type": null
},
{
"param": "order",
"type": null
}
] | {
"returns": [
{
"docstring": "the finite difference coefficients along with the points used in a dictionary\n{'points':[],'coefs':[]}",
"docstring_tokens": [
"the",
"finite",
"difference",
"coefficients",
"along",
"with",
"the",
"points"... |
450d71736f634ce9cfbdd7614f76037d1b069247 | saadtony/modified_equation_code_test | src/MOIRA.py | [
"MIT"
] | Python | expr | <not_specific> | def expr(self, points, direction, order, time):
'''
Generates an expression based on the stencil points, the direction, order of the derivative, and the time at which the expression is evaluated.
Parameters:
points (list of int): N points used for the stencil gen function
... |
Generates an expression based on the stencil points, the direction, order of the derivative, and the time at which the expression is evaluated.
Parameters:
points (list of int): N points used for the stencil gen function
direction (string): the name of the independent variable... | Generates an expression based on the stencil points, the direction, order of the derivative, and the time at which the expression is evaluated. | [
"Generates",
"an",
"expression",
"based",
"on",
"the",
"stencil",
"points",
"the",
"direction",
"order",
"of",
"the",
"derivative",
"and",
"the",
"time",
"at",
"which",
"the",
"expression",
"is",
"evaluated",
"."
] | def expr(self, points, direction, order, time):
points = points
direction = direction
order = order
time = time
stencil = self.stencil_gen(points, order)
expression = 0
for coef, pt in zip(stencil['coefs'], stencil['points']):
kwargs = {}
f... | [
"def",
"expr",
"(",
"self",
",",
"points",
",",
"direction",
",",
"order",
",",
"time",
")",
":",
"points",
"=",
"points",
"direction",
"=",
"direction",
"order",
"=",
"order",
"time",
"=",
"time",
"stencil",
"=",
"self",
".",
"stencil_gen",
"(",
"poin... | Generates an expression based on the stencil points, the direction, order of the derivative, and the time at which the expression is evaluated. | [
"Generates",
"an",
"expression",
"based",
"on",
"the",
"stencil",
"points",
"the",
"direction",
"order",
"of",
"the",
"derivative",
"and",
"the",
"time",
"at",
"which",
"the",
"expression",
"is",
"evaluated",
"."
] | [
"'''\n Generates an expression based on the stencil points, the direction, order of the derivative, and the time at which the expression is evaluated.\n\n Parameters:\n points (list of int): N points used for the stencil gen function\n direction (string): the name of the indepen... | [
{
"param": "self",
"type": null
},
{
"param": "points",
"type": null
},
{
"param": "direction",
"type": null
},
{
"param": "order",
"type": null
},
{
"param": "time",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
450d71736f634ce9cfbdd7614f76037d1b069247 | saadtony/modified_equation_code_test | src/MOIRA.py | [
"MIT"
] | Python | modified_equation | <not_specific> | def modified_equation(self, nterms):
'''
Computes the values of the modified equation coefficients a_{ijk} where i, j and k represent
the order of derivatives in the <indep var1\> , <indep var2\>, and <indep var3\> directions, respectively. These are written as
a_ijk * u_{ijk}.
... |
Computes the values of the modified equation coefficients a_{ijk} where i, j and k represent
the order of derivatives in the <indep var1\> , <indep var2\>, and <indep var3\> directions, respectively. These are written as
a_ijk * u_{ijk}.
Parameters:
nterms (int):Number of t... | Computes the values of the modified equation coefficients a_{ijk} where i, j and k represent
the order of derivatives in the , , and directions, respectively. These are written as
a_ijk * u_{ijk}. | [
"Computes",
"the",
"values",
"of",
"the",
"modified",
"equation",
"coefficients",
"a_",
"{",
"ijk",
"}",
"where",
"i",
"j",
"and",
"k",
"represent",
"the",
"order",
"of",
"derivatives",
"in",
"the",
"and",
"directions",
"respectively",
".",
"These",
"are",
... | def modified_equation(self, nterms):
try:
A = symbols('A')
lhs1 = simplify(self.lhs / self.function(self.t['index'], **self.indicies))
rhs1 = simplify(self.rhs / self.function(self.t['index'], **self.indicies))
eq = lhs1 - rhs1
eq = eq.subs(exp(self.t[... | [
"def",
"modified_equation",
"(",
"self",
",",
"nterms",
")",
":",
"try",
":",
"A",
"=",
"symbols",
"(",
"'A'",
")",
"lhs1",
"=",
"simplify",
"(",
"self",
".",
"lhs",
"/",
"self",
".",
"function",
"(",
"self",
".",
"t",
"[",
"'index'",
"]",
",",
"... | Computes the values of the modified equation coefficients a_{ijk} where i, j and k represent
the order of derivatives in the <indep var1\> , <indep var2\>, and <indep var3\> directions, respectively. | [
"Computes",
"the",
"values",
"of",
"the",
"modified",
"equation",
"coefficients",
"a_",
"{",
"ijk",
"}",
"where",
"i",
"j",
"and",
"k",
"represent",
"the",
"order",
"of",
"derivatives",
"in",
"the",
"<indep",
"var1",
"\\",
">",
"<indep",
"var2",
"\\",
">... | [
"'''\n Computes the values of the modified equation coefficients a_{ijk} where i, j and k represent\n the order of derivatives in the <indep var1\\> , <indep var2\\>, and <indep var3\\> directions, respectively. These are written as\n a_ijk * u_{ijk}.\n\n Parameters:\n nterms ... | [
{
"param": "self",
"type": null
},
{
"param": "nterms",
"type": null
}
] | {
"returns": [
{
"docstring": "true if finished without error, false otherwise",
"docstring_tokens": [
"true",
"if",
"finished",
"without",
"error",
"false",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"params": [
{... |
0f707127987362601034b3c54fcbc45b6c08f784 | hoang-tn-nguyen/Medical_Report_Generation | utils/framework.py | [
"Apache-2.0"
] | Python | data_to_device | Any | def data_to_device(self, data: Any, device: Any) -> Any:
"""This function moves data to CPU/GPU recursively (i.e. Tensor, tuple, list, dict).
Anything else such as int, float, np.array, etc, will be ignored.
"""
if isinstance(data, torch.Tensor):
data = data.to(device)
... | This function moves data to CPU/GPU recursively (i.e. Tensor, tuple, list, dict).
Anything else such as int, float, np.array, etc, will be ignored.
| This function moves data to CPU/GPU recursively .
Anything else such as int, float, np.array, etc, will be ignored. | [
"This",
"function",
"moves",
"data",
"to",
"CPU",
"/",
"GPU",
"recursively",
".",
"Anything",
"else",
"such",
"as",
"int",
"float",
"np",
".",
"array",
"etc",
"will",
"be",
"ignored",
"."
] | def data_to_device(self, data: Any, device: Any) -> Any:
if isinstance(data, torch.Tensor):
data = data.to(device)
elif isinstance(data, tuple):
data = tuple(self.data_to_device(item, device) for item in data)
elif isinstance(data, list):
data = list(self.data... | [
"def",
"data_to_device",
"(",
"self",
",",
"data",
":",
"Any",
",",
"device",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"data",
",",
"torch",
".",
"Tensor",
")",
":",
"data",
"=",
"data",
".",
"to",
"(",
"device",
")",
"elif",
"... | This function moves data to CPU/GPU recursively (i.e. | [
"This",
"function",
"moves",
"data",
"to",
"CPU",
"/",
"GPU",
"recursively",
"(",
"i",
".",
"e",
"."
] | [
"\"\"\"This function moves data to CPU/GPU recursively (i.e. Tensor, tuple, list, dict).\n Anything else such as int, float, np.array, etc, will be ignored.\n \"\"\"",
"# keep as is for other data types"
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": "Any"
},
{
"param": "device",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "Any",
"docstring": null,
"docstring_tokens": ... |
0f707127987362601034b3c54fcbc45b6c08f784 | hoang-tn-nguyen/Medical_Report_Generation | utils/framework.py | [
"Apache-2.0"
] | Python | data_to_model | Any | def data_to_model(self, data: Any) -> Any:
"""
Map data inputs to model's parameters.
"""
if isinstance(data, dict):
if self.data_pipeline_mapper:
if isinstance(self.data_pipeline_mapper, dict):
kwargs = []
for input_key... |
Map data inputs to model's parameters.
| Map data inputs to model's parameters. | [
"Map",
"data",
"inputs",
"to",
"model",
"'",
"s",
"parameters",
"."
] | def data_to_model(self, data: Any) -> Any:
if isinstance(data, dict):
if self.data_pipeline_mapper:
if isinstance(self.data_pipeline_mapper, dict):
kwargs = []
for input_key, model_key in self.data_pipeline_mapper.items():
... | [
"def",
"data_to_model",
"(",
"self",
",",
"data",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"if",
"self",
".",
"data_pipeline_mapper",
":",
"if",
"isinstance",
"(",
"self",
".",
"data_pipeline_mapper",
","... | Map data inputs to model's parameters. | [
"Map",
"data",
"inputs",
"to",
"model",
"'",
"s",
"parameters",
"."
] | [
"\"\"\"\n Map data inputs to model's parameters.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "Any",
"docstring": null,
"docstring_tokens": ... |
0f707127987362601034b3c54fcbc45b6c08f784 | hoang-tn-nguyen/Medical_Report_Generation | utils/framework.py | [
"Apache-2.0"
] | Python | data_transpose | Any | def data_transpose(self, data: list[Any], dim: int = 0) -> Any:
"""
Convert list of elements into elements' structure.
Example:
(no inner / undefined structure)
[1,2,3,4,5]
--> [1,2,3,4,5]
(inner structure is a list)
[[1,2],[3,4],[5,6]... |
Convert list of elements into elements' structure.
Example:
(no inner / undefined structure)
[1,2,3,4,5]
--> [1,2,3,4,5]
(inner structure is a list)
[[1,2],[3,4],[5,6]]
--> [[1,3,5], [2,4,6]]
(inner structure is a tup... | Convert list of elements into elements' structure. | [
"Convert",
"list",
"of",
"elements",
"into",
"elements",
"'",
"structure",
"."
] | def data_transpose(self, data: list[Any], dim: int = 0) -> Any:
if isinstance(data[0], dict):
out_dict = {}
for k in data[0]:
out_dict[k] = []
for item in data:
for k in item:
out_dict[k].append(item[k])
return o... | [
"def",
"data_transpose",
"(",
"self",
",",
"data",
":",
"list",
"[",
"Any",
"]",
",",
"dim",
":",
"int",
"=",
"0",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"data",
"[",
"0",
"]",
",",
"dict",
")",
":",
"out_dict",
"=",
"{",
"}",
"for",
... | Convert list of elements into elements' structure. | [
"Convert",
"list",
"of",
"elements",
"into",
"elements",
"'",
"structure",
"."
] | [
"\"\"\"\n Convert list of elements into elements' structure.\n Example:\n (no inner / undefined structure)\n [1,2,3,4,5]\n --> [1,2,3,4,5]\n\n (inner structure is a list)\n [[1,2],[3,4],[5,6]]\n --> [[1,3,5], [2,4,6]]\n\n (in... | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": "list[Any]"
},
{
"param": "dim",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "list[Any]",
"docstring": null,
"docstring_tok... |
0f707127987362601034b3c54fcbc45b6c08f784 | hoang-tn-nguyen/Medical_Report_Generation | utils/framework.py | [
"Apache-2.0"
] | Python | stats_to_str | str | def stats_to_str(self, stats: dict[str, Any]) -> str:
"""
Convert computed stats into a string for visualization.
"""
return " | ".join(
["{}: {:.3f}".format(key, value) for key, value in stats.items()]
) |
Convert computed stats into a string for visualization.
| Convert computed stats into a string for visualization. | [
"Convert",
"computed",
"stats",
"into",
"a",
"string",
"for",
"visualization",
"."
] | def stats_to_str(self, stats: dict[str, Any]) -> str:
return " | ".join(
["{}: {:.3f}".format(key, value) for key, value in stats.items()]
) | [
"def",
"stats_to_str",
"(",
"self",
",",
"stats",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"return",
"\" | \"",
".",
"join",
"(",
"[",
"\"{}: {:.3f}\"",
".",
"format",
"(",
"key",
",",
"value",
")",
"for",
"key",
",",
"value... | Convert computed stats into a string for visualization. | [
"Convert",
"computed",
"stats",
"into",
"a",
"string",
"for",
"visualization",
"."
] | [
"\"\"\"\n Convert computed stats into a string for visualization.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "stats",
"type": "dict[str, Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stats",
"type": "dict[str, Any]",
"docstring": null,
"docstri... |
d74cd84b6065d54e0978abe0f181bce09dccf752 | siangooding/transformers | examples/tests/trainer/test_trainer_ext.py | [
"Apache-2.0"
] | Python | require_fairscale | <not_specific> | def require_fairscale(test_case):
"""
Decorator marking a test that requires fairscale
"""
if not is_fairscale_available():
return unittest.skip("test requires fairscale")(test_case)
else:
return test_case |
Decorator marking a test that requires fairscale
| Decorator marking a test that requires fairscale | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"fairscale"
] | def require_fairscale(test_case):
if not is_fairscale_available():
return unittest.skip("test requires fairscale")(test_case)
else:
return test_case | [
"def",
"require_fairscale",
"(",
"test_case",
")",
":",
"if",
"not",
"is_fairscale_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires fairscale\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires fairscale | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"fairscale"
] | [
"\"\"\"\n Decorator marking a test that requires fairscale\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d74cd84b6065d54e0978abe0f181bce09dccf752 | siangooding/transformers | examples/tests/trainer/test_trainer_ext.py | [
"Apache-2.0"
] | Python | require_apex | <not_specific> | def require_apex(test_case):
"""
Decorator marking a test that requires apex
"""
if not is_apex_available():
return unittest.skip("test requires apex")(test_case)
else:
return test_case |
Decorator marking a test that requires apex
| Decorator marking a test that requires apex | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"apex"
] | def require_apex(test_case):
if not is_apex_available():
return unittest.skip("test requires apex")(test_case)
else:
return test_case | [
"def",
"require_apex",
"(",
"test_case",
")",
":",
"if",
"not",
"is_apex_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires apex\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires apex | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"apex"
] | [
"\"\"\"\n Decorator marking a test that requires apex\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | default_compute_objective | float | def default_compute_objective(metrics: Dict[str, float]) -> float:
"""
The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.
Args:
metrics (:ob... |
The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.
Args:
metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluate method.
R... | The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no
metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise. | [
"The",
"default",
"objective",
"to",
"maximize",
"/",
"minimize",
"when",
"doing",
"an",
"hyperparameter",
"search",
".",
"It",
"is",
"the",
"evaluation",
"loss",
"if",
"no",
"metrics",
"are",
"provided",
"to",
"the",
":",
"class",
":",
"`",
"~transformers",... | def default_compute_objective(metrics: Dict[str, float]) -> float:
metrics = copy.deepcopy(metrics)
loss = metrics.pop("eval_loss", None)
_ = metrics.pop("epoch", None)
speed_metrics = [m for m in metrics.keys() if m.endswith("_runtime") or m.endswith("_samples_per_second")]
for sm in speed_metrics:... | [
"def",
"default_compute_objective",
"(",
"metrics",
":",
"Dict",
"[",
"str",
",",
"float",
"]",
")",
"->",
"float",
":",
"metrics",
"=",
"copy",
".",
"deepcopy",
"(",
"metrics",
")",
"loss",
"=",
"metrics",
".",
"pop",
"(",
"\"eval_loss\"",
",",
"None",
... | The default objective to maximize/minimize when doing an hyperparameter search. | [
"The",
"default",
"objective",
"to",
"maximize",
"/",
"minimize",
"when",
"doing",
"an",
"hyperparameter",
"search",
"."
] | [
"\"\"\"\n The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no\n metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.\n\n Args:\n metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluat... | [
{
"param": "metrics",
"type": "Dict[str, float]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "metrics",
"type": "Dict[str, float]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [
{
"identifier": "metrics (",
"type": null,
... |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | total_processes_number | <not_specific> | def total_processes_number(local_rank):
"""
Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs.
"""
if is_torch_tpu_available():
import torch_xla.core.xla_model as xm
return xm.xrt_world_size()
elif is_sagemaker_distributed_available():
... |
Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs.
| Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs. | [
"Return",
"the",
"number",
"of",
"processes",
"launched",
"in",
"parallel",
".",
"Works",
"with",
"`",
"torch",
".",
"distributed",
"`",
"and",
"TPUs",
"."
] | def total_processes_number(local_rank):
if is_torch_tpu_available():
import torch_xla.core.xla_model as xm
return xm.xrt_world_size()
elif is_sagemaker_distributed_available():
import smdistributed.dataparallel.torch.distributed as dist
return dist.get_world_size()
elif local... | [
"def",
"total_processes_number",
"(",
"local_rank",
")",
":",
"if",
"is_torch_tpu_available",
"(",
")",
":",
"import",
"torch_xla",
".",
"core",
".",
"xla_model",
"as",
"xm",
"return",
"xm",
".",
"xrt_world_size",
"(",
")",
"elif",
"is_sagemaker_distributed_availa... | Return the number of processes launched in parallel. | [
"Return",
"the",
"number",
"of",
"processes",
"launched",
"in",
"parallel",
"."
] | [
"\"\"\"\n Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs.\n \"\"\""
] | [
{
"param": "local_rank",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "local_rank",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | speed_metrics | <not_specific> | def speed_metrics(split, start_time, num_samples=None):
"""
Measure and return speed performance metrics.
This function requires a time snapshot `start_time` before the operation to be measured starts and this function
should be run immediately after the operation to be measured has completed.
Arg... |
Measure and return speed performance metrics.
This function requires a time snapshot `start_time` before the operation to be measured starts and this function
should be run immediately after the operation to be measured has completed.
Args:
- split: name to prefix metric (like train, eval, test.... | Measure and return speed performance metrics.
This function requires a time snapshot `start_time` before the operation to be measured starts and this function
should be run immediately after the operation to be measured has completed.
name to prefix metric (like train, eval, test...)
start_time: operation start time... | [
"Measure",
"and",
"return",
"speed",
"performance",
"metrics",
".",
"This",
"function",
"requires",
"a",
"time",
"snapshot",
"`",
"start_time",
"`",
"before",
"the",
"operation",
"to",
"be",
"measured",
"starts",
"and",
"this",
"function",
"should",
"be",
"run... | def speed_metrics(split, start_time, num_samples=None):
runtime = time.time() - start_time
result = {f"{split}_runtime": round(runtime, 4)}
if num_samples is not None:
samples_per_second = 1 / (runtime / num_samples)
result[f"{split}_samples_per_second"] = round(samples_per_second, 3)
re... | [
"def",
"speed_metrics",
"(",
"split",
",",
"start_time",
",",
"num_samples",
"=",
"None",
")",
":",
"runtime",
"=",
"time",
".",
"time",
"(",
")",
"-",
"start_time",
"result",
"=",
"{",
"f\"{split}_runtime\"",
":",
"round",
"(",
"runtime",
",",
"4",
")",... | Measure and return speed performance metrics. | [
"Measure",
"and",
"return",
"speed",
"performance",
"metrics",
"."
] | [
"\"\"\"\n Measure and return speed performance metrics.\n\n This function requires a time snapshot `start_time` before the operation to be measured starts and this function\n should be run immediately after the operation to be measured has completed.\n\n Args:\n\n - split: name to prefix metric (like... | [
{
"param": "split",
"type": null
},
{
"param": "start_time",
"type": null
},
{
"param": "num_samples",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "split",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start_time",
"type": null,
"docstring": null,
"docstring_tok... |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | derive_stage | <not_specific> | def derive_stage(self):
""" derives the stage/caller name automatically """
caller = inspect.currentframe().f_back.f_back.f_code.co_name
if caller in self.stages:
return self.stages[caller]
else:
raise ValueError(
f"was called from {caller}, but on... | derives the stage/caller name automatically | derives the stage/caller name automatically | [
"derives",
"the",
"stage",
"/",
"caller",
"name",
"automatically"
] | def derive_stage(self):
caller = inspect.currentframe().f_back.f_back.f_code.co_name
if caller in self.stages:
return self.stages[caller]
else:
raise ValueError(
f"was called from {caller}, but only expect to be called from one of {self.stages.keys()}"
... | [
"def",
"derive_stage",
"(",
"self",
")",
":",
"caller",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_back",
".",
"f_code",
".",
"co_name",
"if",
"caller",
"in",
"self",
".",
"stages",
":",
"return",
"self",
".",
"stages",
"[",
... | derives the stage/caller name automatically | [
"derives",
"the",
"stage",
"/",
"caller",
"name",
"automatically"
] | [
"\"\"\" derives the stage/caller name automatically \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | start | <not_specific> | def start(self):
""" start tracking for the caller's stage """
if self.skip_memory_metrics:
return
stage = self.derive_stage()
# deal with nested calls of eval during train - simply ignore those
if self.cur_stage is not None and self.cur_stage != stage:
r... | start tracking for the caller's stage | start tracking for the caller's stage | [
"start",
"tracking",
"for",
"the",
"caller",
"'",
"s",
"stage"
] | def start(self):
if self.skip_memory_metrics:
return
stage = self.derive_stage()
if self.cur_stage is not None and self.cur_stage != stage:
return
self.cur_stage = stage
if self.torch is not None:
self.torch.cuda.reset_peak_memory_stats()
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"skip_memory_metrics",
":",
"return",
"stage",
"=",
"self",
".",
"derive_stage",
"(",
")",
"if",
"self",
".",
"cur_stage",
"is",
"not",
"None",
"and",
"self",
".",
"cur_stage",
"!=",
"stage",
":... | start tracking for the caller's stage | [
"start",
"tracking",
"for",
"the",
"caller",
"'",
"s",
"stage"
] | [
"\"\"\" start tracking for the caller's stage \"\"\"",
"# deal with nested calls of eval during train - simply ignore those",
"# gpu",
"# cpu"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | stop | <not_specific> | def stop(self, stage):
""" stop tracking for the passed stage """
# deal with nested calls of eval during train - simply ignore those
if self.cur_stage is not None and self.cur_stage != stage:
return
if self.torch is not None:
self.torch.cuda.empty_cache()
... | stop tracking for the passed stage | stop tracking for the passed stage | [
"stop",
"tracking",
"for",
"the",
"passed",
"stage"
] | def stop(self, stage):
if self.cur_stage is not None and self.cur_stage != stage:
return
if self.torch is not None:
self.torch.cuda.empty_cache()
gc.collect()
if self.torch is not None:
mem_cur = self.torch.cuda.memory_allocated()
self.gpu[... | [
"def",
"stop",
"(",
"self",
",",
"stage",
")",
":",
"if",
"self",
".",
"cur_stage",
"is",
"not",
"None",
"and",
"self",
".",
"cur_stage",
"!=",
"stage",
":",
"return",
"if",
"self",
".",
"torch",
"is",
"not",
"None",
":",
"self",
".",
"torch",
".",... | stop tracking for the passed stage | [
"stop",
"tracking",
"for",
"the",
"passed",
"stage"
] | [
"\"\"\" stop tracking for the passed stage \"\"\"",
"# deal with nested calls of eval during train - simply ignore those",
"# gpu",
"# this is the difference between the start and the end allocated memory",
"# can be negative",
"# this is the difference if any between the start and the peak",
"# cpu",
... | [
{
"param": "self",
"type": null
},
{
"param": "stage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stage",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | update_metrics | <not_specific> | def update_metrics(self, stage, metrics):
""" stop tracking for the passed stage """
if self.skip_memory_metrics:
return
# deal with nested calls of eval during train - simply ignore those
if self.cur_stage is not None and self.cur_stage != stage:
return
... | stop tracking for the passed stage | stop tracking for the passed stage | [
"stop",
"tracking",
"for",
"the",
"passed",
"stage"
] | def update_metrics(self, stage, metrics):
if self.skip_memory_metrics:
return
if self.cur_stage is not None and self.cur_stage != stage:
return
stages = [stage]
if not self.init_reported:
stages.insert(0, "init")
self.init_reported = True
... | [
"def",
"update_metrics",
"(",
"self",
",",
"stage",
",",
"metrics",
")",
":",
"if",
"self",
".",
"skip_memory_metrics",
":",
"return",
"if",
"self",
".",
"cur_stage",
"is",
"not",
"None",
"and",
"self",
".",
"cur_stage",
"!=",
"stage",
":",
"return",
"st... | stop tracking for the passed stage | [
"stop",
"tracking",
"for",
"the",
"passed",
"stage"
] | [
"\"\"\" stop tracking for the passed stage \"\"\"",
"# deal with nested calls of eval during train - simply ignore those",
"# since we don't have a way to return init metrics, we push them into the first of train/val/predict"
] | [
{
"param": "self",
"type": null
},
{
"param": "stage",
"type": null
},
{
"param": "metrics",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stage",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5e0f1ae948718c62812e8e47c2983b85fc0d0d7a | siangooding/transformers | src/transformers/trainer_utils.py | [
"Apache-2.0"
] | Python | stop_and_update_metrics | <not_specific> | def stop_and_update_metrics(self, metrics=None):
""" combine stop + update in one call for simpler code """
if self.skip_memory_metrics:
return
stage = self.derive_stage()
self.stop(stage)
# init doesn't have metrics to update so we just save that data for later sta... | combine stop + update in one call for simpler code | combine stop + update in one call for simpler code | [
"combine",
"stop",
"+",
"update",
"in",
"one",
"call",
"for",
"simpler",
"code"
] | def stop_and_update_metrics(self, metrics=None):
if self.skip_memory_metrics:
return
stage = self.derive_stage()
self.stop(stage)
if metrics is not None:
self.update_metrics(stage, metrics) | [
"def",
"stop_and_update_metrics",
"(",
"self",
",",
"metrics",
"=",
"None",
")",
":",
"if",
"self",
".",
"skip_memory_metrics",
":",
"return",
"stage",
"=",
"self",
".",
"derive_stage",
"(",
")",
"self",
".",
"stop",
"(",
"stage",
")",
"if",
"metrics",
"... | combine stop + update in one call for simpler code | [
"combine",
"stop",
"+",
"update",
"in",
"one",
"call",
"for",
"simpler",
"code"
] | [
"\"\"\" combine stop + update in one call for simpler code \"\"\"",
"# init doesn't have metrics to update so we just save that data for later stages to retrieve"
] | [
{
"param": "self",
"type": null
},
{
"param": "metrics",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "metrics",
"type": null,
"docstring": null,
"docstring_tokens"... |
249c8f9ddffa79f66014cca40ca64f6a92ac0bc0 | siangooding/transformers | src/transformers/configuration_utils.py | [
"Apache-2.0"
] | Python | save_pretrained | null | def save_pretrained(self, save_directory: Union[str, os.PathLike]):
"""
Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the
:func:`~transformers.PretrainedConfig.from_pretrained` class method.
Args:
save_directory (:obj:`str... |
Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the
:func:`~transformers.PretrainedConfig.from_pretrained` class method.
Args:
save_directory (:obj:`str` or :obj:`os.PathLike`):
Directory where the configuration JSO... | Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the | [
"Save",
"a",
"configuration",
"object",
"to",
"the",
"directory",
"`",
"`",
"save_directory",
"`",
"`",
"so",
"that",
"it",
"can",
"be",
"re",
"-",
"loaded",
"using",
"the"
] | def save_pretrained(self, save_directory: Union[str, os.PathLike]):
if os.path.isfile(save_directory):
raise AssertionError("Provided path ({}) should be a directory, not a file".format(save_directory))
os.makedirs(save_directory, exist_ok=True)
output_config_file = os.path.join(save... | [
"def",
"save_pretrained",
"(",
"self",
",",
"save_directory",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"save_directory",
")",
":",
"raise",
"AssertionError",
"(",
"\"Provided path ({}... | Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the | [
"Save",
"a",
"configuration",
"object",
"to",
"the",
"directory",
"`",
"`",
"save_directory",
"`",
"`",
"so",
"that",
"it",
"can",
"be",
"re",
"-",
"loaded",
"using",
"the"
] | [
"\"\"\"\n Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the\n :func:`~transformers.PretrainedConfig.from_pretrained` class method.\n\n Args:\n save_directory (:obj:`str` or :obj:`os.PathLike`):\n Directory where the ... | [
{
"param": "self",
"type": null
},
{
"param": "save_directory",
"type": "Union[str, os.PathLike]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "save_directory",
"type": "Union[str, os.PathLike]",
"docstring": nu... |
249c8f9ddffa79f66014cca40ca64f6a92ac0bc0 | siangooding/transformers | src/transformers/configuration_utils.py | [
"Apache-2.0"
] | Python | from_dict | "PretrainedConfig" | def from_dict(cls, config_dict: Dict[str, Any], **kwargs) -> "PretrainedConfig":
"""
Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters.
Args:
config_dict (:obj:`Dict[str, Any]`):
Dictionary that will be used to instantiate ... |
Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters.
Args:
config_dict (:obj:`Dict[str, Any]`):
Dictionary that will be used to instantiate the configuration object. Such a dictionary can be
retrieved from a pretrain... | Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters. | [
"Instantiates",
"a",
":",
"class",
":",
"`",
"~transformers",
".",
"PretrainedConfig",
"`",
"from",
"a",
"Python",
"dictionary",
"of",
"parameters",
"."
] | def from_dict(cls, config_dict: Dict[str, Any], **kwargs) -> "PretrainedConfig":
return_unused_kwargs = kwargs.pop("return_unused_kwargs", False)
config = cls(**config_dict)
if hasattr(config, "pruned_heads"):
config.pruned_heads = dict((int(key), value) for key, value in config.prun... | [
"def",
"from_dict",
"(",
"cls",
",",
"config_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"**",
"kwargs",
")",
"->",
"\"PretrainedConfig\"",
":",
"return_unused_kwargs",
"=",
"kwargs",
".",
"pop",
"(",
"\"return_unused_kwargs\"",
",",
"False",
")",
... | Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters. | [
"Instantiates",
"a",
":",
"class",
":",
"`",
"~transformers",
".",
"PretrainedConfig",
"`",
"from",
"a",
"Python",
"dictionary",
"of",
"parameters",
"."
] | [
"\"\"\"\n Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters.\n\n Args:\n config_dict (:obj:`Dict[str, Any]`):\n Dictionary that will be used to instantiate the configuration object. Such a dictionary can be\n retrieve... | [
{
"param": "cls",
"type": null
},
{
"param": "config_dict",
"type": "Dict[str, Any]"
}
] | {
"returns": [
{
"docstring": ":class:`PretrainedConfig`: The configuration object instantiated from those parameters.",
"docstring_tokens": [
":",
"class",
":",
"`",
"PretrainedConfig",
"`",
":",
"The",
"configuration",
"... |
249c8f9ddffa79f66014cca40ca64f6a92ac0bc0 | siangooding/transformers | src/transformers/configuration_utils.py | [
"Apache-2.0"
] | Python | to_diff_dict | Dict[str, Any] | def to_diff_dict(self) -> Dict[str, Any]:
"""
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this... |
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance,
| Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary. | [
"Removes",
"all",
"attributes",
"from",
"config",
"which",
"correspond",
"to",
"the",
"default",
"config",
"attributes",
"for",
"better",
"readability",
"and",
"serializes",
"to",
"a",
"Python",
"dictionary",
"."
] | def to_diff_dict(self) -> Dict[str, Any]:
config_dict = self.to_dict()
default_config_dict = PretrainedConfig().to_dict()
class_config_dict = self.__class__().to_dict() if not self.is_composition else {}
serializable_config_dict = {}
for key, value in config_dict.items():
... | [
"def",
"to_diff_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"config_dict",
"=",
"self",
".",
"to_dict",
"(",
")",
"default_config_dict",
"=",
"PretrainedConfig",
"(",
")",
".",
"to_dict",
"(",
")",
"class_config_dict",
"=",
"... | Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary. | [
"Removes",
"all",
"attributes",
"from",
"config",
"which",
"correspond",
"to",
"the",
"default",
"config",
"attributes",
"for",
"better",
"readability",
"and",
"serializes",
"to",
"a",
"Python",
"dictionary",
"."
] | [
"\"\"\"\n Removes all attributes from config which correspond to the default config attributes for better readability and\n serializes to a Python dictionary.\n\n Returns:\n :obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance,\n \"\... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.",
"docstring_tokens": [
":",
"obj",
":",
"`",
"Dict",
"[",
"str",
"Any",
"]",
"`",
":... |
249c8f9ddffa79f66014cca40ca64f6a92ac0bc0 | siangooding/transformers | src/transformers/configuration_utils.py | [
"Apache-2.0"
] | Python | to_dict | Dict[str, Any] | def to_dict(self) -> Dict[str, Any]:
"""
Serializes this instance to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
"""
output = copy.deepcopy(self.__dict__)
if hasattr(self.__cl... |
Serializes this instance to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
| Serializes this instance to a Python dictionary. | [
"Serializes",
"this",
"instance",
"to",
"a",
"Python",
"dictionary",
"."
] | def to_dict(self) -> Dict[str, Any]:
output = copy.deepcopy(self.__dict__)
if hasattr(self.__class__, "model_type"):
output["model_type"] = self.__class__.model_type
output["transformers_version"] = __version__
return output | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"output",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"__dict__",
")",
"if",
"hasattr",
"(",
"self",
".",
"__class__",
",",
"\"model_type\"",
")",
":",
"output",
... | Serializes this instance to a Python dictionary. | [
"Serializes",
"this",
"instance",
"to",
"a",
"Python",
"dictionary",
"."
] | [
"\"\"\"\n Serializes this instance to a Python dictionary.\n\n Returns:\n :obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.\n \"\"\"",
"# Transformers version when serializing the model"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": ":obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.",
"docstring_tokens": [
":",
"obj",
":",
"`",
"Dict",
"[",
"str",
"Any",
"]",
"`",
":... |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_git_lfs | <not_specific> | def require_git_lfs(test_case):
"""
Decorator marking a test that requires git-lfs.
git-lfs requires additional dependencies, and tests are skipped by default. Set the RUN_GIT_LFS_TESTS environment
variable to a truthy value to run them.
"""
if not _run_git_lfs_tests:
return unittest.sk... |
Decorator marking a test that requires git-lfs.
git-lfs requires additional dependencies, and tests are skipped by default. Set the RUN_GIT_LFS_TESTS environment
variable to a truthy value to run them.
| Decorator marking a test that requires git-lfs.
git-lfs requires additional dependencies, and tests are skipped by default. Set the RUN_GIT_LFS_TESTS environment
variable to a truthy value to run them. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"git",
"-",
"lfs",
".",
"git",
"-",
"lfs",
"requires",
"additional",
"dependencies",
"and",
"tests",
"are",
"skipped",
"by",
"default",
".",
"Set",
"the",
"RUN_GIT_LFS_TESTS",
"environment",
"variable",
... | def require_git_lfs(test_case):
if not _run_git_lfs_tests:
return unittest.skip("test of git lfs workflow")(test_case)
else:
return test_case | [
"def",
"require_git_lfs",
"(",
"test_case",
")",
":",
"if",
"not",
"_run_git_lfs_tests",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test of git lfs workflow\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires git-lfs. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"git",
"-",
"lfs",
"."
] | [
"\"\"\"\n Decorator marking a test that requires git-lfs.\n\n git-lfs requires additional dependencies, and tests are skipped by default. Set the RUN_GIT_LFS_TESTS environment\n variable to a truthy value to run them.\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_torch_scatter | <not_specific> | def require_torch_scatter(test_case):
"""
Decorator marking a test that requires PyTorch scatter.
These tests are skipped when PyTorch scatter isn't installed.
"""
if not is_scatter_available():
return unittest.skip("test requires PyTorch scatter")(test_case)
else:
return test_... |
Decorator marking a test that requires PyTorch scatter.
These tests are skipped when PyTorch scatter isn't installed.
| Decorator marking a test that requires PyTorch scatter.
These tests are skipped when PyTorch scatter isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"PyTorch",
"scatter",
".",
"These",
"tests",
"are",
"skipped",
"when",
"PyTorch",
"scatter",
"isn",
"'",
"t",
"installed",
"."
] | def require_torch_scatter(test_case):
if not is_scatter_available():
return unittest.skip("test requires PyTorch scatter")(test_case)
else:
return test_case | [
"def",
"require_torch_scatter",
"(",
"test_case",
")",
":",
"if",
"not",
"is_scatter_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires PyTorch scatter\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires PyTorch scatter. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"PyTorch",
"scatter",
"."
] | [
"\"\"\"\n Decorator marking a test that requires PyTorch scatter.\n\n These tests are skipped when PyTorch scatter isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_tf | <not_specific> | def require_tf(test_case):
"""
Decorator marking a test that requires TensorFlow.
These tests are skipped when TensorFlow isn't installed.
"""
if not is_tf_available():
return unittest.skip("test requires TensorFlow")(test_case)
else:
return test_case |
Decorator marking a test that requires TensorFlow.
These tests are skipped when TensorFlow isn't installed.
| Decorator marking a test that requires TensorFlow.
These tests are skipped when TensorFlow isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"TensorFlow",
".",
"These",
"tests",
"are",
"skipped",
"when",
"TensorFlow",
"isn",
"'",
"t",
"installed",
"."
] | def require_tf(test_case):
if not is_tf_available():
return unittest.skip("test requires TensorFlow")(test_case)
else:
return test_case | [
"def",
"require_tf",
"(",
"test_case",
")",
":",
"if",
"not",
"is_tf_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires TensorFlow\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires TensorFlow. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"TensorFlow",
"."
] | [
"\"\"\"\n Decorator marking a test that requires TensorFlow.\n\n These tests are skipped when TensorFlow isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_flax | <not_specific> | def require_flax(test_case):
"""
Decorator marking a test that requires JAX & Flax
These tests are skipped when one / both are not installed
"""
if not is_flax_available():
test_case = unittest.skip("test requires JAX & Flax")(test_case)
return test_case |
Decorator marking a test that requires JAX & Flax
These tests are skipped when one / both are not installed
| Decorator marking a test that requires JAX & Flax
These tests are skipped when one / both are not installed | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"JAX",
"&",
"Flax",
"These",
"tests",
"are",
"skipped",
"when",
"one",
"/",
"both",
"are",
"not",
"installed"
] | def require_flax(test_case):
if not is_flax_available():
test_case = unittest.skip("test requires JAX & Flax")(test_case)
return test_case | [
"def",
"require_flax",
"(",
"test_case",
")",
":",
"if",
"not",
"is_flax_available",
"(",
")",
":",
"test_case",
"=",
"unittest",
".",
"skip",
"(",
"\"test requires JAX & Flax\"",
")",
"(",
"test_case",
")",
"return",
"test_case"
] | Decorator marking a test that requires JAX & Flax
These tests are skipped when one / both are not installed | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"JAX",
"&",
"Flax",
"These",
"tests",
"are",
"skipped",
"when",
"one",
"/",
"both",
"are",
"not",
"installed"
] | [
"\"\"\"\n Decorator marking a test that requires JAX & Flax\n\n These tests are skipped when one / both are not installed\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_sentencepiece | <not_specific> | def require_sentencepiece(test_case):
"""
Decorator marking a test that requires SentencePiece.
These tests are skipped when SentencePiece isn't installed.
"""
if not is_sentencepiece_available():
return unittest.skip("test requires SentencePiece")(test_case)
else:
return test_... |
Decorator marking a test that requires SentencePiece.
These tests are skipped when SentencePiece isn't installed.
| Decorator marking a test that requires SentencePiece.
These tests are skipped when SentencePiece isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"SentencePiece",
".",
"These",
"tests",
"are",
"skipped",
"when",
"SentencePiece",
"isn",
"'",
"t",
"installed",
"."
] | def require_sentencepiece(test_case):
if not is_sentencepiece_available():
return unittest.skip("test requires SentencePiece")(test_case)
else:
return test_case | [
"def",
"require_sentencepiece",
"(",
"test_case",
")",
":",
"if",
"not",
"is_sentencepiece_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires SentencePiece\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires SentencePiece. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"SentencePiece",
"."
] | [
"\"\"\"\n Decorator marking a test that requires SentencePiece.\n\n These tests are skipped when SentencePiece isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_pandas | <not_specific> | def require_pandas(test_case):
"""
Decorator marking a test that requires pandas. These tests are skipped when pandas isn't installed.
"""
if not is_pandas_available():
return unittest.skip("test requires pandas")(test_case)
else:
return test_case |
Decorator marking a test that requires pandas. These tests are skipped when pandas isn't installed.
| Decorator marking a test that requires pandas. These tests are skipped when pandas isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"pandas",
".",
"These",
"tests",
"are",
"skipped",
"when",
"pandas",
"isn",
"'",
"t",
"installed",
"."
] | def require_pandas(test_case):
if not is_pandas_available():
return unittest.skip("test requires pandas")(test_case)
else:
return test_case | [
"def",
"require_pandas",
"(",
"test_case",
")",
":",
"if",
"not",
"is_pandas_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires pandas\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires pandas. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"pandas",
"."
] | [
"\"\"\"\n Decorator marking a test that requires pandas. These tests are skipped when pandas isn't installed.\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_scatter | <not_specific> | def require_scatter(test_case):
"""
Decorator marking a test that requires PyTorch Scatter. These tests are skipped when PyTorch Scatter isn't
installed.
"""
if not is_scatter_available():
return unittest.skip("test requires PyTorch Scatter")(test_case)
else:
return test_case |
Decorator marking a test that requires PyTorch Scatter. These tests are skipped when PyTorch Scatter isn't
installed.
| Decorator marking a test that requires PyTorch Scatter. These tests are skipped when PyTorch Scatter isn't
installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"PyTorch",
"Scatter",
".",
"These",
"tests",
"are",
"skipped",
"when",
"PyTorch",
"Scatter",
"isn",
"'",
"t",
"installed",
"."
] | def require_scatter(test_case):
if not is_scatter_available():
return unittest.skip("test requires PyTorch Scatter")(test_case)
else:
return test_case | [
"def",
"require_scatter",
"(",
"test_case",
")",
":",
"if",
"not",
"is_scatter_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires PyTorch Scatter\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires PyTorch Scatter. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"PyTorch",
"Scatter",
"."
] | [
"\"\"\"\n Decorator marking a test that requires PyTorch Scatter. These tests are skipped when PyTorch Scatter isn't\n installed.\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_faiss | <not_specific> | def require_faiss(test_case):
"""Decorator marking a test that requires faiss."""
if not is_faiss_available():
return unittest.skip("test requires `faiss`")(test_case)
else:
return test_case | Decorator marking a test that requires faiss. | Decorator marking a test that requires faiss. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"faiss",
"."
] | def require_faiss(test_case):
if not is_faiss_available():
return unittest.skip("test requires `faiss`")(test_case)
else:
return test_case | [
"def",
"require_faiss",
"(",
"test_case",
")",
":",
"if",
"not",
"is_faiss_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires `faiss`\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires faiss. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"faiss",
"."
] | [
"\"\"\"Decorator marking a test that requires faiss.\"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_optuna | <not_specific> | def require_optuna(test_case):
"""
Decorator marking a test that requires optuna.
These tests are skipped when optuna isn't installed.
"""
if not is_optuna_available():
return unittest.skip("test requires optuna")(test_case)
else:
return test_case |
Decorator marking a test that requires optuna.
These tests are skipped when optuna isn't installed.
| Decorator marking a test that requires optuna.
These tests are skipped when optuna isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"optuna",
".",
"These",
"tests",
"are",
"skipped",
"when",
"optuna",
"isn",
"'",
"t",
"installed",
"."
] | def require_optuna(test_case):
if not is_optuna_available():
return unittest.skip("test requires optuna")(test_case)
else:
return test_case | [
"def",
"require_optuna",
"(",
"test_case",
")",
":",
"if",
"not",
"is_optuna_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires optuna\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires optuna. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"optuna",
"."
] | [
"\"\"\"\n Decorator marking a test that requires optuna.\n\n These tests are skipped when optuna isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_ray | <not_specific> | def require_ray(test_case):
"""
Decorator marking a test that requires Ray/tune.
These tests are skipped when Ray/tune isn't installed.
"""
if not is_ray_available():
return unittest.skip("test requires Ray/tune")(test_case)
else:
return test_case |
Decorator marking a test that requires Ray/tune.
These tests are skipped when Ray/tune isn't installed.
| Decorator marking a test that requires Ray/tune.
These tests are skipped when Ray/tune isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"Ray",
"/",
"tune",
".",
"These",
"tests",
"are",
"skipped",
"when",
"Ray",
"/",
"tune",
"isn",
"'",
"t",
"installed",
"."
] | def require_ray(test_case):
if not is_ray_available():
return unittest.skip("test requires Ray/tune")(test_case)
else:
return test_case | [
"def",
"require_ray",
"(",
"test_case",
")",
":",
"if",
"not",
"is_ray_available",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires Ray/tune\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires Ray/tune. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"Ray",
"/",
"tune",
"."
] | [
"\"\"\"\n Decorator marking a test that requires Ray/tune.\n\n These tests are skipped when Ray/tune isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d16d8c07d096a25ff4511aceec34437123e3fd5 | siangooding/transformers | src/transformers/testing_utils.py | [
"Apache-2.0"
] | Python | require_soundfile | <not_specific> | def require_soundfile(test_case):
"""
Decorator marking a test that requires soundfile
These tests are skipped when soundfile isn't installed.
"""
if not is_soundfile_availble():
return unittest.skip("test requires soundfile")(test_case)
else:
return test_case |
Decorator marking a test that requires soundfile
These tests are skipped when soundfile isn't installed.
| Decorator marking a test that requires soundfile
These tests are skipped when soundfile isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"soundfile",
"These",
"tests",
"are",
"skipped",
"when",
"soundfile",
"isn",
"'",
"t",
"installed",
"."
] | def require_soundfile(test_case):
if not is_soundfile_availble():
return unittest.skip("test requires soundfile")(test_case)
else:
return test_case | [
"def",
"require_soundfile",
"(",
"test_case",
")",
":",
"if",
"not",
"is_soundfile_availble",
"(",
")",
":",
"return",
"unittest",
".",
"skip",
"(",
"\"test requires soundfile\"",
")",
"(",
"test_case",
")",
"else",
":",
"return",
"test_case"
] | Decorator marking a test that requires soundfile
These tests are skipped when soundfile isn't installed. | [
"Decorator",
"marking",
"a",
"test",
"that",
"requires",
"soundfile",
"These",
"tests",
"are",
"skipped",
"when",
"soundfile",
"isn",
"'",
"t",
"installed",
"."
] | [
"\"\"\"\n Decorator marking a test that requires soundfile\n\n These tests are skipped when soundfile isn't installed.\n\n \"\"\""
] | [
{
"param": "test_case",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c45189cb1c4d5dc2a23ad51891a89d8a5cba0724 | siangooding/transformers | src/transformers/models/marian/modeling_tf_marian.py | [
"Apache-2.0"
] | Python | _init_weight | <not_specific> | def _init_weight(n_pos: int, dim: int):
"""
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. [dim // 2:]
"""
position_enc = np.array(
[[pos / np.power(10000, 2 * (j // 2) / dim) ... |
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. [dim // 2:]
| Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. | [
"Identical",
"to",
"the",
"XLM",
"create_sinusoidal_embeddings",
"except",
"features",
"are",
"not",
"interleaved",
".",
"The",
"cos",
"features",
"are",
"in",
"the",
"2nd",
"half",
"of",
"the",
"vector",
"."
] | def _init_weight(n_pos: int, dim: int):
position_enc = np.array(
[[pos / np.power(10000, 2 * (j // 2) / dim) for j in range(dim)] for pos in range(n_pos)]
)
position_enc[:, 0 : dim // 2] = np.sin(position_enc[:, 0::2])
position_enc[:, dim // 2 :] = np.cos(position_enc[:, 1::2... | [
"def",
"_init_weight",
"(",
"n_pos",
":",
"int",
",",
"dim",
":",
"int",
")",
":",
"position_enc",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"pos",
"/",
"np",
".",
"power",
"(",
"10000",
",",
"2",
"*",
"(",
"j",
"//",
"2",
")",
"/",
"dim",
")",... | Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. | [
"Identical",
"to",
"the",
"XLM",
"create_sinusoidal_embeddings",
"except",
"features",
"are",
"not",
"interleaved",
"."
] | [
"\"\"\"\n Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in\n the 2nd half of the vector. [dim // 2:]\n \"\"\"",
"# index 0 is all zero",
"# convert to tensor"
] | [
{
"param": "n_pos",
"type": "int"
},
{
"param": "dim",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n_pos",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dim",
"type": "int",
"docstring": null,
"docstring_tokens":... |
4a13a46c75415d788dbcf1c068395e8ea014d76a | siangooding/transformers | src/transformers/models/longformer/modeling_tf_longformer.py | [
"Apache-2.0"
] | Python | _sliding_chunks_query_key_matmul | <not_specific> | def _sliding_chunks_query_key_matmul(self, query, key, window_overlap):
"""
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
o... |
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an
overlap of size window_overlap
| Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w with an
overlap of size window_overlap | [
"Matrix",
"multiplication",
"of",
"query",
"and",
"key",
"tensors",
"using",
"with",
"a",
"sliding",
"window",
"attention",
"pattern",
".",
"This",
"implementation",
"splits",
"the",
"input",
"into",
"overlapping",
"chunks",
"of",
"size",
"2w",
"with",
"an",
"... | def _sliding_chunks_query_key_matmul(self, query, key, window_overlap):
batch_size, seq_len, num_heads, head_dim = shape_list(query)
tf.debugging.assert_equal(
seq_len % (window_overlap * 2),
0,
message=f"Sequence length should be multiple of {window_overlap * 2}. Giv... | [
"def",
"_sliding_chunks_query_key_matmul",
"(",
"self",
",",
"query",
",",
"key",
",",
"window_overlap",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"shape_list",
"(",
"query",
")",
"tf",
".",
"debugging",
".",
"assert_equal... | Matrix multiplication of query and key tensors using with a sliding window attention pattern. | [
"Matrix",
"multiplication",
"of",
"query",
"and",
"key",
"tensors",
"using",
"with",
"a",
"sliding",
"window",
"attention",
"pattern",
"."
] | [
"\"\"\"\n Matrix multiplication of query and key tensors using with a sliding window attention pattern. This\n implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained Longformer) with an\n overlap of size window_overlap\n \"\"\"",
"# group batch_size... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "window_overlap",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
4a13a46c75415d788dbcf1c068395e8ea014d76a | siangooding/transformers | src/transformers/models/longformer/modeling_tf_longformer.py | [
"Apache-2.0"
] | Python | _sliding_chunks_matmul_attn_probs_value | <not_specific> | def _sliding_chunks_matmul_attn_probs_value(self, attn_probs, value, window_overlap):
"""
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
"""
batch_size, seq_len, num_heads, head_dim = shape... |
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
| Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs` | [
"Same",
"as",
"_sliding_chunks_query_key_matmul",
"but",
"for",
"attn_probs",
"and",
"value",
"tensors",
".",
"Returned",
"tensor",
"will",
"be",
"of",
"the",
"same",
"shape",
"as",
"`",
"attn_probs",
"`"
] | def _sliding_chunks_matmul_attn_probs_value(self, attn_probs, value, window_overlap):
batch_size, seq_len, num_heads, head_dim = shape_list(value)
tf.debugging.assert_equal(
seq_len % (window_overlap * 2),
0,
message="Seq_len has to be multiple of 2 * window_overlap",... | [
"def",
"_sliding_chunks_matmul_attn_probs_value",
"(",
"self",
",",
"attn_probs",
",",
"value",
",",
"window_overlap",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"shape_list",
"(",
"value",
")",
"tf",
".",
"debugging",
".",
... | Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. | [
"Same",
"as",
"_sliding_chunks_query_key_matmul",
"but",
"for",
"attn_probs",
"and",
"value",
"tensors",
"."
] | [
"\"\"\"\n Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the\n same shape as `attn_probs`\n \"\"\"",
"# group batch_size and num_heads dimensions into one, then chunk seq_len into chunks of size 2 window overlap",
"# group batch_siz... | [
{
"param": "self",
"type": null
},
{
"param": "attn_probs",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "window_overlap",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attn_probs",
"type": null,
"docstring": null,
"docstring_toke... |
4a13a46c75415d788dbcf1c068395e8ea014d76a | siangooding/transformers | src/transformers/models/longformer/modeling_tf_longformer.py | [
"Apache-2.0"
] | Python | _pad_to_window_size | <not_specific> | def _pad_to_window_size(
self,
input_ids,
attention_mask,
token_type_ids,
position_ids,
inputs_embeds,
pad_token_id,
):
"""A helper function to pad tokens and mask to work with implementation of Longformer selfattention."""
# padding
at... | A helper function to pad tokens and mask to work with implementation of Longformer selfattention. | A helper function to pad tokens and mask to work with implementation of Longformer selfattention. | [
"A",
"helper",
"function",
"to",
"pad",
"tokens",
"and",
"mask",
"to",
"work",
"with",
"implementation",
"of",
"Longformer",
"selfattention",
"."
] | def _pad_to_window_size(
self,
input_ids,
attention_mask,
token_type_ids,
position_ids,
inputs_embeds,
pad_token_id,
):
attention_window = (
self.attention_window if isinstance(self.attention_window, int) else max(self.attention_window)
... | [
"def",
"_pad_to_window_size",
"(",
"self",
",",
"input_ids",
",",
"attention_mask",
",",
"token_type_ids",
",",
"position_ids",
",",
"inputs_embeds",
",",
"pad_token_id",
",",
")",
":",
"attention_window",
"=",
"(",
"self",
".",
"attention_window",
"if",
"isinstan... | A helper function to pad tokens and mask to work with implementation of Longformer selfattention. | [
"A",
"helper",
"function",
"to",
"pad",
"tokens",
"and",
"mask",
"to",
"work",
"with",
"implementation",
"of",
"Longformer",
"selfattention",
"."
] | [
"\"\"\"A helper function to pad tokens and mask to work with implementation of Longformer selfattention.\"\"\"",
"# padding",
"# pad with position_id = pad_token_id as in modeling_roberta.RobertaEmbeddings",
"# no attention on the padding tokens",
"# pad with token_type_id = 0"
] | [
{
"param": "self",
"type": null
},
{
"param": "input_ids",
"type": null
},
{
"param": "attention_mask",
"type": null
},
{
"param": "token_type_ids",
"type": null
},
{
"param": "position_ids",
"type": null
},
{
"param": "inputs_embeds",
"type": null... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_ids",
"type": null,
"docstring": null,
"docstring_token... |
bb3231f9a0e8ea241c38d68db36bb397d06bf051 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/base.py | [
"MIT"
] | Python | authenticate | <not_specific> | def authenticate(self):
"""
Default implementation does nothing, must be overridden
:return:
"""
return None |
Default implementation does nothing, must be overridden
:return:
| Default implementation does nothing, must be overridden | [
"Default",
"implementation",
"does",
"nothing",
"must",
"be",
"overridden"
] | def authenticate(self):
return None | [
"def",
"authenticate",
"(",
"self",
")",
":",
"return",
"None"
] | Default implementation does nothing, must be overridden | [
"Default",
"implementation",
"does",
"nothing",
"must",
"be",
"overridden"
] | [
"\"\"\"\n Default implementation does nothing, must be overridden\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
bb3231f9a0e8ea241c38d68db36bb397d06bf051 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/base.py | [
"MIT"
] | Python | harmonize_dict | <not_specific> | def harmonize_dict(mapping, input_dict):
"""
Sanitizes incoming data into a dictionary with keys valid for a given domain (e.g. Django user models)
:param mapping: Dict containing the mapping of incoming to outgoing data.
:param input_dict: dict of data to be harmonized
:return: ... |
Sanitizes incoming data into a dictionary with keys valid for a given domain (e.g. Django user models)
:param mapping: Dict containing the mapping of incoming to outgoing data.
:param input_dict: dict of data to be harmonized
:return: dict containing keys from mapping and values from in... | Sanitizes incoming data into a dictionary with keys valid for a given domain | [
"Sanitizes",
"incoming",
"data",
"into",
"a",
"dictionary",
"with",
"keys",
"valid",
"for",
"a",
"given",
"domain"
] | def harmonize_dict(mapping, input_dict):
output_dict = dict()
for k, v in mapping.items():
if v in input_dict:
output_dict[k] = input_dict[v]
return output_dict | [
"def",
"harmonize_dict",
"(",
"mapping",
",",
"input_dict",
")",
":",
"output_dict",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"mapping",
".",
"items",
"(",
")",
":",
"if",
"v",
"in",
"input_dict",
":",
"output_dict",
"[",
"k",
"]",
"=",
"... | Sanitizes incoming data into a dictionary with keys valid for a given domain (e.g. | [
"Sanitizes",
"incoming",
"data",
"into",
"a",
"dictionary",
"with",
"keys",
"valid",
"for",
"a",
"given",
"domain",
"(",
"e",
".",
"g",
"."
] | [
"\"\"\"\n Sanitizes incoming data into a dictionary with keys valid for a given domain (e.g. Django user models)\n :param mapping: Dict containing the mapping of incoming to outgoing data.\n :param input_dict: dict of data to be harmonized\n :return: dict containing keys from mapping and... | [
{
"param": "mapping",
"type": null
},
{
"param": "input_dict",
"type": null
}
] | {
"returns": [
{
"docstring": "dict containing keys from mapping and values from input_dict",
"docstring_tokens": [
"dict",
"containing",
"keys",
"from",
"mapping",
"and",
"values",
"from",
"input_dict"
],
"type": null... |
bb3231f9a0e8ea241c38d68db36bb397d06bf051 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/base.py | [
"MIT"
] | Python | harmonize_user_details | <not_specific> | def harmonize_user_details(self, details):
"""
Harmonizes incoming details into a dictionary suitable for a django user model
:param details: user details from an external provider
:return: dict containing only keys valid for django user model
"""
return self.harmonize_di... |
Harmonizes incoming details into a dictionary suitable for a django user model
:param details: user details from an external provider
:return: dict containing only keys valid for django user model
| Harmonizes incoming details into a dictionary suitable for a django user model | [
"Harmonizes",
"incoming",
"details",
"into",
"a",
"dictionary",
"suitable",
"for",
"a",
"django",
"user",
"model"
] | def harmonize_user_details(self, details):
return self.harmonize_dict(self.get_user_details_map(), details) | [
"def",
"harmonize_user_details",
"(",
"self",
",",
"details",
")",
":",
"return",
"self",
".",
"harmonize_dict",
"(",
"self",
".",
"get_user_details_map",
"(",
")",
",",
"details",
")"
] | Harmonizes incoming details into a dictionary suitable for a django user model | [
"Harmonizes",
"incoming",
"details",
"into",
"a",
"dictionary",
"suitable",
"for",
"a",
"django",
"user",
"model"
] | [
"\"\"\"\n Harmonizes incoming details into a dictionary suitable for a django user model\n :param details: user details from an external provider\n :return: dict containing only keys valid for django user model\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "details",
"type": null
}
] | {
"returns": [
{
"docstring": "dict containing only keys valid for django user model",
"docstring_tokens": [
"dict",
"containing",
"only",
"keys",
"valid",
"for",
"django",
"user",
"model"
],
"type": null
}
],
... |
bb3231f9a0e8ea241c38d68db36bb397d06bf051 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/base.py | [
"MIT"
] | Python | update_model | <not_specific> | def update_model(model, attrs):
"""
Updates a model object with the given attributes
:param model: A model object
:param attrs: A dictionary of attribute keys and values
:return: the incoming model object, after updating and saving
"""
for attr, value in attrs.ite... |
Updates a model object with the given attributes
:param model: A model object
:param attrs: A dictionary of attribute keys and values
:return: the incoming model object, after updating and saving
| Updates a model object with the given attributes | [
"Updates",
"a",
"model",
"object",
"with",
"the",
"given",
"attributes"
] | def update_model(model, attrs):
for attr, value in attrs.items():
if value:
setattr(model, attr, value)
model.save()
return model | [
"def",
"update_model",
"(",
"model",
",",
"attrs",
")",
":",
"for",
"attr",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"value",
":",
"setattr",
"(",
"model",
",",
"attr",
",",
"value",
")",
"model",
".",
"save",
"(",
")",
"re... | Updates a model object with the given attributes | [
"Updates",
"a",
"model",
"object",
"with",
"the",
"given",
"attributes"
] | [
"\"\"\"\n Updates a model object with the given attributes\n :param model: A model object\n :param attrs: A dictionary of attribute keys and values\n :return: the incoming model object, after updating and saving\n \"\"\""
] | [
{
"param": "model",
"type": null
},
{
"param": "attrs",
"type": null
}
] | {
"returns": [
{
"docstring": "the incoming model object, after updating and saving",
"docstring_tokens": [
"the",
"incoming",
"model",
"object",
"after",
"updating",
"and",
"saving"
],
"type": null
}
],
"raises": [],
... |
bb3231f9a0e8ea241c38d68db36bb397d06bf051 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/base.py | [
"MIT"
] | Python | save_user | <not_specific> | def save_user(self, raw_user_dict, update=True):
"""
Creates or updates a user object from the provided dictionary
:param raw_user_dict: dictionary of user details from the external provider
:param update: True to update existing users with incoming data
:return:
"""
... |
Creates or updates a user object from the provided dictionary
:param raw_user_dict: dictionary of user details from the external provider
:param update: True to update existing users with incoming data
:return:
| Creates or updates a user object from the provided dictionary | [
"Creates",
"or",
"updates",
"a",
"user",
"object",
"from",
"the",
"provided",
"dictionary"
] | def save_user(self, raw_user_dict, update=True):
user_dict = self.harmonize_user_details(raw_user_dict)
if 'username' not in user_dict:
return None
user, created = get_user_model().objects.get_or_create(username=user_dict.get('username'))
if created or update:
use... | [
"def",
"save_user",
"(",
"self",
",",
"raw_user_dict",
",",
"update",
"=",
"True",
")",
":",
"user_dict",
"=",
"self",
".",
"harmonize_user_details",
"(",
"raw_user_dict",
")",
"if",
"'username'",
"not",
"in",
"user_dict",
":",
"return",
"None",
"user",
",",... | Creates or updates a user object from the provided dictionary | [
"Creates",
"or",
"updates",
"a",
"user",
"object",
"from",
"the",
"provided",
"dictionary"
] | [
"\"\"\"\n Creates or updates a user object from the provided dictionary\n :param raw_user_dict: dictionary of user details from the external provider\n :param update: True to update existing users with incoming data\n :return:\n \"\"\"",
"# Update the keys"
] | [
{
"param": "self",
"type": null
},
{
"param": "raw_user_dict",
"type": null
},
{
"param": "update",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
11c202b83589fb248ed3b589590c0b338c25f879 | Duke-GCB/gcb-web-auth | gcb_web_auth/views.py | [
"MIT"
] | Python | push_state | <not_specific> | def push_state(request, state_string, destination_param='next'):
"""
Saves the OAuth state parameter from a request along with a redirect location
:param request: A request object that may contain the destination param as a query param
:param state_string: The state to store
:param destination_param... |
Saves the OAuth state parameter from a request along with a redirect location
:param request: A request object that may contain the destination param as a query param
:param state_string: The state to store
:param destination_param: the parameter name in the URL that contains the destination to store
... | Saves the OAuth state parameter from a request along with a redirect location | [
"Saves",
"the",
"OAuth",
"state",
"parameter",
"from",
"a",
"request",
"along",
"with",
"a",
"redirect",
"location"
] | def push_state(request, state_string, destination_param='next'):
if not state_string:
raise StateException('State string must be present')
saved_state = OAuthState.objects.create(state=state_string)
if destination_param in request.GET:
saved_state.destination = request.GET[destination_param]... | [
"def",
"push_state",
"(",
"request",
",",
"state_string",
",",
"destination_param",
"=",
"'next'",
")",
":",
"if",
"not",
"state_string",
":",
"raise",
"StateException",
"(",
"'State string must be present'",
")",
"saved_state",
"=",
"OAuthState",
".",
"objects",
... | Saves the OAuth state parameter from a request along with a redirect location | [
"Saves",
"the",
"OAuth",
"state",
"parameter",
"from",
"a",
"request",
"along",
"with",
"a",
"redirect",
"location"
] | [
"\"\"\"\n Saves the OAuth state parameter from a request along with a redirect location\n :param request: A request object that may contain the destination param as a query param\n :param state_string: The state to store\n :param destination_param: the parameter name in the URL that contains the destina... | [
{
"param": "request",
"type": null
},
{
"param": "state_string",
"type": null
},
{
"param": "destination_param",
"type": null
}
] | {
"returns": [
{
"docstring": "The persisted OAuthState object",
"docstring_tokens": [
"The",
"persisted",
"OAuthState",
"object"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstri... |
11c202b83589fb248ed3b589590c0b338c25f879 | Duke-GCB/gcb-web-auth | gcb_web_auth/views.py | [
"MIT"
] | Python | pop_state | <not_specific> | def pop_state(request):
"""
Utility function to validate OAuth state and restore destination redirect param
If the request does not specify state or it does not match a recent state, an exception is raised
:param request: a request object that must have 'state=' in the GET parameters
:return: The va... |
Utility function to validate OAuth state and restore destination redirect param
If the request does not specify state or it does not match a recent state, an exception is raised
:param request: a request object that must have 'state=' in the GET parameters
:return: The value of the stored destination
... | Utility function to validate OAuth state and restore destination redirect param
If the request does not specify state or it does not match a recent state, an exception is raised | [
"Utility",
"function",
"to",
"validate",
"OAuth",
"state",
"and",
"restore",
"destination",
"redirect",
"param",
"If",
"the",
"request",
"does",
"not",
"specify",
"state",
"or",
"it",
"does",
"not",
"match",
"a",
"recent",
"state",
"an",
"exception",
"is",
"... | def pop_state(request):
if 'state' in request.GET:
state_string = request.GET['state']
try:
state = OAuthState.objects.get(state=state_string)
destination = state.destination
state.delete()
return destination
except ObjectDoesNotExist as e:
... | [
"def",
"pop_state",
"(",
"request",
")",
":",
"if",
"'state'",
"in",
"request",
".",
"GET",
":",
"state_string",
"=",
"request",
".",
"GET",
"[",
"'state'",
"]",
"try",
":",
"state",
"=",
"OAuthState",
".",
"objects",
".",
"get",
"(",
"state",
"=",
"... | Utility function to validate OAuth state and restore destination redirect param
If the request does not specify state or it does not match a recent state, an exception is raised | [
"Utility",
"function",
"to",
"validate",
"OAuth",
"state",
"and",
"restore",
"destination",
"redirect",
"param",
"If",
"the",
"request",
"does",
"not",
"specify",
"state",
"or",
"it",
"does",
"not",
"match",
"a",
"recent",
"state",
"an",
"exception",
"is",
"... | [
"\"\"\"\n Utility function to validate OAuth state and restore destination redirect param\n If the request does not specify state or it does not match a recent state, an exception is raised\n :param request: a request object that must have 'state=' in the GET parameters\n :return: The value of the store... | [
{
"param": "request",
"type": null
}
] | {
"returns": [
{
"docstring": "The value of the stored destination",
"docstring_tokens": [
"The",
"value",
"of",
"the",
"stored",
"destination"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "request",
... |
ba40eb68ad99cfefb6160fbf9cba99e33f5e1df4 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/dukeds.py | [
"MIT"
] | Python | harmonize_user_details | <not_specific> | def harmonize_user_details(self, details):
"""
Overrides harmonize_user_details in BaseBackend to append @duke.edu to usernames from DukeDS
:param details: incoming dictionary of user details
:return: details harmonized for a django user object
"""
details = super(DukeDSA... |
Overrides harmonize_user_details in BaseBackend to append @duke.edu to usernames from DukeDS
:param details: incoming dictionary of user details
:return: details harmonized for a django user object
| Overrides harmonize_user_details in BaseBackend to append @duke.edu to usernames from DukeDS | [
"Overrides",
"harmonize_user_details",
"in",
"BaseBackend",
"to",
"append",
"@duke",
".",
"edu",
"to",
"usernames",
"from",
"DukeDS"
] | def harmonize_user_details(self, details):
details = super(DukeDSAuthBackend, self).harmonize_user_details(details)
if 'username' in details:
details['username'] = '{}@duke.edu'.format(details['username'])
return details | [
"def",
"harmonize_user_details",
"(",
"self",
",",
"details",
")",
":",
"details",
"=",
"super",
"(",
"DukeDSAuthBackend",
",",
"self",
")",
".",
"harmonize_user_details",
"(",
"details",
")",
"if",
"'username'",
"in",
"details",
":",
"details",
"[",
"'usernam... | Overrides harmonize_user_details in BaseBackend to append @duke.edu to usernames from DukeDS | [
"Overrides",
"harmonize_user_details",
"in",
"BaseBackend",
"to",
"append",
"@duke",
".",
"edu",
"to",
"usernames",
"from",
"DukeDS"
] | [
"\"\"\"\n Overrides harmonize_user_details in BaseBackend to append @duke.edu to usernames from DukeDS\n :param details: incoming dictionary of user details\n :return: details harmonized for a django user object\n \"\"\"",
"# For DukeDS, we need to append @duke.edu to username"
] | [
{
"param": "self",
"type": null
},
{
"param": "details",
"type": null
}
] | {
"returns": [
{
"docstring": "details harmonized for a django user object",
"docstring_tokens": [
"details",
"harmonized",
"for",
"a",
"django",
"user",
"object"
],
"type": null
}
],
"raises": [],
"params": [
{
"i... |
ba40eb68ad99cfefb6160fbf9cba99e33f5e1df4 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/dukeds.py | [
"MIT"
] | Python | authenticate | <not_specific> | def authenticate(self, token):
"""
Authenticate a user with a DukeDS API token. Returns None if no user could be authenticated,
and sets the errors list with the reasons
:param token: A JWT token
:return: an authenticated, populated user if found, or None if not.
"""
... |
Authenticate a user with a DukeDS API token. Returns None if no user could be authenticated,
and sets the errors list with the reasons
:param token: A JWT token
:return: an authenticated, populated user if found, or None if not.
| Authenticate a user with a DukeDS API token. Returns None if no user could be authenticated,
and sets the errors list with the reasons | [
"Authenticate",
"a",
"user",
"with",
"a",
"DukeDS",
"API",
"token",
".",
"Returns",
"None",
"if",
"no",
"user",
"could",
"be",
"authenticated",
"and",
"sets",
"the",
"errors",
"list",
"with",
"the",
"reasons"
] | def authenticate(self, token):
self.failure_reason = None
try:
check_jwt_token(token)
except InvalidTokenError as e:
self.failure_reason = e
return None
user = get_local_user(token)
if user:
return user
config = make_auth_co... | [
"def",
"authenticate",
"(",
"self",
",",
"token",
")",
":",
"self",
".",
"failure_reason",
"=",
"None",
"try",
":",
"check_jwt_token",
"(",
"token",
")",
"except",
"InvalidTokenError",
"as",
"e",
":",
"self",
".",
"failure_reason",
"=",
"e",
"return",
"Non... | Authenticate a user with a DukeDS API token. | [
"Authenticate",
"a",
"user",
"with",
"a",
"DukeDS",
"API",
"token",
"."
] | [
"\"\"\"\n Authenticate a user with a DukeDS API token. Returns None if no user could be authenticated,\n and sets the errors list with the reasons\n :param token: A JWT token\n :return: an authenticated, populated user if found, or None if not.\n \"\"\"",
"# 1. check if token is... | [
{
"param": "self",
"type": null
},
{
"param": "token",
"type": null
}
] | {
"returns": [
{
"docstring": "an authenticated, populated user if found, or None if not.",
"docstring_tokens": [
"an",
"authenticated",
"populated",
"user",
"if",
"found",
"or",
"None",
"if",
"not",
"."
],
... |
ba40eb68ad99cfefb6160fbf9cba99e33f5e1df4 | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/dukeds.py | [
"MIT"
] | Python | handle_new_user | null | def handle_new_user(self, user, details):
"""
Stub method to allow custom behavior for new DukeDS users
:param user: A django model user
:param raw_user_dict: user details from DukeDS API, including their id
"""
pass |
Stub method to allow custom behavior for new DukeDS users
:param user: A django model user
:param raw_user_dict: user details from DukeDS API, including their id
| Stub method to allow custom behavior for new DukeDS users | [
"Stub",
"method",
"to",
"allow",
"custom",
"behavior",
"for",
"new",
"DukeDS",
"users"
] | def handle_new_user(self, user, details):
pass | [
"def",
"handle_new_user",
"(",
"self",
",",
"user",
",",
"details",
")",
":",
"pass"
] | Stub method to allow custom behavior for new DukeDS users | [
"Stub",
"method",
"to",
"allow",
"custom",
"behavior",
"for",
"new",
"DukeDS",
"users"
] | [
"\"\"\"\n Stub method to allow custom behavior for new DukeDS users\n :param user: A django model user\n :param raw_user_dict: user details from DukeDS API, including their id\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "details",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": "A django model user",
"doc... |
8e2e6b5b572e28ced24689776ac234c93a793426 | Duke-GCB/gcb-web-auth | gcb_web_auth/dukeds_auth.py | [
"MIT"
] | Python | internal_request_auth_header | <not_specific> | def internal_request_auth_header(self):
"""
Transforms the header that clients will specify into the META key
that the server here will see. Header fields are prefixed with 'HTTP_',
uppercased, and '-' is replaced with '_'
:return:
"""
return 'HTTP_{}'.format(self... |
Transforms the header that clients will specify into the META key
that the server here will see. Header fields are prefixed with 'HTTP_',
uppercased, and '-' is replaced with '_'
:return:
| Transforms the header that clients will specify into the META key
that the server here will see. | [
"Transforms",
"the",
"header",
"that",
"clients",
"will",
"specify",
"into",
"the",
"META",
"key",
"that",
"the",
"server",
"here",
"will",
"see",
"."
] | def internal_request_auth_header(self):
return 'HTTP_{}'.format(self.request_auth_header.replace('-','_').upper()) | [
"def",
"internal_request_auth_header",
"(",
"self",
")",
":",
"return",
"'HTTP_{}'",
".",
"format",
"(",
"self",
".",
"request_auth_header",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
".",
"upper",
"(",
")",
")"
] | Transforms the header that clients will specify into the META key
that the server here will see. | [
"Transforms",
"the",
"header",
"that",
"clients",
"will",
"specify",
"into",
"the",
"META",
"key",
"that",
"the",
"server",
"here",
"will",
"see",
"."
] | [
"\"\"\"\n Transforms the header that clients will specify into the META key\n that the server here will see. Header fields are prefixed with 'HTTP_',\n uppercased, and '-' is replaced with '_'\n :return:\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
da53752dcf6b6cccf46e141a566ea1d87d74739d | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/oauth.py | [
"MIT"
] | Python | check_user_details | null | def check_user_details(self, details):
"""
Stub method to allow checking OAuth user details and raising PermissionDenied if not valid
:param details: A dictionary of OAuth user info
"""
pass |
Stub method to allow checking OAuth user details and raising PermissionDenied if not valid
:param details: A dictionary of OAuth user info
| Stub method to allow checking OAuth user details and raising PermissionDenied if not valid | [
"Stub",
"method",
"to",
"allow",
"checking",
"OAuth",
"user",
"details",
"and",
"raising",
"PermissionDenied",
"if",
"not",
"valid"
] | def check_user_details(self, details):
pass | [
"def",
"check_user_details",
"(",
"self",
",",
"details",
")",
":",
"pass"
] | Stub method to allow checking OAuth user details and raising PermissionDenied if not valid | [
"Stub",
"method",
"to",
"allow",
"checking",
"OAuth",
"user",
"details",
"and",
"raising",
"PermissionDenied",
"if",
"not",
"valid"
] | [
"\"\"\"\n Stub method to allow checking OAuth user details and raising PermissionDenied if not valid\n :param details: A dictionary of OAuth user info\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "details",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "details",
"type": null,
"docstring": "A dictionary of OAuth user in... |
da53752dcf6b6cccf46e141a566ea1d87d74739d | Duke-GCB/gcb-web-auth | gcb_web_auth/backends/oauth.py | [
"MIT"
] | Python | verify_user_belongs_to_group | null | def verify_user_belongs_to_group(self, duke_unique_id, group_name):
"""
Using the singleton GroupManagerConnection object check to see if a user belongs to a group and raises
PermissionDenied if missing setup or user is not a member of the group.
:param duke_unique_id: str: unique duke i... |
Using the singleton GroupManagerConnection object check to see if a user belongs to a group and raises
PermissionDenied if missing setup or user is not a member of the group.
:param duke_unique_id: str: unique duke id for a user
:param group_name: str: name of the group to check
... | Using the singleton GroupManagerConnection object check to see if a user belongs to a group and raises
PermissionDenied if missing setup or user is not a member of the group. | [
"Using",
"the",
"singleton",
"GroupManagerConnection",
"object",
"check",
"to",
"see",
"if",
"a",
"user",
"belongs",
"to",
"a",
"group",
"and",
"raises",
"PermissionDenied",
"if",
"missing",
"setup",
"or",
"user",
"is",
"not",
"a",
"member",
"of",
"the",
"gr... | def verify_user_belongs_to_group(self, duke_unique_id, group_name):
group_manager_connection = GroupManagerConnection.objects.first()
if not group_manager_connection:
logger.error(MISSING_GROUP_MANAGER_SETUP)
raise PermissionDenied(MISSING_GROUP_MANAGER_SETUP)
if not user... | [
"def",
"verify_user_belongs_to_group",
"(",
"self",
",",
"duke_unique_id",
",",
"group_name",
")",
":",
"group_manager_connection",
"=",
"GroupManagerConnection",
".",
"objects",
".",
"first",
"(",
")",
"if",
"not",
"group_manager_connection",
":",
"logger",
".",
"e... | Using the singleton GroupManagerConnection object check to see if a user belongs to a group and raises
PermissionDenied if missing setup or user is not a member of the group. | [
"Using",
"the",
"singleton",
"GroupManagerConnection",
"object",
"check",
"to",
"see",
"if",
"a",
"user",
"belongs",
"to",
"a",
"group",
"and",
"raises",
"PermissionDenied",
"if",
"missing",
"setup",
"or",
"user",
"is",
"not",
"a",
"member",
"of",
"the",
"gr... | [
"\"\"\"\n Using the singleton GroupManagerConnection object check to see if a user belongs to a group and raises\n PermissionDenied if missing setup or user is not a member of the group.\n :param duke_unique_id: str: unique duke id for a user\n :param group_name: str: name of the group t... | [
{
"param": "self",
"type": null
},
{
"param": "duke_unique_id",
"type": null
},
{
"param": "group_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "duke_unique_id",
"type": null,
"docstring": "unique duke id for a u... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | check_jwt_token | <not_specific> | def check_jwt_token(token):
"""
Uses PyJWT to parse and verify the token expiration
:param token: A JWT token to check
:return: The decoded token, or raises if invalid/expired
"""
# jwt.decode will verify the expiration date of the token
# We won't have the secret so we can't verify the sign... |
Uses PyJWT to parse and verify the token expiration
:param token: A JWT token to check
:return: The decoded token, or raises if invalid/expired
| Uses PyJWT to parse and verify the token expiration | [
"Uses",
"PyJWT",
"to",
"parse",
"and",
"verify",
"the",
"token",
"expiration"
] | def check_jwt_token(token):
return decode(token, options={'verify_signature': False}) | [
"def",
"check_jwt_token",
"(",
"token",
")",
":",
"return",
"decode",
"(",
"token",
",",
"options",
"=",
"{",
"'verify_signature'",
":",
"False",
"}",
")"
] | Uses PyJWT to parse and verify the token expiration | [
"Uses",
"PyJWT",
"to",
"parse",
"and",
"verify",
"the",
"token",
"expiration"
] | [
"\"\"\"\n Uses PyJWT to parse and verify the token expiration\n :param token: A JWT token to check\n :return: The decoded token, or raises if invalid/expired\n \"\"\"",
"# jwt.decode will verify the expiration date of the token",
"# We won't have the secret so we can't verify the signature, but we s... | [
{
"param": "token",
"type": null
}
] | {
"returns": [
{
"docstring": "The decoded token, or raises if invalid/expired",
"docstring_tokens": [
"The",
"decoded",
"token",
"or",
"raises",
"if",
"invalid",
"/",
"expired"
],
"type": null
}
],
"raises": [... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | current_user_details | <not_specific> | def current_user_details(oauth_service, user):
"""
A simple method to make an OAuth request to the user details endpoint, that will automatically refresh the token
:param oauth_service: An OAuthService model object
:param user: a django model user
:return:
"""
session = make_refreshing_oauth... |
A simple method to make an OAuth request to the user details endpoint, that will automatically refresh the token
:param oauth_service: An OAuthService model object
:param user: a django model user
:return:
| A simple method to make an OAuth request to the user details endpoint, that will automatically refresh the token | [
"A",
"simple",
"method",
"to",
"make",
"an",
"OAuth",
"request",
"to",
"the",
"user",
"details",
"endpoint",
"that",
"will",
"automatically",
"refresh",
"the",
"token"
] | def current_user_details(oauth_service, user):
session = make_refreshing_oauth_session(oauth_service, user)
return fetch_user_details(oauth_service, session) | [
"def",
"current_user_details",
"(",
"oauth_service",
",",
"user",
")",
":",
"session",
"=",
"make_refreshing_oauth_session",
"(",
"oauth_service",
",",
"user",
")",
"return",
"fetch_user_details",
"(",
"oauth_service",
",",
"session",
")"
] | A simple method to make an OAuth request to the user details endpoint, that will automatically refresh the token | [
"A",
"simple",
"method",
"to",
"make",
"an",
"OAuth",
"request",
"to",
"the",
"user",
"details",
"endpoint",
"that",
"will",
"automatically",
"refresh",
"the",
"token"
] | [
"\"\"\"\n A simple method to make an OAuth request to the user details endpoint, that will automatically refresh the token\n :param oauth_service: An OAuthService model object\n :param user: a django model user\n :return:\n \"\"\""
] | [
{
"param": "oauth_service",
"type": null
},
{
"param": "user",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "oauth_service",
"type": null,
"docstring": "An OAuthService model object",
"docstring_tokens": [
"An",
... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | user_details_from_token | <not_specific> | def user_details_from_token(oauth_service, token_dict):
"""
Fetches user details from the oauth_service's resource URI, using only a token dict
:param oauth_service: An OAuthService model object
:param token_dict: a dict containing the access_token
:return:
"""
session = make_oauth_session(o... |
Fetches user details from the oauth_service's resource URI, using only a token dict
:param oauth_service: An OAuthService model object
:param token_dict: a dict containing the access_token
:return:
| Fetches user details from the oauth_service's resource URI, using only a token dict | [
"Fetches",
"user",
"details",
"from",
"the",
"oauth_service",
"'",
"s",
"resource",
"URI",
"using",
"only",
"a",
"token",
"dict"
] | def user_details_from_token(oauth_service, token_dict):
session = make_oauth_session(oauth_service)
session.token = token_dict
return fetch_user_details(oauth_service, session) | [
"def",
"user_details_from_token",
"(",
"oauth_service",
",",
"token_dict",
")",
":",
"session",
"=",
"make_oauth_session",
"(",
"oauth_service",
")",
"session",
".",
"token",
"=",
"token_dict",
"return",
"fetch_user_details",
"(",
"oauth_service",
",",
"session",
")... | Fetches user details from the oauth_service's resource URI, using only a token dict | [
"Fetches",
"user",
"details",
"from",
"the",
"oauth_service",
"'",
"s",
"resource",
"URI",
"using",
"only",
"a",
"token",
"dict"
] | [
"\"\"\"\n Fetches user details from the oauth_service's resource URI, using only a token dict\n :param oauth_service: An OAuthService model object\n :param token_dict: a dict containing the access_token\n :return:\n \"\"\""
] | [
{
"param": "oauth_service",
"type": null
},
{
"param": "token_dict",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "oauth_service",
"type": null,
"docstring": "An OAuthService model object",
"docstring_tokens": [
"An",
... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | revoke_token | null | def revoke_token(token):
"""
Revokes a token using it's service's revoke_uri and the refresh_token
:param token: an OAuthToken object
:return: JSON response of the revoke status
"""
service = token.service
auth = (service.client_id, service.client_secret,)
# Revoking the refresh token wi... |
Revokes a token using it's service's revoke_uri and the refresh_token
:param token: an OAuthToken object
:return: JSON response of the revoke status
| Revokes a token using it's service's revoke_uri and the refresh_token | [
"Revokes",
"a",
"token",
"using",
"it",
"'",
"s",
"service",
"'",
"s",
"revoke_uri",
"and",
"the",
"refresh_token"
] | def revoke_token(token):
service = token.service
auth = (service.client_id, service.client_secret,)
data = {'token': token.token_dict.get('refresh_token')}
response = requests.post(service.revoke_uri, auth=auth, data=data)
try:
response.raise_for_status()
except requests.HTTPError as e:
... | [
"def",
"revoke_token",
"(",
"token",
")",
":",
"service",
"=",
"token",
".",
"service",
"auth",
"=",
"(",
"service",
".",
"client_id",
",",
"service",
".",
"client_secret",
",",
")",
"data",
"=",
"{",
"'token'",
":",
"token",
".",
"token_dict",
".",
"g... | Revokes a token using it's service's revoke_uri and the refresh_token | [
"Revokes",
"a",
"token",
"using",
"it",
"'",
"s",
"service",
"'",
"s",
"revoke_uri",
"and",
"the",
"refresh_token"
] | [
"\"\"\"\n Revokes a token using it's service's revoke_uri and the refresh_token\n :param token: an OAuthToken object\n :return: JSON response of the revoke status\n \"\"\"",
"# Revoking the refresh token will revoke its parents too"
] | [
{
"param": "token",
"type": null
}
] | {
"returns": [
{
"docstring": "JSON response of the revoke status",
"docstring_tokens": [
"JSON",
"response",
"of",
"the",
"revoke",
"status"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "token",
"t... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | make_auth_config | <not_specific> | def make_auth_config(token):
"""
Returns a DukeDS config object populated with URL and such
from this application's django settings
:param token: The authorization token for DukeDS
:return: a ddsc.config.Config
"""
config = Config()
endpoint = get_default_dds_endpoint()
config.update... |
Returns a DukeDS config object populated with URL and such
from this application's django settings
:param token: The authorization token for DukeDS
:return: a ddsc.config.Config
| Returns a DukeDS config object populated with URL and such
from this application's django settings | [
"Returns",
"a",
"DukeDS",
"config",
"object",
"populated",
"with",
"URL",
"and",
"such",
"from",
"this",
"application",
"'",
"s",
"django",
"settings"
] | def make_auth_config(token):
config = Config()
endpoint = get_default_dds_endpoint()
config.update_properties({
Config.URL: endpoint.api_root,
})
config.values[Config.AUTH] = token
return config | [
"def",
"make_auth_config",
"(",
"token",
")",
":",
"config",
"=",
"Config",
"(",
")",
"endpoint",
"=",
"get_default_dds_endpoint",
"(",
")",
"config",
".",
"update_properties",
"(",
"{",
"Config",
".",
"URL",
":",
"endpoint",
".",
"api_root",
",",
"}",
")"... | Returns a DukeDS config object populated with URL and such
from this application's django settings | [
"Returns",
"a",
"DukeDS",
"config",
"object",
"populated",
"with",
"URL",
"and",
"such",
"from",
"this",
"application",
"'",
"s",
"django",
"settings"
] | [
"\"\"\"\n Returns a DukeDS config object populated with URL and such\n from this application's django settings\n :param token: The authorization token for DukeDS\n :return: a ddsc.config.Config\n \"\"\""
] | [
{
"param": "token",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "token",
"type": null,
"docstring": "The authorization token for DukeDS",
"docstring_tokens": [
"The",
... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | save_dukeds_token | <not_specific> | def save_dukeds_token(user, token):
"""
Saves a DukeDSAPIToken object containing the provided token for the specified user
:param user: A django User
:param token: the token text to save
:return: The newly created token
"""
remove_invalid_dukeds_tokens(user)
return DukeDSAPIToken.objects... |
Saves a DukeDSAPIToken object containing the provided token for the specified user
:param user: A django User
:param token: the token text to save
:return: The newly created token
| Saves a DukeDSAPIToken object containing the provided token for the specified user | [
"Saves",
"a",
"DukeDSAPIToken",
"object",
"containing",
"the",
"provided",
"token",
"for",
"the",
"specified",
"user"
] | def save_dukeds_token(user, token):
remove_invalid_dukeds_tokens(user)
return DukeDSAPIToken.objects.create(user=user, key=token) | [
"def",
"save_dukeds_token",
"(",
"user",
",",
"token",
")",
":",
"remove_invalid_dukeds_tokens",
"(",
"user",
")",
"return",
"DukeDSAPIToken",
".",
"objects",
".",
"create",
"(",
"user",
"=",
"user",
",",
"key",
"=",
"token",
")"
] | Saves a DukeDSAPIToken object containing the provided token for the specified user | [
"Saves",
"a",
"DukeDSAPIToken",
"object",
"containing",
"the",
"provided",
"token",
"for",
"the",
"specified",
"user"
] | [
"\"\"\"\n Saves a DukeDSAPIToken object containing the provided token for the specified user\n :param user: A django User\n :param token: the token text to save\n :return: The newly created token\n \"\"\""
] | [
{
"param": "user",
"type": null
},
{
"param": "token",
"type": null
}
] | {
"returns": [
{
"docstring": "The newly created token",
"docstring_tokens": [
"The",
"newly",
"created",
"token"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "user",
"type": null,
"docstring": "A django User... |
2d92aeafbe90ba0245b44a728d5eb6d519b7f243 | Duke-GCB/gcb-web-auth | gcb_web_auth/utils.py | [
"MIT"
] | Python | remove_invalid_dukeds_tokens | null | def remove_invalid_dukeds_tokens(user):
"""
Examines a user's DukeDSAPITokens, removing any that are invalid JWTs (e.g. expired)
:param user: a django User
:return: None
"""
for token in DukeDSAPIToken.objects.filter(user=user):
try:
check_jwt_token(token.key)
except ... |
Examines a user's DukeDSAPITokens, removing any that are invalid JWTs (e.g. expired)
:param user: a django User
:return: None
| Examines a user's DukeDSAPITokens, removing any that are invalid JWTs | [
"Examines",
"a",
"user",
"'",
"s",
"DukeDSAPITokens",
"removing",
"any",
"that",
"are",
"invalid",
"JWTs"
] | def remove_invalid_dukeds_tokens(user):
for token in DukeDSAPIToken.objects.filter(user=user):
try:
check_jwt_token(token.key)
except InvalidTokenError as e:
token.delete() | [
"def",
"remove_invalid_dukeds_tokens",
"(",
"user",
")",
":",
"for",
"token",
"in",
"DukeDSAPIToken",
".",
"objects",
".",
"filter",
"(",
"user",
"=",
"user",
")",
":",
"try",
":",
"check_jwt_token",
"(",
"token",
".",
"key",
")",
"except",
"InvalidTokenErro... | Examines a user's DukeDSAPITokens, removing any that are invalid JWTs (e.g. | [
"Examines",
"a",
"user",
"'",
"s",
"DukeDSAPITokens",
"removing",
"any",
"that",
"are",
"invalid",
"JWTs",
"(",
"e",
".",
"g",
"."
] | [
"\"\"\"\n Examines a user's DukeDSAPITokens, removing any that are invalid JWTs (e.g. expired)\n :param user: a django User\n :return: None\n \"\"\""
] | [
{
"param": "user",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "user",
"type": null,
"docstring": "a django User",
"docstring_tokens": [
"a",
"django",
"Us... |
843523f191ce6cd8528995ed06357b38cd5b5104 | Duke-GCB/gcb-web-auth | gcb_web_auth/tests_utils.py | [
"MIT"
] | Python | make_oauth_service | <not_specific> | def make_oauth_service(cls=MagicMock, save=False):
"""
Helper method that can make a mock service with the parameters
or a full database-backed object if the OAuthService class is passed
:param cls: Class to instantiate
:param save: If true, call save() on the service afer creating
:return: a mo... |
Helper method that can make a mock service with the parameters
or a full database-backed object if the OAuthService class is passed
:param cls: Class to instantiate
:param save: If true, call save() on the service afer creating
:return: a mocked object or database backed (ready for save())
| Helper method that can make a mock service with the parameters
or a full database-backed object if the OAuthService class is passed | [
"Helper",
"method",
"that",
"can",
"make",
"a",
"mock",
"service",
"with",
"the",
"parameters",
"or",
"a",
"full",
"database",
"-",
"backed",
"object",
"if",
"the",
"OAuthService",
"class",
"is",
"passed"
] | def make_oauth_service(cls=MagicMock, save=False):
service = cls(client_id='id123',
client_secret='secret456',
redirect_uri='redirect',
scope='scope1',
authorization_uri='authorize',
token_uri='token')
if save: service.sav... | [
"def",
"make_oauth_service",
"(",
"cls",
"=",
"MagicMock",
",",
"save",
"=",
"False",
")",
":",
"service",
"=",
"cls",
"(",
"client_id",
"=",
"'id123'",
",",
"client_secret",
"=",
"'secret456'",
",",
"redirect_uri",
"=",
"'redirect'",
",",
"scope",
"=",
"'... | Helper method that can make a mock service with the parameters
or a full database-backed object if the OAuthService class is passed | [
"Helper",
"method",
"that",
"can",
"make",
"a",
"mock",
"service",
"with",
"the",
"parameters",
"or",
"a",
"full",
"database",
"-",
"backed",
"object",
"if",
"the",
"OAuthService",
"class",
"is",
"passed"
] | [
"\"\"\"\n Helper method that can make a mock service with the parameters\n or a full database-backed object if the OAuthService class is passed\n :param cls: Class to instantiate\n :param save: If true, call save() on the service afer creating\n :return: a mocked object or database backed (ready for ... | [
{
"param": "cls",
"type": null
},
{
"param": "save",
"type": null
}
] | {
"returns": [
{
"docstring": "a mocked object or database backed (ready for save())",
"docstring_tokens": [
"a",
"mocked",
"object",
"or",
"database",
"backed",
"(",
"ready",
"for",
"save",
"()",
")"
... |
7c0b49106e71e0195929c04548dac386906b89cd | Duke-GCB/gcb-web-auth | gcb_web_auth/groupmanager.py | [
"MIT"
] | Python | user_belongs_to_group | <not_specific> | def user_belongs_to_group(group_manager_connection, duke_unique_id, group_name):
"""
Returns True if the user associated with duke_unique_id is in a particular GroupManager group
:param group_manager_connection: GroupManagerConnection: settings used to talk to group manager
:param duke_unique_id: str: u... |
Returns True if the user associated with duke_unique_id is in a particular GroupManager group
:param group_manager_connection: GroupManagerConnection: settings used to talk to group manager
:param duke_unique_id: str: unique id (number) of the user we want to check
:param group_name: str: name of the g... | Returns True if the user associated with duke_unique_id is in a particular GroupManager group | [
"Returns",
"True",
"if",
"the",
"user",
"associated",
"with",
"duke_unique_id",
"is",
"in",
"a",
"particular",
"GroupManager",
"group"
] | def user_belongs_to_group(group_manager_connection, duke_unique_id, group_name):
return group_name in get_users_group_names(group_manager_connection, duke_unique_id) | [
"def",
"user_belongs_to_group",
"(",
"group_manager_connection",
",",
"duke_unique_id",
",",
"group_name",
")",
":",
"return",
"group_name",
"in",
"get_users_group_names",
"(",
"group_manager_connection",
",",
"duke_unique_id",
")"
] | Returns True if the user associated with duke_unique_id is in a particular GroupManager group | [
"Returns",
"True",
"if",
"the",
"user",
"associated",
"with",
"duke_unique_id",
"is",
"in",
"a",
"particular",
"GroupManager",
"group"
] | [
"\"\"\"\n Returns True if the user associated with duke_unique_id is in a particular GroupManager group\n :param group_manager_connection: GroupManagerConnection: settings used to talk to group manager\n :param duke_unique_id: str: unique id (number) of the user we want to check\n :param group_name: str... | [
{
"param": "group_manager_connection",
"type": null
},
{
"param": "duke_unique_id",
"type": null
},
{
"param": "group_name",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the user belongs to that agroup",
"docstring_tokens": [
"True",
"if",
"the",
"user",
"belongs",
"to",
"that",
"agroup"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
7c0b49106e71e0195929c04548dac386906b89cd | Duke-GCB/gcb-web-auth | gcb_web_auth/groupmanager.py | [
"MIT"
] | Python | make_users_groups_url | <not_specific> | def make_users_groups_url(base_url, duke_unique_id):
"""
Create url for fetching a users groups.
:param base_url: base group manager url (eg. 'https://groups.oit.duke.edu/grouper-ws/servicesRest/json/v2_1_500/')
:param duke_unique_id: str: unique id (number) of the user we want to build a url for
:r... |
Create url for fetching a users groups.
:param base_url: base group manager url (eg. 'https://groups.oit.duke.edu/grouper-ws/servicesRest/json/v2_1_500/')
:param duke_unique_id: str: unique id (number) of the user we want to build a url for
:return: str: url we created
| Create url for fetching a users groups. | [
"Create",
"url",
"for",
"fetching",
"a",
"users",
"groups",
"."
] | def make_users_groups_url(base_url, duke_unique_id):
return "{}/subjects/{}/groups".format(base_url, duke_unique_id) | [
"def",
"make_users_groups_url",
"(",
"base_url",
",",
"duke_unique_id",
")",
":",
"return",
"\"{}/subjects/{}/groups\"",
".",
"format",
"(",
"base_url",
",",
"duke_unique_id",
")"
] | Create url for fetching a users groups. | [
"Create",
"url",
"for",
"fetching",
"a",
"users",
"groups",
"."
] | [
"\"\"\"\n Create url for fetching a users groups.\n :param base_url: base group manager url (eg. 'https://groups.oit.duke.edu/grouper-ws/servicesRest/json/v2_1_500/')\n :param duke_unique_id: str: unique id (number) of the user we want to build a url for\n :return: str: url we created\n \"\"\""
] | [
{
"param": "base_url",
"type": null
},
{
"param": "duke_unique_id",
"type": null
}
] | {
"returns": [
{
"docstring": "url we created",
"docstring_tokens": [
"url",
"we",
"created"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "base_url",
"type": null,
"docstring": "base group manager url",
"docstr... |
2135288cf7e1e0132c11a41eca5f0fe9f260752d | calebmeyer/meal-planner | Pick meals!.py | [
"Unlicense"
] | Python | valid | <not_specific> | def valid(day, meal):
""" A meal is valid if it feeds enough people """
if "Tuesday" not in day:
return True # Today is not Tuesday, so any meal will work
else:
if meal.feeds_a_crowd.item() == "Yes":
return True # today is Tuesday and the meal feeds a crowd
return False | A meal is valid if it feeds enough people | A meal is valid if it feeds enough people | [
"A",
"meal",
"is",
"valid",
"if",
"it",
"feeds",
"enough",
"people"
] | def valid(day, meal):
if "Tuesday" not in day:
return True
else:
if meal.feeds_a_crowd.item() == "Yes":
return True
return False | [
"def",
"valid",
"(",
"day",
",",
"meal",
")",
":",
"if",
"\"Tuesday\"",
"not",
"in",
"day",
":",
"return",
"True",
"else",
":",
"if",
"meal",
".",
"feeds_a_crowd",
".",
"item",
"(",
")",
"==",
"\"Yes\"",
":",
"return",
"True",
"return",
"False"
] | A meal is valid if it feeds enough people | [
"A",
"meal",
"is",
"valid",
"if",
"it",
"feeds",
"enough",
"people"
] | [
"\"\"\" A meal is valid if it feeds enough people \"\"\"",
"# Today is not Tuesday, so any meal will work",
"# today is Tuesday and the meal feeds a crowd"
] | [
{
"param": "day",
"type": null
},
{
"param": "meal",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "day",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meal",
"type": null,
"docstring": null,
"docstring_tokens": []... |
6057f8b9cdd26040146dbd777544a19c58871e01 | Androcks/SlideWord | StageClass.py | [
"Apache-2.0"
] | Python | gridDisplay | null | def gridDisplay(self):
'Displays the current Grid In ASCII style graphics.'
print()
print(end = '')
for xAxis in self.grid:
for yAxis in xAxis:# prints segments side by side
print(yAxis, end=' ')
print()# finishes the line, moves o... | Displays the current Grid In ASCII style graphics. | Displays the current Grid In ASCII style graphics. | [
"Displays",
"the",
"current",
"Grid",
"In",
"ASCII",
"style",
"graphics",
"."
] | def gridDisplay(self):
print()
print(end = '')
for xAxis in self.grid:
for yAxis in xAxis:
print(yAxis, end=' ')
print()
print()
print(self.movesRemaining, " moves remaining")
print(self.totalSlides, " made this game!") | [
"def",
"gridDisplay",
"(",
"self",
")",
":",
"print",
"(",
")",
"print",
"(",
"end",
"=",
"''",
")",
"for",
"xAxis",
"in",
"self",
".",
"grid",
":",
"for",
"yAxis",
"in",
"xAxis",
":",
"print",
"(",
"yAxis",
",",
"end",
"=",
"' '",
")",
"print",
... | Displays the current Grid In ASCII style graphics. | [
"Displays",
"the",
"current",
"Grid",
"In",
"ASCII",
"style",
"graphics",
"."
] | [
"'Displays the current Grid In ASCII style graphics.'",
"# prints segments side by side\r",
"# finishes the line, moves on to next\r",
"#Shows amount of moves remaining\r",
"#Shows total amount of moves\r"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6057f8b9cdd26040146dbd777544a19c58871e01 | Androcks/SlideWord | StageClass.py | [
"Apache-2.0"
] | Python | letFill | null | def letFill(self):
'Fills empty space with new random letters.\
Letters randomly assigned via RandomGen'
for xAxis in range(len(self.grid)):#for every xaxis list in the grid
for yAxis in range(len(self.grid[xAxis])):
if self.grid[xAxis][yAxis] == '$':
... | Fills empty space with new random letters.\
Letters randomly assigned via RandomGen | Fills empty space with new random letters.\
Letters randomly assigned via RandomGen | [
"Fills",
"empty",
"space",
"with",
"new",
"random",
"letters",
".",
"\\",
"Letters",
"randomly",
"assigned",
"via",
"RandomGen"
] | def letFill(self):
for xAxis in range(len(self.grid)):
for yAxis in range(len(self.grid[xAxis])):
if self.grid[xAxis][yAxis] == '$':
self.grid[xAxis][yAxis] = randomTest.grabALetter() | [
"def",
"letFill",
"(",
"self",
")",
":",
"for",
"xAxis",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
")",
")",
":",
"for",
"yAxis",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"grid",
"[",
"xAxis",
"]",
")",
")",
":",
"if",
"self",
... | Fills empty space with new random letters.\
Letters randomly assigned via RandomGen | [
"Fills",
"empty",
"space",
"with",
"new",
"random",
"letters",
".",
"\\",
"Letters",
"randomly",
"assigned",
"via",
"RandomGen"
] | [
"'Fills empty space with new random letters.\\\r\n Letters randomly assigned via RandomGen'",
"#for every xaxis list in the grid\r",
"#Replaces Empty Space with randomly assigned letter from\r",
"#semi-random generator.\r",
"#Now getting letters from our scrabble distribution\r"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6057f8b9cdd26040146dbd777544a19c58871e01 | Androcks/SlideWord | StageClass.py | [
"Apache-2.0"
] | Python | letDel | null | def letDel(self, x, y, wordLength = 3, orient = True):
'Deletes letters in stage replacing them with empty "$". \
xStart & yStart are starting coords for deletion\
wordLength is length of deletion from the left or down the starting point\
orient is the orientation of deletion (True/False) (verti... | Deletes letters in stage replacing them with empty "$". \
xStart & yStart are starting coords for deletion\
wordLength is length of deletion from the left or down the starting point\
orient is the orientation of deletion (True/False) (vertical/horizontal). | Deletes letters in stage replacing them with empty "$". \
xStart & yStart are starting coords for deletion\
wordLength is length of deletion from the left or down the starting point\
orient is the orientation of deletion (True/False) (vertical/horizontal). | [
"Deletes",
"letters",
"in",
"stage",
"replacing",
"them",
"with",
"empty",
"\"",
"$",
"\"",
".",
"\\",
"xStart",
"&",
"yStart",
"are",
"starting",
"coords",
"for",
"deletion",
"\\",
"wordLength",
"is",
"length",
"of",
"deletion",
"from",
"the",
"left",
"or... | def letDel(self, x, y, wordLength = 3, orient = True):
self.grid[x][y] = '$'
print()
if wordLength != 1 and orient == True:
self.letDel(x + 1, y, wordLength - 1, orient)
elif wordLength != 1:
self.letDel(x, y + 1, wordLength - 1, orient) | [
"def",
"letDel",
"(",
"self",
",",
"x",
",",
"y",
",",
"wordLength",
"=",
"3",
",",
"orient",
"=",
"True",
")",
":",
"self",
".",
"grid",
"[",
"x",
"]",
"[",
"y",
"]",
"=",
"'$'",
"print",
"(",
")",
"if",
"wordLength",
"!=",
"1",
"and",
"orie... | Deletes letters in stage replacing them with empty "$". | [
"Deletes",
"letters",
"in",
"stage",
"replacing",
"them",
"with",
"empty",
"\"",
"$",
"\"",
"."
] | [
"'Deletes letters in stage replacing them with empty \"$\". \\\r\n xStart & yStart are starting coords for deletion\\\r\n wordLength is length of deletion from the left or down the starting point\\\r\n orient is the orientation of deletion (True/False) (vertical/horizontal).'",
"#Replaces value at x,y co... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "y",
"type": null
},
{
"param": "wordLength",
"type": null
},
{
"param": "orient",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
6057f8b9cdd26040146dbd777544a19c58871e01 | Androcks/SlideWord | StageClass.py | [
"Apache-2.0"
] | Python | letLineInsert | null | def letLineInsert(self, x, y, wordLength = 3, orient = True):
'Inserts letters into space in line formation.\
Essentially, the opposite of letDel. See letDel'
self.grid[x][y] = randomTest.grabALetter() #Random Letters replace space
#LetLineInsert works recursively. Same logic as LetDel
... | Inserts letters into space in line formation.\
Essentially, the opposite of letDel. See letDel | Inserts letters into space in line formation.\
Essentially, the opposite of letDel. See letDel | [
"Inserts",
"letters",
"into",
"space",
"in",
"line",
"formation",
".",
"\\",
"Essentially",
"the",
"opposite",
"of",
"letDel",
".",
"See",
"letDel"
] | def letLineInsert(self, x, y, wordLength = 3, orient = True):
self.grid[x][y] = randomTest.grabALetter()
if wordLength != 1 and orient == True:
self.letLineInsert(x + 1, y, wordLength - 1, orient)
elif wordLength != 1:
self.letLineInsert(x, y + 1, wordLength - 1, orient) | [
"def",
"letLineInsert",
"(",
"self",
",",
"x",
",",
"y",
",",
"wordLength",
"=",
"3",
",",
"orient",
"=",
"True",
")",
":",
"self",
".",
"grid",
"[",
"x",
"]",
"[",
"y",
"]",
"=",
"randomTest",
".",
"grabALetter",
"(",
")",
"if",
"wordLength",
"!... | Inserts letters into space in line formation.\
Essentially, the opposite of letDel. | [
"Inserts",
"letters",
"into",
"space",
"in",
"line",
"formation",
".",
"\\",
"Essentially",
"the",
"opposite",
"of",
"letDel",
"."
] | [
"'Inserts letters into space in line formation.\\\r\n Essentially, the opposite of letDel. See letDel'",
"#Random Letters replace space\r",
"#LetLineInsert works recursively. Same logic as LetDel\r"
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "y",
"type": null
},
{
"param": "wordLength",
"type": null
},
{
"param": "orient",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
6057f8b9cdd26040146dbd777544a19c58871e01 | Androcks/SlideWord | StageClass.py | [
"Apache-2.0"
] | Python | slide | null | def slide(self, startx, starty, orient, move):
'Moves letters within grid in a wrapparound style.\
Startx & StartY implement coords of the letter to be moved.\
orient can be string u, d, r, and l, for directions.\
move is the amount of space the letter is to be moved.'
if mo... | Moves letters within grid in a wrapparound style.\
Startx & StartY implement coords of the letter to be moved.\
orient can be string u, d, r, and l, for directions.\
move is the amount of space the letter is to be moved. | Moves letters within grid in a wrapparound style.\
Startx & StartY implement coords of the letter to be moved.\
orient can be string u, d, r, and l, for directions.\
move is the amount of space the letter is to be moved. | [
"Moves",
"letters",
"within",
"grid",
"in",
"a",
"wrapparound",
"style",
".",
"\\",
"Startx",
"&",
"StartY",
"implement",
"coords",
"of",
"the",
"letter",
"to",
"be",
"moved",
".",
"\\",
"orient",
"can",
"be",
"string",
"u",
"d",
"r",
"and",
"l",
"for"... | def slide(self, startx, starty, orient, move):
if move < 0:
if orient == 'r':
orient = 'l'
elif orient == 'r':
orient = 'l'
elif orient == 'u':
orient = 'd'
elif orient == 'd':
orient = 'u'
... | [
"def",
"slide",
"(",
"self",
",",
"startx",
",",
"starty",
",",
"orient",
",",
"move",
")",
":",
"if",
"move",
"<",
"0",
":",
"if",
"orient",
"==",
"'r'",
":",
"orient",
"=",
"'l'",
"elif",
"orient",
"==",
"'r'",
":",
"orient",
"=",
"'l'",
"elif"... | Moves letters within grid in a wrapparound style.\
Startx & StartY implement coords of the letter to be moved.\
orient can be string u, d, r, and l, for directions.\
move is the amount of space the letter is to be moved. | [
"Moves",
"letters",
"within",
"grid",
"in",
"a",
"wrapparound",
"style",
".",
"\\",
"Startx",
"&",
"StartY",
"implement",
"coords",
"of",
"the",
"letter",
"to",
"be",
"moved",
".",
"\\",
"orient",
"can",
"be",
"string",
"u",
"d",
"r",
"and",
"l",
"for"... | [
"'Moves letters within grid in a wrapparound style.\\\r\n Startx & StartY implement coords of the letter to be moved.\\\r\n orient can be string u, d, r, and l, for directions.\\\r\n move is the amount of space the letter is to be moved.'",
"# In case of a negative number, the orient is switched.\r",
"... | [
{
"param": "self",
"type": null
},
{
"param": "startx",
"type": null
},
{
"param": "starty",
"type": null
},
{
"param": "orient",
"type": null
},
{
"param": "move",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startx",
"type": null,
"docstring": null,
"docstring_tokens":... |
8b7ba39e04a495c35a48ce39d981039f5504d670 | Androcks/SlideWord | graphicWordFinder.py | [
"Apache-2.0"
] | Python | graphicWordFinder | <not_specific> | def graphicWordFinder(stage, score = True):
'Takes a Stage object and goes through the 2 dimensional grid \
horizontally and vertically and compares strings of size \
gridSize to 3 to a dictionary to confirm if they are a word.\
If score is True then it will distribute more slides for the player'
... | Takes a Stage object and goes through the 2 dimensional grid \
horizontally and vertically and compares strings of size \
gridSize to 3 to a dictionary to confirm if they are a word.\
If score is True then it will distribute more slides for the player | Takes a Stage object and goes through the 2 dimensional grid \
horizontally and vertically and compares strings of size \
gridSize to 3 to a dictionary to confirm if they are a word.\
If score is True then it will distribute more slides for the player | [
"Takes",
"a",
"Stage",
"object",
"and",
"goes",
"through",
"the",
"2",
"dimensional",
"grid",
"\\",
"horizontally",
"and",
"vertically",
"and",
"compares",
"strings",
"of",
"size",
"\\",
"gridSize",
"to",
"3",
"to",
"a",
"dictionary",
"to",
"confirm",
"if",
... | def graphicWordFinder(stage, score = True):
foundWord = False
wordsX = []
wordsY = []
xIndex = 0
for xAxis in stage.grid:
for wordLength in reversed(range(3, stage.gridSize + 1)):
index = 0
checkWord = []
while index < (stage.gridSize + 1 - wordLength):... | [
"def",
"graphicWordFinder",
"(",
"stage",
",",
"score",
"=",
"True",
")",
":",
"foundWord",
"=",
"False",
"wordsX",
"=",
"[",
"]",
"wordsY",
"=",
"[",
"]",
"xIndex",
"=",
"0",
"for",
"xAxis",
"in",
"stage",
".",
"grid",
":",
"for",
"wordLength",
"in"... | Takes a Stage object and goes through the 2 dimensional grid \
horizontally and vertically and compares strings of size \
gridSize to 3 to a dictionary to confirm if they are a word.\
If score is True then it will distribute more slides for the player | [
"Takes",
"a",
"Stage",
"object",
"and",
"goes",
"through",
"the",
"2",
"dimensional",
"grid",
"\\",
"horizontally",
"and",
"vertically",
"and",
"compares",
"strings",
"of",
"size",
"\\",
"gridSize",
"to",
"3",
"to",
"a",
"dictionary",
"to",
"confirm",
"if",
... | [
"'Takes a Stage object and goes through the 2 dimensional grid \\\r\n horizontally and vertically and compares strings of size \\\r\n gridSize to 3 to a dictionary to confirm if they are a word.\\\r\n If score is True then it will distribute more slides for the player'",
"#value used to state that a word... | [
{
"param": "stage",
"type": null
},
{
"param": "score",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "score",
"type": null,
"docstring": null,
"docstring_tokens":... |
4be03cb21f766c02e8b09a4f30335cb047d4752b | Androcks/SlideWord | Save.py | [
"Apache-2.0"
] | Python | save | null | def save(stage):
'Allows for the current game to be saved for a later time.\
The convinience of this function fills you with determination.'
saveFile = open('save.txt', 'w+')#Creates the file to be saved in.
saveFile.write(str(stage.gridSize) + '\n')#the grid size is put in 1st line
#Grid is s... | Allows for the current game to be saved for a later time.\
The convinience of this function fills you with determination. | Allows for the current game to be saved for a later time.\
The convinience of this function fills you with determination. | [
"Allows",
"for",
"the",
"current",
"game",
"to",
"be",
"saved",
"for",
"a",
"later",
"time",
".",
"\\",
"The",
"convinience",
"of",
"this",
"function",
"fills",
"you",
"with",
"determination",
"."
] | def save(stage):
saveFile = open('save.txt', 'w+')
saveFile.write(str(stage.gridSize) + '\n')
for xAxis in range(len(stage.grid)):
for yAxis in range(len(stage.grid[xAxis])):
saveFile.write(str(stage.grid[xAxis][yAxis]))
saveFile.write('\n')
saveFile.write(str(stage.movesR... | [
"def",
"save",
"(",
"stage",
")",
":",
"saveFile",
"=",
"open",
"(",
"'save.txt'",
",",
"'w+'",
")",
"saveFile",
".",
"write",
"(",
"str",
"(",
"stage",
".",
"gridSize",
")",
"+",
"'\\n'",
")",
"for",
"xAxis",
"in",
"range",
"(",
"len",
"(",
"stage... | Allows for the current game to be saved for a later time.\
The convinience of this function fills you with determination. | [
"Allows",
"for",
"the",
"current",
"game",
"to",
"be",
"saved",
"for",
"a",
"later",
"time",
".",
"\\",
"The",
"convinience",
"of",
"this",
"function",
"fills",
"you",
"with",
"determination",
"."
] | [
"'Allows for the current game to be saved for a later time.\\\r\n The convinience of this function fills you with determination.'",
"#Creates the file to be saved in.\r",
"#the grid size is put in 1st line\r",
"#Grid is saved with every x axis on its own line.\r",
"#Amount of moves remaining and the tot... | [
{
"param": "stage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
250ec490eac3644f79a3739345ec32a496fa2c42 | noahdietz/storage-testbench | gcs/object.py | [
"Apache-2.0"
] | Python | _decompress_on_download | <not_specific> | def _decompress_on_download(self, request):
"""Returns True if a request requires decompressive transcoding."""
if self.metadata.content_encoding != "gzip":
return False
# If `gzip` appears in the `Accept-Encoding` header then we disable
# decompressive transcoding
re... | Returns True if a request requires decompressive transcoding. | Returns True if a request requires decompressive transcoding. | [
"Returns",
"True",
"if",
"a",
"request",
"requires",
"decompressive",
"transcoding",
"."
] | def _decompress_on_download(self, request):
if self.metadata.content_encoding != "gzip":
return False
return not ("gzip" in request.headers.get("accept-encoding", "")) | [
"def",
"_decompress_on_download",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"metadata",
".",
"content_encoding",
"!=",
"\"gzip\"",
":",
"return",
"False",
"return",
"not",
"(",
"\"gzip\"",
"in",
"request",
".",
"headers",
".",
"get",
"(",
"... | Returns True if a request requires decompressive transcoding. | [
"Returns",
"True",
"if",
"a",
"request",
"requires",
"decompressive",
"transcoding",
"."
] | [
"\"\"\"Returns True if a request requires decompressive transcoding.\"\"\"",
"# If `gzip` appears in the `Accept-Encoding` header then we disable",
"# decompressive transcoding"
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
8c172839906e757930fe736175e05394095fac15 | noahdietz/storage-testbench | gcs/upload.py | [
"Apache-2.0"
] | Python | init_write_object_grpc | <not_specific> | def init_write_object_grpc(cls, db, request_iterator, context):
"""Process an WriteObject streaming RPC, returning the upload object associated with it."""
upload, object_checksums, is_resumable = None, None, False
for request in request_iterator:
first_message = request.WhichOneof("... | Process an WriteObject streaming RPC, returning the upload object associated with it. | Process an WriteObject streaming RPC, returning the upload object associated with it. | [
"Process",
"an",
"WriteObject",
"streaming",
"RPC",
"returning",
"the",
"upload",
"object",
"associated",
"with",
"it",
"."
] | def init_write_object_grpc(cls, db, request_iterator, context):
upload, object_checksums, is_resumable = None, None, False
for request in request_iterator:
first_message = request.WhichOneof("first_message")
if first_message == "upload_id":
upload = db.get_upload(... | [
"def",
"init_write_object_grpc",
"(",
"cls",
",",
"db",
",",
"request_iterator",
",",
"context",
")",
":",
"upload",
",",
"object_checksums",
",",
"is_resumable",
"=",
"None",
",",
"None",
",",
"False",
"for",
"request",
"in",
"request_iterator",
":",
"first_m... | Process an WriteObject streaming RPC, returning the upload object associated with it. | [
"Process",
"an",
"WriteObject",
"streaming",
"RPC",
"returning",
"the",
"upload",
"object",
"associated",
"with",
"it",
"."
] | [
"\"\"\"Process an WriteObject streaming RPC, returning the upload object associated with it.\"\"\"",
"# The object checksums may appear only in the first message *or* the last message, but not both"
] | [
{
"param": "cls",
"type": null
},
{
"param": "db",
"type": null
},
{
"param": "request_iterator",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "db",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
a3a1586f1e36163df2c97b0e55755039d8a8a4a6 | noahdietz/storage-testbench | testbench/servers/projects_rest_server.py | [
"Apache-2.0"
] | Python | hmac_keys_list | <not_specific> | def hmac_keys_list(project_id):
"""Implement the 'HmacKeys: list' API: return the HMAC keys in a project."""
# Lookup the bucket, if this fails the bucket does not exist, and this
# function should return an error.
project = db.get_project(project_id)
result = {
"kind... | Implement the 'HmacKeys: list' API: return the HMAC keys in a project. | Implement the 'HmacKeys: list' API: return the HMAC keys in a project. | [
"Implement",
"the",
"'",
"HmacKeys",
":",
"list",
"'",
"API",
":",
"return",
"the",
"HMAC",
"keys",
"in",
"a",
"project",
"."
] | def hmac_keys_list(project_id):
project = db.get_project(project_id)
result = {
"kind": "storage#hmacKeysMetadata",
"next_page_token": "",
"items": [],
}
state_filter = lambda x: x.get("state") != "DELETED"
if flask.request.args.get("deleted") ... | [
"def",
"hmac_keys_list",
"(",
"project_id",
")",
":",
"project",
"=",
"db",
".",
"get_project",
"(",
"project_id",
")",
"result",
"=",
"{",
"\"kind\"",
":",
"\"storage#hmacKeysMetadata\"",
",",
"\"next_page_token\"",
":",
"\"\"",
",",
"\"items\"",
":",
"[",
"]... | Implement the 'HmacKeys: list' API: return the HMAC keys in a project. | [
"Implement",
"the",
"'",
"HmacKeys",
":",
"list",
"'",
"API",
":",
"return",
"the",
"HMAC",
"keys",
"in",
"a",
"project",
"."
] | [
"\"\"\"Implement the 'HmacKeys: list' API: return the HMAC keys in a project.\"\"\"",
"# Lookup the bucket, if this fails the bucket does not exist, and this",
"# function should return an error."
] | [
{
"param": "project_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "project_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9137b09e4fe40726526cd0d3db2c1fe6df0e7eb7 | noahdietz/storage-testbench | gcs/project.py | [
"Apache-2.0"
] | Python | delete_key | <not_specific> | def delete_key(self, key_id, context):
"""Delete an existing HMAC key from the service account."""
key = self.keys.get(key_id)
if key is None:
return testbench.error.notfound("key %s" % key_id, context)
resource = key.get("metadata")
# by constructions our keys always... | Delete an existing HMAC key from the service account. | Delete an existing HMAC key from the service account. | [
"Delete",
"an",
"existing",
"HMAC",
"key",
"from",
"the",
"service",
"account",
"."
] | def delete_key(self, key_id, context):
key = self.keys.get(key_id)
if key is None:
return testbench.error.notfound("key %s" % key_id, context)
resource = key.get("metadata")
assert resource is not None
if resource.get("state") == "ACTIVE":
return testbench... | [
"def",
"delete_key",
"(",
"self",
",",
"key_id",
",",
"context",
")",
":",
"key",
"=",
"self",
".",
"keys",
".",
"get",
"(",
"key_id",
")",
"if",
"key",
"is",
"None",
":",
"return",
"testbench",
".",
"error",
".",
"notfound",
"(",
"\"key %s\"",
"%",
... | Delete an existing HMAC key from the service account. | [
"Delete",
"an",
"existing",
"HMAC",
"key",
"from",
"the",
"service",
"account",
"."
] | [
"\"\"\"Delete an existing HMAC key from the service account.\"\"\"",
"# by constructions our keys always have a `metadata`` field"
] | [
{
"param": "self",
"type": null
},
{
"param": "key_id",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key_id",
"type": null,
"docstring": null,
"docstring_tokens":... |
9137b09e4fe40726526cd0d3db2c1fe6df0e7eb7 | noahdietz/storage-testbench | gcs/project.py | [
"Apache-2.0"
] | Python | _check_etag | <not_specific> | def _check_etag(self, key_resource, etag, where):
"""Verify that ETag values match the current ETag."""
expected = key_resource.get("etag")
if etag is None or etag == expected:
return
testbench.error.mismatch(
"ETag for `HmacKeys: update` in %s" % where, expected,... | Verify that ETag values match the current ETag. | Verify that ETag values match the current ETag. | [
"Verify",
"that",
"ETag",
"values",
"match",
"the",
"current",
"ETag",
"."
] | def _check_etag(self, key_resource, etag, where):
expected = key_resource.get("etag")
if etag is None or etag == expected:
return
testbench.error.mismatch(
"ETag for `HmacKeys: update` in %s" % where, expected, etag, None
) | [
"def",
"_check_etag",
"(",
"self",
",",
"key_resource",
",",
"etag",
",",
"where",
")",
":",
"expected",
"=",
"key_resource",
".",
"get",
"(",
"\"etag\"",
")",
"if",
"etag",
"is",
"None",
"or",
"etag",
"==",
"expected",
":",
"return",
"testbench",
".",
... | Verify that ETag values match the current ETag. | [
"Verify",
"that",
"ETag",
"values",
"match",
"the",
"current",
"ETag",
"."
] | [
"\"\"\"Verify that ETag values match the current ETag.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key_resource",
"type": null
},
{
"param": "etag",
"type": null
},
{
"param": "where",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key_resource",
"type": null,
"docstring": null,
"docstring_to... |
9137b09e4fe40726526cd0d3db2c1fe6df0e7eb7 | noahdietz/storage-testbench | gcs/project.py | [
"Apache-2.0"
] | Python | update_key | <not_specific> | def update_key(self, key_id, payload, context):
"""Get an existing HMAC key from the service account."""
key = self.keys.get(key_id)
if key is None:
return testbench.error.notfound("key %s" % key_id, context)
metadata = key.get("metadata")
# by constructions our keys ... | Get an existing HMAC key from the service account. | Get an existing HMAC key from the service account. | [
"Get",
"an",
"existing",
"HMAC",
"key",
"from",
"the",
"service",
"account",
"."
] | def update_key(self, key_id, payload, context):
key = self.keys.get(key_id)
if key is None:
return testbench.error.notfound("key %s" % key_id, context)
metadata = key.get("metadata")
assert metadata is not None
if context is None:
self._check_etag(metadata... | [
"def",
"update_key",
"(",
"self",
",",
"key_id",
",",
"payload",
",",
"context",
")",
":",
"key",
"=",
"self",
".",
"keys",
".",
"get",
"(",
"key_id",
")",
"if",
"key",
"is",
"None",
":",
"return",
"testbench",
".",
"error",
".",
"notfound",
"(",
"... | Get an existing HMAC key from the service account. | [
"Get",
"an",
"existing",
"HMAC",
"key",
"from",
"the",
"service",
"account",
"."
] | [
"\"\"\"Get an existing HMAC key from the service account.\"\"\"",
"# by constructions our keys always have a `metadata`` field",
"# Unlike production, we never hold on to deleted keys"
] | [
{
"param": "self",
"type": null
},
{
"param": "key_id",
"type": null
},
{
"param": "payload",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key_id",
"type": null,
"docstring": null,
"docstring_tokens":... |
9137b09e4fe40726526cd0d3db2c1fe6df0e7eb7 | noahdietz/storage-testbench | gcs/project.py | [
"Apache-2.0"
] | Python | delete_hmac_key | <not_specific> | def delete_hmac_key(self, access_id, context=None):
"""Remove a key from the project."""
(service_account, key_id) = access_id.split(":", 2)
sa = self.service_accounts.get(service_account)
if sa is None:
return testbench.error.notfound(
"service account for ke... | Remove a key from the project. | Remove a key from the project. | [
"Remove",
"a",
"key",
"from",
"the",
"project",
"."
] | def delete_hmac_key(self, access_id, context=None):
(service_account, key_id) = access_id.split(":", 2)
sa = self.service_accounts.get(service_account)
if sa is None:
return testbench.error.notfound(
"service account for key=%s" % access_id, context
)
... | [
"def",
"delete_hmac_key",
"(",
"self",
",",
"access_id",
",",
"context",
"=",
"None",
")",
":",
"(",
"service_account",
",",
"key_id",
")",
"=",
"access_id",
".",
"split",
"(",
"\":\"",
",",
"2",
")",
"sa",
"=",
"self",
".",
"service_accounts",
".",
"g... | Remove a key from the project. | [
"Remove",
"a",
"key",
"from",
"the",
"project",
"."
] | [
"\"\"\"Remove a key from the project.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "access_id",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "access_id",
"type": null,
"docstring": null,
"docstring_token... |
9137b09e4fe40726526cd0d3db2c1fe6df0e7eb7 | noahdietz/storage-testbench | gcs/project.py | [
"Apache-2.0"
] | Python | update_hmac_key | <not_specific> | def update_hmac_key(self, access_id, payload, context=None):
"""Update an existing key in the project."""
(service_account, key_id) = access_id.split(":", 2)
sa = self.service_accounts.get(service_account, None)
if sa is None:
return testbench.error.notfound(
... | Update an existing key in the project. | Update an existing key in the project. | [
"Update",
"an",
"existing",
"key",
"in",
"the",
"project",
"."
] | def update_hmac_key(self, access_id, payload, context=None):
(service_account, key_id) = access_id.split(":", 2)
sa = self.service_accounts.get(service_account, None)
if sa is None:
return testbench.error.notfound(
"service account for key=%s" % access_id, context
... | [
"def",
"update_hmac_key",
"(",
"self",
",",
"access_id",
",",
"payload",
",",
"context",
"=",
"None",
")",
":",
"(",
"service_account",
",",
"key_id",
")",
"=",
"access_id",
".",
"split",
"(",
"\":\"",
",",
"2",
")",
"sa",
"=",
"self",
".",
"service_ac... | Update an existing key in the project. | [
"Update",
"an",
"existing",
"key",
"in",
"the",
"project",
"."
] | [
"\"\"\"Update an existing key in the project.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "access_id",
"type": null
},
{
"param": "payload",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "access_id",
"type": null,
"docstring": null,
"docstring_token... |
b19946716f1284a710aed8cec70c693655e84bf3 | noahdietz/storage-testbench | testbench/proto2rest.py | [
"Apache-2.0"
] | Python | __postprocess_object_rest | <not_specific> | def __postprocess_object_rest(metadata):
"""The protos for storage/v2 renamed some fields in ways that require some custom coding."""
# For some fields the storage/v2 name just needs to change slightly.
bucket_id = testbench.common.bucket_name_from_proto(metadata.get("bucket", None))
metadata = testbenc... | The protos for storage/v2 renamed some fields in ways that require some custom coding. | The protos for storage/v2 renamed some fields in ways that require some custom coding. | [
"The",
"protos",
"for",
"storage",
"/",
"v2",
"renamed",
"some",
"fields",
"in",
"ways",
"that",
"require",
"some",
"custom",
"coding",
"."
] | def __postprocess_object_rest(metadata):
bucket_id = testbench.common.bucket_name_from_proto(metadata.get("bucket", None))
metadata = testbench.common.rest_adjust(
metadata,
{
"bucket": lambda x: ("bucket", bucket_id),
"createTime": lambda x: ("timeCreated", x),
... | [
"def",
"__postprocess_object_rest",
"(",
"metadata",
")",
":",
"bucket_id",
"=",
"testbench",
".",
"common",
".",
"bucket_name_from_proto",
"(",
"metadata",
".",
"get",
"(",
"\"bucket\"",
",",
"None",
")",
")",
"metadata",
"=",
"testbench",
".",
"common",
".",... | The protos for storage/v2 renamed some fields in ways that require some custom coding. | [
"The",
"protos",
"for",
"storage",
"/",
"v2",
"renamed",
"some",
"fields",
"in",
"ways",
"that",
"require",
"some",
"custom",
"coding",
"."
] | [
"\"\"\"The protos for storage/v2 renamed some fields in ways that require some custom coding.\"\"\"",
"# For some fields the storage/v2 name just needs to change slightly.",
"# Checksums need special treatment",
"# Finally the ACLs, if present, require additional fields"
] | [
{
"param": "metadata",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "metadata",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | DeleteBucket | null | def DeleteBucket(self, request, context):
"""Permanently deletes an empty bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Permanently deletes an empty bucket.
| Permanently deletes an empty bucket. | [
"Permanently",
"deletes",
"an",
"empty",
"bucket",
"."
] | def DeleteBucket(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"DeleteBucket",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Permanently deletes an empty bucket. | [
"Permanently",
"deletes",
"an",
"empty",
"bucket",
"."
] | [
"\"\"\"Permanently deletes an empty bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | GetBucket | null | def GetBucket(self, request, context):
"""Returns metadata for the specified bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Returns metadata for the specified bucket.
| Returns metadata for the specified bucket. | [
"Returns",
"metadata",
"for",
"the",
"specified",
"bucket",
"."
] | def GetBucket(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"GetBucket",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedError"... | Returns metadata for the specified bucket. | [
"Returns",
"metadata",
"for",
"the",
"specified",
"bucket",
"."
] | [
"\"\"\"Returns metadata for the specified bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | ListBuckets | null | def ListBuckets(self, request, context):
"""Retrieves a list of buckets for a given project.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Retrieves a list of buckets for a given project.
| Retrieves a list of buckets for a given project. | [
"Retrieves",
"a",
"list",
"of",
"buckets",
"for",
"a",
"given",
"project",
"."
] | def ListBuckets(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"ListBuckets",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErro... | Retrieves a list of buckets for a given project. | [
"Retrieves",
"a",
"list",
"of",
"buckets",
"for",
"a",
"given",
"project",
"."
] | [
"\"\"\"Retrieves a list of buckets for a given project.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | LockBucketRetentionPolicy | null | def LockBucketRetentionPolicy(self, request, context):
"""Locks retention policy on a bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Locks retention policy on a bucket.
| Locks retention policy on a bucket. | [
"Locks",
"retention",
"policy",
"on",
"a",
"bucket",
"."
] | def LockBucketRetentionPolicy(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"LockBucketRetentionPolicy",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotI... | Locks retention policy on a bucket. | [
"Locks",
"retention",
"policy",
"on",
"a",
"bucket",
"."
] | [
"\"\"\"Locks retention policy on a bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | GetIamPolicy | null | def GetIamPolicy(self, request, context):
"""Gets the IAM policy for a specified bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Gets the IAM policy for a specified bucket.
| Gets the IAM policy for a specified bucket. | [
"Gets",
"the",
"IAM",
"policy",
"for",
"a",
"specified",
"bucket",
"."
] | def GetIamPolicy(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"GetIamPolicy",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Gets the IAM policy for a specified bucket. | [
"Gets",
"the",
"IAM",
"policy",
"for",
"a",
"specified",
"bucket",
"."
] | [
"\"\"\"Gets the IAM policy for a specified bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | SetIamPolicy | null | def SetIamPolicy(self, request, context):
"""Updates an IAM policy for the specified bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Updates an IAM policy for the specified bucket.
| Updates an IAM policy for the specified bucket. | [
"Updates",
"an",
"IAM",
"policy",
"for",
"the",
"specified",
"bucket",
"."
] | def SetIamPolicy(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"SetIamPolicy",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Updates an IAM policy for the specified bucket. | [
"Updates",
"an",
"IAM",
"policy",
"for",
"the",
"specified",
"bucket",
"."
] | [
"\"\"\"Updates an IAM policy for the specified bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | TestIamPermissions | null | def TestIamPermissions(self, request, context):
"""Tests a set of permissions on the given bucket to see which, if
any, are held by the caller.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Me... | Tests a set of permissions on the given bucket to see which, if
any, are held by the caller.
| Tests a set of permissions on the given bucket to see which, if
any, are held by the caller. | [
"Tests",
"a",
"set",
"of",
"permissions",
"on",
"the",
"given",
"bucket",
"to",
"see",
"which",
"if",
"any",
"are",
"held",
"by",
"the",
"caller",
"."
] | def TestIamPermissions(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"TestIamPermissions",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplemen... | Tests a set of permissions on the given bucket to see which, if
any, are held by the caller. | [
"Tests",
"a",
"set",
"of",
"permissions",
"on",
"the",
"given",
"bucket",
"to",
"see",
"which",
"if",
"any",
"are",
"held",
"by",
"the",
"caller",
"."
] | [
"\"\"\"Tests a set of permissions on the given bucket to see which, if\n any, are held by the caller.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.