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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0d8ff2e6fabc65d32ba134581c2bf2061be14b16 | bwindsor22/gutenberg | gutenberg/cleanup/strip_headers.py | [
"Apache-2.0"
] | Python | _main | null | def _main():
"""Command line interface to the module.
"""
from argparse import ArgumentParser, FileType
from gutenberg import Error
from gutenberg._util.os import reopen_encoded
parser = ArgumentParser(description='Remove headers and footers from a '
'Pr... | Command line interface to the module.
| Command line interface to the module. | [
"Command",
"line",
"interface",
"to",
"the",
"module",
"."
] | def _main():
from argparse import ArgumentParser, FileType
from gutenberg import Error
from gutenberg._util.os import reopen_encoded
parser = ArgumentParser(description='Remove headers and footers from a '
'Project Gutenberg text')
parser.add_argument('infile'... | [
"def",
"_main",
"(",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
",",
"FileType",
"from",
"gutenberg",
"import",
"Error",
"from",
"gutenberg",
".",
"_util",
".",
"os",
"import",
"reopen_encoded",
"parser",
"=",
"ArgumentParser",
"(",
"description",... | Command line interface to the module. | [
"Command",
"line",
"interface",
"to",
"the",
"module",
"."
] | [
"\"\"\"Command line interface to the module.\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
978105cf9c97ac72757a2e6f8c4ddfae3d2aedbc | bwindsor22/gutenberg | gutenberg/_domain_model/types.py | [
"Apache-2.0"
] | Python | rdf_bind_to_string | null | def rdf_bind_to_string(rdf_type):
"""Python2/3 compatibility wrapper around rdflib.term.bind that binds a
term to the appropriate string type.
"""
string_type = unicode if sys.version_info < (3,) else str # noqa
bind(rdf_type, string_type) | Python2/3 compatibility wrapper around rdflib.term.bind that binds a
term to the appropriate string type.
| Python2/3 compatibility wrapper around rdflib.term.bind that binds a
term to the appropriate string type. | [
"Python2",
"/",
"3",
"compatibility",
"wrapper",
"around",
"rdflib",
".",
"term",
".",
"bind",
"that",
"binds",
"a",
"term",
"to",
"the",
"appropriate",
"string",
"type",
"."
] | def rdf_bind_to_string(rdf_type):
string_type = unicode if sys.version_info < (3,) else str
bind(rdf_type, string_type) | [
"def",
"rdf_bind_to_string",
"(",
"rdf_type",
")",
":",
"string_type",
"=",
"unicode",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
")",
"else",
"str",
"bind",
"(",
"rdf_type",
",",
"string_type",
")"
] | Python2/3 compatibility wrapper around rdflib.term.bind that binds a
term to the appropriate string type. | [
"Python2",
"/",
"3",
"compatibility",
"wrapper",
"around",
"rdflib",
".",
"term",
".",
"bind",
"that",
"binds",
"a",
"term",
"to",
"the",
"appropriate",
"string",
"type",
"."
] | [
"\"\"\"Python2/3 compatibility wrapper around rdflib.term.bind that binds a\n term to the appropriate string type.\n\n \"\"\"",
"# noqa"
] | [
{
"param": "rdf_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rdf_type",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
29a5446515e74d56bf567eb64afdd9eb670b090b | mottosso/mitx-6.00.1x | week2/l4problem11.py | [
"MIT"
] | Python | isVowel2 | <not_specific> | def isVowel2(char):
'''
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
'''
return char.lower() in 'aeiou' |
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
| a single letter of any case
returns: True if char is a vowel and False otherwise. | [
"a",
"single",
"letter",
"of",
"any",
"case",
"returns",
":",
"True",
"if",
"char",
"is",
"a",
"vowel",
"and",
"False",
"otherwise",
"."
] | def isVowel2(char):
return char.lower() in 'aeiou' | [
"def",
"isVowel2",
"(",
"char",
")",
":",
"return",
"char",
".",
"lower",
"(",
")",
"in",
"'aeiou'"
] | char: a single letter of any case
returns: True if char is a vowel and False otherwise. | [
"char",
":",
"a",
"single",
"letter",
"of",
"any",
"case",
"returns",
":",
"True",
"if",
"char",
"is",
"a",
"vowel",
"and",
"False",
"otherwise",
"."
] | [
"'''\n char: a single letter of any case\n\n returns: True if char is a vowel and False otherwise.\n '''"
] | [
{
"param": "char",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "char",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bd264adaf77db026ce0b4d9a89fef6e966055a5f | mottosso/mitx-6.00.1x | pset1/problem2.py | [
"MIT"
] | Python | count_bob | <not_specific> | def count_bob(s):
"""Return number of occurrences of `bob`
Including partial occurrences, like "bobob" which is 2.
"""
count = 0
for i in xrange(max(0, len(s) - 2)):
count += s[i:i + 3] == 'bob'
print 'The number of times bob occurs is: %i' % count
return count | Return number of occurrences of `bob`
Including partial occurrences, like "bobob" which is 2.
| Return number of occurrences of `bob`
Including partial occurrences, like "bobob" which is 2. | [
"Return",
"number",
"of",
"occurrences",
"of",
"`",
"bob",
"`",
"Including",
"partial",
"occurrences",
"like",
"\"",
"bobob",
"\"",
"which",
"is",
"2",
"."
] | def count_bob(s):
count = 0
for i in xrange(max(0, len(s) - 2)):
count += s[i:i + 3] == 'bob'
print 'The number of times bob occurs is: %i' % count
return count | [
"def",
"count_bob",
"(",
"s",
")",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"xrange",
"(",
"max",
"(",
"0",
",",
"len",
"(",
"s",
")",
"-",
"2",
")",
")",
":",
"count",
"+=",
"s",
"[",
"i",
":",
"i",
"+",
"3",
"]",
"==",
"'bob'",
"print"... | Return number of occurrences of `bob`
Including partial occurrences, like "bobob" which is 2. | [
"Return",
"number",
"of",
"occurrences",
"of",
"`",
"bob",
"`",
"Including",
"partial",
"occurrences",
"like",
"\"",
"bobob",
"\"",
"which",
"is",
"2",
"."
] | [
"\"\"\"Return number of occurrences of `bob`\n\n\tIncluding partial occurrences, like \"bobob\" which is 2.\n\n\t\"\"\""
] | [
{
"param": "s",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9d9c146fab06f66e83fec6e73e2120b4bf9906bd | mottosso/mitx-6.00.1x | week2/l4problem10.py | [
"MIT"
] | Python | isVowel | <not_specific> | def isVowel(char):
'''
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
'''
if char.lower() == 'a':
return True
if char.lower() == 'e':
return True
if char.lower() == 'i':
return True
if char.lower() == 'o':
return True
... |
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
| a single letter of any case
returns: True if char is a vowel and False otherwise. | [
"a",
"single",
"letter",
"of",
"any",
"case",
"returns",
":",
"True",
"if",
"char",
"is",
"a",
"vowel",
"and",
"False",
"otherwise",
"."
] | def isVowel(char):
if char.lower() == 'a':
return True
if char.lower() == 'e':
return True
if char.lower() == 'i':
return True
if char.lower() == 'o':
return True
if char.lower() == 'u':
return True
return False | [
"def",
"isVowel",
"(",
"char",
")",
":",
"if",
"char",
".",
"lower",
"(",
")",
"==",
"'a'",
":",
"return",
"True",
"if",
"char",
".",
"lower",
"(",
")",
"==",
"'e'",
":",
"return",
"True",
"if",
"char",
".",
"lower",
"(",
")",
"==",
"'i'",
":",... | char: a single letter of any case
returns: True if char is a vowel and False otherwise. | [
"char",
":",
"a",
"single",
"letter",
"of",
"any",
"case",
"returns",
":",
"True",
"if",
"char",
"is",
"a",
"vowel",
"and",
"False",
"otherwise",
"."
] | [
"'''\n char: a single letter of any case\n\n returns: True if char is a vowel and False otherwise.\n '''"
] | [
{
"param": "char",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "char",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ebaa3101ebc7c9acd461ed4f854ef2c4f204caf1 | mottosso/mitx-6.00.1x | week2/l4problem9.py | [
"MIT"
] | Python | odd | <not_specific> | def odd(x):
'''
x: int or float.
returns: True if x is odd, False otherwise
'''
return bool(x % 2) |
x: int or float.
returns: True if x is odd, False otherwise
| int or float.
returns: True if x is odd, False otherwise | [
"int",
"or",
"float",
".",
"returns",
":",
"True",
"if",
"x",
"is",
"odd",
"False",
"otherwise"
] | def odd(x):
return bool(x % 2) | [
"def",
"odd",
"(",
"x",
")",
":",
"return",
"bool",
"(",
"x",
"%",
"2",
")"
] | x: int or float. | [
"x",
":",
"int",
"or",
"float",
"."
] | [
"'''\n x: int or float.\n\n returns: True if x is odd, False otherwise\n '''"
] | [
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ca6ecec3cf5a3e87c8ef0ef8fc49760c13aa89e9 | mottosso/mitx-6.00.1x | week2/l4problem5.py | [
"MIT"
] | Python | clip | <not_specific> | def clip(lo, x, hi):
'''
Takes in three numbers and returns a value based on the value of x.
Returns:
- lo, when x < lo
- hi, when x > hi
- x, otherwise
'''
return max(lo, min(hi, x)) |
Takes in three numbers and returns a value based on the value of x.
Returns:
- lo, when x < lo
- hi, when x > hi
- x, otherwise
| Takes in three numbers and returns a value based on the value of x. | [
"Takes",
"in",
"three",
"numbers",
"and",
"returns",
"a",
"value",
"based",
"on",
"the",
"value",
"of",
"x",
"."
] | def clip(lo, x, hi):
return max(lo, min(hi, x)) | [
"def",
"clip",
"(",
"lo",
",",
"x",
",",
"hi",
")",
":",
"return",
"max",
"(",
"lo",
",",
"min",
"(",
"hi",
",",
"x",
")",
")"
] | Takes in three numbers and returns a value based on the value of x. | [
"Takes",
"in",
"three",
"numbers",
"and",
"returns",
"a",
"value",
"based",
"on",
"the",
"value",
"of",
"x",
"."
] | [
"'''\n Takes in three numbers and returns a value based on the value of x.\n Returns:\n - lo, when x < lo\n - hi, when x > hi\n - x, otherwise\n '''"
] | [
{
"param": "lo",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "hi",
"type": null
}
] | {
"returns": [
{
"docstring": "lo, when x < lo\nhi, when x > hi\nx, otherwise",
"docstring_tokens": [
"lo",
"when",
"x",
"<",
"lo",
"hi",
"when",
"x",
">",
"hi",
"x",
"otherwise"
],
"type": null... |
31864a1a938cad727ca90d4ce37cfef2ae3d570a | felidadae/platform-resource-manager | prm/prm/analyze/thresh.py | [
"Apache-2.0"
] | Python | partition_utilization | <not_specific> | def partition_utilization(cpu_number, step=50):
"""
Partition utilizaton bins based on requested CPU number and step count
cpu_number - processor count assigned to workload
step - bin range of one partition, default value is half processor
"""
utilization_upper = (cpu_number + 1) * 100
... |
Partition utilizaton bins based on requested CPU number and step count
cpu_number - processor count assigned to workload
step - bin range of one partition, default value is half processor
| Partition utilizaton bins based on requested CPU number and step count
cpu_number - processor count assigned to workload
step - bin range of one partition, default value is half processor | [
"Partition",
"utilizaton",
"bins",
"based",
"on",
"requested",
"CPU",
"number",
"and",
"step",
"count",
"cpu_number",
"-",
"processor",
"count",
"assigned",
"to",
"workload",
"step",
"-",
"bin",
"range",
"of",
"one",
"partition",
"default",
"value",
"is",
"hal... | def partition_utilization(cpu_number, step=50):
utilization_upper = (cpu_number + 1) * 100
utilization_lower = cpu_number * 50
utilization_bar = np.arange(utilization_lower, utilization_upper, step)
return utilization_bar | [
"def",
"partition_utilization",
"(",
"cpu_number",
",",
"step",
"=",
"50",
")",
":",
"utilization_upper",
"=",
"(",
"cpu_number",
"+",
"1",
")",
"*",
"100",
"utilization_lower",
"=",
"cpu_number",
"*",
"50",
"utilization_bar",
"=",
"np",
".",
"arange",
"(",
... | Partition utilizaton bins based on requested CPU number and step count
cpu_number - processor count assigned to workload
step - bin range of one partition, default value is half processor | [
"Partition",
"utilizaton",
"bins",
"based",
"on",
"requested",
"CPU",
"number",
"and",
"step",
"count",
"cpu_number",
"-",
"processor",
"count",
"assigned",
"to",
"workload",
"step",
"-",
"bin",
"range",
"of",
"one",
"partition",
"default",
"value",
"is",
"hal... | [
"\"\"\"\n Partition utilizaton bins based on requested CPU number and step count\n cpu_number - processor count assigned to workload\n step - bin range of one partition, default value is half processor\n \"\"\""
] | [
{
"param": "cpu_number",
"type": null
},
{
"param": "step",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cpu_number",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "step",
"type": null,
"docstring": null,
"docstring_toke... |
a8fe8b1ede2da791af69c58ca035f2017b9e1de0 | felidadae/platform-resource-manager | prm/prm/detector.py | [
"Apache-2.0"
] | Python | _get_threshold_metrics | <not_specific> | def _get_threshold_metrics(self):
"""Encode threshold objects as OWCA metrics.
In contrast to *_threshold metrics from Container,
all utilization partitions are exposed for all workloads.
"""
metrics = []
# Only when debugging is enabled.
if log.getEffectiveLevel(... | Encode threshold objects as OWCA metrics.
In contrast to *_threshold metrics from Container,
all utilization partitions are exposed for all workloads.
| Encode threshold objects as OWCA metrics.
In contrast to *_threshold metrics from Container,
all utilization partitions are exposed for all workloads. | [
"Encode",
"threshold",
"objects",
"as",
"OWCA",
"metrics",
".",
"In",
"contrast",
"to",
"*",
"_threshold",
"metrics",
"from",
"Container",
"all",
"utilization",
"partitions",
"are",
"exposed",
"for",
"all",
"workloads",
"."
] | def _get_threshold_metrics(self):
metrics = []
if log.getEffectiveLevel() == logging.DEBUG:
for cid, threshold in self.analyzer.threshold.items():
if cid == 'lcutilmax':
metrics.append(
OwcaMetric(name='threshold_lcutilmax', value=t... | [
"def",
"_get_threshold_metrics",
"(",
"self",
")",
":",
"metrics",
"=",
"[",
"]",
"if",
"log",
".",
"getEffectiveLevel",
"(",
")",
"==",
"logging",
".",
"DEBUG",
":",
"for",
"cid",
",",
"threshold",
"in",
"self",
".",
"analyzer",
".",
"threshold",
".",
... | Encode threshold objects as OWCA metrics. | [
"Encode",
"threshold",
"objects",
"as",
"OWCA",
"metrics",
"."
] | [
"\"\"\"Encode threshold objects as OWCA metrics.\n In contrast to *_threshold metrics from Container,\n all utilization partitions are exposed for all workloads.\n \"\"\"",
"# Only when debugging is enabled."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1951150242e38ac67ae3fd1561d934188ce31bf2 | felidadae/platform-resource-manager | prm/prm/container.py | [
"Apache-2.0"
] | Python | update_measurement | null | def update_measurement(self, timestamp: float, measurements: Measurements):
"""
update measurements in current cycle and calculate metrics
"""
if self.measurements:
metrics = self.metrics
delta_t = timestamp - self.timestamp
metrics[Metric.CYC] = measu... |
update measurements in current cycle and calculate metrics
| update measurements in current cycle and calculate metrics | [
"update",
"measurements",
"in",
"current",
"cycle",
"and",
"calculate",
"metrics"
] | def update_measurement(self, timestamp: float, measurements: Measurements):
if self.measurements:
metrics = self.metrics
delta_t = timestamp - self.timestamp
metrics[Metric.CYC] = measurements[MetricName.CYCLES] -\
self.measurements[MetricName.CYCLES]
... | [
"def",
"update_measurement",
"(",
"self",
",",
"timestamp",
":",
"float",
",",
"measurements",
":",
"Measurements",
")",
":",
"if",
"self",
".",
"measurements",
":",
"metrics",
"=",
"self",
".",
"metrics",
"delta_t",
"=",
"timestamp",
"-",
"self",
".",
"ti... | update measurements in current cycle and calculate metrics | [
"update",
"measurements",
"in",
"current",
"cycle",
"and",
"calculate",
"metrics"
] | [
"\"\"\"\n update measurements in current cycle and calculate metrics\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "timestamp",
"type": "float"
},
{
"param": "measurements",
"type": "Measurements"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "timestamp",
"type": "float",
"docstring": null,
"docstring_to... |
1951150242e38ac67ae3fd1561d934188ce31bf2 | felidadae/platform-resource-manager | prm/prm/container.py | [
"Apache-2.0"
] | Python | contention_detect | <not_specific> | def contention_detect(self, threshs):
""" detect resouce contention after find proper utilization bin """
if not threshs:
return [], []
metrics = self.metrics
for i in range(0, len(threshs)):
thresh = threshs[i]
if metrics[Metric.UTIL] < thresh['util_... | detect resouce contention after find proper utilization bin | detect resouce contention after find proper utilization bin | [
"detect",
"resouce",
"contention",
"after",
"find",
"proper",
"utilization",
"bin"
] | def contention_detect(self, threshs):
if not threshs:
return [], []
metrics = self.metrics
for i in range(0, len(threshs)):
thresh = threshs[i]
if metrics[Metric.UTIL] < thresh['util_start']:
if i == 0:
return [], []
... | [
"def",
"contention_detect",
"(",
"self",
",",
"threshs",
")",
":",
"if",
"not",
"threshs",
":",
"return",
"[",
"]",
",",
"[",
"]",
"metrics",
"=",
"self",
".",
"metrics",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"threshs",
")",
")",
... | detect resouce contention after find proper utilization bin | [
"detect",
"resouce",
"contention",
"after",
"find",
"proper",
"utilization",
"bin"
] | [
"\"\"\" detect resouce contention after find proper utilization bin \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "threshs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "threshs",
"type": null,
"docstring": null,
"docstring_tokens"... |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | list_pids | <not_specific> | def list_pids(container):
"""
list all process id of one container
container - container object listed from Docker
"""
procs = container.top()['Processes']
pids = [pid[1] for pid in procs] if procs else []
return [tid for pid in pids
for tid in os.listdir('/proc/' + pid + '/t... |
list all process id of one container
container - container object listed from Docker
| list all process id of one container
container - container object listed from Docker | [
"list",
"all",
"process",
"id",
"of",
"one",
"container",
"container",
"-",
"container",
"object",
"listed",
"from",
"Docker"
] | def list_pids(container):
procs = container.top()['Processes']
pids = [pid[1] for pid in procs] if procs else []
return [tid for pid in pids
for tid in os.listdir('/proc/' + pid + '/task')] if pids else [] | [
"def",
"list_pids",
"(",
"container",
")",
":",
"procs",
"=",
"container",
".",
"top",
"(",
")",
"[",
"'Processes'",
"]",
"pids",
"=",
"[",
"pid",
"[",
"1",
"]",
"for",
"pid",
"in",
"procs",
"]",
"if",
"procs",
"else",
"[",
"]",
"return",
"[",
"t... | list all process id of one container
container - container object listed from Docker | [
"list",
"all",
"process",
"id",
"of",
"one",
"container",
"container",
"-",
"container",
"object",
"listed",
"from",
"Docker"
] | [
"\"\"\"\n list all process id of one container\n container - container object listed from Docker\n \"\"\""
] | [
{
"param": "container",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "container",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | mon_util_cycle | null | def mon_util_cycle(ctx):
"""
CPU utilization monitor timer function
ctx - agent context
"""
findbe = False
lc_utils = 0
be_utils = 0
date = datetime.now().isoformat()
bes = []
newbe = False
containers = ctx.docker_client.containers.list()
remove_finished_containers({c... |
CPU utilization monitor timer function
ctx - agent context
| CPU utilization monitor timer function
ctx - agent context | [
"CPU",
"utilization",
"monitor",
"timer",
"function",
"ctx",
"-",
"agent",
"context"
] | def mon_util_cycle(ctx):
findbe = False
lc_utils = 0
be_utils = 0
date = datetime.now().isoformat()
bes = []
newbe = False
containers = ctx.docker_client.containers.list()
remove_finished_containers({c.id for c in containers}, ctx.util_cons)
for container in containers:
cid =... | [
"def",
"mon_util_cycle",
"(",
"ctx",
")",
":",
"findbe",
"=",
"False",
"lc_utils",
"=",
"0",
"be_utils",
"=",
"0",
"date",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"isoformat",
"(",
")",
"bes",
"=",
"[",
"]",
"newbe",
"=",
"False",
"containers",
... | CPU utilization monitor timer function
ctx - agent context | [
"CPU",
"utilization",
"monitor",
"timer",
"function",
"ctx",
"-",
"agent",
"context"
] | [
"\"\"\"\n CPU utilization monitor timer function\n ctx - agent context\n \"\"\""
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | mon_metric_cycle | null | def mon_metric_cycle(ctx):
"""
Platform metrics monitor timer function
ctx - agent context
"""
containers = ctx.docker_client.containers.list()
cgroups = []
cids = []
bes = []
lcs = []
newcon = False
newbe = False
remove_finished_containers({c.id for c in containers},... |
Platform metrics monitor timer function
ctx - agent context
| Platform metrics monitor timer function
ctx - agent context | [
"Platform",
"metrics",
"monitor",
"timer",
"function",
"ctx",
"-",
"agent",
"context"
] | def mon_metric_cycle(ctx):
containers = ctx.docker_client.containers.list()
cgroups = []
cids = []
bes = []
lcs = []
newcon = False
newbe = False
remove_finished_containers({c.id for c in containers}, ctx.metric_cons)
for container in containers:
cid = container.id
na... | [
"def",
"mon_metric_cycle",
"(",
"ctx",
")",
":",
"containers",
"=",
"ctx",
".",
"docker_client",
".",
"containers",
".",
"list",
"(",
")",
"cgroups",
"=",
"[",
"]",
"cids",
"=",
"[",
"]",
"bes",
"=",
"[",
"]",
"lcs",
"=",
"[",
"]",
"newcon",
"=",
... | Platform metrics monitor timer function
ctx - agent context | [
"Platform",
"metrics",
"monitor",
"timer",
"function",
"ctx",
"-",
"agent",
"context"
] | [
"\"\"\"\n Platform metrics monitor timer function\n ctx - agent context\n \"\"\""
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | init_threshbins | <not_specific> | def init_threshbins(jdata):
"""
Initialize thresholds in all bins for one workload
jdata - thresholds data for one workload
"""
key_mappings = [
('util_start', 'UTIL_START'),
('util_end', 'UTIL_END'),
('cpi', 'CPI_THRESH'),
('mpki', 'MPKI_THRESH'),
('mb', ... |
Initialize thresholds in all bins for one workload
jdata - thresholds data for one workload
| Initialize thresholds in all bins for one workload
jdata - thresholds data for one workload | [
"Initialize",
"thresholds",
"in",
"all",
"bins",
"for",
"one",
"workload",
"jdata",
"-",
"thresholds",
"data",
"for",
"one",
"workload"
] | def init_threshbins(jdata):
key_mappings = [
('util_start', 'UTIL_START'),
('util_end', 'UTIL_END'),
('cpi', 'CPI_THRESH'),
('mpki', 'MPKI_THRESH'),
('mb', 'MB_THRESH'),
('l2spki', 'L2SPKI_THRESH'),
('mspki', 'MSPKI_THRESH'),
]
return [
{
... | [
"def",
"init_threshbins",
"(",
"jdata",
")",
":",
"key_mappings",
"=",
"[",
"(",
"'util_start'",
",",
"'UTIL_START'",
")",
",",
"(",
"'util_end'",
",",
"'UTIL_END'",
")",
",",
"(",
"'cpi'",
",",
"'CPI_THRESH'",
")",
",",
"(",
"'mpki'",
",",
"'MPKI_THRESH'"... | Initialize thresholds in all bins for one workload
jdata - thresholds data for one workload | [
"Initialize",
"thresholds",
"in",
"all",
"bins",
"for",
"one",
"workload",
"jdata",
"-",
"thresholds",
"data",
"for",
"one",
"workload"
] | [
"\"\"\"\n Initialize thresholds in all bins for one workload\n jdata - thresholds data for one workload\n \"\"\""
] | [
{
"param": "jdata",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "jdata",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | init_tdp_map | <not_specific> | def init_tdp_map(args):
"""
Initialize thresholds for TDP contention for all workloads
args - agent command line arguments
"""
tdp_file = args.tdp_file if hasattr(args, 'tdp_file')\
and args.tdp_file else 'tdp_thresh.csv'
tdp_df = pd.read_csv(tdp_file)
key = 'CID' if args.key_cid... |
Initialize thresholds for TDP contention for all workloads
args - agent command line arguments
| Initialize thresholds for TDP contention for all workloads
args - agent command line arguments | [
"Initialize",
"thresholds",
"for",
"TDP",
"contention",
"for",
"all",
"workloads",
"args",
"-",
"agent",
"command",
"line",
"arguments"
] | def init_tdp_map(args):
tdp_file = args.tdp_file if hasattr(args, 'tdp_file')\
and args.tdp_file else 'tdp_thresh.csv'
tdp_df = pd.read_csv(tdp_file)
key = 'CID' if args.key_cid else 'CNAME'
cids = tdp_df[key].unique()
thresh_map = {}
for cid in cids:
tdpdata = tdp_df[tdp_df[key]... | [
"def",
"init_tdp_map",
"(",
"args",
")",
":",
"tdp_file",
"=",
"args",
".",
"tdp_file",
"if",
"hasattr",
"(",
"args",
",",
"'tdp_file'",
")",
"and",
"args",
".",
"tdp_file",
"else",
"'tdp_thresh.csv'",
"tdp_df",
"=",
"pd",
".",
"read_csv",
"(",
"tdp_file",... | Initialize thresholds for TDP contention for all workloads
args - agent command line arguments | [
"Initialize",
"thresholds",
"for",
"TDP",
"contention",
"for",
"all",
"workloads",
"args",
"-",
"agent",
"command",
"line",
"arguments"
] | [
"\"\"\"\n Initialize thresholds for TDP contention for all workloads\n args - agent command line arguments\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | init_threshmap | <not_specific> | def init_threshmap(args):
"""
Initialize thresholds for other contentions for all workloads
args - agent command line arguments
"""
thresh_file = args.thresh_file if hasattr(args, 'thresh_file')\
and args.thresh_file else 'thresh.csv'
thresh_df = pd.read_csv(thresh_file)
key = 'C... |
Initialize thresholds for other contentions for all workloads
args - agent command line arguments
| Initialize thresholds for other contentions for all workloads
args - agent command line arguments | [
"Initialize",
"thresholds",
"for",
"other",
"contentions",
"for",
"all",
"workloads",
"args",
"-",
"agent",
"command",
"line",
"arguments"
] | def init_threshmap(args):
thresh_file = args.thresh_file if hasattr(args, 'thresh_file')\
and args.thresh_file else 'thresh.csv'
thresh_df = pd.read_csv(thresh_file)
key = 'CID' if args.key_cid else 'CNAME'
cids = thresh_df[key].unique()
thresh_map = {}
for cid in cids:
jdata = t... | [
"def",
"init_threshmap",
"(",
"args",
")",
":",
"thresh_file",
"=",
"args",
".",
"thresh_file",
"if",
"hasattr",
"(",
"args",
",",
"'thresh_file'",
")",
"and",
"args",
".",
"thresh_file",
"else",
"'thresh.csv'",
"thresh_df",
"=",
"pd",
".",
"read_csv",
"(",
... | Initialize thresholds for other contentions for all workloads
args - agent command line arguments | [
"Initialize",
"thresholds",
"for",
"other",
"contentions",
"for",
"all",
"workloads",
"args",
"-",
"agent",
"command",
"line",
"arguments"
] | [
"\"\"\"\n Initialize thresholds for other contentions for all workloads\n args - agent command line arguments\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | init_wlset | null | def init_wlset(ctx):
"""
Initialize workload set for both LC and BE
ctx - agent context
"""
key = 'CID' if ctx.args.key_cid else 'CNAME'
wl_df = pd.read_csv(ctx.args.workload_conf_file)
lcs = []
bes = []
for row_turple in wl_df.iterrows():
row = row_turple[1]
work... |
Initialize workload set for both LC and BE
ctx - agent context
| Initialize workload set for both LC and BE
ctx - agent context | [
"Initialize",
"workload",
"set",
"for",
"both",
"LC",
"and",
"BE",
"ctx",
"-",
"agent",
"context"
] | def init_wlset(ctx):
key = 'CID' if ctx.args.key_cid else 'CNAME'
wl_df = pd.read_csv(ctx.args.workload_conf_file)
lcs = []
bes = []
for row_turple in wl_df.iterrows():
row = row_turple[1]
workload = row[key]
if row['TYPE'] == 'LC':
lcs.append(workload)
el... | [
"def",
"init_wlset",
"(",
"ctx",
")",
":",
"key",
"=",
"'CID'",
"if",
"ctx",
".",
"args",
".",
"key_cid",
"else",
"'CNAME'",
"wl_df",
"=",
"pd",
".",
"read_csv",
"(",
"ctx",
".",
"args",
".",
"workload_conf_file",
")",
"lcs",
"=",
"[",
"]",
"bes",
... | Initialize workload set for both LC and BE
ctx - agent context | [
"Initialize",
"workload",
"set",
"for",
"both",
"LC",
"and",
"BE",
"ctx",
"-",
"agent",
"context"
] | [
"\"\"\"\n Initialize workload set for both LC and BE\n ctx - agent context\n \"\"\""
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | update_sysmax | null | def update_sysmax(ctx, lc_utils):
"""
Update system maximal utilization based on utilization of LC workloads
ctx - agent context
lc_utils - monitored LC workload utilization maximal value
"""
ctx.sysmax_util = int(lc_utils)
subprocess.Popen('echo ' + str(ctx.sysmax_util) + ' > ' + ct... |
Update system maximal utilization based on utilization of LC workloads
ctx - agent context
lc_utils - monitored LC workload utilization maximal value
| Update system maximal utilization based on utilization of LC workloads
ctx - agent context
lc_utils - monitored LC workload utilization maximal value | [
"Update",
"system",
"maximal",
"utilization",
"based",
"on",
"utilization",
"of",
"LC",
"workloads",
"ctx",
"-",
"agent",
"context",
"lc_utils",
"-",
"monitored",
"LC",
"workload",
"utilization",
"maximal",
"value"
] | def update_sysmax(ctx, lc_utils):
ctx.sysmax_util = int(lc_utils)
subprocess.Popen('echo ' + str(ctx.sysmax_util) + ' > ' + ctx.sysmax_file,
shell=True) | [
"def",
"update_sysmax",
"(",
"ctx",
",",
"lc_utils",
")",
":",
"ctx",
".",
"sysmax_util",
"=",
"int",
"(",
"lc_utils",
")",
"subprocess",
".",
"Popen",
"(",
"'echo '",
"+",
"str",
"(",
"ctx",
".",
"sysmax_util",
")",
"+",
"' > '",
"+",
"ctx",
".",
"s... | Update system maximal utilization based on utilization of LC workloads
ctx - agent context
lc_utils - monitored LC workload utilization maximal value | [
"Update",
"system",
"maximal",
"utilization",
"based",
"on",
"utilization",
"of",
"LC",
"workloads",
"ctx",
"-",
"agent",
"context",
"lc_utils",
"-",
"monitored",
"LC",
"workload",
"utilization",
"maximal",
"value"
] | [
"\"\"\"\n Update system maximal utilization based on utilization of LC workloads\n ctx - agent context\n lc_utils - monitored LC workload utilization maximal value\n \"\"\""
] | [
{
"param": "ctx",
"type": null
},
{
"param": "lc_utils",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lc_utils",
"type": null,
"docstring": null,
"docstring_tokens"... |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | init_sysmax | null | def init_sysmax(ctx):
"""
Initialize historical system maximal utilization from model file
ctx - agent context
"""
try:
with open(ctx.sysmax_file, 'r') as f:
ctx.sysmax_util = int(f.read().strip())
except (IOError, ValueError):
ctx.sysmax_util = cpu_count() * 100
... |
Initialize historical system maximal utilization from model file
ctx - agent context
| Initialize historical system maximal utilization from model file
ctx - agent context | [
"Initialize",
"historical",
"system",
"maximal",
"utilization",
"from",
"model",
"file",
"ctx",
"-",
"agent",
"context"
] | def init_sysmax(ctx):
try:
with open(ctx.sysmax_file, 'r') as f:
ctx.sysmax_util = int(f.read().strip())
except (IOError, ValueError):
ctx.sysmax_util = cpu_count() * 100
if ctx.args.verbose:
print(ctx.sysmax_util) | [
"def",
"init_sysmax",
"(",
"ctx",
")",
":",
"try",
":",
"with",
"open",
"(",
"ctx",
".",
"sysmax_file",
",",
"'r'",
")",
"as",
"f",
":",
"ctx",
".",
"sysmax_util",
"=",
"int",
"(",
"f",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
")",
"excep... | Initialize historical system maximal utilization from model file
ctx - agent context | [
"Initialize",
"historical",
"system",
"maximal",
"utilization",
"from",
"model",
"file",
"ctx",
"-",
"agent",
"context"
] | [
"\"\"\"\n Initialize historical system maximal utilization from model file\n ctx - agent context\n \"\"\""
] | [
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | detect_cgroup_driver | <not_specific> | def detect_cgroup_driver():
"""
Detect docker cgroup parent dir based on cgroup driver type
"""
client = docker.from_env()
dockinfo = client.info()
cgroup_driver = dockinfo['CgroupDriver']
if cgroup_driver != 'cgroupfs':
print('Unknown cgroup driver: ' + cgroup_driver)
return cg... |
Detect docker cgroup parent dir based on cgroup driver type
| Detect docker cgroup parent dir based on cgroup driver type | [
"Detect",
"docker",
"cgroup",
"parent",
"dir",
"based",
"on",
"cgroup",
"driver",
"type"
] | def detect_cgroup_driver():
client = docker.from_env()
dockinfo = client.info()
cgroup_driver = dockinfo['CgroupDriver']
if cgroup_driver != 'cgroupfs':
print('Unknown cgroup driver: ' + cgroup_driver)
return cgroup_driver | [
"def",
"detect_cgroup_driver",
"(",
")",
":",
"client",
"=",
"docker",
".",
"from_env",
"(",
")",
"dockinfo",
"=",
"client",
".",
"info",
"(",
")",
"cgroup_driver",
"=",
"dockinfo",
"[",
"'CgroupDriver'",
"]",
"if",
"cgroup_driver",
"!=",
"'cgroupfs'",
":",
... | Detect docker cgroup parent dir based on cgroup driver type | [
"Detect",
"docker",
"cgroup",
"parent",
"dir",
"based",
"on",
"cgroup",
"driver",
"type"
] | [
"\"\"\"\n Detect docker cgroup parent dir based on cgroup driver type\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
620709c06139f1d7c95d50f55ffa289086079cd7 | felidadae/platform-resource-manager | eris/eris.py | [
"Apache-2.0"
] | Python | parse_arguments | <not_specific> | def parse_arguments():
""" agent command line arguments parse function """
parser = ArgumentParser(description='eris agent monitor\
container CPU utilization and platform\
metrics, detect potential resource\
contention and regu... | agent command line arguments parse function | agent command line arguments parse function | [
"agent",
"command",
"line",
"arguments",
"parse",
"function"
] | def parse_arguments():
parser = ArgumentParser(description='eris agent monitor\
container CPU utilization and platform\
metrics, detect potential resource\
contention and regulate \
task resource usages')... | [
"def",
"parse_arguments",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"'eris agent monitor\\\n container CPU utilization and platform\\\n metrics, detect potential resource\\\n content... | agent command line arguments parse function | [
"agent",
"command",
"line",
"arguments",
"parse",
"function"
] | [
"\"\"\" agent command line arguments parse function \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
77d5896cd2b2a537cb0224c95d02edd385b36ffb | MatthewKleinsmith/portrait-seg | portraitseg/data_augmentations.py | [
"MIT"
] | Python | apply_data_aug | <not_specific> | def apply_data_aug(inp, target, data_aug, kwargs=None):
"""
Applies the transform to the input and target in the same way.
"""
concatenation = np.concatenate([inp, target[None, :]])
if kwargs:
concatenation_aug = data_aug(concatenation, **kwargs)
else:
concatenation_aug = data_au... |
Applies the transform to the input and target in the same way.
| Applies the transform to the input and target in the same way. | [
"Applies",
"the",
"transform",
"to",
"the",
"input",
"and",
"target",
"in",
"the",
"same",
"way",
"."
] | def apply_data_aug(inp, target, data_aug, kwargs=None):
concatenation = np.concatenate([inp, target[None, :]])
if kwargs:
concatenation_aug = data_aug(concatenation, **kwargs)
else:
concatenation_aug = data_aug(concatenation)
inp, target = concatenation_aug[:-1], concatenation_aug[-1]
... | [
"def",
"apply_data_aug",
"(",
"inp",
",",
"target",
",",
"data_aug",
",",
"kwargs",
"=",
"None",
")",
":",
"concatenation",
"=",
"np",
".",
"concatenate",
"(",
"[",
"inp",
",",
"target",
"[",
"None",
",",
":",
"]",
"]",
")",
"if",
"kwargs",
":",
"c... | Applies the transform to the input and target in the same way. | [
"Applies",
"the",
"transform",
"to",
"the",
"input",
"and",
"target",
"in",
"the",
"same",
"way",
"."
] | [
"\"\"\"\n Applies the transform to the input and target in the same way.\n \"\"\""
] | [
{
"param": "inp",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "data_aug",
"type": null
},
{
"param": "kwargs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inp",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens": ... |
77d5896cd2b2a537cb0224c95d02edd385b36ffb | MatthewKleinsmith/portrait-seg | portraitseg/data_augmentations.py | [
"MIT"
] | Python | mirror | <not_specific> | def mirror(inp, target):
"""
- Horizontal flip
- Appropriate for image transformation tasks
- Requires the width axis to be the last axis
"""
def mirror(image):
return np.flip(image, -1).copy()
inp, target = apply_data_aug(inp, target, mirror)
return inp, target |
- Horizontal flip
- Appropriate for image transformation tasks
- Requires the width axis to be the last axis
| Horizontal flip
Appropriate for image transformation tasks
Requires the width axis to be the last axis | [
"Horizontal",
"flip",
"Appropriate",
"for",
"image",
"transformation",
"tasks",
"Requires",
"the",
"width",
"axis",
"to",
"be",
"the",
"last",
"axis"
] | def mirror(inp, target):
def mirror(image):
return np.flip(image, -1).copy()
inp, target = apply_data_aug(inp, target, mirror)
return inp, target | [
"def",
"mirror",
"(",
"inp",
",",
"target",
")",
":",
"def",
"mirror",
"(",
"image",
")",
":",
"return",
"np",
".",
"flip",
"(",
"image",
",",
"-",
"1",
")",
".",
"copy",
"(",
")",
"inp",
",",
"target",
"=",
"apply_data_aug",
"(",
"inp",
",",
"... | Horizontal flip
Appropriate for image transformation tasks
Requires the width axis to be the last axis | [
"Horizontal",
"flip",
"Appropriate",
"for",
"image",
"transformation",
"tasks",
"Requires",
"the",
"width",
"axis",
"to",
"be",
"the",
"last",
"axis"
] | [
"\"\"\"\n - Horizontal flip\n - Appropriate for image transformation tasks\n - Requires the width axis to be the last axis\n \"\"\""
] | [
{
"param": "inp",
"type": null
},
{
"param": "target",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inp",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens": ... |
471473e0663f08ce4e55e3090db1b6cedbb6f8db | sjgitty/opentitan | hw/ip/otbn/dv/otbnsim/sim/sim.py | [
"Apache-2.0"
] | Python | run | int | def run(self, verbose: bool) -> int:
'''Run until ECALL.
Return the number of cycles taken.
'''
insn_count = 0
while self.state.running:
self.step(verbose)
insn_count += 1
return insn_count | Run until ECALL.
Return the number of cycles taken.
| Run until ECALL.
Return the number of cycles taken. | [
"Run",
"until",
"ECALL",
".",
"Return",
"the",
"number",
"of",
"cycles",
"taken",
"."
] | def run(self, verbose: bool) -> int:
insn_count = 0
while self.state.running:
self.step(verbose)
insn_count += 1
return insn_count | [
"def",
"run",
"(",
"self",
",",
"verbose",
":",
"bool",
")",
"->",
"int",
":",
"insn_count",
"=",
"0",
"while",
"self",
".",
"state",
".",
"running",
":",
"self",
".",
"step",
"(",
"verbose",
")",
"insn_count",
"+=",
"1",
"return",
"insn_count"
] | Run until ECALL. | [
"Run",
"until",
"ECALL",
"."
] | [
"'''Run until ECALL.\n\n Return the number of cycles taken.\n\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "verbose",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "verbose",
"type": "bool",
"docstring": null,
"docstring_token... |
471473e0663f08ce4e55e3090db1b6cedbb6f8db | sjgitty/opentitan | hw/ip/otbn/dv/otbnsim/sim/sim.py | [
"Apache-2.0"
] | Python | step | Tuple[Optional[OTBNInsn], List[str]] | def step(self, verbose: bool) -> Tuple[Optional[OTBNInsn], List[str]]:
'''Run a single instruction.
Returns the instruction, together with a list of the architectural
changes that have happened. If the model isn't currently running,
returns no instruction and no changes.
'''
... | Run a single instruction.
Returns the instruction, together with a list of the architectural
changes that have happened. If the model isn't currently running,
returns no instruction and no changes.
| Run a single instruction.
Returns the instruction, together with a list of the architectural
changes that have happened. If the model isn't currently running,
returns no instruction and no changes. | [
"Run",
"a",
"single",
"instruction",
".",
"Returns",
"the",
"instruction",
"together",
"with",
"a",
"list",
"of",
"the",
"architectural",
"changes",
"that",
"have",
"happened",
".",
"If",
"the",
"model",
"isn",
"'",
"t",
"currently",
"running",
"returns",
"n... | def step(self, verbose: bool) -> Tuple[Optional[OTBNInsn], List[str]]:
if not self.state.running:
return (None, [])
was_stalled = self.state.stalled
if was_stalled:
insn = None
changes = []
else:
word_pc = int(self.state.pc) >> 2
... | [
"def",
"step",
"(",
"self",
",",
"verbose",
":",
"bool",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"OTBNInsn",
"]",
",",
"List",
"[",
"str",
"]",
"]",
":",
"if",
"not",
"self",
".",
"state",
".",
"running",
":",
"return",
"(",
"None",
",",
"[",
... | Run a single instruction. | [
"Run",
"a",
"single",
"instruction",
"."
] | [
"'''Run a single instruction.\n\n Returns the instruction, together with a list of the architectural\n changes that have happened. If the model isn't currently running,\n returns no instruction and no changes.\n\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "verbose",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "verbose",
"type": "bool",
"docstring": null,
"docstring_token... |
c338f04701625bc460d46449eec1692aa7d56e6c | sjgitty/opentitan | hw/ip/otbn/dv/otbnsim/sim/state.py | [
"Apache-2.0"
] | Python | step | Optional[int] | def step(self, next_pc: int) -> Optional[int]:
'''Update loop stack. If we should loop, return new PC'''
if self.stack:
top = self.stack[-1]
if next_pc == top.match_addr:
assert top.restarts_left > 0
top.restarts_left -= 1
if not t... | Update loop stack. If we should loop, return new PC | Update loop stack. If we should loop, return new PC | [
"Update",
"loop",
"stack",
".",
"If",
"we",
"should",
"loop",
"return",
"new",
"PC"
] | def step(self, next_pc: int) -> Optional[int]:
if self.stack:
top = self.stack[-1]
if next_pc == top.match_addr:
assert top.restarts_left > 0
top.restarts_left -= 1
if not top.restarts_left:
self.stack.pop()
... | [
"def",
"step",
"(",
"self",
",",
"next_pc",
":",
"int",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"self",
".",
"stack",
":",
"top",
"=",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
"if",
"next_pc",
"==",
"top",
".",
"match_addr",
":",
"a... | Update loop stack. | [
"Update",
"loop",
"stack",
"."
] | [
"'''Update loop stack. If we should loop, return new PC'''",
"# 1-based iteration number"
] | [
{
"param": "self",
"type": null
},
{
"param": "next_pc",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "next_pc",
"type": "int",
"docstring": null,
"docstring_tokens... |
c338f04701625bc460d46449eec1692aa7d56e6c | sjgitty/opentitan | hw/ip/otbn/dv/otbnsim/sim/state.py | [
"Apache-2.0"
] | Python | add_with_carry | Tuple[int, FlagReg] | def add_with_carry(a: int, b: int, carry_in: int) -> Tuple[int, FlagReg]:
'''Compute a + b + carry_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and carry_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the FlagR... | Compute a + b + carry_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and carry_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the FlagReg that the computation generates.
| Compute a + b + carry_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and carry_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the FlagReg that the computation generates. | [
"Compute",
"a",
"+",
"b",
"+",
"carry_in",
"and",
"resulting",
"flags",
".",
"Here",
"a",
"and",
"b",
"are",
"unsigned",
"256",
"-",
"bit",
"numbers",
"and",
"carry_in",
"is",
"0",
"or",
"1",
".",
"Returns",
"a",
"pair",
"(",
"result",
"flags",
")",
... | def add_with_carry(a: int, b: int, carry_in: int) -> Tuple[int, FlagReg]:
mask256 = (1 << 256) - 1
assert 0 <= a <= mask256
assert 0 <= b <= mask256
assert 0 <= carry_in <= 1
result = a + b + carry_in
carryless_result = result & mask256
C = bool((result >> 256) & ... | [
"def",
"add_with_carry",
"(",
"a",
":",
"int",
",",
"b",
":",
"int",
",",
"carry_in",
":",
"int",
")",
"->",
"Tuple",
"[",
"int",
",",
"FlagReg",
"]",
":",
"mask256",
"=",
"(",
"1",
"<<",
"256",
")",
"-",
"1",
"assert",
"0",
"<=",
"a",
"<=",
... | Compute a + b + carry_in and resulting flags. | [
"Compute",
"a",
"+",
"b",
"+",
"carry_in",
"and",
"resulting",
"flags",
"."
] | [
"'''Compute a + b + carry_in and resulting flags.\n\n Here, a and b are unsigned 256-bit numbers and carry_in is 0 or 1.\n Returns a pair (result, flags) where result is the unsigned 256-bit\n result and flags is the FlagReg that the computation generates.\n\n '''"
] | [
{
"param": "a",
"type": "int"
},
{
"param": "b",
"type": "int"
},
{
"param": "carry_in",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b",
"type": "int",
"docstring": null,
"docstring_tokens": [],
... |
c338f04701625bc460d46449eec1692aa7d56e6c | sjgitty/opentitan | hw/ip/otbn/dv/otbnsim/sim/state.py | [
"Apache-2.0"
] | Python | sub_with_borrow | Tuple[int, FlagReg] | def sub_with_borrow(a: int, b: int, borrow_in: int) -> Tuple[int, FlagReg]:
'''Compute a - b - borrow_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and borrow_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the F... | Compute a - b - borrow_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and borrow_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the FlagReg that the computation generates.
| Compute a - b - borrow_in and resulting flags.
Here, a and b are unsigned 256-bit numbers and borrow_in is 0 or 1.
Returns a pair (result, flags) where result is the unsigned 256-bit
result and flags is the FlagReg that the computation generates. | [
"Compute",
"a",
"-",
"b",
"-",
"borrow_in",
"and",
"resulting",
"flags",
".",
"Here",
"a",
"and",
"b",
"are",
"unsigned",
"256",
"-",
"bit",
"numbers",
"and",
"borrow_in",
"is",
"0",
"or",
"1",
".",
"Returns",
"a",
"pair",
"(",
"result",
"flags",
")"... | def sub_with_borrow(a: int, b: int, borrow_in: int) -> Tuple[int, FlagReg]:
mask256 = (1 << 256) - 1
assert 0 <= a <= mask256
assert 0 <= b <= mask256
assert 0 <= borrow_in <= 1
result = a - b - borrow_in
carryless_result = result & mask256
C = bool((result >> 256... | [
"def",
"sub_with_borrow",
"(",
"a",
":",
"int",
",",
"b",
":",
"int",
",",
"borrow_in",
":",
"int",
")",
"->",
"Tuple",
"[",
"int",
",",
"FlagReg",
"]",
":",
"mask256",
"=",
"(",
"1",
"<<",
"256",
")",
"-",
"1",
"assert",
"0",
"<=",
"a",
"<=",
... | Compute a - b - borrow_in and resulting flags. | [
"Compute",
"a",
"-",
"b",
"-",
"borrow_in",
"and",
"resulting",
"flags",
"."
] | [
"'''Compute a - b - borrow_in and resulting flags.\n\n Here, a and b are unsigned 256-bit numbers and borrow_in is 0 or 1.\n Returns a pair (result, flags) where result is the unsigned 256-bit\n result and flags is the FlagReg that the computation generates.\n\n '''"
] | [
{
"param": "a",
"type": "int"
},
{
"param": "b",
"type": "int"
},
{
"param": "borrow_in",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b",
"type": "int",
"docstring": null,
"docstring_tokens": [],
... |
525907bc8e32072734736b266577a055132fd086 | sjgitty/opentitan | util/rom-ext-manifest-generator.py | [
"Apache-2.0"
] | Python | generate_cheader | null | def generate_cheader(fields, input_dir, output_dir):
""" Generates C header file from the `template_file`.
It produces a list of tuples with a field name and the `MemoryRegion`
object, whic is used in the `template_path`. The resulting header file is
placed into `output_path`.
"""
template_pat... | Generates C header file from the `template_file`.
It produces a list of tuples with a field name and the `MemoryRegion`
object, whic is used in the `template_path`. The resulting header file is
placed into `output_path`.
| Generates C header file from the `template_file`.
It produces a list of tuples with a field name and the `MemoryRegion`
object, whic is used in the `template_path`. The resulting header file is
placed into `output_path`. | [
"Generates",
"C",
"header",
"file",
"from",
"the",
"`",
"template_file",
"`",
".",
"It",
"produces",
"a",
"list",
"of",
"tuples",
"with",
"a",
"field",
"name",
"and",
"the",
"`",
"MemoryRegion",
"`",
"object",
"whic",
"is",
"used",
"in",
"the",
"`",
"t... | def generate_cheader(fields, input_dir, output_dir):
template_path = input_dir / 'manifest.h.tpl'
output_path = output_dir / 'manifest.h'
base_name = Name.from_snake_case("ROM_EXT")
items = []
offset = 0
for field in fields:
assert field['size'] % 8 == 0
size_bytes = field['size'... | [
"def",
"generate_cheader",
"(",
"fields",
",",
"input_dir",
",",
"output_dir",
")",
":",
"template_path",
"=",
"input_dir",
"/",
"'manifest.h.tpl'",
"output_path",
"=",
"output_dir",
"/",
"'manifest.h'",
"base_name",
"=",
"Name",
".",
"from_snake_case",
"(",
"\"RO... | Generates C header file from the `template_file`. | [
"Generates",
"C",
"header",
"file",
"from",
"the",
"`",
"template_file",
"`",
"."
] | [
"\"\"\" Generates C header file from the `template_file`.\n\n It produces a list of tuples with a field name and the `MemoryRegion`\n object, whic is used in the `template_path`. The resulting header file is\n placed into `output_path`.\n \"\"\""
] | [
{
"param": "fields",
"type": null
},
{
"param": "input_dir",
"type": null
},
{
"param": "output_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fields",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_dir",
"type": null,
"docstring": null,
"docstring_tok... |
a2c3692eea1505a46dd8cb70fcd42bbeacf83229 | cadCAD-org/cadCAD_machine_search | cadcad_machine_search/visualizations/goal_impact.py | [
"MIT"
] | Python | plot_goal_ternary | None | def plot_goal_ternary(df: pd.DataFrame,
kpis: Dict[str, callable],
goals: Dict[str, callable],
control_params: set) -> None:
"""
Arguments
---
df: Observation dataframe
kpis: Dictionary of funtions that scores a given combination of control params
... |
Arguments
---
df: Observation dataframe
kpis: Dictionary of funtions that scores a given combination of control params
goals: Dictionary of how the goals are metrified. One of the keys must be 'combined'
control_params: Set of the columns to be used as features.
| Arguments
df: Observation dataframe
kpis: Dictionary of funtions that scores a given combination of control params
goals: Dictionary of how the goals are metrified. One of the keys must be 'combined'
control_params: Set of the columns to be used as features. | [
"Arguments",
"df",
":",
"Observation",
"dataframe",
"kpis",
":",
"Dictionary",
"of",
"funtions",
"that",
"scores",
"a",
"given",
"combination",
"of",
"control",
"params",
"goals",
":",
"Dictionary",
"of",
"how",
"the",
"goals",
"are",
"metrified",
".",
"One",
... | def plot_goal_ternary(df: pd.DataFrame,
kpis: Dict[str, callable],
goals: Dict[str, callable],
control_params: set) -> None:
if len(goals.keys()) != 4:
raise ValueError('The `goals` dictionary must have four elements')
output = []
for kpi, kpi_funct... | [
"def",
"plot_goal_ternary",
"(",
"df",
":",
"pd",
".",
"DataFrame",
",",
"kpis",
":",
"Dict",
"[",
"str",
",",
"callable",
"]",
",",
"goals",
":",
"Dict",
"[",
"str",
",",
"callable",
"]",
",",
"control_params",
":",
"set",
")",
"->",
"None",
":",
... | Arguments
df: Observation dataframe
kpis: Dictionary of funtions that scores a given combination of control params
goals: Dictionary of how the goals are metrified. | [
"Arguments",
"df",
":",
"Observation",
"dataframe",
"kpis",
":",
"Dictionary",
"of",
"funtions",
"that",
"scores",
"a",
"given",
"combination",
"of",
"control",
"params",
"goals",
":",
"Dictionary",
"of",
"how",
"the",
"goals",
"are",
"metrified",
"."
] | [
"\"\"\"\n Arguments\n ---\n df: Observation dataframe\n kpis: Dictionary of funtions that scores a given combination of control params\n goals: Dictionary of how the goals are metrified. One of the keys must be 'combined'\n control_params: Set of the columns to be used as features.\n \"\"\"",
... | [
{
"param": "df",
"type": "pd.DataFrame"
},
{
"param": "kpis",
"type": "Dict[str, callable]"
},
{
"param": "goals",
"type": "Dict[str, callable]"
},
{
"param": "control_params",
"type": "set"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kpis",
"type": "Dict[str, callable]",
"docstring": null,
... |
5d5b8cbf85a4283a30a9bdc235ad9fd97eebbc03 | cadCAD-org/cadCAD_machine_search | cadcad_machine_search/tools/param_sweep.py | [
"MIT"
] | Python | sweep_cartesian_product | Dict[str, tuple] | def sweep_cartesian_product(sweep_params: Dict[str, tuple]) -> Dict[str, tuple]:
"""
Makes a cartesian product from dictionary values.
This is useful for plugging inside the sys_params dict, like:
```python
sweep_params = {'a': [0.1, 0.2], 'b': [1, 2]}
product_sweep
sys_params = {**cartesi... |
Makes a cartesian product from dictionary values.
This is useful for plugging inside the sys_params dict, like:
```python
sweep_params = {'a': [0.1, 0.2], 'b': [1, 2]}
product_sweep
sys_params = {**cartesian_product_sweep(sweep_params),
'c': [0.1]}
```
Usage:
>>... | Makes a cartesian product from dictionary values.
| [
"Makes",
"a",
"cartesian",
"product",
"from",
"dictionary",
"values",
"."
] | def sweep_cartesian_product(sweep_params: Dict[str, tuple]) -> Dict[str, tuple]:
cartesian_product = product(*sweep_params.values())
transpose_cartesian_product = zip(*cartesian_product)
zipped_sweep_params = zip(sweep_params.keys(), transpose_cartesian_product)
sweep_dict = dict(zipped_sweep_params)
... | [
"def",
"sweep_cartesian_product",
"(",
"sweep_params",
":",
"Dict",
"[",
"str",
",",
"tuple",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"tuple",
"]",
":",
"cartesian_product",
"=",
"product",
"(",
"*",
"sweep_params",
".",
"values",
"(",
")",
")",
"transp... | Makes a cartesian product from dictionary values. | [
"Makes",
"a",
"cartesian",
"product",
"from",
"dictionary",
"values",
"."
] | [
"\"\"\"\n Makes a cartesian product from dictionary values.\n\n This is useful for plugging inside the sys_params dict, like:\n ```python\n sweep_params = {'a': [0.1, 0.2], 'b': [1, 2]}\n product_sweep \n sys_params = {**cartesian_product_sweep(sweep_params),\n 'c': [0.1]}\n ``... | [
{
"param": "sweep_params",
"type": "Dict[str, tuple]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sweep_params",
"type": "Dict[str, tuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f074baf34170eb89d6aacb04dcf53d0fab2fdb85 | cadCAD-org/cadCAD_machine_search | cadcad_machine_search/visualizations/sensitivity.py | [
"MIT"
] | Python | f | <not_specific> | def f(X: pd.DataFrame,
y: pd.Series,
target: str,
ax_dt: object,
ax_rf: object,
label: str = 'target'):
"""
Fit DT and RF classifiers for summarizing the sensivity.
"""
model = DecisionTreeClassifier(class_weight='balanced',
max_depth=5,
... |
Fit DT and RF classifiers for summarizing the sensivity.
| Fit DT and RF classifiers for summarizing the sensivity. | [
"Fit",
"DT",
"and",
"RF",
"classifiers",
"for",
"summarizing",
"the",
"sensivity",
"."
] | def f(X: pd.DataFrame,
y: pd.Series,
target: str,
ax_dt: object,
ax_rf: object,
label: str = 'target'):
model = DecisionTreeClassifier(class_weight='balanced',
max_depth=5,
)
rf = RandomForestClassifier()
mod... | [
"def",
"f",
"(",
"X",
":",
"pd",
".",
"DataFrame",
",",
"y",
":",
"pd",
".",
"Series",
",",
"target",
":",
"str",
",",
"ax_dt",
":",
"object",
",",
"ax_rf",
":",
"object",
",",
"label",
":",
"str",
"=",
"'target'",
")",
":",
"model",
"=",
"Deci... | Fit DT and RF classifiers for summarizing the sensivity. | [
"Fit",
"DT",
"and",
"RF",
"classifiers",
"for",
"summarizing",
"the",
"sensivity",
"."
] | [
"\"\"\"\n Fit DT and RF classifiers for summarizing the sensivity.\n \"\"\""
] | [
{
"param": "X",
"type": "pd.DataFrame"
},
{
"param": "y",
"type": "pd.Series"
},
{
"param": "target",
"type": "str"
},
{
"param": "ax_dt",
"type": "object"
},
{
"param": "ax_rf",
"type": "object"
},
{
"param": "label",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": "pd.Series",
"docstring": null,
"docstring... |
f074baf34170eb89d6aacb04dcf53d0fab2fdb85 | cadCAD-org/cadCAD_machine_search | cadcad_machine_search/visualizations/sensitivity.py | [
"MIT"
] | Python | param_sensitivity_plot | <not_specific> | def param_sensitivity_plot(df: pd.DataFrame,
control_params: set,
target: str,
label: str = 'target'):
"""
Plot the sensivity of the 'target' column vs
a list of control parameters, which are data frame columns.
"""
fea... |
Plot the sensivity of the 'target' column vs
a list of control parameters, which are data frame columns.
| Plot the sensivity of the 'target' column vs
a list of control parameters, which are data frame columns. | [
"Plot",
"the",
"sensivity",
"of",
"the",
"'",
"target",
"'",
"column",
"vs",
"a",
"list",
"of",
"control",
"parameters",
"which",
"are",
"data",
"frame",
"columns",
"."
] | def param_sensitivity_plot(df: pd.DataFrame,
control_params: set,
target: str,
label: str = 'target'):
features = set(control_params) - {target}
X = df.loc[:, features]
y = (df[target] > 0)
fig, axes = plt.subplots(nrows=2,... | [
"def",
"param_sensitivity_plot",
"(",
"df",
":",
"pd",
".",
"DataFrame",
",",
"control_params",
":",
"set",
",",
"target",
":",
"str",
",",
"label",
":",
"str",
"=",
"'target'",
")",
":",
"features",
"=",
"set",
"(",
"control_params",
")",
"-",
"{",
"t... | Plot the sensivity of the 'target' column vs
a list of control parameters, which are data frame columns. | [
"Plot",
"the",
"sensivity",
"of",
"the",
"'",
"target",
"'",
"column",
"vs",
"a",
"list",
"of",
"control",
"parameters",
"which",
"are",
"data",
"frame",
"columns",
"."
] | [
"\"\"\"\n Plot the sensivity of the 'target' column vs\n a list of control parameters, which are data frame columns.\n \"\"\"",
"# Visualize"
] | [
{
"param": "df",
"type": "pd.DataFrame"
},
{
"param": "control_params",
"type": "set"
},
{
"param": "target",
"type": "str"
},
{
"param": "label",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "control_params",
"type": "set",
"docstring": null,
"d... |
f074baf34170eb89d6aacb04dcf53d0fab2fdb85 | cadCAD-org/cadCAD_machine_search | cadcad_machine_search/visualizations/sensitivity.py | [
"MIT"
] | Python | kpi_sensitivity_plot | null | def kpi_sensitivity_plot(df: pd.DataFrame,
run_utility: callable,
control_params: set,
label: str = 'target'):
"""
Plots the sensitivity of a result dataset towards a KPI.
Arguments
df: data frame containing all the simulation r... |
Plots the sensitivity of a result dataset towards a KPI.
Arguments
df: data frame containing all the simulation results, incl params.
run_utility: function that aggregates a (subset_id, run) data into a number
control_params: columns on data frame for doing sensitivity analysis
| Plots the sensitivity of a result dataset towards a KPI.
Arguments
df: data frame containing all the simulation results, incl params.
run_utility: function that aggregates a (subset_id, run) data into a number
control_params: columns on data frame for doing sensitivity analysis | [
"Plots",
"the",
"sensitivity",
"of",
"a",
"result",
"dataset",
"towards",
"a",
"KPI",
".",
"Arguments",
"df",
":",
"data",
"frame",
"containing",
"all",
"the",
"simulation",
"results",
"incl",
"params",
".",
"run_utility",
":",
"function",
"that",
"aggregates"... | def kpi_sensitivity_plot(df: pd.DataFrame,
run_utility: callable,
control_params: set,
label: str = 'target'):
labels = df.groupby(['subset', 'run']).apply(run_utility)
labels.name = 'target'
labels_df = labels
cols = ['subset', ... | [
"def",
"kpi_sensitivity_plot",
"(",
"df",
":",
"pd",
".",
"DataFrame",
",",
"run_utility",
":",
"callable",
",",
"control_params",
":",
"set",
",",
"label",
":",
"str",
"=",
"'target'",
")",
":",
"labels",
"=",
"df",
".",
"groupby",
"(",
"[",
"'subset'",... | Plots the sensitivity of a result dataset towards a KPI. | [
"Plots",
"the",
"sensitivity",
"of",
"a",
"result",
"dataset",
"towards",
"a",
"KPI",
"."
] | [
"\"\"\"\n Plots the sensitivity of a result dataset towards a KPI.\n\n Arguments\n df: data frame containing all the simulation results, incl params.\n run_utility: function that aggregates a (subset_id, run) data into a number\n control_params: columns on data frame for doing sensitivity analysis\n ... | [
{
"param": "df",
"type": "pd.DataFrame"
},
{
"param": "run_utility",
"type": "callable"
},
{
"param": "control_params",
"type": "set"
},
{
"param": "label",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "run_utility",
"type": "callable",
"docstring": null,
... |
3b91952aaaae22cb61816e203498b7d44c67e5e0 | glyph/streamrandom | streamrandom.py | [
"MIT"
] | Python | seed | null | def seed(self, a=None):
"""
Create a new stream from the given seed.
"""
raise NotImplementedError(
"To re-seed, create a new StreamRandom with a new stream."
) |
Create a new stream from the given seed.
| Create a new stream from the given seed. | [
"Create",
"a",
"new",
"stream",
"from",
"the",
"given",
"seed",
"."
] | def seed(self, a=None):
raise NotImplementedError(
"To re-seed, create a new StreamRandom with a new stream."
) | [
"def",
"seed",
"(",
"self",
",",
"a",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"To re-seed, create a new StreamRandom with a new stream.\"",
")"
] | Create a new stream from the given seed. | [
"Create",
"a",
"new",
"stream",
"from",
"the",
"given",
"seed",
"."
] | [
"\"\"\"\n Create a new stream from the given seed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "a",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "a",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
3b91952aaaae22cb61816e203498b7d44c67e5e0 | glyph/streamrandom | streamrandom.py | [
"MIT"
] | Python | jumpahead | null | def jumpahead(self, n):
"""
Jump ahead in the stream as if C{random} had been called C{n} times.
"""
self._stream.seek(n * 7, 1) |
Jump ahead in the stream as if C{random} had been called C{n} times.
| Jump ahead in the stream as if C{random} had been called C{n} times. | [
"Jump",
"ahead",
"in",
"the",
"stream",
"as",
"if",
"C",
"{",
"random",
"}",
"had",
"been",
"called",
"C",
"{",
"n",
"}",
"times",
"."
] | def jumpahead(self, n):
self._stream.seek(n * 7, 1) | [
"def",
"jumpahead",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"_stream",
".",
"seek",
"(",
"n",
"*",
"7",
",",
"1",
")"
] | Jump ahead in the stream as if C{random} had been called C{n} times. | [
"Jump",
"ahead",
"in",
"the",
"stream",
"as",
"if",
"C",
"{",
"random",
"}",
"had",
"been",
"called",
"C",
"{",
"n",
"}",
"times",
"."
] | [
"\"\"\"\n Jump ahead in the stream as if C{random} had been called C{n} times.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "n",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
3b91952aaaae22cb61816e203498b7d44c67e5e0 | glyph/streamrandom | streamrandom.py | [
"MIT"
] | Python | uuid4 | <not_specific> | def uuid4(self):
"""
Bonus method! Generate UUID4s from a deterministic source of
randomness.
"""
integer = self.randint(0, _uint128max)
return UUID(int=((integer & _offBits) | _onBits)) |
Bonus method! Generate UUID4s from a deterministic source of
randomness.
| Bonus method. Generate UUID4s from a deterministic source of
randomness. | [
"Bonus",
"method",
".",
"Generate",
"UUID4s",
"from",
"a",
"deterministic",
"source",
"of",
"randomness",
"."
] | def uuid4(self):
integer = self.randint(0, _uint128max)
return UUID(int=((integer & _offBits) | _onBits)) | [
"def",
"uuid4",
"(",
"self",
")",
":",
"integer",
"=",
"self",
".",
"randint",
"(",
"0",
",",
"_uint128max",
")",
"return",
"UUID",
"(",
"int",
"=",
"(",
"(",
"integer",
"&",
"_offBits",
")",
"|",
"_onBits",
")",
")"
] | Bonus method! | [
"Bonus",
"method!"
] | [
"\"\"\"\n Bonus method! Generate UUID4s from a deterministic source of\n randomness.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
99d6eadd7e8beb78890655ad9b60f35bf364b313 | WorldEditors/PaddleHelix | apps/pretrained_compound/info_graph/utils.py | [
"Apache-2.0"
] | Python | calc_rocauc_score | <not_specific> | def calc_rocauc_score(labels, preds, valid):
"""compute ROC-AUC and averaged across tasks
"""
if labels.ndim == 1:
labels = labels.reshape(-1, 1)
preds = preds.reshape(-1, 1)
rocauc_list = []
for i in range(labels.shape[1]):
c_valid = valid[:, i].astype("bool")
c_lab... | compute ROC-AUC and averaged across tasks
| compute ROC-AUC and averaged across tasks | [
"compute",
"ROC",
"-",
"AUC",
"and",
"averaged",
"across",
"tasks"
] | def calc_rocauc_score(labels, preds, valid):
if labels.ndim == 1:
labels = labels.reshape(-1, 1)
preds = preds.reshape(-1, 1)
rocauc_list = []
for i in range(labels.shape[1]):
c_valid = valid[:, i].astype("bool")
c_label, c_pred = labels[c_valid, i], preds[c_valid, i]
... | [
"def",
"calc_rocauc_score",
"(",
"labels",
",",
"preds",
",",
"valid",
")",
":",
"if",
"labels",
".",
"ndim",
"==",
"1",
":",
"labels",
"=",
"labels",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
")",
"preds",
"=",
"preds",
".",
"reshape",
"(",
"-",
... | compute ROC-AUC and averaged across tasks | [
"compute",
"ROC",
"-",
"AUC",
"and",
"averaged",
"across",
"tasks"
] | [
"\"\"\"compute ROC-AUC and averaged across tasks\n \"\"\"",
"#AUC is only defined when there is at least one positive data."
] | [
{
"param": "labels",
"type": null
},
{
"param": "preds",
"type": null
},
{
"param": "valid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "labels",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "preds",
"type": null,
"docstring": null,
"docstring_tokens"... |
5c69a9c15765f862ea21e4cf449c27b815f89cd6 | WorldEditors/PaddleHelix | apps/pretrained_protein/tape/data_gen.py | [
"Apache-2.0"
] | Python | sequence_sample_reader | <not_specific> | def sequence_sample_reader(filenames, label_name):
"""
DataLoader for sequence classification tasks.
"""
def __reader__():
for filename in filenames:
data = np.load(filename)
token_ids = data['token_ids']
labels = data[label_name]
lengths = data['l... |
DataLoader for sequence classification tasks.
| DataLoader for sequence classification tasks. | [
"DataLoader",
"for",
"sequence",
"classification",
"tasks",
"."
] | def sequence_sample_reader(filenames, label_name):
def __reader__():
for filename in filenames:
data = np.load(filename)
token_ids = data['token_ids']
labels = data[label_name]
lengths = data['lengths']
offset = 0
for i in range(lengths... | [
"def",
"sequence_sample_reader",
"(",
"filenames",
",",
"label_name",
")",
":",
"def",
"__reader__",
"(",
")",
":",
"for",
"filename",
"in",
"filenames",
":",
"data",
"=",
"np",
".",
"load",
"(",
"filename",
")",
"token_ids",
"=",
"data",
"[",
"'token_ids'... | DataLoader for sequence classification tasks. | [
"DataLoader",
"for",
"sequence",
"classification",
"tasks",
"."
] | [
"\"\"\"\n DataLoader for sequence classification tasks.\n \"\"\""
] | [
{
"param": "filenames",
"type": null
},
{
"param": "label_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filenames",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "label_name",
"type": null,
"docstring": null,
"docstring... |
ff939c43abc158c6447c6bc572aff823cb2ed6d3 | ixc/django-fieldlevel-permissions | fieldlevel/admin.py | [
"MIT"
] | Python | can_change_inline | <not_specific> | def can_change_inline(self, request, obj, inline_name):
"""
Returns boolean indicating whether the user has necessary permissions to
view the passed inline.
"""
return True |
Returns boolean indicating whether the user has necessary permissions to
view the passed inline.
| Returns boolean indicating whether the user has necessary permissions to
view the passed inline. | [
"Returns",
"boolean",
"indicating",
"whether",
"the",
"user",
"has",
"necessary",
"permissions",
"to",
"view",
"the",
"passed",
"inline",
"."
] | def can_change_inline(self, request, obj, inline_name):
return True | [
"def",
"can_change_inline",
"(",
"self",
",",
"request",
",",
"obj",
",",
"inline_name",
")",
":",
"return",
"True"
] | Returns boolean indicating whether the user has necessary permissions to
view the passed inline. | [
"Returns",
"boolean",
"indicating",
"whether",
"the",
"user",
"has",
"necessary",
"permissions",
"to",
"view",
"the",
"passed",
"inline",
"."
] | [
"\"\"\"\n Returns boolean indicating whether the user has necessary permissions to\n view the passed inline.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "obj",
"type": null
},
{
"param": "inline_name",
"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"... |
ff939c43abc158c6447c6bc572aff823cb2ed6d3 | ixc/django-fieldlevel-permissions | fieldlevel/admin.py | [
"MIT"
] | Python | can_change_field | <not_specific> | def can_change_field(self, request, obj, field_name):
"""
Returns boolean indicating whether the user has necessary permissions to
view the passed field.
"""
return True |
Returns boolean indicating whether the user has necessary permissions to
view the passed field.
| Returns boolean indicating whether the user has necessary permissions to
view the passed field. | [
"Returns",
"boolean",
"indicating",
"whether",
"the",
"user",
"has",
"necessary",
"permissions",
"to",
"view",
"the",
"passed",
"field",
"."
] | def can_change_field(self, request, obj, field_name):
return True | [
"def",
"can_change_field",
"(",
"self",
",",
"request",
",",
"obj",
",",
"field_name",
")",
":",
"return",
"True"
] | Returns boolean indicating whether the user has necessary permissions to
view the passed field. | [
"Returns",
"boolean",
"indicating",
"whether",
"the",
"user",
"has",
"necessary",
"permissions",
"to",
"view",
"the",
"passed",
"field",
"."
] | [
"\"\"\"\n Returns boolean indicating whether the user has necessary permissions to\n view the passed field.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "obj",
"type": null
},
{
"param": "field_name",
"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"... |
a51c36cb5aea24a9833b1f88fac2ec36985684ce | RmStorm/asks | asks/__init__.py | [
"MIT"
] | Python | init | null | def init(library):
"""
Unused. asks+anyio auto-detects your library.
"""
warn(
"init is deprecated. asks + anyio now auto-detects" " your async library",
DeprecationWarning,
)
pass |
Unused. asks+anyio auto-detects your library.
| Unused. asks+anyio auto-detects your library. | [
"Unused",
".",
"asks",
"+",
"anyio",
"auto",
"-",
"detects",
"your",
"library",
"."
] | def init(library):
warn(
"init is deprecated. asks + anyio now auto-detects" " your async library",
DeprecationWarning,
)
pass | [
"def",
"init",
"(",
"library",
")",
":",
"warn",
"(",
"\"init is deprecated. asks + anyio now auto-detects\"",
"\" your async library\"",
",",
"DeprecationWarning",
",",
")",
"pass"
] | Unused. | [
"Unused",
"."
] | [
"\"\"\"\n Unused. asks+anyio auto-detects your library.\n \"\"\""
] | [
{
"param": "library",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "library",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cfb2e64e60bc3d1402eb1ec2670ab7eaeed8f5bd | RmStorm/asks | asks/cookie_utils.py | [
"MIT"
] | Python | parse_cookies | null | def parse_cookies(response, host):
"""
Sticks cookies to a response.
"""
cookie_pie = []
try:
for cookie in response.headers["set-cookie"]:
cookie_jar = {}
name_val, *rest = cookie.split(";")
name, value = name_val.split("=", 1)
cookie_jar["nam... |
Sticks cookies to a response.
| Sticks cookies to a response. | [
"Sticks",
"cookies",
"to",
"a",
"response",
"."
] | def parse_cookies(response, host):
cookie_pie = []
try:
for cookie in response.headers["set-cookie"]:
cookie_jar = {}
name_val, *rest = cookie.split(";")
name, value = name_val.split("=", 1)
cookie_jar["name"] = name.strip()
cookie_jar["value"]... | [
"def",
"parse_cookies",
"(",
"response",
",",
"host",
")",
":",
"cookie_pie",
"=",
"[",
"]",
"try",
":",
"for",
"cookie",
"in",
"response",
".",
"headers",
"[",
"\"set-cookie\"",
"]",
":",
"cookie_jar",
"=",
"{",
"}",
"name_val",
",",
"*",
"rest",
"=",... | Sticks cookies to a response. | [
"Sticks",
"cookies",
"to",
"a",
"response",
"."
] | [
"\"\"\"\n Sticks cookies to a response.\n \"\"\""
] | [
{
"param": "response",
"type": null
},
{
"param": "host",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "response",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "host",
"type": null,
"docstring": null,
"docstring_tokens... |
cd86561b3a1e7240ae7e69601f753a1df6c783bd | RmStorm/asks | asks/utils.py | [
"MIT"
] | Python | unquote_unreserved | <not_specific> | def unquote_unreserved(uri):
"""Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
:rtype: str
"""
parts = uri.split("%")
for i in range(1, len(parts)):
h = parts[i][0:2]
if len(h) == 2 an... | Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
:rtype: str
| Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded. | [
"Un",
"-",
"escape",
"any",
"percent",
"-",
"escape",
"sequences",
"in",
"a",
"URI",
"that",
"are",
"unreserved",
"characters",
".",
"This",
"leaves",
"all",
"reserved",
"illegal",
"and",
"non",
"-",
"ASCII",
"bytes",
"encoded",
"."
] | def unquote_unreserved(uri):
parts = uri.split("%")
for i in range(1, len(parts)):
h = parts[i][0:2]
if len(h) == 2 and h.isalnum():
try:
c = chr(int(h, 16))
except ValueError:
raise ValueError("Invalid percent-escape sequence: '%s'" % h)
... | [
"def",
"unquote_unreserved",
"(",
"uri",
")",
":",
"parts",
"=",
"uri",
".",
"split",
"(",
"\"%\"",
")",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"parts",
")",
")",
":",
"h",
"=",
"parts",
"[",
"i",
"]",
"[",
"0",
":",
"2",
"]",
... | Un-escape any percent-escape sequences in a URI that are unreserved
characters. | [
"Un",
"-",
"escape",
"any",
"percent",
"-",
"escape",
"sequences",
"in",
"a",
"URI",
"that",
"are",
"unreserved",
"characters",
"."
] | [
"\"\"\"Un-escape any percent-escape sequences in a URI that are unreserved\n characters. This leaves all reserved, illegal and non-ASCII bytes encoded.\n :rtype: str\n \"\"\""
] | [
{
"param": "uri",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "uri",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
cd86561b3a1e7240ae7e69601f753a1df6c783bd | RmStorm/asks | asks/utils.py | [
"MIT"
] | Python | requote_uri | <not_specific> | def requote_uri(uri):
"""Re-quote the given URI.
This function passes the given URI through an unquote/quote cycle to
ensure that it is fully and consistently quoted.
:rtype: str
"""
safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
safe_without_percent = "!#$&'()*+,/:;=?@[]~"
try:
# Un... | Re-quote the given URI.
This function passes the given URI through an unquote/quote cycle to
ensure that it is fully and consistently quoted.
:rtype: str
| Re-quote the given URI.
This function passes the given URI through an unquote/quote cycle to
ensure that it is fully and consistently quoted. | [
"Re",
"-",
"quote",
"the",
"given",
"URI",
".",
"This",
"function",
"passes",
"the",
"given",
"URI",
"through",
"an",
"unquote",
"/",
"quote",
"cycle",
"to",
"ensure",
"that",
"it",
"is",
"fully",
"and",
"consistently",
"quoted",
"."
] | def requote_uri(uri):
safe_with_percent = "!#$%&'()*+,/:;=?@[]~"
safe_without_percent = "!#$&'()*+,/:;=?@[]~"
try:
return quote(unquote_unreserved(uri), safe=safe_with_percent)
except ValueError:
return quote(uri, safe=safe_without_percent) | [
"def",
"requote_uri",
"(",
"uri",
")",
":",
"safe_with_percent",
"=",
"\"!#$%&'()*+,/:;=?@[]~\"",
"safe_without_percent",
"=",
"\"!#$&'()*+,/:;=?@[]~\"",
"try",
":",
"return",
"quote",
"(",
"unquote_unreserved",
"(",
"uri",
")",
",",
"safe",
"=",
"safe_with_percent",
... | Re-quote the given URI. | [
"Re",
"-",
"quote",
"the",
"given",
"URI",
"."
] | [
"\"\"\"Re-quote the given URI.\n This function passes the given URI through an unquote/quote cycle to\n ensure that it is fully and consistently quoted.\n :rtype: str\n \"\"\"",
"# Unquote only the unreserved characters",
"# Then quote only illegal characters (do not quote reserved,",
"# unreserve... | [
{
"param": "uri",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "uri",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
3b599f66832f144d9725bc1e06d3efa436eb96b8 | RmStorm/asks | asks/base_funcs.py | [
"MIT"
] | Python | request | <not_specific> | async def request(method, uri, **kwargs):
"""Base function for one time http requests.
Args:
method (str): The http method to use. For example 'GET'
uri (str): The url of the resource.
Example: 'https://example.com/stuff'
kwargs: Any number of arguments supported, found here... | Base function for one time http requests.
Args:
method (str): The http method to use. For example 'GET'
uri (str): The url of the resource.
Example: 'https://example.com/stuff'
kwargs: Any number of arguments supported, found here:
http://asks.rtfd.io/en/latest/overv... | Base function for one time http requests. | [
"Base",
"function",
"for",
"one",
"time",
"http",
"requests",
"."
] | async def request(method, uri, **kwargs):
c_interact = kwargs.pop("persist_cookies", None)
ssl_context = kwargs.pop("ssl_context", None)
async with Session(persist_cookies=c_interact, ssl_context=ssl_context) as s:
r = await s.request(method, url=uri, **kwargs)
return r | [
"async",
"def",
"request",
"(",
"method",
",",
"uri",
",",
"**",
"kwargs",
")",
":",
"c_interact",
"=",
"kwargs",
".",
"pop",
"(",
"\"persist_cookies\"",
",",
"None",
")",
"ssl_context",
"=",
"kwargs",
".",
"pop",
"(",
"\"ssl_context\"",
",",
"None",
")"... | Base function for one time http requests. | [
"Base",
"function",
"for",
"one",
"time",
"http",
"requests",
"."
] | [
"\"\"\"Base function for one time http requests.\n\n Args:\n method (str): The http method to use. For example 'GET'\n uri (str): The url of the resource.\n Example: 'https://example.com/stuff'\n kwargs: Any number of arguments supported, found here:\n http://asks.rtfd.... | [
{
"param": "method",
"type": null
},
{
"param": "uri",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "method",
"type": null,
"docstring": "The http method to use. For example 'GET'",
"docstring_tokens": [
"The... |
d1423155bd388d131dd9dfbfd9eec2759842e441 | HAKSOAT/Strikometer | manage.py | [
"Apache-2.0"
] | Python | make_shell_context | <not_specific> | def make_shell_context():
"""
Ensures returned values are accessible in the interactive shell
without importing them.
:return: a dictionary of values to be imported
"""
return dict(app=app, db=models.db, News=models.News) |
Ensures returned values are accessible in the interactive shell
without importing them.
:return: a dictionary of values to be imported
| Ensures returned values are accessible in the interactive shell
without importing them. | [
"Ensures",
"returned",
"values",
"are",
"accessible",
"in",
"the",
"interactive",
"shell",
"without",
"importing",
"them",
"."
] | def make_shell_context():
return dict(app=app, db=models.db, News=models.News) | [
"def",
"make_shell_context",
"(",
")",
":",
"return",
"dict",
"(",
"app",
"=",
"app",
",",
"db",
"=",
"models",
".",
"db",
",",
"News",
"=",
"models",
".",
"News",
")"
] | Ensures returned values are accessible in the interactive shell
without importing them. | [
"Ensures",
"returned",
"values",
"are",
"accessible",
"in",
"the",
"interactive",
"shell",
"without",
"importing",
"them",
"."
] | [
"\"\"\"\n Ensures returned values are accessible in the interactive shell\n without importing them.\n\n :return: a dictionary of values to be imported\n \"\"\""
] | [] | {
"returns": [
{
"docstring": "a dictionary of values to be imported",
"docstring_tokens": [
"a",
"dictionary",
"of",
"values",
"to",
"be",
"imported"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
... |
46f88bc8c5ed5b92985e82548a02fc2a56d560a6 | HAKSOAT/Strikometer | app.py | [
"Apache-2.0"
] | Python | about | <not_specific> | def about():
"""
Function is invoked when requests is made to url: dommainname/about
:return: a rendered template for the about page
"""
return render_template("about.html") |
Function is invoked when requests is made to url: dommainname/about
:return: a rendered template for the about page
| Function is invoked when requests is made to url: dommainname/about | [
"Function",
"is",
"invoked",
"when",
"requests",
"is",
"made",
"to",
"url",
":",
"dommainname",
"/",
"about"
] | def about():
return render_template("about.html") | [
"def",
"about",
"(",
")",
":",
"return",
"render_template",
"(",
"\"about.html\"",
")"
] | Function is invoked when requests is made to url: dommainname/about | [
"Function",
"is",
"invoked",
"when",
"requests",
"is",
"made",
"to",
"url",
":",
"dommainname",
"/",
"about"
] | [
"\"\"\"\n Function is invoked when requests is made to url: dommainname/about\n :return: a rendered template for the about page\n \"\"\""
] | [] | {
"returns": [
{
"docstring": "a rendered template for the about page",
"docstring_tokens": [
"a",
"rendered",
"template",
"for",
"the",
"about",
"page"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": []... |
46f88bc8c5ed5b92985e82548a02fc2a56d560a6 | HAKSOAT/Strikometer | app.py | [
"Apache-2.0"
] | Python | contact | <not_specific> | def contact():
"""
Function is invoked when requests is made to url: dommainname/contact
:return: a rendered template for the about page
"""
# Accesses the contact form and renders it in the contact html file
# Submits the filled form and sends the values in a mail to a configured e... |
Function is invoked when requests is made to url: dommainname/contact
:return: a rendered template for the about page
| Function is invoked when requests is made to url: dommainname/contact | [
"Function",
"is",
"invoked",
"when",
"requests",
"is",
"made",
"to",
"url",
":",
"dommainname",
"/",
"contact"
] | def contact():
form = forms.ContactForm()
if form.validate_on_submit():
flash("Thanks for reaching out.")
contact_mailer = mailer.Mailer(form.first_name.data, form.last_name.data, form.email.data, form.message.data)
contact_mailer.send_messages()
return redirect(url_for("index"))... | [
"def",
"contact",
"(",
")",
":",
"form",
"=",
"forms",
".",
"ContactForm",
"(",
")",
"if",
"form",
".",
"validate_on_submit",
"(",
")",
":",
"flash",
"(",
"\"Thanks for reaching out.\"",
")",
"contact_mailer",
"=",
"mailer",
".",
"Mailer",
"(",
"form",
"."... | Function is invoked when requests is made to url: dommainname/contact | [
"Function",
"is",
"invoked",
"when",
"requests",
"is",
"made",
"to",
"url",
":",
"dommainname",
"/",
"contact"
] | [
"\"\"\"\n Function is invoked when requests is made to url: dommainname/contact\n :return: a rendered template for the about page\n \"\"\"",
"# Accesses the contact form and renders it in the contact html file",
"# Submits the filled form and sends the values in a mail to a configured email... | [] | {
"returns": [
{
"docstring": "a rendered template for the about page",
"docstring_tokens": [
"a",
"rendered",
"template",
"for",
"the",
"about",
"page"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": []... |
46f88bc8c5ed5b92985e82548a02fc2a56d560a6 | HAKSOAT/Strikometer | app.py | [
"Apache-2.0"
] | Python | page_not_found | <not_specific> | def page_not_found(e):
"""
Function is invoked when the requests made to the url have no response i.e. the page
doesn't exist.
The errorhandler decorator passes an error message to the function.
Therefore is has to be received even when not used.
:param e: The error message
:return: a rend... |
Function is invoked when the requests made to the url have no response i.e. the page
doesn't exist.
The errorhandler decorator passes an error message to the function.
Therefore is has to be received even when not used.
:param e: The error message
:return: a rendered template for the 404 page... | Function is invoked when the requests made to the url have no response i.e. the page
doesn't exist.
The errorhandler decorator passes an error message to the function.
Therefore is has to be received even when not used. | [
"Function",
"is",
"invoked",
"when",
"the",
"requests",
"made",
"to",
"the",
"url",
"have",
"no",
"response",
"i",
".",
"e",
".",
"the",
"page",
"doesn",
"'",
"t",
"exist",
".",
"The",
"errorhandler",
"decorator",
"passes",
"an",
"error",
"message",
"to"... | def page_not_found(e):
return render_template("404.html") | [
"def",
"page_not_found",
"(",
"e",
")",
":",
"return",
"render_template",
"(",
"\"404.html\"",
")"
] | Function is invoked when the requests made to the url have no response i.e. | [
"Function",
"is",
"invoked",
"when",
"the",
"requests",
"made",
"to",
"the",
"url",
"have",
"no",
"response",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Function is invoked when the requests made to the url have no response i.e. the page\n doesn't exist.\n\n The errorhandler decorator passes an error message to the function.\n Therefore is has to be received even when not used.\n\n :param e: The error message\n :return: a rendered templa... | [
{
"param": "e",
"type": null
}
] | {
"returns": [
{
"docstring": "a rendered template for the 404 page",
"docstring_tokens": [
"a",
"rendered",
"template",
"for",
"the",
"404",
"page"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "e... |
592193aa281272b88eb5e131ed906e091fc00014 | mkleinert/pyxplorer_plus | pyxplorer_plus/loader.py | [
"BSD-2-Clause"
] | Python | check_separator | <not_specific> | def check_separator(self, data):
"""
THis method evaluates a list of separators on the input data to check which one
is correct. This is done by first splitting the input by newline and then
checking if the split by separator is equal for each input row except the last
that might... |
THis method evaluates a list of separators on the input data to check which one
is correct. This is done by first splitting the input by newline and then
checking if the split by separator is equal for each input row except the last
that might be incomplete due to the limited input data... | THis method evaluates a list of separators on the input data to check which one
is correct. This is done by first splitting the input by newline and then
checking if the split by separator is equal for each input row except the last
that might be incomplete due to the limited input data | [
"THis",
"method",
"evaluates",
"a",
"list",
"of",
"separators",
"on",
"the",
"input",
"data",
"to",
"check",
"which",
"one",
"is",
"correct",
".",
"This",
"is",
"done",
"by",
"first",
"splitting",
"the",
"input",
"by",
"newline",
"and",
"then",
"checking",... | def check_separator(self, data):
sep_list = [r'\t', r';', r',', r'|', r'\s+']
data_copy = data
for sep in sep_list:
splitted = data_copy.split("\n")
parts = [len(re.split(sep, line)) for line in splitted]
if sum(parts) == len(splitted):
continu... | [
"def",
"check_separator",
"(",
"self",
",",
"data",
")",
":",
"sep_list",
"=",
"[",
"r'\\t'",
",",
"r';'",
",",
"r','",
",",
"r'|'",
",",
"r'\\s+'",
"]",
"data_copy",
"=",
"data",
"for",
"sep",
"in",
"sep_list",
":",
"splitted",
"=",
"data_copy",
".",
... | THis method evaluates a list of separators on the input data to check which one
is correct. | [
"THis",
"method",
"evaluates",
"a",
"list",
"of",
"separators",
"on",
"the",
"input",
"data",
"to",
"check",
"which",
"one",
"is",
"correct",
"."
] | [
"\"\"\"\n THis method evaluates a list of separators on the input data to check which one\n is correct. This is done by first splitting the input by newline and then\n checking if the split by separator is equal for each input row except the last\n that might be incomplete due to the lim... | [
{
"param": "self",
"type": null
},
{
"param": "data",
"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
... |
25f9363fdab2cbea1d71c488e49e6d2225471121 | mkleinert/pyxplorer_plus | pyxplorer_plus/types.py | [
"BSD-2-Clause"
] | Python | min | <not_specific> | def min(self):
"""
:returns the minimum of the column
"""
res = self._qexec("min(%s)" % self._name)
if len(res) > 0:
self._min = res[0][0]
return self._min |
:returns the minimum of the column
| :returns the minimum of the column | [
":",
"returns",
"the",
"minimum",
"of",
"the",
"column"
] | def min(self):
res = self._qexec("min(%s)" % self._name)
if len(res) > 0:
self._min = res[0][0]
return self._min | [
"def",
"min",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"min(%s)\"",
"%",
"self",
".",
"_name",
")",
"if",
"len",
"(",
"res",
")",
">",
"0",
":",
"self",
".",
"_min",
"=",
"res",
"[",
"0",
"]",
"[",
"0",
"]",
"return",
... | :returns the minimum of the column | [
":",
"returns",
"the",
"minimum",
"of",
"the",
"column"
] | [
"\"\"\"\n :returns the minimum of the column\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
25f9363fdab2cbea1d71c488e49e6d2225471121 | mkleinert/pyxplorer_plus | pyxplorer_plus/types.py | [
"BSD-2-Clause"
] | Python | max | <not_specific> | def max(self):
"""
:returns the maximum of the column
"""
res = self._qexec("max(%s)" % self._name)
if len(res) > 0:
self._max = res[0][0]
return self._max |
:returns the maximum of the column
| :returns the maximum of the column | [
":",
"returns",
"the",
"maximum",
"of",
"the",
"column"
] | def max(self):
res = self._qexec("max(%s)" % self._name)
if len(res) > 0:
self._max = res[0][0]
return self._max | [
"def",
"max",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"max(%s)\"",
"%",
"self",
".",
"_name",
")",
"if",
"len",
"(",
"res",
")",
">",
"0",
":",
"self",
".",
"_max",
"=",
"res",
"[",
"0",
"]",
"[",
"0",
"]",
"return",
... | :returns the maximum of the column | [
":",
"returns",
"the",
"maximum",
"of",
"the",
"column"
] | [
"\"\"\"\n :returns the maximum of the column\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
25f9363fdab2cbea1d71c488e49e6d2225471121 | mkleinert/pyxplorer_plus | pyxplorer_plus/types.py | [
"BSD-2-Clause"
] | Python | distribution | <not_specific> | def distribution(self, limit=1024):
"""
Build the distribution of distinct values
"""
res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
order="__cnt DESC LIMIT %d" % limit)
dist = []
cnt = self._table.size()
... |
Build the distribution of distinct values
| Build the distribution of distinct values | [
"Build",
"the",
"distribution",
"of",
"distinct",
"values"
] | def distribution(self, limit=1024):
res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
order="__cnt DESC LIMIT %d" % limit)
dist = []
cnt = self._table.size()
for i, r in enumerate(res):
dist.append(list(r) + [i, r[1] ... | [
"def",
"distribution",
"(",
"self",
",",
"limit",
"=",
"1024",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"%s, count(*) as __cnt\"",
"%",
"self",
".",
"name",
"(",
")",
",",
"group",
"=",
"\"%s\"",
"%",
"self",
".",
"name",
"(",
")",
",",
... | Build the distribution of distinct values | [
"Build",
"the",
"distribution",
"of",
"distinct",
"values"
] | [
"\"\"\"\n Build the distribution of distinct values\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "limit",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "limit",
"type": null,
"docstring": null,
"docstring_tokens": ... |
25f9363fdab2cbea1d71c488e49e6d2225471121 | mkleinert/pyxplorer_plus | pyxplorer_plus/types.py | [
"BSD-2-Clause"
] | Python | column | <not_specific> | def column(self, col):
"""
Given either a column index or name return the column structure
:param col: either index or name
:return: column data structure
"""
if type(col) is str:
for c in self._cols:
if c.name == col:
retur... |
Given either a column index or name return the column structure
:param col: either index or name
:return: column data structure
| Given either a column index or name return the column structure | [
"Given",
"either",
"a",
"column",
"index",
"or",
"name",
"return",
"the",
"column",
"structure"
] | def column(self, col):
if type(col) is str:
for c in self._cols:
if c.name == col:
return c
else:
return self._cols[col] | [
"def",
"column",
"(",
"self",
",",
"col",
")",
":",
"if",
"type",
"(",
"col",
")",
"is",
"str",
":",
"for",
"c",
"in",
"self",
".",
"_cols",
":",
"if",
"c",
".",
"name",
"==",
"col",
":",
"return",
"c",
"else",
":",
"return",
"self",
".",
"_c... | Given either a column index or name return the column structure | [
"Given",
"either",
"a",
"column",
"index",
"or",
"name",
"return",
"the",
"column",
"structure"
] | [
"\"\"\"\n Given either a column index or name return the column structure\n :param col: either index or name\n :return: column data structure\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "col",
"type": null
}
] | {
"returns": [
{
"docstring": "column data structure",
"docstring_tokens": [
"column",
"data",
"structure"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens... |
f3f8c04468e5950c577a59619a0dd95601338fa4 | cosmicwize/Telethon | telethon/helpers.py | [
"MIT"
] | Python | _cancel | null | async def _cancel(log, **tasks):
"""
Helper to cancel one or more tasks gracefully, logging exceptions.
"""
for name, task in tasks.items():
if not task:
continue
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
... |
Helper to cancel one or more tasks gracefully, logging exceptions.
| Helper to cancel one or more tasks gracefully, logging exceptions. | [
"Helper",
"to",
"cancel",
"one",
"or",
"more",
"tasks",
"gracefully",
"logging",
"exceptions",
"."
] | async def _cancel(log, **tasks):
for name, task in tasks.items():
if not task:
continue
task.cancel()
try:
await task
except asyncio.CancelledError:
pass
except Exception:
log.exception('Unhandled exception from %s after cancel'... | [
"async",
"def",
"_cancel",
"(",
"log",
",",
"**",
"tasks",
")",
":",
"for",
"name",
",",
"task",
"in",
"tasks",
".",
"items",
"(",
")",
":",
"if",
"not",
"task",
":",
"continue",
"task",
".",
"cancel",
"(",
")",
"try",
":",
"await",
"task",
"exce... | Helper to cancel one or more tasks gracefully, logging exceptions. | [
"Helper",
"to",
"cancel",
"one",
"or",
"more",
"tasks",
"gracefully",
"logging",
"exceptions",
"."
] | [
"\"\"\"\n Helper to cancel one or more tasks gracefully, logging exceptions.\n \"\"\""
] | [
{
"param": "log",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "log",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4295be11164c2ffb90dd4bf2b827e5ffa926e62b | cosmicwize/Telethon | telethon/sessions/sqlite.py | [
"MIT"
] | Python | save | null | def save(self):
"""Saves the current session object as session_user_id.session"""
# This is a no-op if there are no changes to commit, so there's
# no need for us to keep track of an "unsaved changes" variable.
if self._conn is not None:
self._conn.commit() | Saves the current session object as session_user_id.session | Saves the current session object as session_user_id.session | [
"Saves",
"the",
"current",
"session",
"object",
"as",
"session_user_id",
".",
"session"
] | def save(self):
if self._conn is not None:
self._conn.commit() | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"_conn",
"is",
"not",
"None",
":",
"self",
".",
"_conn",
".",
"commit",
"(",
")"
] | Saves the current session object as session_user_id.session | [
"Saves",
"the",
"current",
"session",
"object",
"as",
"session_user_id",
".",
"session"
] | [
"\"\"\"Saves the current session object as session_user_id.session\"\"\"",
"# This is a no-op if there are no changes to commit, so there's",
"# no need for us to keep track of an \"unsaved changes\" variable."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4295be11164c2ffb90dd4bf2b827e5ffa926e62b | cosmicwize/Telethon | telethon/sessions/sqlite.py | [
"MIT"
] | Python | close | null | def close(self):
"""Closes the connection unless we're working in-memory"""
if self.filename != ':memory:':
if self._conn is not None:
self._conn.commit()
self._conn.close()
self._conn = None | Closes the connection unless we're working in-memory | Closes the connection unless we're working in-memory | [
"Closes",
"the",
"connection",
"unless",
"we",
"'",
"re",
"working",
"in",
"-",
"memory"
] | def close(self):
if self.filename != ':memory:':
if self._conn is not None:
self._conn.commit()
self._conn.close()
self._conn = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"!=",
"':memory:'",
":",
"if",
"self",
".",
"_conn",
"is",
"not",
"None",
":",
"self",
".",
"_conn",
".",
"commit",
"(",
")",
"self",
".",
"_conn",
".",
"close",
"(",
")",
"sel... | Closes the connection unless we're working in-memory | [
"Closes",
"the",
"connection",
"unless",
"we",
"'",
"re",
"working",
"in",
"-",
"memory"
] | [
"\"\"\"Closes the connection unless we're working in-memory\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4295be11164c2ffb90dd4bf2b827e5ffa926e62b | cosmicwize/Telethon | telethon/sessions/sqlite.py | [
"MIT"
] | Python | process_entities | <not_specific> | def process_entities(self, tlo):
"""Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added.
"""
if not self.save_entities:
return
rows = self._entities_to_rows(tlo)
if not... | Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added.
| Processes all the found entities on the given TLObject,
unless .enabled is False.
Returns True if new input entities were added. | [
"Processes",
"all",
"the",
"found",
"entities",
"on",
"the",
"given",
"TLObject",
"unless",
".",
"enabled",
"is",
"False",
".",
"Returns",
"True",
"if",
"new",
"input",
"entities",
"were",
"added",
"."
] | def process_entities(self, tlo):
if not self.save_entities:
return
rows = self._entities_to_rows(tlo)
if not rows:
return
c = self._cursor()
try:
c.executemany(
'insert or replace into entities values (?,?,?,?,?)', rows)
... | [
"def",
"process_entities",
"(",
"self",
",",
"tlo",
")",
":",
"if",
"not",
"self",
".",
"save_entities",
":",
"return",
"rows",
"=",
"self",
".",
"_entities_to_rows",
"(",
"tlo",
")",
"if",
"not",
"rows",
":",
"return",
"c",
"=",
"self",
".",
"_cursor"... | Processes all the found entities on the given TLObject,
unless .enabled is False. | [
"Processes",
"all",
"the",
"found",
"entities",
"on",
"the",
"given",
"TLObject",
"unless",
".",
"enabled",
"is",
"False",
"."
] | [
"\"\"\"Processes all the found entities on the given TLObject,\n unless .enabled is False.\n\n Returns True if new input entities were added.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tlo",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tlo",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _get_border | <not_specific> | def _get_border(self, border, size):
"""Get final border for the target size.
This function generates a `final_border` according to image's shape.
The area between `final_border` and `size - final_border` is the
`center range`. We randomly choose center from the `center range`
t... | Get final border for the target size.
This function generates a `final_border` according to image's shape.
The area between `final_border` and `size - final_border` is the
`center range`. We randomly choose center from the `center range`
to avoid our random center is too close to origin... | Get final border for the target size.
This function generates a `final_border` according to image's shape. | [
"Get",
"final",
"border",
"for",
"the",
"target",
"size",
".",
"This",
"function",
"generates",
"a",
"`",
"final_border",
"`",
"according",
"to",
"image",
"'",
"s",
"shape",
"."
] | def _get_border(self, border, size):
i = pow(2, np.ceil(np.log2(np.ceil(2 * border / size))))
return border // i | [
"def",
"_get_border",
"(",
"self",
",",
"border",
",",
"size",
")",
":",
"i",
"=",
"pow",
"(",
"2",
",",
"np",
".",
"ceil",
"(",
"np",
".",
"log2",
"(",
"np",
".",
"ceil",
"(",
"2",
"*",
"border",
"/",
"size",
")",
")",
")",
")",
"return",
... | Get final border for the target size. | [
"Get",
"final",
"border",
"for",
"the",
"target",
"size",
"."
] | [
"\"\"\"Get final border for the target size.\n\n This function generates a `final_border` according to image's shape.\n The area between `final_border` and `size - final_border` is the\n `center range`. We randomly choose center from the `center range`\n to avoid our random center is too... | [
{
"param": "self",
"type": null
},
{
"param": "border",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [
{
"docstring": "The final border.",
"docstring_tokens": [
"The",
"final",
"border",
"."
],
"type": "int"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_t... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _filter_boxes | <not_specific> | def _filter_boxes(self, patch, boxes):
"""Check whether the center of each box is in the patch.
Args:
patch (list[int]): The cropped area, [left, top, right, bottom].
boxes (numpy array, (N x 4)): Ground truth boxes.
Returns:
mask (numpy array, (N,)): Each bo... | Check whether the center of each box is in the patch.
Args:
patch (list[int]): The cropped area, [left, top, right, bottom].
boxes (numpy array, (N x 4)): Ground truth boxes.
Returns:
mask (numpy array, (N,)): Each box is inside or outside the patch.
| Check whether the center of each box is in the patch. | [
"Check",
"whether",
"the",
"center",
"of",
"each",
"box",
"is",
"in",
"the",
"patch",
"."
] | def _filter_boxes(self, patch, boxes):
center = (boxes[:, :2] + boxes[:, 2:]) / 2
mask = (center[:, 0] > patch[0]) * (center[:, 1] > patch[1]) * (
center[:, 0] < patch[2]) * (
center[:, 1] < patch[3])
return mask | [
"def",
"_filter_boxes",
"(",
"self",
",",
"patch",
",",
"boxes",
")",
":",
"center",
"=",
"(",
"boxes",
"[",
":",
",",
":",
"2",
"]",
"+",
"boxes",
"[",
":",
",",
"2",
":",
"]",
")",
"/",
"2",
"mask",
"=",
"(",
"center",
"[",
":",
",",
"0",... | Check whether the center of each box is in the patch. | [
"Check",
"whether",
"the",
"center",
"of",
"each",
"box",
"is",
"in",
"the",
"patch",
"."
] | [
"\"\"\"Check whether the center of each box is in the patch.\n\n Args:\n patch (list[int]): The cropped area, [left, top, right, bottom].\n boxes (numpy array, (N x 4)): Ground truth boxes.\n Returns:\n mask (numpy array, (N,)): Each box is inside or outside the patch.... | [
{
"param": "self",
"type": null
},
{
"param": "patch",
"type": null
},
{
"param": "boxes",
"type": null
}
] | {
"returns": [
{
"docstring": "mask (numpy array, (N,)): Each box is inside or outside the patch.",
"docstring_tokens": [
"mask",
"(",
"numpy",
"array",
"(",
"N",
"))",
":",
"Each",
"box",
"is",
"inside",
... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _crop_image_and_paste | <not_specific> | def _crop_image_and_paste(self, image, center, size):
"""Crop image with a given center and size, then paste the cropped
image to a blank image with two centers align.
This function is equivalent to generating a blank image with `size` as
its shape. Then cover it on the original image w... | Crop image with a given center and size, then paste the cropped
image to a blank image with two centers align.
This function is equivalent to generating a blank image with `size` as
its shape. Then cover it on the original image with two centers (
the center of blank image and the rando... | Crop image with a given center and size, then paste the cropped
image to a blank image with two centers align.
This function is equivalent to generating a blank image with `size` as
its shape. Then cover it on the original image with two centers (
the center of blank image and the random center of original image)
alig... | [
"Crop",
"image",
"with",
"a",
"given",
"center",
"and",
"size",
"then",
"paste",
"the",
"cropped",
"image",
"to",
"a",
"blank",
"image",
"with",
"two",
"centers",
"align",
".",
"This",
"function",
"is",
"equivalent",
"to",
"generating",
"a",
"blank",
"imag... | def _crop_image_and_paste(self, image, center, size):
center_y, center_x = center
target_h, target_w = size
img_h, img_w, img_c = image.shape
x0 = max(0, center_x - target_w // 2)
x1 = min(center_x + target_w // 2, img_w)
y0 = max(0, center_y - target_h // 2)
y1 =... | [
"def",
"_crop_image_and_paste",
"(",
"self",
",",
"image",
",",
"center",
",",
"size",
")",
":",
"center_y",
",",
"center_x",
"=",
"center",
"target_h",
",",
"target_w",
"=",
"size",
"img_h",
",",
"img_w",
",",
"img_c",
"=",
"image",
".",
"shape",
"x0",
... | Crop image with a given center and size, then paste the cropped
image to a blank image with two centers align. | [
"Crop",
"image",
"with",
"a",
"given",
"center",
"and",
"size",
"then",
"paste",
"the",
"cropped",
"image",
"to",
"a",
"blank",
"image",
"with",
"two",
"centers",
"align",
"."
] | [
"\"\"\"Crop image with a given center and size, then paste the cropped\n image to a blank image with two centers align.\n\n This function is equivalent to generating a blank image with `size` as\n its shape. Then cover it on the original image with two centers (\n the center of blank ima... | [
{
"param": "self",
"type": null
},
{
"param": "image",
"type": null
},
{
"param": "center",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [
{
"docstring": "cropped_img (np array, target_h x target_w x C): Cropped image.\nborder (np array, 4): The distance of four border of `cropped_img`\nto the original image area, [top, bottom, left, right]\npatch (list[int]): The cropped area, [left, top, right, bottom].",
"docstring_toke... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _train_aug | <not_specific> | def _train_aug(self, results):
"""Random crop and around padding the original image.
Args:
results (dict): Image infomations in the augment pipeline.
Returns:
results (dict): The updated dict.
"""
img = results['img']
h, w, c = img.shape
b... | Random crop and around padding the original image.
Args:
results (dict): Image infomations in the augment pipeline.
Returns:
results (dict): The updated dict.
| Random crop and around padding the original image. | [
"Random",
"crop",
"and",
"around",
"padding",
"the",
"original",
"image",
"."
] | def _train_aug(self, results):
img = results['img']
h, w, c = img.shape
boxes = results['gt_bboxes']
while True:
scale = random.choice(self.ratios)
new_h = int(self.crop_size[0] * scale)
new_w = int(self.crop_size[1] * scale)
h_border = sel... | [
"def",
"_train_aug",
"(",
"self",
",",
"results",
")",
":",
"img",
"=",
"results",
"[",
"'img'",
"]",
"h",
",",
"w",
",",
"c",
"=",
"img",
".",
"shape",
"boxes",
"=",
"results",
"[",
"'gt_bboxes'",
"]",
"while",
"True",
":",
"scale",
"=",
"random",... | Random crop and around padding the original image. | [
"Random",
"crop",
"and",
"around",
"padding",
"the",
"original",
"image",
"."
] | [
"\"\"\"Random crop and around padding the original image.\n\n Args:\n results (dict): Image infomations in the augment pipeline.\n Returns:\n results (dict): The updated dict.\n \"\"\"",
"# if image do not have valid bbox, any crop patch is valid.",
"# crop bboxes acco... | [
{
"param": "self",
"type": null
},
{
"param": "results",
"type": null
}
] | {
"returns": [
{
"docstring": "results (dict): The updated dict.",
"docstring_tokens": [
"results",
"(",
"dict",
")",
":",
"The",
"updated",
"dict",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _mosaic_combine | <not_specific> | def _mosaic_combine(self, loc, center_position_xy, img_shape_wh):
"""Calculate global coordinate of mosaic image and local coordinate of
cropped sub-image.
Args:
loc (str): Index for the sub-image, loc in ('top_left',
'top_right', 'bottom_left', 'bottom_right').
... | Calculate global coordinate of mosaic image and local coordinate of
cropped sub-image.
Args:
loc (str): Index for the sub-image, loc in ('top_left',
'top_right', 'bottom_left', 'bottom_right').
center_position_xy (Sequence[float]): Mixing center for 4 images,
... | Calculate global coordinate of mosaic image and local coordinate of
cropped sub-image. | [
"Calculate",
"global",
"coordinate",
"of",
"mosaic",
"image",
"and",
"local",
"coordinate",
"of",
"cropped",
"sub",
"-",
"image",
"."
] | def _mosaic_combine(self, loc, center_position_xy, img_shape_wh):
assert loc in ('top_left', 'top_right', 'bottom_left', 'bottom_right')
if loc == 'top_left':
x1, y1, x2, y2 = max(center_position_xy[0] - img_shape_wh[0], 0), \
max(center_position_xy[1] - img_shap... | [
"def",
"_mosaic_combine",
"(",
"self",
",",
"loc",
",",
"center_position_xy",
",",
"img_shape_wh",
")",
":",
"assert",
"loc",
"in",
"(",
"'top_left'",
",",
"'top_right'",
",",
"'bottom_left'",
",",
"'bottom_right'",
")",
"if",
"loc",
"==",
"'top_left'",
":",
... | Calculate global coordinate of mosaic image and local coordinate of
cropped sub-image. | [
"Calculate",
"global",
"coordinate",
"of",
"mosaic",
"image",
"and",
"local",
"coordinate",
"of",
"cropped",
"sub",
"-",
"image",
"."
] | [
"\"\"\"Calculate global coordinate of mosaic image and local coordinate of\n cropped sub-image.\n\n Args:\n loc (str): Index for the sub-image, loc in ('top_left',\n 'top_right', 'bottom_left', 'bottom_right').\n center_position_xy (Sequence[float]): Mixing center fo... | [
{
"param": "self",
"type": null
},
{
"param": "loc",
"type": null
},
{
"param": "center_position_xy",
"type": null
},
{
"param": "img_shape_wh",
"type": null
}
] | {
"returns": [
{
"docstring": "Corresponding coordinate of pasting and\ncropping\npaste_coord (tuple): paste corner coordinate in mosaic image.\ncrop_coord (tuple): crop corner coordinate in mosaic image.",
"docstring_tokens": [
"Corresponding",
"coordinate",
"of",
"pas... |
a4a4eea373b5034af6571348f0bf5856841a7ca2 | G-Naughty/Fine-grained-OBB-Detection | mmdet/datasets/pipelines/transforms.py | [
"Apache-2.0"
] | Python | _filter_box_candidates | <not_specific> | def _filter_box_candidates(self, bboxes, masks, labels, diffs, trunc):
"""Filter out bboxes too small after Mosaic."""
bbox_w = bboxes[:, 2] - bboxes[:, 0]
bbox_h = bboxes[:, 3] - bboxes[:, 1]
valid_inds = (bbox_w > self.min_bbox_size) & \
(bbox_h > self.min_bbox_siz... | Filter out bboxes too small after Mosaic. | Filter out bboxes too small after Mosaic. | [
"Filter",
"out",
"bboxes",
"too",
"small",
"after",
"Mosaic",
"."
] | def _filter_box_candidates(self, bboxes, masks, labels, diffs, trunc):
bbox_w = bboxes[:, 2] - bboxes[:, 0]
bbox_h = bboxes[:, 3] - bboxes[:, 1]
valid_inds = (bbox_w > self.min_bbox_size) & \
(bbox_h > self.min_bbox_size)
valid_inds = np.nonzero(valid_inds)[0]
... | [
"def",
"_filter_box_candidates",
"(",
"self",
",",
"bboxes",
",",
"masks",
",",
"labels",
",",
"diffs",
",",
"trunc",
")",
":",
"bbox_w",
"=",
"bboxes",
"[",
":",
",",
"2",
"]",
"-",
"bboxes",
"[",
":",
",",
"0",
"]",
"bbox_h",
"=",
"bboxes",
"[",
... | Filter out bboxes too small after Mosaic. | [
"Filter",
"out",
"bboxes",
"too",
"small",
"after",
"Mosaic",
"."
] | [
"\"\"\"Filter out bboxes too small after Mosaic.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bboxes",
"type": null
},
{
"param": "masks",
"type": null
},
{
"param": "labels",
"type": null
},
{
"param": "diffs",
"type": null
},
{
"param": "trunc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bboxes",
"type": null,
"docstring": null,
"docstring_tokens":... |
492b4b74345595e16e52d31397279a44b9828ec1 | G-Naughty/Fine-grained-OBB-Detection | competition_trick/WBF_emsemble.py | [
"Apache-2.0"
] | Python | WBF | null | def WBF(args, iou_thr=0.55, draw_image=True):
"""
This example shows how to ensemble boxes from 2 models using WBF method
:return:
"""
weights = args.weights
results = defaultdict(lambda: defaultdict(defaultdict))
print('loading results:')
# 提取预测结果
for model_num, model_result in enum... |
This example shows how to ensemble boxes from 2 models using WBF method
:return:
| This example shows how to ensemble boxes from 2 models using WBF method | [
"This",
"example",
"shows",
"how",
"to",
"ensemble",
"boxes",
"from",
"2",
"models",
"using",
"WBF",
"method"
] | def WBF(args, iou_thr=0.55, draw_image=True):
weights = args.weights
results = defaultdict(lambda: defaultdict(defaultdict))
print('loading results:')
for model_num, model_result in enumerate(args.models_result):
result_files = os.listdir(model_result)
for result_file in result_files: ... | [
"def",
"WBF",
"(",
"args",
",",
"iou_thr",
"=",
"0.55",
",",
"draw_image",
"=",
"True",
")",
":",
"weights",
"=",
"args",
".",
"weights",
"results",
"=",
"defaultdict",
"(",
"lambda",
":",
"defaultdict",
"(",
"defaultdict",
")",
")",
"print",
"(",
"'lo... | This example shows how to ensemble boxes from 2 models using WBF method | [
"This",
"example",
"shows",
"how",
"to",
"ensemble",
"boxes",
"from",
"2",
"models",
"using",
"WBF",
"method"
] | [
"\"\"\"\n This example shows how to ensemble boxes from 2 models using WBF method\n :return:\n \"\"\"",
"# 提取预测结果",
"#对每个模型",
"#每个图片",
"# 打开xml文档",
"# 获得root节点",
"# 每个结果",
"# 子节点下节点name的值",
"# object下每个点",
"#bbox = anchor_finetune(bbox, img_size=img_size[img_name])",
"# else:",
"# ... | [
{
"param": "args",
"type": null
},
{
"param": "iou_thr",
"type": null
},
{
"param": "draw_image",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
71d66d4f95382a3458a48dd2583cbd147add52c3 | saberraz/mergin-py-client | mergin/utils.py | [
"MIT"
] | Python | unique_path_name | <not_specific> | def unique_path_name(path):
"""
Generates an unique name for the given path. If the given path does
not exist yet it will be returned unchanged, otherwise a sequntial
number will be added to the path in format:
- if path is a directory: "folder" -> "folder (1)"
- if path is a file: "filename... |
Generates an unique name for the given path. If the given path does
not exist yet it will be returned unchanged, otherwise a sequntial
number will be added to the path in format:
- if path is a directory: "folder" -> "folder (1)"
- if path is a file: "filename.txt" -> "filename (1).txt"
:p... | Generates an unique name for the given path. | [
"Generates",
"an",
"unique",
"name",
"for",
"the",
"given",
"path",
"."
] | def unique_path_name(path):
unique_path = str(path)
is_dir = os.path.isdir(path)
head, tail = os.path.split(os.path.normpath(path))
ext = ''.join(Path(tail).suffixes)
file_name = tail.replace(ext, '')
i = 0
while os.path.exists(unique_path):
i += 1
if is_dir:
uniq... | [
"def",
"unique_path_name",
"(",
"path",
")",
":",
"unique_path",
"=",
"str",
"(",
"path",
")",
"is_dir",
"=",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".... | Generates an unique name for the given path. | [
"Generates",
"an",
"unique",
"name",
"for",
"the",
"given",
"path",
"."
] | [
"\"\"\"\n Generates an unique name for the given path. If the given path does\n not exist yet it will be returned unchanged, otherwise a sequntial\n number will be added to the path in format:\n - if path is a directory: \"folder\" -> \"folder (1)\"\n - if path is a file: \"filename.txt\" -> \"fi... | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "path to file or directory",
"docstring_tokens": [
"path",
"to",... |
71d66d4f95382a3458a48dd2583cbd147add52c3 | saberraz/mergin-py-client | mergin/utils.py | [
"MIT"
] | Python | conflicted_copy_file_name | <not_specific> | def conflicted_copy_file_name(path, user, version):
"""
Generates a file name for the conflict copy file in the following form
<filename> (conflicted copy, <username> v<version>).gpkg. Example:
* data (conflicted copy, martin v5).gpkg
:param path: name of the file
:type path: str
:param use... |
Generates a file name for the conflict copy file in the following form
<filename> (conflicted copy, <username> v<version>).gpkg. Example:
* data (conflicted copy, martin v5).gpkg
:param path: name of the file
:type path: str
:param user: name of the user
:type user: str
:param version:... | Generates a file name for the conflict copy file in the following form
(conflicted copy, v).gpkg. Example:
data (conflicted copy, martin v5).gpkg | [
"Generates",
"a",
"file",
"name",
"for",
"the",
"conflict",
"copy",
"file",
"in",
"the",
"following",
"form",
"(",
"conflicted",
"copy",
"v",
")",
".",
"gpkg",
".",
"Example",
":",
"data",
"(",
"conflicted",
"copy",
"martin",
"v5",
")",
".",
"gpkg"
] | def conflicted_copy_file_name(path, user, version):
if not path:
return ''
head, tail = os.path.split(os.path.normpath(path))
ext = ''.join(Path(tail).suffixes)
file_name = tail.replace(ext, '')
return os.path.join(head, file_name) + f" (conflicted copy, {user} v{version}){ext}" | [
"def",
"conflicted_copy_file_name",
"(",
"path",
",",
"user",
",",
"version",
")",
":",
"if",
"not",
"path",
":",
"return",
"''",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
... | Generates a file name for the conflict copy file in the following form
<filename> (conflicted copy, <username> v<version>).gpkg. | [
"Generates",
"a",
"file",
"name",
"for",
"the",
"conflict",
"copy",
"file",
"in",
"the",
"following",
"form",
"<filename",
">",
"(",
"conflicted",
"copy",
"<username",
">",
"v<version",
">",
")",
".",
"gpkg",
"."
] | [
"\"\"\"\n Generates a file name for the conflict copy file in the following form\n <filename> (conflicted copy, <username> v<version>).gpkg. Example:\n * data (conflicted copy, martin v5).gpkg\n\n :param path: name of the file\n :type path: str\n :param user: name of the user\n :type user: str\... | [
{
"param": "path",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [
{
"docstring": "new file name",
"docstring_tokens": [
"new",
"file",
"name"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "name of the file",
"docstring_tokens"... |
71d66d4f95382a3458a48dd2583cbd147add52c3 | saberraz/mergin-py-client | mergin/utils.py | [
"MIT"
] | Python | edit_conflict_file_name | <not_specific> | def edit_conflict_file_name(path, user, version):
"""
Generates a file name for the edit conflict file in the following form
<filename> (edit conflict, <username> v<version>).gpkg. Example:
* data (edit conflict, martin v5).gpkg
:param path: name of the file
:type path: str
:param user: nam... |
Generates a file name for the edit conflict file in the following form
<filename> (edit conflict, <username> v<version>).gpkg. Example:
* data (edit conflict, martin v5).gpkg
:param path: name of the file
:type path: str
:param user: name of the user
:type user: str
:param version: ver... | Generates a file name for the edit conflict file in the following form
(edit conflict, v).gpkg. Example:
data (edit conflict, martin v5).gpkg | [
"Generates",
"a",
"file",
"name",
"for",
"the",
"edit",
"conflict",
"file",
"in",
"the",
"following",
"form",
"(",
"edit",
"conflict",
"v",
")",
".",
"gpkg",
".",
"Example",
":",
"data",
"(",
"edit",
"conflict",
"martin",
"v5",
")",
".",
"gpkg"
] | def edit_conflict_file_name(path, user, version):
if not path:
return ''
head, tail = os.path.split(os.path.normpath(path))
ext = ''.join(Path(tail).suffixes)
file_name = tail.replace(ext, '')
return os.path.join(head, file_name) + f" (edit conflict, {user} v{version}).json" | [
"def",
"edit_conflict_file_name",
"(",
"path",
",",
"user",
",",
"version",
")",
":",
"if",
"not",
"path",
":",
"return",
"''",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
")... | Generates a file name for the edit conflict file in the following form
<filename> (edit conflict, <username> v<version>).gpkg. | [
"Generates",
"a",
"file",
"name",
"for",
"the",
"edit",
"conflict",
"file",
"in",
"the",
"following",
"form",
"<filename",
">",
"(",
"edit",
"conflict",
"<username",
">",
"v<version",
">",
")",
".",
"gpkg",
"."
] | [
"\"\"\"\n Generates a file name for the edit conflict file in the following form\n <filename> (edit conflict, <username> v<version>).gpkg. Example:\n * data (edit conflict, martin v5).gpkg\n\n :param path: name of the file\n :type path: str\n :param user: name of the user\n :type user: str\n ... | [
{
"param": "path",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [
{
"docstring": "new file name",
"docstring_tokens": [
"new",
"file",
"name"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": "name of the file",
"docstring_tokens"... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | _download_items | <not_specific> | def _download_items(file, directory, diff_only=False):
""" Returns an array of download queue items """
file_dir = os.path.dirname(os.path.normpath(os.path.join(directory, file['path'])))
basename = os.path.basename(file['diff']['path']) if diff_only else os.path.basename(file['path'])
file_size = file... | Returns an array of download queue items | Returns an array of download queue items | [
"Returns",
"an",
"array",
"of",
"download",
"queue",
"items"
] | def _download_items(file, directory, diff_only=False):
file_dir = os.path.dirname(os.path.normpath(os.path.join(directory, file['path'])))
basename = os.path.basename(file['diff']['path']) if diff_only else os.path.basename(file['path'])
file_size = file['diff']['size'] if diff_only else file['size']
ch... | [
"def",
"_download_items",
"(",
"file",
",",
"directory",
",",
"diff_only",
"=",
"False",
")",
":",
"file_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"directory",
","... | Returns an array of download queue items | [
"Returns",
"an",
"array",
"of",
"download",
"queue",
"items"
] | [
"\"\"\" Returns an array of download queue items \"\"\""
] | [
{
"param": "file",
"type": null
},
{
"param": "directory",
"type": null
},
{
"param": "diff_only",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_token... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | _cleanup_failed_download | null | def _cleanup_failed_download(directory, mergin_project=None):
"""
If a download job fails, there will be the newly created directory left behind with some
temporary files in it. We want to remove it because a new download would fail because
the directory already exists.
"""
# First try to get th... |
If a download job fails, there will be the newly created directory left behind with some
temporary files in it. We want to remove it because a new download would fail because
the directory already exists.
| If a download job fails, there will be the newly created directory left behind with some
temporary files in it. We want to remove it because a new download would fail because
the directory already exists. | [
"If",
"a",
"download",
"job",
"fails",
"there",
"will",
"be",
"the",
"newly",
"created",
"directory",
"left",
"behind",
"with",
"some",
"temporary",
"files",
"in",
"it",
".",
"We",
"want",
"to",
"remove",
"it",
"because",
"a",
"new",
"download",
"would",
... | def _cleanup_failed_download(directory, mergin_project=None):
if mergin_project is not None:
mergin_project.remove_logging_handler()
shutil.rmtree(directory) | [
"def",
"_cleanup_failed_download",
"(",
"directory",
",",
"mergin_project",
"=",
"None",
")",
":",
"if",
"mergin_project",
"is",
"not",
"None",
":",
"mergin_project",
".",
"remove_logging_handler",
"(",
")",
"shutil",
".",
"rmtree",
"(",
"directory",
")"
] | If a download job fails, there will be the newly created directory left behind with some
temporary files in it. | [
"If",
"a",
"download",
"job",
"fails",
"there",
"will",
"be",
"the",
"newly",
"created",
"directory",
"left",
"behind",
"with",
"some",
"temporary",
"files",
"in",
"it",
"."
] | [
"\"\"\"\n If a download job fails, there will be the newly created directory left behind with some\n temporary files in it. We want to remove it because a new download would fail because\n the directory already exists.\n \"\"\"",
"# First try to get the Mergin project logger and remove its handlers to... | [
{
"param": "directory",
"type": null
},
{
"param": "mergin_project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mergin_project",
"type": null,
"docstring": null,
"docst... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_project_async | <not_specific> | def download_project_async(mc, project_path, directory, project_version=None):
"""
Starts project download in background and returns handle to the pending project download.
Using that object it is possible to watch progress or cancel the ongoing work.
"""
if '/' not in project_path:
raise C... |
Starts project download in background and returns handle to the pending project download.
Using that object it is possible to watch progress or cancel the ongoing work.
| Starts project download in background and returns handle to the pending project download.
Using that object it is possible to watch progress or cancel the ongoing work. | [
"Starts",
"project",
"download",
"in",
"background",
"and",
"returns",
"handle",
"to",
"the",
"pending",
"project",
"download",
".",
"Using",
"that",
"object",
"it",
"is",
"possible",
"to",
"watch",
"progress",
"or",
"cancel",
"the",
"ongoing",
"work",
"."
] | def download_project_async(mc, project_path, directory, project_version=None):
if '/' not in project_path:
raise ClientError("Project name needs to be fully qualified, e.g. <username>/<projectname>")
if os.path.exists(directory):
raise ClientError("Project directory already exists")
os.maked... | [
"def",
"download_project_async",
"(",
"mc",
",",
"project_path",
",",
"directory",
",",
"project_version",
"=",
"None",
")",
":",
"if",
"'/'",
"not",
"in",
"project_path",
":",
"raise",
"ClientError",
"(",
"\"Project name needs to be fully qualified, e.g. <username>/<pr... | Starts project download in background and returns handle to the pending project download. | [
"Starts",
"project",
"download",
"in",
"background",
"and",
"returns",
"handle",
"to",
"the",
"pending",
"project",
"download",
"."
] | [
"\"\"\"\n Starts project download in background and returns handle to the pending project download.\n Using that object it is possible to watch progress or cancel the ongoing work.\n \"\"\"",
"# check whether we download the latest version or not",
"# prepare download",
"# stuff to do at the end of d... | [
{
"param": "mc",
"type": null
},
{
"param": "project_path",
"type": null
},
{
"param": "directory",
"type": null
},
{
"param": "project_version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project_path",
"type": null,
"docstring": null,
"docstring_toke... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_project_is_running | <not_specific> | def download_project_is_running(job):
"""
Returns true/false depending on whether we have some pending downloads.
It also forwards any exceptions from workers (e.g. some network errors). If an exception
is raised, it is advised to call download_project_cancel() to abort the job.
"""
for future ... |
Returns true/false depending on whether we have some pending downloads.
It also forwards any exceptions from workers (e.g. some network errors). If an exception
is raised, it is advised to call download_project_cancel() to abort the job.
| Returns true/false depending on whether we have some pending downloads.
It also forwards any exceptions from workers . If an exception
is raised, it is advised to call download_project_cancel() to abort the job. | [
"Returns",
"true",
"/",
"false",
"depending",
"on",
"whether",
"we",
"have",
"some",
"pending",
"downloads",
".",
"It",
"also",
"forwards",
"any",
"exceptions",
"from",
"workers",
".",
"If",
"an",
"exception",
"is",
"raised",
"it",
"is",
"advised",
"to",
"... | def download_project_is_running(job):
for future in job.futures:
if future.done() and future.exception() is not None:
_cleanup_failed_download(job.directory, job.mp)
raise future.exception()
if future.running():
return True
return False | [
"def",
"download_project_is_running",
"(",
"job",
")",
":",
"for",
"future",
"in",
"job",
".",
"futures",
":",
"if",
"future",
".",
"done",
"(",
")",
"and",
"future",
".",
"exception",
"(",
")",
"is",
"not",
"None",
":",
"_cleanup_failed_download",
"(",
... | Returns true/false depending on whether we have some pending downloads. | [
"Returns",
"true",
"/",
"false",
"depending",
"on",
"whether",
"we",
"have",
"some",
"pending",
"downloads",
"."
] | [
"\"\"\"\n Returns true/false depending on whether we have some pending downloads.\n\n It also forwards any exceptions from workers (e.g. some network errors). If an exception\n is raised, it is advised to call download_project_cancel() to abort the job.\n \"\"\""
] | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_project_finalize | null | def download_project_finalize(job):
"""
To be called when download in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread (e.g. directly from a handler when download is complete).
If any of the workers has thrown any exceptio... |
To be called when download in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread (e.g. directly from a handler when download is complete).
If any of the workers has thrown any exception, it will be re-raised (e.g. some network ... | To be called when download in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread .
If any of the workers has thrown any exception, it will be re-raised .
That also means that the whole job has been aborted. | [
"To",
"be",
"called",
"when",
"download",
"in",
"the",
"background",
"is",
"finished",
"and",
"we",
"need",
"to",
"do",
"the",
"finalization",
"(",
"merge",
"chunks",
"etc",
".",
")",
"This",
"should",
"not",
"be",
"called",
"from",
"a",
"worker",
"threa... | def download_project_finalize(job):
job.executor.shutdown(wait=True)
for future in job.futures:
if future.exception() is not None:
_cleanup_failed_download(job.directory, job.mp)
raise future.exception()
job.mp.log.info("--- download finished")
for task in job.update_task... | [
"def",
"download_project_finalize",
"(",
"job",
")",
":",
"job",
".",
"executor",
".",
"shutdown",
"(",
"wait",
"=",
"True",
")",
"for",
"future",
"in",
"job",
".",
"futures",
":",
"if",
"future",
".",
"exception",
"(",
")",
"is",
"not",
"None",
":",
... | To be called when download in the background is finished and we need to do the finalization (merge chunks etc.) | [
"To",
"be",
"called",
"when",
"download",
"in",
"the",
"background",
"is",
"finished",
"and",
"we",
"need",
"to",
"do",
"the",
"finalization",
"(",
"merge",
"chunks",
"etc",
".",
")"
] | [
"\"\"\"\n To be called when download in the background is finished and we need to do the finalization (merge chunks etc.)\n\n This should not be called from a worker thread (e.g. directly from a handler when download is complete).\n\n If any of the workers has thrown any exception, it will be re-raised (e.... | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_project_cancel | null | def download_project_cancel(job):
"""
To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time).
"""
job.mp.log.info("user cancelled downloading...")
# set job as cancelled
job.is_cancelled = Tr... |
To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time).
| To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time). | [
"To",
"be",
"called",
"(",
"from",
"main",
"thread",
")",
"to",
"cancel",
"a",
"job",
"that",
"has",
"downloads",
"in",
"progress",
".",
"Returns",
"once",
"all",
"background",
"tasks",
"have",
"exited",
"(",
"may",
"block",
"for",
"a",
"bit",
"of",
"t... | def download_project_cancel(job):
job.mp.log.info("user cancelled downloading...")
job.is_cancelled = True
job.executor.shutdown(wait=True)
job.mp.log.info("--- download cancelled") | [
"def",
"download_project_cancel",
"(",
"job",
")",
":",
"job",
".",
"mp",
".",
"log",
".",
"info",
"(",
"\"user cancelled downloading...\"",
")",
"job",
".",
"is_cancelled",
"=",
"True",
"job",
".",
"executor",
".",
"shutdown",
"(",
"wait",
"=",
"True",
")... | To be called (from main thread) to cancel a job that has downloads in progress. | [
"To",
"be",
"called",
"(",
"from",
"main",
"thread",
")",
"to",
"cancel",
"a",
"job",
"that",
"has",
"downloads",
"in",
"progress",
"."
] | [
"\"\"\"\n To be called (from main thread) to cancel a job that has downloads in progress.\n Returns once all background tasks have exited (may block for a bit of time).\n \"\"\"",
"# set job as cancelled"
] | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | apply | null | def apply(self, directory, mp):
""" assemble downloaded chunks into a single file """
if self.destination_file is None:
basename = os.path.basename(self.file_path)
file_dir = os.path.dirname(os.path.normpath(os.path.join(directory, self.file_path)))
dest_file_path = ... | assemble downloaded chunks into a single file | assemble downloaded chunks into a single file | [
"assemble",
"downloaded",
"chunks",
"into",
"a",
"single",
"file"
] | def apply(self, directory, mp):
if self.destination_file is None:
basename = os.path.basename(self.file_path)
file_dir = os.path.dirname(os.path.normpath(os.path.join(directory, self.file_path)))
dest_file_path = os.path.join(file_dir, basename)
else:
file... | [
"def",
"apply",
"(",
"self",
",",
"directory",
",",
"mp",
")",
":",
"if",
"self",
".",
"destination_file",
"is",
"None",
":",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"file_path",
")",
"file_dir",
"=",
"os",
".",
"path",... | assemble downloaded chunks into a single file | [
"assemble",
"downloaded",
"chunks",
"into",
"a",
"single",
"file"
] | [
"\"\"\" assemble downloaded chunks into a single file \"\"\"",
"# ignore check if we download not-latest version of gpkg file (possibly reconstructed on server on demand)",
"# merge chunks together (and delete them afterwards)",
"# Make a copy of the file to meta dir only if there is no user-specified path fo... | [
{
"param": "self",
"type": null
},
{
"param": "directory",
"type": null
},
{
"param": "mp",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_token... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_blocking | null | def download_blocking(self, mc, mp, project_path):
""" Starts download and only returns once the file has been fully downloaded and saved """
mp.log.debug(f"Downloading {self.file_path} version={self.version} diff={self.diff_only} part={self.part_index}")
start = self.part_index * (1 + CHUNK_SI... | Starts download and only returns once the file has been fully downloaded and saved | Starts download and only returns once the file has been fully downloaded and saved | [
"Starts",
"download",
"and",
"only",
"returns",
"once",
"the",
"file",
"has",
"been",
"fully",
"downloaded",
"and",
"saved"
] | def download_blocking(self, mc, mp, project_path):
mp.log.debug(f"Downloading {self.file_path} version={self.version} diff={self.diff_only} part={self.part_index}")
start = self.part_index * (1 + CHUNK_SIZE)
resp = mc.get("/v1/project/raw/{}".format(project_path), data={
"file": ... | [
"def",
"download_blocking",
"(",
"self",
",",
"mc",
",",
"mp",
",",
"project_path",
")",
":",
"mp",
".",
"log",
".",
"debug",
"(",
"f\"Downloading {self.file_path} version={self.version} diff={self.diff_only} part={self.part_index}\"",
")",
"start",
"=",
"self",
".",
... | Starts download and only returns once the file has been fully downloaded and saved | [
"Starts",
"download",
"and",
"only",
"returns",
"once",
"the",
"file",
"has",
"been",
"fully",
"downloaded",
"and",
"saved"
] | [
"\"\"\" Starts download and only returns once the file has been fully downloaded and saved \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "mc",
"type": null
},
{
"param": "mp",
"type": null
},
{
"param": "project_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mc",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | pull_project_async | <not_specific> | def pull_project_async(mc, directory):
"""
Starts project pull in background and returns handle to the pending job.
Using that object it is possible to watch progress or cancel the ongoing work.
"""
mp = MerginProject(directory)
if mp.has_unfinished_pull():
try:
mp.resolve_u... |
Starts project pull in background and returns handle to the pending job.
Using that object it is possible to watch progress or cancel the ongoing work.
| Starts project pull in background and returns handle to the pending job.
Using that object it is possible to watch progress or cancel the ongoing work. | [
"Starts",
"project",
"pull",
"in",
"background",
"and",
"returns",
"handle",
"to",
"the",
"pending",
"job",
".",
"Using",
"that",
"object",
"it",
"is",
"possible",
"to",
"watch",
"progress",
"or",
"cancel",
"the",
"ongoing",
"work",
"."
] | def pull_project_async(mc, directory):
mp = MerginProject(directory)
if mp.has_unfinished_pull():
try:
mp.resolve_unfinished_pull(mc.username())
except ClientError as err:
mp.log.error("Error resolving unfinished pull: " + str(err))
mp.log.info("--- pull abort... | [
"def",
"pull_project_async",
"(",
"mc",
",",
"directory",
")",
":",
"mp",
"=",
"MerginProject",
"(",
"directory",
")",
"if",
"mp",
".",
"has_unfinished_pull",
"(",
")",
":",
"try",
":",
"mp",
".",
"resolve_unfinished_pull",
"(",
"mc",
".",
"username",
"(",... | Starts project pull in background and returns handle to the pending job. | [
"Starts",
"project",
"pull",
"in",
"background",
"and",
"returns",
"handle",
"to",
"the",
"pending",
"job",
"."
] | [
"\"\"\"\n Starts project pull in background and returns handle to the pending job.\n Using that object it is possible to watch progress or cancel the ongoing work.\n \"\"\"",
"# Project is up to date",
"# we either download a versioned file using diffs (strongly preferred),",
"# but if we don't have ... | [
{
"param": "mc",
"type": null
},
{
"param": "directory",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens"... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | pull_project_is_running | <not_specific> | def pull_project_is_running(job):
"""
Returns true/false depending on whether we have some pending downloads
It also forwards any exceptions from workers (e.g. some network errors). If an exception
is raised, it is advised to call pull_project_cancel() to abort the job.
"""
for future in job.fu... |
Returns true/false depending on whether we have some pending downloads
It also forwards any exceptions from workers (e.g. some network errors). If an exception
is raised, it is advised to call pull_project_cancel() to abort the job.
| Returns true/false depending on whether we have some pending downloads
It also forwards any exceptions from workers . If an exception
is raised, it is advised to call pull_project_cancel() to abort the job. | [
"Returns",
"true",
"/",
"false",
"depending",
"on",
"whether",
"we",
"have",
"some",
"pending",
"downloads",
"It",
"also",
"forwards",
"any",
"exceptions",
"from",
"workers",
".",
"If",
"an",
"exception",
"is",
"raised",
"it",
"is",
"advised",
"to",
"call",
... | def pull_project_is_running(job):
for future in job.futures:
if future.done() and future.exception() is not None:
job.mp.log.error("Error while pulling data: " + str(future.exception()))
job.mp.log.info("--- pull aborted")
raise future.exception()
if future.runnin... | [
"def",
"pull_project_is_running",
"(",
"job",
")",
":",
"for",
"future",
"in",
"job",
".",
"futures",
":",
"if",
"future",
".",
"done",
"(",
")",
"and",
"future",
".",
"exception",
"(",
")",
"is",
"not",
"None",
":",
"job",
".",
"mp",
".",
"log",
"... | Returns true/false depending on whether we have some pending downloads
It also forwards any exceptions from workers (e.g. | [
"Returns",
"true",
"/",
"false",
"depending",
"on",
"whether",
"we",
"have",
"some",
"pending",
"downloads",
"It",
"also",
"forwards",
"any",
"exceptions",
"from",
"workers",
"(",
"e",
".",
"g",
"."
] | [
"\"\"\"\n Returns true/false depending on whether we have some pending downloads\n\n It also forwards any exceptions from workers (e.g. some network errors). If an exception\n is raised, it is advised to call pull_project_cancel() to abort the job.\n \"\"\""
] | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | pull_project_cancel | null | def pull_project_cancel(job):
"""
To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time).
"""
job.mp.log.info("user cancelled the pull...")
# set job as cancelled
job.is_cancelled = True
... |
To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time).
| To be called (from main thread) to cancel a job that has downloads in progress.
Returns once all background tasks have exited (may block for a bit of time). | [
"To",
"be",
"called",
"(",
"from",
"main",
"thread",
")",
"to",
"cancel",
"a",
"job",
"that",
"has",
"downloads",
"in",
"progress",
".",
"Returns",
"once",
"all",
"background",
"tasks",
"have",
"exited",
"(",
"may",
"block",
"for",
"a",
"bit",
"of",
"t... | def pull_project_cancel(job):
job.mp.log.info("user cancelled the pull...")
job.is_cancelled = True
job.executor.shutdown(wait=True)
job.mp.log.info("--- pull cancelled") | [
"def",
"pull_project_cancel",
"(",
"job",
")",
":",
"job",
".",
"mp",
".",
"log",
".",
"info",
"(",
"\"user cancelled the pull...\"",
")",
"job",
".",
"is_cancelled",
"=",
"True",
"job",
".",
"executor",
".",
"shutdown",
"(",
"wait",
"=",
"True",
")",
"j... | To be called (from main thread) to cancel a job that has downloads in progress. | [
"To",
"be",
"called",
"(",
"from",
"main",
"thread",
")",
"to",
"cancel",
"a",
"job",
"that",
"has",
"downloads",
"in",
"progress",
"."
] | [
"\"\"\"\n To be called (from main thread) to cancel a job that has downloads in progress.\n Returns once all background tasks have exited (may block for a bit of time).\n \"\"\"",
"# set job as cancelled"
] | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | pull_project_finalize | <not_specific> | def pull_project_finalize(job):
"""
To be called when pull in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread (e.g. directly from a handler when download is complete)
If any of the workers has thrown any exception, it wil... |
To be called when pull in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread (e.g. directly from a handler when download is complete)
If any of the workers has thrown any exception, it will be re-raised (e.g. some network error... | To be called when pull in the background is finished and we need to do the finalization (merge chunks etc.)
This should not be called from a worker thread
If any of the workers has thrown any exception, it will be re-raised .
That also means that the whole job has been aborted. | [
"To",
"be",
"called",
"when",
"pull",
"in",
"the",
"background",
"is",
"finished",
"and",
"we",
"need",
"to",
"do",
"the",
"finalization",
"(",
"merge",
"chunks",
"etc",
".",
")",
"This",
"should",
"not",
"be",
"called",
"from",
"a",
"worker",
"thread",
... | def pull_project_finalize(job):
job.executor.shutdown(wait=True)
for future in job.futures:
if future.exception() is not None:
job.mp.log.error("Error while pulling data: " + str(future.exception()))
job.mp.log.info("--- pull aborted")
raise future.exception()
job... | [
"def",
"pull_project_finalize",
"(",
"job",
")",
":",
"job",
".",
"executor",
".",
"shutdown",
"(",
"wait",
"=",
"True",
")",
"for",
"future",
"in",
"job",
".",
"futures",
":",
"if",
"future",
".",
"exception",
"(",
")",
"is",
"not",
"None",
":",
"jo... | To be called when pull in the background is finished and we need to do the finalization (merge chunks etc.) | [
"To",
"be",
"called",
"when",
"pull",
"in",
"the",
"background",
"is",
"finished",
"and",
"we",
"need",
"to",
"do",
"the",
"finalization",
"(",
"merge",
"chunks",
"etc",
".",
")"
] | [
"\"\"\"\n To be called when pull in the background is finished and we need to do the finalization (merge chunks etc.)\n\n This should not be called from a worker thread (e.g. directly from a handler when download is complete)\n\n If any of the workers has thrown any exception, it will be re-raised (e.g. so... | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_file_async | <not_specific> | def download_file_async(mc, project_dir, file_path, output_file, version):
"""
Starts background download project file at specified version.
Returns handle to the pending download.
"""
mp = MerginProject(project_dir)
project_path = mp.metadata["name"]
ver_info = f"at version {version}" if ve... |
Starts background download project file at specified version.
Returns handle to the pending download.
| Starts background download project file at specified version.
Returns handle to the pending download. | [
"Starts",
"background",
"download",
"project",
"file",
"at",
"specified",
"version",
".",
"Returns",
"handle",
"to",
"the",
"pending",
"download",
"."
] | def download_file_async(mc, project_dir, file_path, output_file, version):
mp = MerginProject(project_dir)
project_path = mp.metadata["name"]
ver_info = f"at version {version}" if version is not None else "at latest version"
mp.log.info(f"Getting {file_path} {ver_info}")
latest_proj_info = mc.projec... | [
"def",
"download_file_async",
"(",
"mc",
",",
"project_dir",
",",
"file_path",
",",
"output_file",
",",
"version",
")",
":",
"mp",
"=",
"MerginProject",
"(",
"project_dir",
")",
"project_path",
"=",
"mp",
".",
"metadata",
"[",
"\"name\"",
"]",
"ver_info",
"=... | Starts background download project file at specified version. | [
"Starts",
"background",
"download",
"project",
"file",
"at",
"specified",
"version",
"."
] | [
"\"\"\"\n Starts background download project file at specified version.\n Returns handle to the pending download.\n \"\"\"",
"# set temporary directory for download"
] | [
{
"param": "mc",
"type": null
},
{
"param": "project_dir",
"type": null
},
{
"param": "file_path",
"type": null
},
{
"param": "output_file",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "project_dir",
"type": null,
"docstring": null,
"docstring_token... |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_file_finalize | null | def download_file_finalize(job):
"""
To be called when download_file_async is finished
"""
job.executor.shutdown(wait=True)
# make sure any exceptions from threads are not lost
for future in job.futures:
if future.exception() is not None:
raise future.exception()
job.mp... |
To be called when download_file_async is finished
| To be called when download_file_async is finished | [
"To",
"be",
"called",
"when",
"download_file_async",
"is",
"finished"
] | def download_file_finalize(job):
job.executor.shutdown(wait=True)
for future in job.futures:
if future.exception() is not None:
raise future.exception()
job.mp.log.info("--- download finished")
temp_dir = None
for task in job.update_tasks:
task.apply(job.directory, job.mp... | [
"def",
"download_file_finalize",
"(",
"job",
")",
":",
"job",
".",
"executor",
".",
"shutdown",
"(",
"wait",
"=",
"True",
")",
"for",
"future",
"in",
"job",
".",
"futures",
":",
"if",
"future",
".",
"exception",
"(",
")",
"is",
"not",
"None",
":",
"r... | To be called when download_file_async is finished | [
"To",
"be",
"called",
"when",
"download_file_async",
"is",
"finished"
] | [
"\"\"\"\n To be called when download_file_async is finished\n \"\"\"",
"# make sure any exceptions from threads are not lost",
"# Remove temporary download directory"
] | [
{
"param": "job",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "job",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a9126c9e074620a7da3ef37c46bbd7257e7aadd | saberraz/mergin-py-client | mergin/client_pull.py | [
"MIT"
] | Python | download_diffs_async | <not_specific> | def download_diffs_async(mc, project_directory, file_path, versions):
"""
Starts background download project file diffs for specified versions.
Returns handle to the pending download.
Args:
mc (MerginClient): MerginClient instance.
project_directory (str): local project directory.
... |
Starts background download project file diffs for specified versions.
Returns handle to the pending download.
Args:
mc (MerginClient): MerginClient instance.
project_directory (str): local project directory.
file_path (str): file path relative to Mergin project root.
versio... | Starts background download project file diffs for specified versions.
Returns handle to the pending download. | [
"Starts",
"background",
"download",
"project",
"file",
"diffs",
"for",
"specified",
"versions",
".",
"Returns",
"handle",
"to",
"the",
"pending",
"download",
"."
] | def download_diffs_async(mc, project_directory, file_path, versions):
mp = MerginProject(project_directory)
project_path = mp.metadata["name"]
file_history = mc.project_file_history_info(project_path, file_path)
mp.log.info(f"--- version: {mc.user_agent_info()}")
mp.log.info(f"--- start download dif... | [
"def",
"download_diffs_async",
"(",
"mc",
",",
"project_directory",
",",
"file_path",
",",
"versions",
")",
":",
"mp",
"=",
"MerginProject",
"(",
"project_directory",
")",
"project_path",
"=",
"mp",
".",
"metadata",
"[",
"\"name\"",
"]",
"file_history",
"=",
"... | Starts background download project file diffs for specified versions. | [
"Starts",
"background",
"download",
"project",
"file",
"diffs",
"for",
"specified",
"versions",
"."
] | [
"\"\"\"\n Starts background download project file diffs for specified versions.\n Returns handle to the pending download.\n\n Args:\n mc (MerginClient): MerginClient instance.\n project_directory (str): local project directory.\n file_path (str): file path relative to Mergin project ro... | [
{
"param": "mc",
"type": null
},
{
"param": "project_directory",
"type": null
},
{
"param": "file_path",
"type": null
},
{
"param": "versions",
"type": null
}
] | {
"returns": [
{
"docstring": "a handle for the pending download.",
"docstring_tokens": [
"a",
"handle",
"for",
"the",
"pending",
"download",
"."
],
"type": "PullJob/None"
}
],
"raises": [],
"params": [
{
"identifi... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | remove_logging_handler | null | def remove_logging_handler(self):
"""Check if there is a logger handler defined for the project and remove it. There should be only one."""
if len(self.log.handlers) > 0:
handler = self.log.handlers[0]
self.log.removeHandler(handler)
handler.flush()
handle... | Check if there is a logger handler defined for the project and remove it. There should be only one. | Check if there is a logger handler defined for the project and remove it. There should be only one. | [
"Check",
"if",
"there",
"is",
"a",
"logger",
"handler",
"defined",
"for",
"the",
"project",
"and",
"remove",
"it",
".",
"There",
"should",
"be",
"only",
"one",
"."
] | def remove_logging_handler(self):
if len(self.log.handlers) > 0:
handler = self.log.handlers[0]
self.log.removeHandler(handler)
handler.flush()
handler.close() | [
"def",
"remove_logging_handler",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"log",
".",
"handlers",
")",
">",
"0",
":",
"handler",
"=",
"self",
".",
"log",
".",
"handlers",
"[",
"0",
"]",
"self",
".",
"log",
".",
"removeHandler",
"(",
"h... | Check if there is a logger handler defined for the project and remove it. | [
"Check",
"if",
"there",
"is",
"a",
"logger",
"handler",
"defined",
"for",
"the",
"project",
"and",
"remove",
"it",
"."
] | [
"\"\"\"Check if there is a logger handler defined for the project and remove it. There should be only one.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | fpath | <not_specific> | def fpath(self, file, other_dir=None):
"""
Helper function to get absolute path of project file. Defaults to project dir but
alternative dir get be provided (mostly meta or temp). Also making sure that parent dirs to file exist.
:param file: relative file path in project (posix)
... |
Helper function to get absolute path of project file. Defaults to project dir but
alternative dir get be provided (mostly meta or temp). Also making sure that parent dirs to file exist.
:param file: relative file path in project (posix)
:type file: str
:param other_dir: alterna... | Helper function to get absolute path of project file. Defaults to project dir but
alternative dir get be provided (mostly meta or temp). Also making sure that parent dirs to file exist. | [
"Helper",
"function",
"to",
"get",
"absolute",
"path",
"of",
"project",
"file",
".",
"Defaults",
"to",
"project",
"dir",
"but",
"alternative",
"dir",
"get",
"be",
"provided",
"(",
"mostly",
"meta",
"or",
"temp",
")",
".",
"Also",
"making",
"sure",
"that",
... | def fpath(self, file, other_dir=None):
root = other_dir or self.dir
abs_path = os.path.abspath(os.path.join(root, file))
f_dir = os.path.dirname(abs_path)
os.makedirs(f_dir, exist_ok=True)
return abs_path | [
"def",
"fpath",
"(",
"self",
",",
"file",
",",
"other_dir",
"=",
"None",
")",
":",
"root",
"=",
"other_dir",
"or",
"self",
".",
"dir",
"abs_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"fil... | Helper function to get absolute path of project file. | [
"Helper",
"function",
"to",
"get",
"absolute",
"path",
"of",
"project",
"file",
"."
] | [
"\"\"\"\n Helper function to get absolute path of project file. Defaults to project dir but\n alternative dir get be provided (mostly meta or temp). Also making sure that parent dirs to file exist.\n\n :param file: relative file path in project (posix)\n :type file: str\n :param o... | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "other_dir",
"type": null
}
] | {
"returns": [
{
"docstring": "file's absolute path",
"docstring_tokens": [
"file",
"'",
"s",
"absolute",
"path"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | fpath_cache | <not_specific> | def fpath_cache(self, file, version=None):
""" Helper function to get absolute path of file in cache dir.
It can be either in root cache directory (.mergin/.cache/) or in some version's subfolder
"""
if version:
return self.fpath(file, os.path.join(self.cache_dir, version))
... | Helper function to get absolute path of file in cache dir.
It can be either in root cache directory (.mergin/.cache/) or in some version's subfolder
| Helper function to get absolute path of file in cache dir.
It can be either in root cache directory (.mergin/.cache/) or in some version's subfolder | [
"Helper",
"function",
"to",
"get",
"absolute",
"path",
"of",
"file",
"in",
"cache",
"dir",
".",
"It",
"can",
"be",
"either",
"in",
"root",
"cache",
"directory",
"(",
".",
"mergin",
"/",
".",
"cache",
"/",
")",
"or",
"in",
"some",
"version",
"'",
"s",... | def fpath_cache(self, file, version=None):
if version:
return self.fpath(file, os.path.join(self.cache_dir, version))
return self.fpath(file, self.cache_dir) | [
"def",
"fpath_cache",
"(",
"self",
",",
"file",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
":",
"return",
"self",
".",
"fpath",
"(",
"file",
",",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"cache_dir",
",",
"version",
")",
")",
... | Helper function to get absolute path of file in cache dir. | [
"Helper",
"function",
"to",
"get",
"absolute",
"path",
"of",
"file",
"in",
"cache",
"dir",
"."
] | [
"\"\"\" Helper function to get absolute path of file in cache dir.\n It can be either in root cache directory (.mergin/.cache/) or in some version's subfolder\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | is_versioned_file | <not_specific> | def is_versioned_file(self, file):
""" Check if file is compatible with geodiff lib and hence suitable for versioning.
:param file: file path
:type file: str
:returns: if file is compatible with geodiff lib
:rtype: bool
"""
diff_extensions = ['.gpkg', '.sqlite']
... | Check if file is compatible with geodiff lib and hence suitable for versioning.
:param file: file path
:type file: str
:returns: if file is compatible with geodiff lib
:rtype: bool
| Check if file is compatible with geodiff lib and hence suitable for versioning. | [
"Check",
"if",
"file",
"is",
"compatible",
"with",
"geodiff",
"lib",
"and",
"hence",
"suitable",
"for",
"versioning",
"."
] | def is_versioned_file(self, file):
diff_extensions = ['.gpkg', '.sqlite']
f_extension = os.path.splitext(file)[1]
return f_extension in diff_extensions | [
"def",
"is_versioned_file",
"(",
"self",
",",
"file",
")",
":",
"diff_extensions",
"=",
"[",
"'.gpkg'",
",",
"'.sqlite'",
"]",
"f_extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file",
")",
"[",
"1",
"]",
"return",
"f_extension",
"in",
"diff_e... | Check if file is compatible with geodiff lib and hence suitable for versioning. | [
"Check",
"if",
"file",
"is",
"compatible",
"with",
"geodiff",
"lib",
"and",
"hence",
"suitable",
"for",
"versioning",
"."
] | [
"\"\"\" Check if file is compatible with geodiff lib and hence suitable for versioning.\n\n :param file: file path\n :type file: str\n :returns: if file is compatible with geodiff lib\n :rtype: bool\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
}
] | {
"returns": [
{
"docstring": "if file is compatible with geodiff lib",
"docstring_tokens": [
"if",
"file",
"is",
"compatible",
"with",
"geodiff",
"lib"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifie... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | is_gpkg_open | <not_specific> | def is_gpkg_open(self, path):
"""
Check whether geopackage file is open (and wal file exists)
:param path: absolute path of file on disk
:type path: str
:returns: whether file is open
:rtype: bool
"""
f_extension = os.path.splitext(path)[1]
if f_e... |
Check whether geopackage file is open (and wal file exists)
:param path: absolute path of file on disk
:type path: str
:returns: whether file is open
:rtype: bool
| Check whether geopackage file is open (and wal file exists) | [
"Check",
"whether",
"geopackage",
"file",
"is",
"open",
"(",
"and",
"wal",
"file",
"exists",
")"
] | def is_gpkg_open(self, path):
f_extension = os.path.splitext(path)[1]
if f_extension != '.gpkg':
return False
if os.path.exists(f'{path}-wal'):
return True
return False | [
"def",
"is_gpkg_open",
"(",
"self",
",",
"path",
")",
":",
"f_extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
"[",
"1",
"]",
"if",
"f_extension",
"!=",
"'.gpkg'",
":",
"return",
"False",
"if",
"os",
".",
"path",
".",
"exists",
... | Check whether geopackage file is open (and wal file exists) | [
"Check",
"whether",
"geopackage",
"file",
"is",
"open",
"(",
"and",
"wal",
"file",
"exists",
")"
] | [
"\"\"\"\n Check whether geopackage file is open (and wal file exists)\n\n :param path: absolute path of file on disk\n :type path: str\n :returns: whether file is open\n :rtype: bool\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "whether file is open",
"docstring_tokens": [
"whether",
"file",
"is",
"open"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docst... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | ignore_file | <not_specific> | def ignore_file(self, file):
"""
Helper function for blacklisting certain types of files.
:param file: file path in project
:type file: str
:returns: whether file should be ignored
:rtype: bool
"""
ignore_ext = re.compile(r'({})$'.format('|'.join(re.escap... |
Helper function for blacklisting certain types of files.
:param file: file path in project
:type file: str
:returns: whether file should be ignored
:rtype: bool
| Helper function for blacklisting certain types of files. | [
"Helper",
"function",
"for",
"blacklisting",
"certain",
"types",
"of",
"files",
"."
] | def ignore_file(self, file):
ignore_ext = re.compile(r'({})$'.format('|'.join(re.escape(x) for x in ['-shm', '-wal', '~', 'pyc', 'swap'])))
ignore_files = ['.DS_Store', '.directory']
name, ext = os.path.splitext(file)
if ext and ignore_ext.search(ext):
return True
if ... | [
"def",
"ignore_file",
"(",
"self",
",",
"file",
")",
":",
"ignore_ext",
"=",
"re",
".",
"compile",
"(",
"r'({})$'",
".",
"format",
"(",
"'|'",
".",
"join",
"(",
"re",
".",
"escape",
"(",
"x",
")",
"for",
"x",
"in",
"[",
"'-shm'",
",",
"'-wal'",
"... | Helper function for blacklisting certain types of files. | [
"Helper",
"function",
"for",
"blacklisting",
"certain",
"types",
"of",
"files",
"."
] | [
"\"\"\"\n Helper function for blacklisting certain types of files.\n\n :param file: file path in project\n :type file: str\n :returns: whether file should be ignored\n :rtype: bool\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
}
] | {
"returns": [
{
"docstring": "whether file should be ignored",
"docstring_tokens": [
"whether",
"file",
"should",
"be",
"ignored"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | inspect_files | <not_specific> | def inspect_files(self):
"""
Inspect files in project directory and return metadata.
:returns: metadata for files in project directory in server required format
:rtype: list[dict]
"""
files_meta = []
for root, dirs, files in os.walk(self.dir, topdown=True):
... |
Inspect files in project directory and return metadata.
:returns: metadata for files in project directory in server required format
:rtype: list[dict]
| Inspect files in project directory and return metadata. | [
"Inspect",
"files",
"in",
"project",
"directory",
"and",
"return",
"metadata",
"."
] | def inspect_files(self):
files_meta = []
for root, dirs, files in os.walk(self.dir, topdown=True):
dirs[:] = [d for d in dirs if d not in ['.mergin']]
for file in files:
if self.ignore_file(file):
continue
abs_path = os.path.abs... | [
"def",
"inspect_files",
"(",
"self",
")",
":",
"files_meta",
"=",
"[",
"]",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"self",
".",
"dir",
",",
"topdown",
"=",
"True",
")",
":",
"dirs",
"[",
":",
"]",
"=",
"[",
"d",... | Inspect files in project directory and return metadata. | [
"Inspect",
"files",
"in",
"project",
"directory",
"and",
"return",
"metadata",
"."
] | [
"\"\"\"\n Inspect files in project directory and return metadata.\n\n :returns: metadata for files in project directory in server required format\n :rtype: list[dict]\n \"\"\"",
"# we need posix path"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "metadata for files in project directory in server required format",
"docstring_tokens": [
"metadata",
"for",
"files",
"in",
"project",
"directory",
"in",
"server",
"required",
"format"
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | compare_file_sets | <not_specific> | def compare_file_sets(self, origin, current):
"""
Helper function to calculate difference between two sets of files metadata using file names and checksums.
:Example:
>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '201... |
Helper function to calculate difference between two sets of files metadata using file names and checksums.
:Example:
>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]
>>> current = [{... | Helper function to calculate difference between two sets of files metadata using file names and checksums. | [
"Helper",
"function",
"to",
"calculate",
"difference",
"between",
"two",
"sets",
"of",
"files",
"metadata",
"using",
"file",
"names",
"and",
"checksums",
"."
] | def compare_file_sets(self, origin, current):
origin_map = {f["path"]: f for f in origin}
current_map = {f["path"]: f for f in current}
removed = [f for f in origin if f["path"] not in current_map]
added = [f for f in current if f["path"] not in origin_map]
updated = []
f... | [
"def",
"compare_file_sets",
"(",
"self",
",",
"origin",
",",
"current",
")",
":",
"origin_map",
"=",
"{",
"f",
"[",
"\"path\"",
"]",
":",
"f",
"for",
"f",
"in",
"origin",
"}",
"current_map",
"=",
"{",
"f",
"[",
"\"path\"",
"]",
":",
"f",
"for",
"f"... | Helper function to calculate difference between two sets of files metadata using file names and checksums. | [
"Helper",
"function",
"to",
"calculate",
"difference",
"between",
"two",
"sets",
"of",
"files",
"metadata",
"using",
"file",
"names",
"and",
"checksums",
"."
] | [
"\"\"\"\n Helper function to calculate difference between two sets of files metadata using file names and checksums.\n\n :Example:\n\n >>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]\n ... | [
{
"param": "self",
"type": null
},
{
"param": "origin",
"type": null
},
{
"param": "current",
"type": null
}
] | {
"returns": [
{
"docstring": "changes between two sets with change type",
"docstring_tokens": [
"changes",
"between",
"two",
"sets",
"with",
"change",
"type"
],
"type": "dict[str, list[dict]]'"
}
],
"raises": [],
"params": ... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | copy_versioned_file_for_upload | <not_specific> | def copy_versioned_file_for_upload(self, f, tmp_dir):
"""
Make a temporary copy of the versioned file using geodiff, to make sure that we have full
content in a single file (nothing left in WAL journal)
"""
path = f["path"]
self.log.info("Making a temporary copy (full upl... |
Make a temporary copy of the versioned file using geodiff, to make sure that we have full
content in a single file (nothing left in WAL journal)
| Make a temporary copy of the versioned file using geodiff, to make sure that we have full
content in a single file (nothing left in WAL journal) | [
"Make",
"a",
"temporary",
"copy",
"of",
"the",
"versioned",
"file",
"using",
"geodiff",
"to",
"make",
"sure",
"that",
"we",
"have",
"full",
"content",
"in",
"a",
"single",
"file",
"(",
"nothing",
"left",
"in",
"WAL",
"journal",
")"
] | def copy_versioned_file_for_upload(self, f, tmp_dir):
path = f["path"]
self.log.info("Making a temporary copy (full upload): " + path)
tmp_file = os.path.join(tmp_dir, path)
os.makedirs(os.path.dirname(tmp_file), exist_ok=True)
self.geodiff.make_copy_sqlite(self.fpath(path), tmp_... | [
"def",
"copy_versioned_file_for_upload",
"(",
"self",
",",
"f",
",",
"tmp_dir",
")",
":",
"path",
"=",
"f",
"[",
"\"path\"",
"]",
"self",
".",
"log",
".",
"info",
"(",
"\"Making a temporary copy (full upload): \"",
"+",
"path",
")",
"tmp_file",
"=",
"os",
".... | Make a temporary copy of the versioned file using geodiff, to make sure that we have full
content in a single file (nothing left in WAL journal) | [
"Make",
"a",
"temporary",
"copy",
"of",
"the",
"versioned",
"file",
"using",
"geodiff",
"to",
"make",
"sure",
"that",
"we",
"have",
"full",
"content",
"in",
"a",
"single",
"file",
"(",
"nothing",
"left",
"in",
"WAL",
"journal",
")"
] | [
"\"\"\"\n Make a temporary copy of the versioned file using geodiff, to make sure that we have full\n content in a single file (nothing left in WAL journal)\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "f",
"type": null
},
{
"param": "tmp_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | apply_pull_changes | <not_specific> | def apply_pull_changes(self, changes, temp_dir, user_name):
"""
Apply changes pulled from server.
Update project files according to file changes. Apply changes to geodiff basefiles as well
so they are up to date with server. In case of conflicts create backups from locally modified vers... |
Apply changes pulled from server.
Update project files according to file changes. Apply changes to geodiff basefiles as well
so they are up to date with server. In case of conflicts create backups from locally modified versions.
.. seealso:: self.get_pull_changes
:param chang... | Apply changes pulled from server.
Update project files according to file changes. Apply changes to geodiff basefiles as well
so they are up to date with server. In case of conflicts create backups from locally modified versions.
| [
"Apply",
"changes",
"pulled",
"from",
"server",
".",
"Update",
"project",
"files",
"according",
"to",
"file",
"changes",
".",
"Apply",
"changes",
"to",
"geodiff",
"basefiles",
"as",
"well",
"so",
"they",
"are",
"up",
"to",
"date",
"with",
"server",
".",
"I... | def apply_pull_changes(self, changes, temp_dir, user_name):
conflicts = []
local_changes = self.get_push_changes()
modified = {}
for f in local_changes["added"] + local_changes["updated"]:
modified.update({f['path']: f})
local_files_map = {}
for f in self.insp... | [
"def",
"apply_pull_changes",
"(",
"self",
",",
"changes",
",",
"temp_dir",
",",
"user_name",
")",
":",
"conflicts",
"=",
"[",
"]",
"local_changes",
"=",
"self",
".",
"get_push_changes",
"(",
")",
"modified",
"=",
"{",
"}",
"for",
"f",
"in",
"local_changes"... | Apply changes pulled from server. | [
"Apply",
"changes",
"pulled",
"from",
"server",
"."
] | [
"\"\"\"\n Apply changes pulled from server.\n\n Update project files according to file changes. Apply changes to geodiff basefiles as well\n so they are up to date with server. In case of conflicts create backups from locally modified versions.\n\n .. seealso:: self.get_pull_changes\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "changes",
"type": null
},
{
"param": "temp_dir",
"type": null
},
{
"param": "user_name",
"type": null
}
] | {
"returns": [
{
"docstring": "files where conflicts were found",
"docstring_tokens": [
"files",
"where",
"conflicts",
"were",
"found"
],
"type": "list[str]"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": nul... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | update_with_rebase | <not_specific> | def update_with_rebase(self, path, src, dest, basefile, temp_dir, user_name):
"""
Update a versioned file with rebase.
Try to peform automatic rebase, create conflict file if failed.pyt
.. seealso:: self.update_without_rebase
:param path: path to geodiff file
:type pat... |
Update a versioned file with rebase.
Try to peform automatic rebase, create conflict file if failed.pyt
.. seealso:: self.update_without_rebase
:param path: path to geodiff file
:type path: str
:param src: path to the server version of the file
:type src: str
... | Update a versioned file with rebase.
Try to peform automatic rebase, create conflict file if failed.pyt
| [
"Update",
"a",
"versioned",
"file",
"with",
"rebase",
".",
"Try",
"to",
"peform",
"automatic",
"rebase",
"create",
"conflict",
"file",
"if",
"failed",
".",
"pyt"
] | def update_with_rebase(self, path, src, dest, basefile, temp_dir, user_name):
self.log.info("updating file with rebase: " + path)
server_diff = self.fpath(f'{path}-server_diff', temp_dir)
local_diff = self.fpath(f'{path}-local_diff', temp_dir)
f_server_backup = self.fpath(f'{path}-serv... | [
"def",
"update_with_rebase",
"(",
"self",
",",
"path",
",",
"src",
",",
"dest",
",",
"basefile",
",",
"temp_dir",
",",
"user_name",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"updating file with rebase: \"",
"+",
"path",
")",
"server_diff",
"=",
"se... | Update a versioned file with rebase. | [
"Update",
"a",
"versioned",
"file",
"with",
"rebase",
"."
] | [
"\"\"\"\n Update a versioned file with rebase.\n\n Try to peform automatic rebase, create conflict file if failed.pyt\n\n .. seealso:: self.update_without_rebase\n\n :param path: path to geodiff file\n :type path: str\n :param src: path to the server version of the file\n ... | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "src",
"type": null
},
{
"param": "dest",
"type": null
},
{
"param": "basefile",
"type": null
},
{
"param": "temp_dir",
"type": null
},
{
"param": "user_name",... | {
"returns": [
{
"docstring": "path to conflict file if rebase fails, empty string on success",
"docstring_tokens": [
"path",
"to",
"conflict",
"file",
"if",
"rebase",
"fails",
"empty",
"string",
"on",
"success"
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | update_without_rebase | null | def update_without_rebase(self, path, src, dest, basefile, temp_dir):
"""
Update a versioned file without rebase.
Apply the diff between local copy and server to both the local
copy and its basefile.
.. seealso:: self.update_with_rebase
:param path: path to geodiff fil... |
Update a versioned file without rebase.
Apply the diff between local copy and server to both the local
copy and its basefile.
.. seealso:: self.update_with_rebase
:param path: path to geodiff file
:type path: str
:param src: path to the server version of the f... | Update a versioned file without rebase.
Apply the diff between local copy and server to both the local
copy and its basefile.
| [
"Update",
"a",
"versioned",
"file",
"without",
"rebase",
".",
"Apply",
"the",
"diff",
"between",
"local",
"copy",
"and",
"server",
"to",
"both",
"the",
"local",
"copy",
"and",
"its",
"basefile",
"."
] | def update_without_rebase(self, path, src, dest, basefile, temp_dir):
self.log.info("updating file without rebase: " + path)
try:
server_diff = self.fpath(f'{path}-server_diff', temp_dir)
self.geodiff.create_changeset(basefile, src, server_diff)
self.geodiff.apply_c... | [
"def",
"update_without_rebase",
"(",
"self",
",",
"path",
",",
"src",
",",
"dest",
",",
"basefile",
",",
"temp_dir",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"updating file without rebase: \"",
"+",
"path",
")",
"try",
":",
"server_diff",
"=",
"se... | Update a versioned file without rebase. | [
"Update",
"a",
"versioned",
"file",
"without",
"rebase",
"."
] | [
"\"\"\"\n Update a versioned file without rebase.\n\n Apply the diff between local copy and server to both the local\n copy and its basefile.\n\n .. seealso:: self.update_with_rebase\n\n :param path: path to geodiff file\n :type path: str\n :param src: path to the se... | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "src",
"type": null
},
{
"param": "dest",
"type": null
},
{
"param": "basefile",
"type": null
},
{
"param": "temp_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": "path to geodiff file",
"do... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | apply_push_changes | null | def apply_push_changes(self, changes):
"""
For geodiff files update basefiles according to changes pushed to server.
:param changes: metadata for pulled files
:type changes: dict[str, list[dict]]
"""
for k, v in changes.items():
for item in v:
... |
For geodiff files update basefiles according to changes pushed to server.
:param changes: metadata for pulled files
:type changes: dict[str, list[dict]]
| For geodiff files update basefiles according to changes pushed to server. | [
"For",
"geodiff",
"files",
"update",
"basefiles",
"according",
"to",
"changes",
"pushed",
"to",
"server",
"."
] | def apply_push_changes(self, changes):
for k, v in changes.items():
for item in v:
path = item['path']
if not self.is_versioned_file(path):
continue
basefile = self.fpath_meta(path)
if k == 'removed':
... | [
"def",
"apply_push_changes",
"(",
"self",
",",
"changes",
")",
":",
"for",
"k",
",",
"v",
"in",
"changes",
".",
"items",
"(",
")",
":",
"for",
"item",
"in",
"v",
":",
"path",
"=",
"item",
"[",
"'path'",
"]",
"if",
"not",
"self",
".",
"is_versioned_... | For geodiff files update basefiles according to changes pushed to server. | [
"For",
"geodiff",
"files",
"update",
"basefiles",
"according",
"to",
"changes",
"pushed",
"to",
"server",
"."
] | [
"\"\"\"\n For geodiff files update basefiles according to changes pushed to server.\n\n :param changes: metadata for pulled files\n :type changes: dict[str, list[dict]]\n \"\"\"",
"# in case for geopackage cannot be created diff (e.g. forced update with committed changes from wal file)... | [
{
"param": "self",
"type": null
},
{
"param": "changes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "changes",
"type": null,
"docstring": "metadata for pulled files",
... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | create_conflicted_copy | <not_specific> | def create_conflicted_copy(self, file, user_name):
"""
Create conflicted copy file next to its origin.
:param file: path of file in project
:type file: str
:returns: path to conflicted copy
:rtype: str
"""
src = self.fpath(file)
if not os.path.exi... |
Create conflicted copy file next to its origin.
:param file: path of file in project
:type file: str
:returns: path to conflicted copy
:rtype: str
| Create conflicted copy file next to its origin. | [
"Create",
"conflicted",
"copy",
"file",
"next",
"to",
"its",
"origin",
"."
] | def create_conflicted_copy(self, file, user_name):
src = self.fpath(file)
if not os.path.exists(src):
return
backup_path = unique_path_name(conflicted_copy_file_name(self.fpath(file), user_name, int_version(self.metadata['version'])))
if self.is_versioned_file(file):
... | [
"def",
"create_conflicted_copy",
"(",
"self",
",",
"file",
",",
"user_name",
")",
":",
"src",
"=",
"self",
".",
"fpath",
"(",
"file",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"src",
")",
":",
"return",
"backup_path",
"=",
"unique_path_n... | Create conflicted copy file next to its origin. | [
"Create",
"conflicted",
"copy",
"file",
"next",
"to",
"its",
"origin",
"."
] | [
"\"\"\"\n Create conflicted copy file next to its origin.\n\n :param file: path of file in project\n :type file: str\n :returns: path to conflicted copy\n :rtype: str\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "user_name",
"type": null
}
] | {
"returns": [
{
"docstring": "path to conflicted copy",
"docstring_tokens": [
"path",
"to",
"conflicted",
"copy"
],
"type": "str"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"... |
346d6db9bebd16517383c66c5e61687aef909e99 | saberraz/mergin-py-client | mergin/merginproject.py | [
"MIT"
] | Python | apply_diffs | <not_specific> | def apply_diffs(self, basefile, diffs):
"""
Helper function to update content of geodiff file using list of diffs.
Input file will be overwritten (make sure to create backup if needed).
:param basefile: abs path to file to be updated
:type basefile: str
:param diffs: lis... |
Helper function to update content of geodiff file using list of diffs.
Input file will be overwritten (make sure to create backup if needed).
:param basefile: abs path to file to be updated
:type basefile: str
:param diffs: list of abs paths to geodiff changeset files
:... | Helper function to update content of geodiff file using list of diffs.
Input file will be overwritten (make sure to create backup if needed). | [
"Helper",
"function",
"to",
"update",
"content",
"of",
"geodiff",
"file",
"using",
"list",
"of",
"diffs",
".",
"Input",
"file",
"will",
"be",
"overwritten",
"(",
"make",
"sure",
"to",
"create",
"backup",
"if",
"needed",
")",
"."
] | def apply_diffs(self, basefile, diffs):
error = None
if not self.is_versioned_file(basefile):
return error
for index, diff in enumerate(diffs):
try:
self.geodiff.apply_changeset(basefile, diff)
except (pygeodiff.GeoDiffLibError, pygeodiff.GeoDi... | [
"def",
"apply_diffs",
"(",
"self",
",",
"basefile",
",",
"diffs",
")",
":",
"error",
"=",
"None",
"if",
"not",
"self",
".",
"is_versioned_file",
"(",
"basefile",
")",
":",
"return",
"error",
"for",
"index",
",",
"diff",
"in",
"enumerate",
"(",
"diffs",
... | Helper function to update content of geodiff file using list of diffs. | [
"Helper",
"function",
"to",
"update",
"content",
"of",
"geodiff",
"file",
"using",
"list",
"of",
"diffs",
"."
] | [
"\"\"\"\n Helper function to update content of geodiff file using list of diffs.\n Input file will be overwritten (make sure to create backup if needed).\n\n :param basefile: abs path to file to be updated\n :type basefile: str\n :param diffs: list of abs paths to geodiff changese... | [
{
"param": "self",
"type": null
},
{
"param": "basefile",
"type": null
},
{
"param": "diffs",
"type": null
}
] | {
"returns": [
{
"docstring": "error message if diffs were not successfully applied or None",
"docstring_tokens": [
"error",
"message",
"if",
"diffs",
"were",
"not",
"successfully",
"applied",
"or",
"None"
],
"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.