Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
copy_m2m_relationships | (obj1, obj2, fields, kwargs=None) |
In-place operation.
Given two saved objects, copies related objects from obj1
to obj2 to field of same name, if field occurs in `fields`
|
In-place operation.
Given two saved objects, copies related objects from obj1
to obj2 to field of same name, if field occurs in `fields`
| def copy_m2m_relationships(obj1, obj2, fields, kwargs=None):
"""
In-place operation.
Given two saved objects, copies related objects from obj1
to obj2 to field of same name, if field occurs in `fields`
"""
for field_name in fields:
if hasattr(obj1, field_name):
try:
... | [
"def",
"copy_m2m_relationships",
"(",
"obj1",
",",
"obj2",
",",
"fields",
",",
"kwargs",
"=",
"None",
")",
":",
"for",
"field_name",
"in",
"fields",
":",
"if",
"hasattr",
"(",
"obj1",
",",
"field_name",
")",
":",
"try",
":",
"field_obj",
"=",
"obj1",
"... | [
529,
0
] | [
552,
89
] | python | en | ['en', 'error', 'th'] | False |
get_type_for_model | (model) |
Return type name for a given model class.
|
Return type name for a given model class.
| def get_type_for_model(model):
"""
Return type name for a given model class.
"""
opts = model._meta.concrete_model._meta
return camelcase_to_underscore(opts.object_name) | [
"def",
"get_type_for_model",
"(",
"model",
")",
":",
"opts",
"=",
"model",
".",
"_meta",
".",
"concrete_model",
".",
"_meta",
"return",
"camelcase_to_underscore",
"(",
"opts",
".",
"object_name",
")"
] | [
555,
0
] | [
560,
52
] | python | en | ['en', 'error', 'th'] | False |
get_model_for_type | (type_name) |
Return model class for a given type name.
|
Return model class for a given type name.
| def get_model_for_type(type_name):
"""
Return model class for a given type name.
"""
model_str = underscore_to_camelcase(type_name)
if model_str == 'User':
use_app = 'auth'
else:
use_app = 'main'
return apps.get_model(use_app, model_str) | [
"def",
"get_model_for_type",
"(",
"type_name",
")",
":",
"model_str",
"=",
"underscore_to_camelcase",
"(",
"type_name",
")",
"if",
"model_str",
"==",
"'User'",
":",
"use_app",
"=",
"'auth'",
"else",
":",
"use_app",
"=",
"'main'",
"return",
"apps",
".",
"get_mo... | [
563,
0
] | [
572,
45
] | python | en | ['en', 'error', 'th'] | False |
get_capacity_type | (uj) | Used for UnifiedJob.capacity_type property, static method will work for partial objects | Used for UnifiedJob.capacity_type property, static method will work for partial objects | def get_capacity_type(uj):
'''Used for UnifiedJob.capacity_type property, static method will work for partial objects'''
model_name = uj._meta.concrete_model._meta.model_name
if model_name in ('job', 'inventoryupdate', 'adhoccommand', 'jobtemplate', 'inventorysource'):
return 'execution'
elif mo... | [
"def",
"get_capacity_type",
"(",
"uj",
")",
":",
"model_name",
"=",
"uj",
".",
"_meta",
".",
"concrete_model",
".",
"_meta",
".",
"model_name",
"if",
"model_name",
"in",
"(",
"'job'",
",",
"'inventoryupdate'",
",",
"'adhoccommand'",
",",
"'jobtemplate'",
",",
... | [
575,
0
] | [
586,
77
] | python | en | ['en', 'en', 'en'] | True |
prefetch_page_capabilities | (model, page, prefetch_list, user) |
Given a `page` list of objects, a nested dictionary of user_capabilities
are returned by id, ex.
{
4: {'edit': True, 'start': True},
6: {'edit': False, 'start': False}
}
Each capability is produced for all items in the page in a single query
Examples of prefetch language:
p... |
Given a `page` list of objects, a nested dictionary of user_capabilities
are returned by id, ex.
{
4: {'edit': True, 'start': True},
6: {'edit': False, 'start': False}
}
Each capability is produced for all items in the page in a single query | def prefetch_page_capabilities(model, page, prefetch_list, user):
"""
Given a `page` list of objects, a nested dictionary of user_capabilities
are returned by id, ex.
{
4: {'edit': True, 'start': True},
6: {'edit': False, 'start': False}
}
Each capability is produced for all item... | [
"def",
"prefetch_page_capabilities",
"(",
"model",
",",
"page",
",",
"prefetch_list",
",",
"user",
")",
":",
"page_ids",
"=",
"[",
"obj",
".",
"id",
"for",
"obj",
"in",
"page",
"]",
"mapping",
"=",
"{",
"}",
"for",
"obj",
"in",
"page",
":",
"mapping",
... | [
589,
0
] | [
659,
18
] | python | en | ['en', 'error', 'th'] | False |
parse_yaml_or_json | (vars_str, silent_failure=True) |
Attempt to parse a string of variables.
First, with JSON parser, if that fails, then with PyYAML.
If both attempts fail, return an empty dictionary if `silent_failure`
is True, re-raise combination error if `silent_failure` if False.
|
Attempt to parse a string of variables.
First, with JSON parser, if that fails, then with PyYAML.
If both attempts fail, return an empty dictionary if `silent_failure`
is True, re-raise combination error if `silent_failure` if False.
| def parse_yaml_or_json(vars_str, silent_failure=True):
"""
Attempt to parse a string of variables.
First, with JSON parser, if that fails, then with PyYAML.
If both attempts fail, return an empty dictionary if `silent_failure`
is True, re-raise combination error if `silent_failure` if False.
"""... | [
"def",
"parse_yaml_or_json",
"(",
"vars_str",
",",
"silent_failure",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"vars_str",
",",
"dict",
")",
":",
"return",
"vars_str",
"elif",
"isinstance",
"(",
"vars_str",
",",
"str",
")",
"and",
"vars_str",
"==",
"... | [
672,
0
] | [
706,
20
] | python | en | ['en', 'error', 'th'] | False |
get_corrected_cpu | (cpu_count) | Some environments will do a correction to the reported CPU number
because the given OpenShift value is a lie
| Some environments will do a correction to the reported CPU number
because the given OpenShift value is a lie
| def get_corrected_cpu(cpu_count): # formerlly get_cpu_capacity
"""Some environments will do a correction to the reported CPU number
because the given OpenShift value is a lie
"""
from django.conf import settings
settings_abscpu = getattr(settings, 'SYSTEM_TASK_ABS_CPU', None)
env_abscpu = os.g... | [
"def",
"get_corrected_cpu",
"(",
"cpu_count",
")",
":",
"# formerlly get_cpu_capacity",
"from",
"django",
".",
"conf",
"import",
"settings",
"settings_abscpu",
"=",
"getattr",
"(",
"settings",
",",
"'SYSTEM_TASK_ABS_CPU'",
",",
"None",
")",
"env_abscpu",
"=",
"os",
... | [
733,
0
] | [
745,
20
] | python | en | ['en', 'en', 'en'] | True |
ignore_inventory_computed_fields | () |
Context manager to ignore updating inventory computed fields.
|
Context manager to ignore updating inventory computed fields.
| def ignore_inventory_computed_fields():
"""
Context manager to ignore updating inventory computed fields.
"""
try:
previous_value = getattr(_inventory_updates, 'is_updating', False)
_inventory_updates.is_updating = True
yield
finally:
_inventory_updates.is_updating = ... | [
"def",
"ignore_inventory_computed_fields",
"(",
")",
":",
"try",
":",
"previous_value",
"=",
"getattr",
"(",
"_inventory_updates",
",",
"'is_updating'",
",",
"False",
")",
"_inventory_updates",
".",
"is_updating",
"=",
"True",
"yield",
"finally",
":",
"_inventory_up... | [
789,
0
] | [
798,
55
] | python | en | ['en', 'error', 'th'] | False |
task_manager_bulk_reschedule | () | Context manager to avoid submitting task multiple times. | Context manager to avoid submitting task multiple times. | def task_manager_bulk_reschedule():
"""Context manager to avoid submitting task multiple times."""
try:
previous_flag = getattr(_task_manager, 'bulk_reschedule', False)
previous_value = getattr(_task_manager, 'needs_scheduling', False)
_task_manager.bulk_reschedule = True
_task_m... | [
"def",
"task_manager_bulk_reschedule",
"(",
")",
":",
"try",
":",
"previous_flag",
"=",
"getattr",
"(",
"_task_manager",
",",
"'bulk_reschedule'",
",",
"False",
")",
"previous_value",
"=",
"getattr",
"(",
"_task_manager",
",",
"'needs_scheduling'",
",",
"False",
"... | [
810,
0
] | [
822,
55
] | python | en | ['en', 'en', 'en'] | True |
ignore_inventory_group_removal | () |
Context manager to ignore moving groups/hosts when group is deleted.
|
Context manager to ignore moving groups/hosts when group is deleted.
| def ignore_inventory_group_removal():
"""
Context manager to ignore moving groups/hosts when group is deleted.
"""
try:
previous_value = getattr(_inventory_updates, 'is_removing', False)
_inventory_updates.is_removing = True
yield
finally:
_inventory_updates.is_removi... | [
"def",
"ignore_inventory_group_removal",
"(",
")",
":",
"try",
":",
"previous_value",
"=",
"getattr",
"(",
"_inventory_updates",
",",
"'is_removing'",
",",
"False",
")",
"_inventory_updates",
".",
"is_removing",
"=",
"True",
"yield",
"finally",
":",
"_inventory_upda... | [
833,
0
] | [
842,
55
] | python | en | ['en', 'error', 'th'] | False |
set_environ | (**environ) |
Temporarily set the process environment variables.
>>> with set_environ(FOO='BAR'):
... assert os.environ['FOO'] == 'BAR'
|
Temporarily set the process environment variables. | def set_environ(**environ):
"""
Temporarily set the process environment variables.
>>> with set_environ(FOO='BAR'):
... assert os.environ['FOO'] == 'BAR'
"""
old_environ = os.environ.copy()
try:
os.environ.update(environ)
yield
finally:
os.environ.clear()
... | [
"def",
"set_environ",
"(",
"*",
"*",
"environ",
")",
":",
"old_environ",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"try",
":",
"os",
".",
"environ",
".",
"update",
"(",
"environ",
")",
"yield",
"finally",
":",
"os",
".",
"environ",
".",
"cl... | [
846,
0
] | [
859,
38
] | python | en | ['en', 'error', 'th'] | False |
get_pk_from_dict | (_dict, key) |
Helper for obtaining a pk from user data dict or None if not present.
|
Helper for obtaining a pk from user data dict or None if not present.
| def get_pk_from_dict(_dict, key):
"""
Helper for obtaining a pk from user data dict or None if not present.
"""
try:
val = _dict[key]
if isinstance(val, object) and hasattr(val, 'id'):
return val.id # return id if given model object
return int(val)
except (TypeEr... | [
"def",
"get_pk_from_dict",
"(",
"_dict",
",",
"key",
")",
":",
"try",
":",
"val",
"=",
"_dict",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"val",
",",
"object",
")",
"and",
"hasattr",
"(",
"val",
",",
"'id'",
")",
":",
"return",
"val",
".",
"id",
... | [
862,
0
] | [
872,
19
] | python | en | ['en', 'error', 'th'] | False |
getattrd | (obj, name, default=NoDefaultProvided) |
Same as getattr(), but allows dot notation lookup
Discussed in:
http://stackoverflow.com/questions/11975781
|
Same as getattr(), but allows dot notation lookup
Discussed in:
http://stackoverflow.com/questions/11975781
| def getattrd(obj, name, default=NoDefaultProvided):
"""
Same as getattr(), but allows dot notation lookup
Discussed in:
http://stackoverflow.com/questions/11975781
"""
try:
return reduce(getattr, name.split("."), obj)
except AttributeError:
if default != NoDefaultProvided:
... | [
"def",
"getattrd",
"(",
"obj",
",",
"name",
",",
"default",
"=",
"NoDefaultProvided",
")",
":",
"try",
":",
"return",
"reduce",
"(",
"getattr",
",",
"name",
".",
"split",
"(",
"\".\"",
")",
",",
"obj",
")",
"except",
"AttributeError",
":",
"if",
"defau... | [
879,
0
] | [
891,
13
] | python | en | ['en', 'error', 'th'] | False |
create_temporary_fifo | (data) | Open fifo named pipe in a new thread using a temporary file path. The
thread blocks until data is read from the pipe.
Returns the path to the fifo.
:param data(bytes): Data to write to the pipe.
| Open fifo named pipe in a new thread using a temporary file path. The
thread blocks until data is read from the pipe.
Returns the path to the fifo.
:param data(bytes): Data to write to the pipe.
| def create_temporary_fifo(data):
"""Open fifo named pipe in a new thread using a temporary file path. The
thread blocks until data is read from the pipe.
Returns the path to the fifo.
:param data(bytes): Data to write to the pipe.
"""
path = os.path.join(tempfile.mkdtemp(), next(tempfile._get_ca... | [
"def",
"create_temporary_fifo",
"(",
"data",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempfile",
".",
"mkdtemp",
"(",
")",
",",
"next",
"(",
"tempfile",
".",
"_get_candidate_names",
"(",
")",
")",
")",
"os",
".",
"mkfifo",
"(",
"p... | [
1006,
0
] | [
1016,
15
] | python | en | ['en', 'en', 'en'] | True |
deepmerge | (a, b) |
Merge dict structures and return the result.
>>> a = {'first': {'all_rows': {'pass': 'dog', 'number': '1'}}}
>>> b = {'first': {'all_rows': {'fail': 'cat', 'number': '5'}}}
>>> import pprint; pprint.pprint(deepmerge(a, b))
{'first': {'all_rows': {'fail': 'cat', 'number': '5', 'pass': 'dog'}}}
|
Merge dict structures and return the result. | def deepmerge(a, b):
"""
Merge dict structures and return the result.
>>> a = {'first': {'all_rows': {'pass': 'dog', 'number': '1'}}}
>>> b = {'first': {'all_rows': {'fail': 'cat', 'number': '5'}}}
>>> import pprint; pprint.pprint(deepmerge(a, b))
{'first': {'all_rows': {'fail': 'cat', 'number'... | [
"def",
"deepmerge",
"(",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"dict",
")",
"and",
"isinstance",
"(",
"b",
",",
"dict",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"k",
",",
"deepmerge",
"(",
"a",
".",
"get",
"(",
"k",
")... | [
1036,
0
] | [
1050,
16
] | python | en | ['en', 'error', 'th'] | False |
create_partition | (tblname, start=None, end=None, partition_label=None, minutely=False) | Creates new partition table for events.
- start defaults to beginning of current hour
- end defaults to end of current hour
- partition_label defaults to YYYYMMDD_HH
- minutely will create partitions that span _a single minute_ for testing purposes
| Creates new partition table for events.
- start defaults to beginning of current hour
- end defaults to end of current hour
- partition_label defaults to YYYYMMDD_HH | def create_partition(tblname, start=None, end=None, partition_label=None, minutely=False):
"""Creates new partition table for events.
- start defaults to beginning of current hour
- end defaults to end of current hour
- partition_label defaults to YYYYMMDD_HH
- minutely will create partitions that ... | [
"def",
"create_partition",
"(",
"tblname",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"partition_label",
"=",
"None",
",",
"minutely",
"=",
"False",
")",
":",
"current_time",
"=",
"now",
"(",
")",
"if",
"not",
"start",
":",
"if",
"minutel... | [
1053,
0
] | [
1086,
9
] | python | en | ['en', 'en', 'en'] | True |
cleanup_new_process | (func) |
Cleanup django connection, cache connection, before executing new thread or processes entry point, func.
|
Cleanup django connection, cache connection, before executing new thread or processes entry point, func.
| def cleanup_new_process(func):
"""
Cleanup django connection, cache connection, before executing new thread or processes entry point, func.
"""
@wraps(func)
def wrapper_cleanup_new_process(*args, **kwargs):
from awx.conf.settings import SettingsWrapper # noqa
django_connection.clo... | [
"def",
"cleanup_new_process",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper_cleanup_new_process",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"awx",
".",
"conf",
".",
"settings",
"import",
"SettingsWrapper",
"# noq... | [
1089,
0
] | [
1103,
38
] | python | en | ['en', 'error', 'th'] | False |
test_modified_not_allowed_field | (somecloud_type) |
If this test fails, that means that read-only fields are showing
up in the activity stream serialization of an instance.
That _probably_ means that you just connected a new model to the
activity_stream_registrar, but did not add its serializer to
the model->serializer mapping.
|
If this test fails, that means that read-only fields are showing
up in the activity stream serialization of an instance. | def test_modified_not_allowed_field(somecloud_type):
"""
If this test fails, that means that read-only fields are showing
up in the activity stream serialization of an instance.
That _probably_ means that you just connected a new model to the
activity_stream_registrar, but did not add its serialize... | [
"def",
"test_modified_not_allowed_field",
"(",
"somecloud_type",
")",
":",
"from",
"awx",
".",
"main",
".",
"registrar",
"import",
"activity_stream_registrar",
"for",
"Model",
"in",
"activity_stream_registrar",
".",
"models",
":",
"assert",
"'modified'",
"not",
"in",
... | [
207,
0
] | [
219,
95
] | python | en | ['en', 'error', 'th'] | False |
Arbiter.start | (self) | \
Initialize the arbiter. Start listening and set pidfile if needed.
| \
Initialize the arbiter. Start listening and set pidfile if needed.
| def start(self):
"""\
Initialize the arbiter. Start listening and set pidfile if needed.
"""
self.log.info("Starting gunicorn %s", __version__)
if 'GUNICORN_PID' in os.environ:
self.master_pid = int(os.environ.get('GUNICORN_PID'))
self.proc_name = self.pr... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Starting gunicorn %s\"",
",",
"__version__",
")",
"if",
"'GUNICORN_PID'",
"in",
"os",
".",
"environ",
":",
"self",
".",
"master_pid",
"=",
"int",
"(",
"os",
".",
"environ",
... | [
119,
4
] | [
166,
33
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.init_signals | (self) | \
Initialize master signal handling. Most of the signals
are queued. Child signals only wake up the master.
| \
Initialize master signal handling. Most of the signals
are queued. Child signals only wake up the master.
| def init_signals(self):
"""\
Initialize master signal handling. Most of the signals
are queued. Child signals only wake up the master.
"""
# close old PIPE
for p in self.PIPE:
os.close(p)
# initialize the pipe
self.PIPE = pair = os.pipe()
... | [
"def",
"init_signals",
"(",
"self",
")",
":",
"# close old PIPE",
"for",
"p",
"in",
"self",
".",
"PIPE",
":",
"os",
".",
"close",
"(",
"p",
")",
"# initialize the pipe",
"self",
".",
"PIPE",
"=",
"pair",
"=",
"os",
".",
"pipe",
"(",
")",
"for",
"p",
... | [
168,
4
] | [
188,
55
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.run | (self) | Main master loop. | Main master loop. | def run(self):
"Main master loop."
self.start()
util._setproctitle("master [%s]" % self.proc_name)
try:
self.manage_workers()
while True:
self.maybe_promote_master()
sig = self.SIG_QUEUE.pop(0) if self.SIG_QUEUE else None
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"start",
"(",
")",
"util",
".",
"_setproctitle",
"(",
"\"master [%s]\"",
"%",
"self",
".",
"proc_name",
")",
"try",
":",
"self",
".",
"manage_workers",
"(",
")",
"while",
"True",
":",
"self",
".",
"ma... | [
195,
4
] | [
237,
24
] | python | en | ['fr', 'id', 'en'] | False |
Arbiter.handle_chld | (self, sig, frame) | SIGCHLD handling | SIGCHLD handling | def handle_chld(self, sig, frame):
"SIGCHLD handling"
self.reap_workers()
self.wakeup() | [
"def",
"handle_chld",
"(",
"self",
",",
"sig",
",",
"frame",
")",
":",
"self",
".",
"reap_workers",
"(",
")",
"self",
".",
"wakeup",
"(",
")"
] | [
239,
4
] | [
242,
21
] | python | de | ['de', 'kk', 'nl'] | False |
Arbiter.handle_hup | (self) | \
HUP handling.
- Reload configuration
- Start the new worker processes with a new configuration
- Gracefully shutdown the old worker processes
| \
HUP handling.
- Reload configuration
- Start the new worker processes with a new configuration
- Gracefully shutdown the old worker processes
| def handle_hup(self):
"""\
HUP handling.
- Reload configuration
- Start the new worker processes with a new configuration
- Gracefully shutdown the old worker processes
"""
self.log.info("Hang up: %s", self.master_name)
self.reload() | [
"def",
"handle_hup",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Hang up: %s\"",
",",
"self",
".",
"master_name",
")",
"self",
".",
"reload",
"(",
")"
] | [
244,
4
] | [
252,
21
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.handle_term | (self) | SIGTERM handling | SIGTERM handling | def handle_term(self):
"SIGTERM handling"
raise StopIteration | [
"def",
"handle_term",
"(",
"self",
")",
":",
"raise",
"StopIteration"
] | [
254,
4
] | [
256,
27
] | python | da | ['de', 'da', 'nl'] | False |
Arbiter.handle_int | (self) | SIGINT handling | SIGINT handling | def handle_int(self):
"SIGINT handling"
self.stop(False)
raise StopIteration | [
"def",
"handle_int",
"(",
"self",
")",
":",
"self",
".",
"stop",
"(",
"False",
")",
"raise",
"StopIteration"
] | [
258,
4
] | [
261,
27
] | python | de | ['de', 'ru', 'en'] | False |
Arbiter.handle_quit | (self) | SIGQUIT handling | SIGQUIT handling | def handle_quit(self):
"SIGQUIT handling"
self.stop(False)
raise StopIteration | [
"def",
"handle_quit",
"(",
"self",
")",
":",
"self",
".",
"stop",
"(",
"False",
")",
"raise",
"StopIteration"
] | [
263,
4
] | [
266,
27
] | python | de | ['de', 'jv', 'nl'] | False |
Arbiter.handle_ttin | (self) | \
SIGTTIN handling.
Increases the number of workers by one.
| \
SIGTTIN handling.
Increases the number of workers by one.
| def handle_ttin(self):
"""\
SIGTTIN handling.
Increases the number of workers by one.
"""
self.num_workers += 1
self.manage_workers() | [
"def",
"handle_ttin",
"(",
"self",
")",
":",
"self",
".",
"num_workers",
"+=",
"1",
"self",
".",
"manage_workers",
"(",
")"
] | [
268,
4
] | [
274,
29
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.handle_ttou | (self) | \
SIGTTOU handling.
Decreases the number of workers by one.
| \
SIGTTOU handling.
Decreases the number of workers by one.
| def handle_ttou(self):
"""\
SIGTTOU handling.
Decreases the number of workers by one.
"""
if self.num_workers <= 1:
return
self.num_workers -= 1
self.manage_workers() | [
"def",
"handle_ttou",
"(",
"self",
")",
":",
"if",
"self",
".",
"num_workers",
"<=",
"1",
":",
"return",
"self",
".",
"num_workers",
"-=",
"1",
"self",
".",
"manage_workers",
"(",
")"
] | [
276,
4
] | [
284,
29
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.handle_usr1 | (self) | \
SIGUSR1 handling.
Kill all workers by sending them a SIGUSR1
| \
SIGUSR1 handling.
Kill all workers by sending them a SIGUSR1
| def handle_usr1(self):
"""\
SIGUSR1 handling.
Kill all workers by sending them a SIGUSR1
"""
self.log.reopen_files()
self.kill_workers(signal.SIGUSR1) | [
"def",
"handle_usr1",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"reopen_files",
"(",
")",
"self",
".",
"kill_workers",
"(",
"signal",
".",
"SIGUSR1",
")"
] | [
286,
4
] | [
292,
41
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.handle_usr2 | (self) | \
SIGUSR2 handling.
Creates a new master/worker set as a slave of the current
master without affecting old workers. Use this to do live
deployment with the ability to backout a change.
| \
SIGUSR2 handling.
Creates a new master/worker set as a slave of the current
master without affecting old workers. Use this to do live
deployment with the ability to backout a change.
| def handle_usr2(self):
"""\
SIGUSR2 handling.
Creates a new master/worker set as a slave of the current
master without affecting old workers. Use this to do live
deployment with the ability to backout a change.
"""
self.reexec() | [
"def",
"handle_usr2",
"(",
"self",
")",
":",
"self",
".",
"reexec",
"(",
")"
] | [
294,
4
] | [
301,
21
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.handle_winch | (self) | SIGWINCH handling | SIGWINCH handling | def handle_winch(self):
"""SIGWINCH handling"""
if self.cfg.daemon:
self.log.info("graceful stop of workers")
self.num_workers = 0
self.kill_workers(signal.SIGTERM)
else:
self.log.debug("SIGWINCH ignored. Not daemonized") | [
"def",
"handle_winch",
"(",
"self",
")",
":",
"if",
"self",
".",
"cfg",
".",
"daemon",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"graceful stop of workers\"",
")",
"self",
".",
"num_workers",
"=",
"0",
"self",
".",
"kill_workers",
"(",
"signal",
".",
... | [
303,
4
] | [
310,
62
] | python | cy | ['de', 'cy', 'ur'] | False |
Arbiter.wakeup | (self) | \
Wake up the arbiter by writing to the PIPE
| \
Wake up the arbiter by writing to the PIPE
| def wakeup(self):
"""\
Wake up the arbiter by writing to the PIPE
"""
try:
os.write(self.PIPE[1], b'.')
except IOError as e:
if e.errno not in [errno.EAGAIN, errno.EINTR]:
raise | [
"def",
"wakeup",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"write",
"(",
"self",
".",
"PIPE",
"[",
"1",
"]",
",",
"b'.'",
")",
"except",
"IOError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"not",
"in",
"[",
"errno",
".",
"EAGAIN",
",",
"e... | [
329,
4
] | [
337,
21
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.halt | (self, reason=None, exit_status=0) | halt arbiter | halt arbiter | def halt(self, reason=None, exit_status=0):
""" halt arbiter """
self.stop()
self.log.info("Shutting down: %s", self.master_name)
if reason is not None:
self.log.info("Reason: %s", reason)
if self.pidfile is not None:
self.pidfile.unlink()
self.cfg... | [
"def",
"halt",
"(",
"self",
",",
"reason",
"=",
"None",
",",
"exit_status",
"=",
"0",
")",
":",
"self",
".",
"stop",
"(",
")",
"self",
".",
"log",
".",
"info",
"(",
"\"Shutting down: %s\"",
",",
"self",
".",
"master_name",
")",
"if",
"reason",
"is",
... | [
339,
4
] | [
348,
29
] | python | de | ['de', 'de', 'ur'] | False |
Arbiter.sleep | (self) | \
Sleep until PIPE is readable or we timeout.
A readable PIPE means a signal occurred.
| \
Sleep until PIPE is readable or we timeout.
A readable PIPE means a signal occurred.
| def sleep(self):
"""\
Sleep until PIPE is readable or we timeout.
A readable PIPE means a signal occurred.
"""
try:
ready = select.select([self.PIPE[0]], [], [], 1.0)
if not ready[0]:
return
while os.read(self.PIPE[0], 1):
... | [
"def",
"sleep",
"(",
"self",
")",
":",
"try",
":",
"ready",
"=",
"select",
".",
"select",
"(",
"[",
"self",
".",
"PIPE",
"[",
"0",
"]",
"]",
",",
"[",
"]",
",",
"[",
"]",
",",
"1.0",
")",
"if",
"not",
"ready",
"[",
"0",
"]",
":",
"return",
... | [
350,
4
] | [
367,
22
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.stop | (self, graceful=True) | \
Stop workers
:attr graceful: boolean, If True (the default) workers will be
killed gracefully (ie. trying to wait for the current connection)
| \
Stop workers | def stop(self, graceful=True):
"""\
Stop workers
:attr graceful: boolean, If True (the default) workers will be
killed gracefully (ie. trying to wait for the current connection)
"""
unlink = (
self.reexec_pid == self.master_pid == 0
and not self.... | [
"def",
"stop",
"(",
"self",
",",
"graceful",
"=",
"True",
")",
":",
"unlink",
"=",
"(",
"self",
".",
"reexec_pid",
"==",
"self",
".",
"master_pid",
"==",
"0",
"and",
"not",
"self",
".",
"systemd",
"and",
"not",
"self",
".",
"cfg",
".",
"reuse_port",
... | [
369,
4
] | [
394,
41
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.reexec | (self) | \
Relaunch the master and workers.
| \
Relaunch the master and workers.
| def reexec(self):
"""\
Relaunch the master and workers.
"""
if self.reexec_pid != 0:
self.log.warning("USR2 signal ignored. Child exists.")
return
if self.master_pid != 0:
self.log.warning("USR2 signal ignored. Parent exists.")
ret... | [
"def",
"reexec",
"(",
"self",
")",
":",
"if",
"self",
".",
"reexec_pid",
"!=",
"0",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"USR2 signal ignored. Child exists.\"",
")",
"return",
"if",
"self",
".",
"master_pid",
"!=",
"0",
":",
"self",
".",
"log"... | [
396,
4
] | [
428,
70
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.murder_workers | (self) | \
Kill unused/idle workers
| \
Kill unused/idle workers
| def murder_workers(self):
"""\
Kill unused/idle workers
"""
if not self.timeout:
return
workers = list(self.WORKERS.items())
for (pid, worker) in workers:
try:
if time.time() - worker.tmp.last_update() <= self.timeout:
... | [
"def",
"murder_workers",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"timeout",
":",
"return",
"workers",
"=",
"list",
"(",
"self",
".",
"WORKERS",
".",
"items",
"(",
")",
")",
"for",
"(",
"pid",
",",
"worker",
")",
"in",
"workers",
":",
"try"... | [
485,
4
] | [
504,
53
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.reap_workers | (self) | \
Reap workers to avoid zombie processes
| \
Reap workers to avoid zombie processes
| def reap_workers(self):
"""\
Reap workers to avoid zombie processes
"""
try:
while True:
wpid, status = os.waitpid(-1, os.WNOHANG)
if not wpid:
break
if self.reexec_pid == wpid:
self.reexe... | [
"def",
"reap_workers",
"(",
"self",
")",
":",
"try",
":",
"while",
"True",
":",
"wpid",
",",
"status",
"=",
"os",
".",
"waitpid",
"(",
"-",
"1",
",",
"os",
".",
"WNOHANG",
")",
"if",
"not",
"wpid",
":",
"break",
"if",
"self",
".",
"reexec_pid",
"... | [
506,
4
] | [
536,
21
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.manage_workers | (self) | \
Maintain the number of workers by spawning or killing
as required.
| \
Maintain the number of workers by spawning or killing
as required.
| def manage_workers(self):
"""\
Maintain the number of workers by spawning or killing
as required.
"""
if len(self.WORKERS) < self.num_workers:
self.spawn_workers()
workers = self.WORKERS.items()
workers = sorted(workers, key=lambda w: w[1].age)
... | [
"def",
"manage_workers",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"WORKERS",
")",
"<",
"self",
".",
"num_workers",
":",
"self",
".",
"spawn_workers",
"(",
")",
"workers",
"=",
"self",
".",
"WORKERS",
".",
"items",
"(",
")",
"workers",
"=... | [
538,
4
] | [
558,
52
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.spawn_workers | (self) | \
Spawn new workers as needed.
This is where a worker process leaves the main loop
of the master process.
| \
Spawn new workers as needed. | def spawn_workers(self):
"""\
Spawn new workers as needed.
This is where a worker process leaves the main loop
of the master process.
"""
for _ in range(self.num_workers - len(self.WORKERS)):
self.spawn_worker()
time.sleep(0.1 * random.random()) | [
"def",
"spawn_workers",
"(",
"self",
")",
":",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"num_workers",
"-",
"len",
"(",
"self",
".",
"WORKERS",
")",
")",
":",
"self",
".",
"spawn_worker",
"(",
")",
"time",
".",
"sleep",
"(",
"0.1",
"*",
"random... | [
606,
4
] | [
616,
45
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.kill_workers | (self, sig) | \
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
| \
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
| def kill_workers(self, sig):
"""\
Kill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
"""
worker_pids = list(self.WORKERS.keys())
for pid in worker_pids:
self.kill_worker(pid, sig) | [
"def",
"kill_workers",
"(",
"self",
",",
"sig",
")",
":",
"worker_pids",
"=",
"list",
"(",
"self",
".",
"WORKERS",
".",
"keys",
"(",
")",
")",
"for",
"pid",
"in",
"worker_pids",
":",
"self",
".",
"kill_worker",
"(",
"pid",
",",
"sig",
")"
] | [
618,
4
] | [
625,
38
] | python | en | ['en', 'ja', 'hi'] | False |
Arbiter.kill_worker | (self, pid, sig) | \
Kill a worker
:attr pid: int, worker pid
:attr sig: `signal.SIG*` value
| \
Kill a worker | def kill_worker(self, pid, sig):
"""\
Kill a worker
:attr pid: int, worker pid
:attr sig: `signal.SIG*` value
"""
try:
os.kill(pid, sig)
except OSError as e:
if e.errno == errno.ESRCH:
try:
worker = sel... | [
"def",
"kill_worker",
"(",
"self",
",",
"pid",
",",
"sig",
")",
":",
"try",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"sig",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"e",
".",
"errno",
"==",
"errno",
".",
"ESRCH",
":",
"try",
":",
"worker... | [
627,
4
] | [
645,
17
] | python | en | ['en', 'ja', 'hi'] | False |
RelativeLinksHelpExtension.extendMarkdown | (self, md: Markdown) | Add RelativeLinksHelpExtension to the Markdown instance. | Add RelativeLinksHelpExtension to the Markdown instance. | def extendMarkdown(self, md: Markdown) -> None:
"""Add RelativeLinksHelpExtension to the Markdown instance."""
md.registerExtension(self)
md.preprocessors.register(RelativeLinks(), "help_relative_links", 520) | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
":",
"Markdown",
")",
"->",
"None",
":",
"md",
".",
"registerExtension",
"(",
"self",
")",
"md",
".",
"preprocessors",
".",
"register",
"(",
"RelativeLinks",
"(",
")",
",",
"\"help_relative_links\"",
",",
"5... | [
72,
4
] | [
75,
78
] | python | en | ['en', 'en', 'en'] | True |
TestFlows._test_flow_correct_dims_NN | (self, flow_name) |
General structure:
flow_params = MLP(x)
pdf(y|x) = flow(y, flow_params)
The tensor being transformed (=y) are of shape (batch_size, event_dims)
- batch_size = len(x) == len(y)
- event_dims = rank(y)
For each element of x, the MLP outputs one parametrization for... |
General structure:
flow_params = MLP(x)
pdf(y|x) = flow(y, flow_params) | def _test_flow_correct_dims_NN(self, flow_name):
"""
General structure:
flow_params = MLP(x)
pdf(y|x) = flow(y, flow_params)
The tensor being transformed (=y) are of shape (batch_size, event_dims)
- batch_size = len(x) == len(y)
- event_dims = rank(y)
Fo... | [
"def",
"_test_flow_correct_dims_NN",
"(",
"self",
",",
"flow_name",
")",
":",
"tests",
"=",
"[",
"{",
"'x'",
":",
"[",
"[",
"1.",
"]",
",",
"[",
"0.",
"]",
",",
"[",
"2.",
"]",
",",
"[",
"4.",
"]",
",",
"[",
"1.",
"]",
"]",
",",
"'y'",
":",
... | [
43,
4
] | [
100,
63
] | python | en | ['en', 'error', 'th'] | False |
CosineDistance.distance | (self, x, y) |
Computes distance measure between vectors x and y. Returns float.
|
Computes distance measure between vectors x and y. Returns float.
| def distance(self, x, y):
"""
Computes distance measure between vectors x and y. Returns float.
"""
if scipy.sparse.issparse(x):
x = x.toarray().ravel()
y = y.toarray().ravel()
return 1.0 - numpy.dot(x, y) | [
"def",
"distance",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"scipy",
".",
"sparse",
".",
"issparse",
"(",
"x",
")",
":",
"x",
"=",
"x",
".",
"toarray",
"(",
")",
".",
"ravel",
"(",
")",
"y",
"=",
"y",
".",
"toarray",
"(",
")",
".",
... | [
31,
4
] | [
39,
36
] | python | en | ['en', 'error', 'th'] | False |
setup | (pipe_config, supplied_mon_coords=None) |
Initialises the pipeline run.
|
Initialises the pipeline run.
| def setup(pipe_config, supplied_mon_coords=None):
"""
Initialises the pipeline run.
"""
if not supplied_mon_coords:
supplied_mon_coords = []
# Setup logfile before we do anything else
log_dir = pipe_config.logging.log_dir
setup_logging(log_dir, debug=pipe_config.logging.debug,
... | [
"def",
"setup",
"(",
"pipe_config",
",",
"supplied_mon_coords",
"=",
"None",
")",
":",
"if",
"not",
"supplied_mon_coords",
":",
"supplied_mon_coords",
"=",
"[",
"]",
"# Setup logfile before we do anything else",
"log_dir",
"=",
"pipe_config",
".",
"logging",
".",
"l... | [
41,
0
] | [
70,
42
] | python | en | ['en', 'error', 'th'] | False |
get_runner | (pipe_config) |
get parallelise props. Defaults to multiproc with autodetect num cores. Wil
initialise the distributor.
One should not mix threads and multiprocessing, but for example AstroPy uses
threads internally. Best practice then is to first do multiprocessing,
and then threading per process. This is the re... |
get parallelise props. Defaults to multiproc with autodetect num cores. Wil
initialise the distributor. | def get_runner(pipe_config):
"""
get parallelise props. Defaults to multiproc with autodetect num cores. Wil
initialise the distributor.
One should not mix threads and multiprocessing, but for example AstroPy uses
threads internally. Best practice then is to first do multiprocessing,
and then t... | [
"def",
"get_runner",
"(",
"pipe_config",
")",
":",
"para",
"=",
"pipe_config",
".",
"parallelise",
"logging",
".",
"info",
"(",
"\"using '{}' method for parallellisation\"",
".",
"format",
"(",
"para",
".",
"method",
")",
")",
"distributor",
"=",
"os",
".",
"e... | [
73,
0
] | [
87,
60
] | python | en | ['en', 'error', 'th'] | False |
load_images | (job_name, job_dir) |
Load all the images for a specific TraP job.
returns:
tuple: a list of paths
|
Load all the images for a specific TraP job. | def load_images(job_name, job_dir):
"""
Load all the images for a specific TraP job.
returns:
tuple: a list of paths
"""
path = os.path.join(job_dir, 'images_to_process.py')
images = imp.load_source('images_to_process', path).images
logger.info("dataset %s contains %s images" % (job... | [
"def",
"load_images",
"(",
"job_name",
",",
"job_dir",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"job_dir",
",",
"'images_to_process.py'",
")",
"images",
"=",
"imp",
".",
"load_source",
"(",
"'images_to_process'",
",",
"path",
")",
".",
... | [
90,
0
] | [
101,
17
] | python | en | ['en', 'error', 'th'] | False |
initialise_dataset | (job_config, supplied_mon_coords) |
sets up a dataset in the database.
if the dataset already exists it will return the job_config from the
previous dataset run.
args:
job_config: a job configuration object
supplied_mon_coords (tuple): a list of monitoring positions
returns:
tuple: job_config and dataset ID... |
sets up a dataset in the database. | def initialise_dataset(job_config, supplied_mon_coords):
"""
sets up a dataset in the database.
if the dataset already exists it will return the job_config from the
previous dataset run.
args:
job_config: a job configuration object
supplied_mon_coords (tuple): a list of monitoring ... | [
"def",
"initialise_dataset",
"(",
"job_config",
",",
"supplied_mon_coords",
")",
":",
"dataset_id",
"=",
"create_dataset",
"(",
"job_config",
".",
"persistence",
".",
"dataset_id",
",",
"job_config",
".",
"persistence",
".",
"description",
")",
"if",
"job_config",
... | [
112,
0
] | [
146,
33
] | python | en | ['en', 'error', 'th'] | False |
extract_metadata | (job_config, accessors, runner) |
args:
job_config: a TKP config object
accessors (tuple): list of tkp.Accessor objects
runner (tkp.distribute.Runner): the runner to use
returns:
tuple: a list of metadata dicts
| def extract_metadata(job_config, accessors, runner):
"""
args:
job_config: a TKP config object
accessors (tuple): list of tkp.Accessor objects
runner (tkp.distribute.Runner): the runner to use
returns:
tuple: a list of metadata dicts
"""
logger.debug("Extracting met... | [
"def",
"extract_metadata",
"(",
"job_config",
",",
"accessors",
",",
"runner",
")",
":",
"logger",
".",
"debug",
"(",
"\"Extracting metadata from images\"",
")",
"imgs",
"=",
"[",
"[",
"a",
"]",
"for",
"a",
"in",
"accessors",
"]",
"metadatas",
"=",
"runner",... | [
149,
0
] | [
167,
20
] | python | en | ['en', 'error', 'th'] | False | |
quality_check | (db_images, accessors, job_config, runner) |
returns:
tuple: a list of db_image and accessor tuples
|
returns:
tuple: a list of db_image and accessor tuples
| def quality_check(db_images, accessors, job_config, runner):
"""
returns:
tuple: a list of db_image and accessor tuples
"""
logger.info("performing quality check")
arguments = [job_config]
rejecteds = runner.map("quality_reject_check", accessors, arguments)
db = tkp.db.Database()
... | [
"def",
"quality_check",
"(",
"db_images",
",",
"accessors",
",",
"job_config",
",",
"runner",
")",
":",
"logger",
".",
"info",
"(",
"\"performing quality check\"",
")",
"arguments",
"=",
"[",
"job_config",
"]",
"rejecteds",
"=",
"runner",
".",
"map",
"(",
"\... | [
190,
0
] | [
229,
22
] | python | en | ['en', 'error', 'th'] | False |
get_metadata_for_sorting | (runner, image_paths) |
Group images per timestamp. Will open all images in parallel using runner.
args:
runner (tkp.distribute.Runner): Runner to use for distribution
image_paths (tuple): list of image paths
returns:
tuple: list of tuples, (timestamp, [list_of_images])
|
Group images per timestamp. Will open all images in parallel using runner. | def get_metadata_for_sorting(runner, image_paths):
"""
Group images per timestamp. Will open all images in parallel using runner.
args:
runner (tkp.distribute.Runner): Runner to use for distribution
image_paths (tuple): list of image paths
returns:
tuple: list of tuples, (timest... | [
"def",
"get_metadata_for_sorting",
"(",
"runner",
",",
"image_paths",
")",
":",
"nested_img",
"=",
"[",
"[",
"i",
"]",
"for",
"i",
"in",
"image_paths",
"]",
"results",
"=",
"runner",
".",
"map",
"(",
"\"get_metadata_for_ordering\"",
",",
"nested_img",
")",
"... | [
297,
0
] | [
314,
17
] | python | en | ['en', 'error', 'th'] | False |
timestamp_step | (runner, images, job_config, dataset_id, copy_images) |
Called from the main loop with all images in a certain timestep
args:
runner (tkp.distribute.Runner): Runner to use for distribution
images (tuple): list of things tkp.accessors can handle, like image
paths or fits objects
job_config: a tkp job config object
... |
Called from the main loop with all images in a certain timestep | def timestamp_step(runner, images, job_config, dataset_id, copy_images):
"""
Called from the main loop with all images in a certain timestep
args:
runner (tkp.distribute.Runner): Runner to use for distribution
images (tuple): list of things tkp.accessors can handle, like image
... | [
"def",
"timestamp_step",
"(",
"runner",
",",
"images",
",",
"job_config",
",",
"dataset_id",
",",
"copy_images",
")",
":",
"# gather all image info",
"accessors",
"=",
"get_accessors",
"(",
"runner",
",",
"images",
")",
"metadatas",
"=",
"extract_metadata",
"(",
... | [
322,
0
] | [
374,
25
] | python | en | ['en', 'error', 'th'] | False |
run_stream | (runner, job_config, dataset_id, copy_images) |
Run the pipeline in stream mode.
Daemon function, doesn't return.
args:
runner (tkp.distribute.Runner): Runner to use for distribution
job_config: a job configuration object
dataset_id (int): The dataset ID to use
|
Run the pipeline in stream mode. | def run_stream(runner, job_config, dataset_id, copy_images):
"""
Run the pipeline in stream mode.
Daemon function, doesn't return.
args:
runner (tkp.distribute.Runner): Runner to use for distribution
job_config: a job configuration object
dataset_id (int): The dataset ID to ... | [
"def",
"run_stream",
"(",
"runner",
",",
"job_config",
",",
"dataset_id",
",",
"copy_images",
")",
":",
"hosts",
"=",
"job_config",
".",
"pipeline",
".",
"hosts",
".",
"split",
"(",
"','",
")",
"ports",
"=",
"[",
"int",
"(",
"p",
")",
"for",
"p",
"in... | [
377,
0
] | [
401,
67
] | python | en | ['en', 'error', 'th'] | False |
run_batch | (image_paths, job_config, runner, dataset_id, copy_images) |
Run the pipeline in batch mode.
args:
job_name (str): job name, used for locating images script
pipe_config: the pipeline configuration object
job_config: a job configuration object
runner (tkp.distribute.Runner): Runner to use for distribution
dataset_id (int): The dat... |
Run the pipeline in batch mode. | def run_batch(image_paths, job_config, runner, dataset_id, copy_images):
"""
Run the pipeline in batch mode.
args:
job_name (str): job name, used for locating images script
pipe_config: the pipeline configuration object
job_config: a job configuration object
runner (tkp.dist... | [
"def",
"run_batch",
"(",
"image_paths",
",",
"job_config",
",",
"runner",
",",
"dataset_id",
",",
"copy_images",
")",
":",
"sorting_metadata",
"=",
"get_metadata_for_sorting",
"(",
"runner",
",",
"image_paths",
")",
"grouped_images",
"=",
"group_per_timestep",
"(",
... | [
404,
0
] | [
424,
84
] | python | en | ['en', 'error', 'th'] | False |
run | (job_name, supplied_mon_coords=None) |
TKP pipeline main loop entry point.
args:
job_name (str): name of the jbo to run
supplied_mon_coords (tuple): list of coordinates to monitor
|
TKP pipeline main loop entry point. | def run(job_name, supplied_mon_coords=None):
"""
TKP pipeline main loop entry point.
args:
job_name (str): name of the jbo to run
supplied_mon_coords (tuple): list of coordinates to monitor
"""
pipe_config = get_pipe_config(job_name)
runner = get_runner(pipe_config)
job_dir,... | [
"def",
"run",
"(",
"job_name",
",",
"supplied_mon_coords",
"=",
"None",
")",
":",
"pipe_config",
"=",
"get_pipe_config",
"(",
"job_name",
")",
"runner",
"=",
"get_runner",
"(",
"pipe_config",
")",
"job_dir",
",",
"job_config",
",",
"dataset_id",
"=",
"setup",
... | [
427,
0
] | [
447,
75
] | python | en | ['en', 'error', 'th'] | False |
TestFinalStatusReporter.test_log_messages_duration | (self) |
Test duration report
:return:
|
Test duration report
:return:
| def test_log_messages_duration(self):
"""
Test duration report
:return:
"""
obj = FinalStatus()
obj.engine = EngineEmul()
obj.parameters = BetterDict()
self.sniff_log(obj.log)
obj.prepare()
obj.startup()
obj.shutdown()
obj.s... | [
"def",
"test_log_messages_duration",
"(",
"self",
")",
":",
"obj",
"=",
"FinalStatus",
"(",
")",
"obj",
".",
"engine",
"=",
"EngineEmul",
"(",
")",
"obj",
".",
"parameters",
"=",
"BetterDict",
"(",
")",
"self",
".",
"sniff_log",
"(",
"obj",
".",
"log",
... | [
89,
4
] | [
103,
99
] | python | en | ['en', 'error', 'th'] | False |
get_safe_phrase | (phrase: str) |
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
|
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
| def get_safe_phrase(phrase: str) -> str:
"""
Safe phrase is in lower case and doesn't contain characters which can
conflict with split boundaries. All conflicting characters are replaced
with low dash (_).
"""
phrase = SPLIT_BOUNDARY_REGEX.sub("_", phrase)
return phrase.lower() | [
"def",
"get_safe_phrase",
"(",
"phrase",
":",
"str",
")",
"->",
"str",
":",
"phrase",
"=",
"SPLIT_BOUNDARY_REGEX",
".",
"sub",
"(",
"\"_\"",
",",
"phrase",
")",
"return",
"phrase",
".",
"lower",
"(",
")"
] | [
190,
0
] | [
197,
25
] | python | en | ['en', 'error', 'th'] | False |
replace_with_safe_phrase | (matchobj: Match[str]) |
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
|
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of the phrase
to upper case.
| def replace_with_safe_phrase(matchobj: Match[str]) -> str:
"""
The idea is to convert IGNORED_PHRASES into safe phrases, see
`get_safe_phrase()` function. The only exception is when the
IGNORED_PHRASE is at the start of the text or after a split
boundary; in this case, we change the first letter of ... | [
"def",
"replace_with_safe_phrase",
"(",
"matchobj",
":",
"Match",
"[",
"str",
"]",
")",
"->",
"str",
":",
"ignored_phrase",
"=",
"matchobj",
".",
"group",
"(",
"0",
")",
"safe_string",
"=",
"get_safe_phrase",
"(",
"ignored_phrase",
")",
"start_index",
"=",
"... | [
200,
0
] | [
222,
22
] | python | en | ['en', 'error', 'th'] | False |
get_safe_text | (text: str) |
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
|
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
| def get_safe_text(text: str) -> str:
"""
This returns text which is rendered by BeautifulSoup and is in the
form that can be split easily and has all IGNORED_PHRASES processed.
"""
soup = BeautifulSoup(text, "lxml")
text = " ".join(soup.text.split()) # Remove extra whitespaces.
for phrase_r... | [
"def",
"get_safe_text",
"(",
"text",
":",
"str",
")",
"->",
"str",
":",
"soup",
"=",
"BeautifulSoup",
"(",
"text",
",",
"\"lxml\"",
")",
"text",
"=",
"\" \"",
".",
"join",
"(",
"soup",
".",
"text",
".",
"split",
"(",
")",
")",
"# Remove extra whitespac... | [
225,
0
] | [
235,
15
] | python | en | ['en', 'error', 'th'] | False |
to_unicode | (s) |
Convert strings to Unicode objects (and return all other data types
unchanged).
|
Convert strings to Unicode objects (and return all other data types
unchanged).
| def to_unicode(s):
"""
Convert strings to Unicode objects (and return all other data types
unchanged).
"""
if isinstance(s, six.string_types):
return force_text(s)
return s | [
"def",
"to_unicode",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"six",
".",
"string_types",
")",
":",
"return",
"force_text",
"(",
"s",
")",
"return",
"s"
] | [
588,
0
] | [
595,
12
] | python | en | ['en', 'error', 'th'] | False |
DatabaseWrapper.check_constraints | (self, table_names=None) |
To check constraints, we set constraints to immediate. Then, when, we're done we must ensure they
are returned to deferred.
|
To check constraints, we set constraints to immediate. Then, when, we're done we must ensure they
are returned to deferred.
| def check_constraints(self, table_names=None):
"""
To check constraints, we set constraints to immediate. Then, when, we're done we must ensure they
are returned to deferred.
"""
self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
self.cursor().execute('SET CONSTRAINTS... | [
"def",
"check_constraints",
"(",
"self",
",",
"table_names",
"=",
"None",
")",
":",
"self",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"'SET CONSTRAINTS ALL IMMEDIATE'",
")",
"self",
".",
"cursor",
"(",
")",
".",
"execute",
"(",
"'SET CONSTRAINTS ALL DEFERR... | [
284,
4
] | [
290,
61
] | python | en | ['en', 'error', 'th'] | False |
endswith_cr | (line) |
Return True if line (a text or byte string) ends with '\r'.
|
Return True if line (a text or byte string) ends with '\r'.
| def endswith_cr(line):
"""
Return True if line (a text or byte string) ends with '\r'.
"""
return line.endswith('\r' if isinstance(line, six.text_type) else b'\r') | [
"def",
"endswith_cr",
"(",
"line",
")",
":",
"return",
"line",
".",
"endswith",
"(",
"'\\r'",
"if",
"isinstance",
"(",
"line",
",",
"six",
".",
"text_type",
")",
"else",
"b'\\r'",
")"
] | [
172,
0
] | [
176,
76
] | python | en | ['en', 'error', 'th'] | False |
endswith_lf | (line) |
Return True if line (a text or byte string) ends with '\n'.
|
Return True if line (a text or byte string) ends with '\n'.
| def endswith_lf(line):
"""
Return True if line (a text or byte string) ends with '\n'.
"""
return line.endswith('\n' if isinstance(line, six.text_type) else b'\n') | [
"def",
"endswith_lf",
"(",
"line",
")",
":",
"return",
"line",
".",
"endswith",
"(",
"'\\n'",
"if",
"isinstance",
"(",
"line",
",",
"six",
".",
"text_type",
")",
"else",
"b'\\n'",
")"
] | [
179,
0
] | [
183,
76
] | python | en | ['en', 'error', 'th'] | False |
equals_lf | (line) |
Return True if line (a text or byte string) equals '\n'.
|
Return True if line (a text or byte string) equals '\n'.
| def equals_lf(line):
"""
Return True if line (a text or byte string) equals '\n'.
"""
return line == ('\n' if isinstance(line, six.text_type) else b'\n') | [
"def",
"equals_lf",
"(",
"line",
")",
":",
"return",
"line",
"==",
"(",
"'\\n'",
"if",
"isinstance",
"(",
"line",
",",
"six",
".",
"text_type",
")",
"else",
"b'\\n'",
")"
] | [
186,
0
] | [
190,
71
] | python | en | ['en', 'error', 'th'] | False |
Config._cast_boolean | (self, value) |
Helper to convert config values to boolean as ConfigParser do.
|
Helper to convert config values to boolean as ConfigParser do.
| def _cast_boolean(self, value):
"""
Helper to convert config values to boolean as ConfigParser do.
"""
value = str(value)
if value.lower() not in self._BOOLEANS:
raise ValueError('Not a boolean: %s' % value)
return self._BOOLEANS[value.lower()] | [
"def",
"_cast_boolean",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"if",
"value",
".",
"lower",
"(",
")",
"not",
"in",
"self",
".",
"_BOOLEANS",
":",
"raise",
"ValueError",
"(",
"'Not a boolean: %s'",
"%",
"value",
")"... | [
43,
4
] | [
51,
44
] | python | en | ['en', 'error', 'th'] | False |
Config.get | (self, option, default=undefined, cast=undefined) |
Return the value for option or default if defined.
|
Return the value for option or default if defined.
| def get(self, option, default=undefined, cast=undefined):
"""
Return the value for option or default if defined.
"""
# We can't avoid __contains__ because value may be empty.
if option in os.environ:
value = os.environ[option]
elif option in self.repository:
... | [
"def",
"get",
"(",
"self",
",",
"option",
",",
"default",
"=",
"undefined",
",",
"cast",
"=",
"undefined",
")",
":",
"# We can't avoid __contains__ because value may be empty.",
"if",
"option",
"in",
"os",
".",
"environ",
":",
"value",
"=",
"os",
".",
"environ... | [
57,
4
] | [
78,
26
] | python | en | ['en', 'error', 'th'] | False |
Config.__call__ | (self, *args, **kwargs) |
Convenient shortcut to get.
|
Convenient shortcut to get.
| def __call__(self, *args, **kwargs):
"""
Convenient shortcut to get.
"""
return self.get(*args, **kwargs) | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | [
80,
4
] | [
84,
40
] | python | en | ['en', 'error', 'th'] | False |
Csv.__init__ | (self, cast=text_type, delimiter=',', strip=string.whitespace, post_process=list) |
Parameters:
cast -- callable that transforms the item just before it's added to the list.
delimiter -- string of delimiters chars passed to shlex.
strip -- string of non-relevant characters to be passed to str.strip after the split.
tuple_ -- boolean to check if it is to return ... |
Parameters:
cast -- callable that transforms the item just before it's added to the list.
delimiter -- string of delimiters chars passed to shlex.
strip -- string of non-relevant characters to be passed to str.strip after the split.
tuple_ -- boolean to check if it is to return ... | def __init__(self, cast=text_type, delimiter=',', strip=string.whitespace, post_process=list):
"""
Parameters:
cast -- callable that transforms the item just before it's added to the list.
delimiter -- string of delimiters chars passed to shlex.
strip -- string of non-relevant ch... | [
"def",
"__init__",
"(",
"self",
",",
"cast",
"=",
"text_type",
",",
"delimiter",
"=",
"','",
",",
"strip",
"=",
"string",
".",
"whitespace",
",",
"post_process",
"=",
"list",
")",
":",
"self",
".",
"cast",
"=",
"cast",
"self",
".",
"delimiter",
"=",
... | [
211,
4
] | [
222,
40
] | python | en | ['en', 'error', 'th'] | False |
Csv.__call__ | (self, value) | The actual transformation | The actual transformation | def __call__(self, value):
"""The actual transformation"""
transform = lambda s: self.cast(s.strip(self.strip))
splitter = shlex(value, posix=True)
splitter.whitespace = self.delimiter
splitter.whitespace_split = True
return self.post_process(transform(s) for s in split... | [
"def",
"__call__",
"(",
"self",
",",
"value",
")",
":",
"transform",
"=",
"lambda",
"s",
":",
"self",
".",
"cast",
"(",
"s",
".",
"strip",
"(",
"self",
".",
"strip",
")",
")",
"splitter",
"=",
"shlex",
"(",
"value",
",",
"posix",
"=",
"True",
")"... | [
224,
4
] | [
232,
64
] | python | en | ['en', 'en', 'en'] | True |
TestApproveRejectModeration.test_approve_moderation_view | (self) |
This posts to the approve moderation view and checks that the page was approved
|
This posts to the approve moderation view and checks that the page was approved
| def test_approve_moderation_view(self):
"""
This posts to the approve moderation view and checks that the page was approved
"""
# Connect a mock signal handler to page_published signal
mock_handler = mock.MagicMock()
page_published.connect(mock_handler)
# Post
... | [
"def",
"test_approve_moderation_view",
"(",
"self",
")",
":",
"# Connect a mock signal handler to page_published signal",
"mock_handler",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"page_published",
".",
"connect",
"(",
"mock_handler",
")",
"# Post",
"response",
"=",
"sel... | [
43,
4
] | [
72,
78
] | python | en | ['en', 'error', 'th'] | False |
TestApproveRejectModeration.test_approve_moderation_view_bad_revision_id | (self) |
This tests that the approve moderation view handles invalid revision ids correctly
|
This tests that the approve moderation view handles invalid revision ids correctly
| def test_approve_moderation_view_bad_revision_id(self):
"""
This tests that the approve moderation view handles invalid revision ids correctly
"""
# Post
response = self.client.post(reverse('wagtailadmin_pages:approve_moderation', args=(12345, )))
# Check that the user r... | [
"def",
"test_approve_moderation_view_bad_revision_id",
"(",
"self",
")",
":",
"# Post",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:approve_moderation'",
",",
"args",
"=",
"(",
"12345",
",",
")",
")",
")",
"# Ch... | [
94,
4
] | [
102,
51
] | python | en | ['en', 'error', 'th'] | False |
TestApproveRejectModeration.test_approve_moderation_view_bad_permissions | (self) |
This tests that the approve moderation view doesn't allow users without moderation permissions
|
This tests that the approve moderation view doesn't allow users without moderation permissions
| def test_approve_moderation_view_bad_permissions(self):
"""
This tests that the approve moderation view doesn't allow users without moderation permissions
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
Permissi... | [
"def",
"test_approve_moderation_view_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
... | [
104,
4
] | [
119,
51
] | python | en | ['en', 'error', 'th'] | False |
TestApproveRejectModeration.test_reject_moderation_view | (self) |
This posts to the reject moderation view and checks that the page was rejected
|
This posts to the reject moderation view and checks that the page was rejected
| def test_reject_moderation_view(self):
"""
This posts to the reject moderation view and checks that the page was rejected
"""
# Post
response = self.client.post(reverse('wagtailadmin_pages:reject_moderation', args=(self.revision.id, )))
# Check that the user was redirect... | [
"def",
"test_reject_moderation_view",
"(",
"self",
")",
":",
"# Post",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:reject_moderation'",
",",
"args",
"=",
"(",
"self",
".",
"revision",
".",
"id",
",",
")",
")... | [
121,
4
] | [
135,
96
] | python | en | ['en', 'error', 'th'] | False |
TestApproveRejectModeration.test_reject_moderation_view_bad_revision_id | (self) |
This tests that the reject moderation view handles invalid revision ids correctly
|
This tests that the reject moderation view handles invalid revision ids correctly
| def test_reject_moderation_view_bad_revision_id(self):
"""
This tests that the reject moderation view handles invalid revision ids correctly
"""
# Post
response = self.client.post(reverse('wagtailadmin_pages:reject_moderation', args=(12345, )))
# Check that the user rece... | [
"def",
"test_reject_moderation_view_bad_revision_id",
"(",
"self",
")",
":",
"# Post",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:reject_moderation'",
",",
"args",
"=",
"(",
"12345",
",",
")",
")",
")",
"# Chec... | [
137,
4
] | [
145,
51
] | python | en | ['en', 'error', 'th'] | False |
TestApproveRejectModeration.test_reject_moderation_view_bad_permissions | (self) |
This tests that the reject moderation view doesn't allow users without moderation permissions
|
This tests that the reject moderation view doesn't allow users without moderation permissions
| def test_reject_moderation_view_bad_permissions(self):
"""
This tests that the reject moderation view doesn't allow users without moderation permissions
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
Permission... | [
"def",
"test_reject_moderation_view_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
... | [
147,
4
] | [
162,
51
] | python | en | ['en', 'error', 'th'] | False |
TestNotificationPreferences.silent_submit | (self) |
Sets up the child_page as needing moderation, without making a request
|
Sets up the child_page as needing moderation, without making a request
| def silent_submit(self):
"""
Sets up the child_page as needing moderation, without making a request
"""
self.child_page.save_revision(user=self.submitter, submitted_for_moderation=True)
self.revision = self.child_page.get_latest_revision() | [
"def",
"silent_submit",
"(",
"self",
")",
":",
"self",
".",
"child_page",
".",
"save_revision",
"(",
"user",
"=",
"self",
".",
"submitter",
",",
"submitted_for_moderation",
"=",
"True",
")",
"self",
".",
"revision",
"=",
"self",
".",
"child_page",
".",
"ge... | [
212,
4
] | [
217,
61
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_bool_prop | (self, element, prop_name) |
Gets bool prop from element
:param element:
:param prop_name:
:return:
|
Gets bool prop from element
:param element:
:param prop_name:
:return:
| def _get_bool_prop(self, element, prop_name):
"""
Gets bool prop from element
:param element:
:param prop_name:
:return:
"""
prop_element = element.find(".//boolProp[@name='" + prop_name + "']")
if prop_element is not None and prop_element.text:
... | [
"def",
"_get_bool_prop",
"(",
"self",
",",
"element",
",",
"prop_name",
")",
":",
"prop_element",
"=",
"element",
".",
"find",
"(",
"\".//boolProp[@name='\"",
"+",
"prop_name",
"+",
"\"']\"",
")",
"if",
"prop_element",
"is",
"not",
"None",
"and",
"prop_element... | [
101,
4
] | [
116,
23
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_string_prop | (self, element, prop_name, default=None) |
Gets string prop from element
:param element:
:param prop_name:
:return:
|
Gets string prop from element
:param element:
:param prop_name:
:return:
| def _get_string_prop(self, element, prop_name, default=None):
"""
Gets string prop from element
:param element:
:param prop_name:
:return:
"""
prop_element = element.find(".//stringProp[@name='" + prop_name + "']")
if prop_element is not None and prop_elem... | [
"def",
"_get_string_prop",
"(",
"self",
",",
"element",
",",
"prop_name",
",",
"default",
"=",
"None",
")",
":",
"prop_element",
"=",
"element",
".",
"find",
"(",
"\".//stringProp[@name='\"",
"+",
"prop_name",
"+",
"\"']\"",
")",
"if",
"prop_element",
"is",
... | [
118,
4
] | [
130,
26
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_concurrency | (self, element) |
concurrency option in tg execution settings
:return:
|
concurrency option in tg execution settings
:return:
| def _get_concurrency(self, element):
"""
concurrency option in tg execution settings
:return:
"""
if element.tag == "ThreadGroup":
concurrency_tag_name = 'ThreadGroup.num_threads'
else:
concurrency_tag_name = 'TargetLevel'
concurrency = sel... | [
"def",
"_get_concurrency",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
".",
"tag",
"==",
"\"ThreadGroup\"",
":",
"concurrency_tag_name",
"=",
"'ThreadGroup.num_threads'",
"else",
":",
"concurrency_tag_name",
"=",
"'TargetLevel'",
"concurrency",
"=",
"sel... | [
132,
4
] | [
143,
26
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_ramp_up | (self, element) |
ramp_up option in tg settings
:param element:
:return:
|
ramp_up option in tg settings
:param element:
:return:
| def _get_ramp_up(self, element):
"""
ramp_up option in tg settings
:param element:
:return:
"""
if element.tag == "ThreadGroup":
ramp_up = self._get_option_string_with_default(element, 'ThreadGroup.ramp_time', "ramp-up", 1)
else:
unit = sel... | [
"def",
"_get_ramp_up",
"(",
"self",
",",
"element",
")",
":",
"if",
"element",
".",
"tag",
"==",
"\"ThreadGroup\"",
":",
"ramp_up",
"=",
"self",
".",
"_get_option_string_with_default",
"(",
"element",
",",
"'ThreadGroup.ramp_time'",
",",
"\"ramp-up\"",
",",
"1",... | [
145,
4
] | [
159,
22
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_iterations | (self, element) |
iteration option in tg execution settings
:param element:
:return:
|
iteration option in tg execution settings
:param element:
:return:
| def _get_iterations(self, element):
"""
iteration option in tg execution settings
:param element:
:return:
"""
controller_element = element.find('.//elementProp')
iterations = self._get_option_string_with_default(controller_element, 'LoopController.loops', "iterat... | [
"def",
"_get_iterations",
"(",
"self",
",",
"element",
")",
":",
"controller_element",
"=",
"element",
".",
"find",
"(",
"'.//elementProp'",
")",
"iterations",
"=",
"self",
".",
"_get_option_string_with_default",
"(",
"controller_element",
",",
"'LoopController.loops'... | [
161,
4
] | [
170,
25
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_duration | (self, tg_element) |
get hold_for and ramp_up from tg element.
:param tg_element:
:return:
|
get hold_for and ramp_up from tg element.
:param tg_element:
:return:
| def _get_duration(self, tg_element):
"""
get hold_for and ramp_up from tg element.
:param tg_element:
:return:
"""
result = {}
ramp_up = self._get_ramp_up(tg_element)
if self._get_bool_prop(tg_element, 'ThreadGroup.scheduler'):
duration_element... | [
"def",
"_get_duration",
"(",
"self",
",",
"tg_element",
")",
":",
"result",
"=",
"{",
"}",
"ramp_up",
"=",
"self",
".",
"_get_ramp_up",
"(",
"tg_element",
")",
"if",
"self",
".",
"_get_bool_prop",
"(",
"tg_element",
",",
"'ThreadGroup.scheduler'",
")",
":",
... | [
172,
4
] | [
201,
21
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_throughput | (self, element) |
Gets throughput from variable throughput timer
:param element:
:return:
|
Gets throughput from variable throughput timer
:param element:
:return:
| def _get_throughput(self, element):
"""
Gets throughput from variable throughput timer
:param element:
:return:
"""
result = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
property_pattern = "kg.apc.jmet... | [
"def",
"_get_throughput",
"(",
"self",
",",
"element",
")",
":",
"result",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"property_pat... | [
203,
4
] | [
226,
21
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_option_string_with_default | (self, element, prop_name, opt_name, default) |
:param element:
:return: dict
|
:param element:
:return: dict
| def _get_option_string_with_default(self, element, prop_name, opt_name, default):
"""
:param element:
:return: dict
"""
result = {}
if element is not None:
prop_value = self._get_string_prop(element, prop_name)
if prop_value and prop_value.isdigit(... | [
"def",
"_get_option_string_with_default",
"(",
"self",
",",
"element",
",",
"prop_name",
",",
"opt_name",
",",
"default",
")",
":",
"result",
"=",
"{",
"}",
"if",
"element",
"is",
"not",
"None",
":",
"prop_value",
"=",
"self",
".",
"_get_string_prop",
"(",
... | [
228,
4
] | [
238,
21
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_request_body | (self, element, request_config) |
Get body params from sampler
:param element:
:return: dict
|
Get body params from sampler
:param element:
:return: dict
| def _get_request_body(self, element, request_config):
"""
Get body params from sampler
:param element:
:return: dict
"""
raw_body = self._get_bool_prop(element, 'HTTPSampler.postBodyRaw')
query = 'elementProp[name="HTTPsampler.Arguments"]>collectionProp>elementPro... | [
"def",
"_get_request_body",
"(",
"self",
",",
"element",
",",
"request_config",
")",
":",
"raw_body",
"=",
"self",
".",
"_get_bool_prop",
"(",
"element",
",",
"'HTTPSampler.postBodyRaw'",
")",
"query",
"=",
"'elementProp[name=\"HTTPsampler.Arguments\"]>collectionProp>elem... | [
240,
4
] | [
260,
75
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_param_incompat | (self, param, val) |
check if parameter can be processed by standard way (see jmx.py _add_body_from_script)
or it must be joined with url string
|
check if parameter can be processed by standard way (see jmx.py _add_body_from_script)
or it must be joined with url string
| def _get_param_incompat(self, param, val):
"""
check if parameter can be processed by standard way (see jmx.py _add_body_from_script)
or it must be joined with url string
"""
if not self._get_bool_prop(param, "HTTPArgument.always_encode"):
return 'always_encode is of... | [
"def",
"_get_param_incompat",
"(",
"self",
",",
"param",
",",
"val",
")",
":",
"if",
"not",
"self",
".",
"_get_bool_prop",
"(",
"param",
",",
"\"HTTPArgument.always_encode\"",
")",
":",
"return",
"'always_encode is off'",
"if",
"not",
"val",
"and",
"self",
"."... | [
302,
4
] | [
310,
53
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_upload_files | (self, element) |
Extract upload files from element
:param element:
:return: dict
|
Extract upload files from element
:param element:
:return: dict
| def _get_upload_files(self, element):
"""
Extract upload files from element
:param element:
:return: dict
"""
query = 'elementProp[name="HTTPsampler.Files"]>collectionProp'
xpath = GenericTranslator().css_to_xpath(query)
colls = element.xpath(xpath)
... | [
"def",
"_get_upload_files",
"(",
"self",
",",
"element",
")",
":",
"query",
"=",
"'elementProp[name=\"HTTPsampler.Files\"]>collectionProp'",
"xpath",
"=",
"GenericTranslator",
"(",
")",
".",
"css_to_xpath",
"(",
"query",
")",
"colls",
"=",
"element",
".",
"xpath",
... | [
312,
4
] | [
333,
45
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_headers | (self, element) |
Get local request headers
:return:
|
Get local request headers
:return:
| def _get_headers(self, element):
"""
Get local request headers
:return:
"""
headers = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
headers_elements = [element for element in hashtree.iterchildren() if element.... | [
"def",
"_get_headers",
"(",
"self",
",",
"element",
")",
":",
"headers",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"headers_elemen... | [
335,
4
] | [
355,
26
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_store_cache | (self, element) |
store-cache option
:param element:
:return:
|
store-cache option
:param element:
:return:
| def _get_store_cache(self, element):
"""
store-cache option
:param element:
:return:
"""
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
cache_managers = [element for element in hashtree.iterchildren() if element.ta... | [
"def",
"_get_store_cache",
"(",
"self",
",",
"element",
")",
":",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"cache_managers",
"=",
"[",
"element",
... | [
357,
4
] | [
369,
17
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_store_cookie | (self, element) |
store-cookie option
:param element:
:return:
|
store-cookie option
:param element:
:return:
| def _get_store_cookie(self, element):
"""
store-cookie option
:param element:
:return:
"""
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
cookie_managers = [element for element in hashtree.iterchildren() if element... | [
"def",
"_get_store_cookie",
"(",
"self",
",",
"element",
")",
":",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"cookie_managers",
"=",
"[",
"element"... | [
371,
4
] | [
383,
17
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_dns_mgr | (self, element) |
use-dns-cache-mgr option
:param element:
:return:
|
use-dns-cache-mgr option
:param element:
:return:
| def _get_dns_mgr(self, element):
"""
use-dns-cache-mgr option
:param element:
:return:
"""
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
dns_managers = [element for element in hashtree.iterchildren() if element.ta... | [
"def",
"_get_dns_mgr",
"(",
"self",
",",
"element",
")",
":",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"dns_managers",
"=",
"[",
"element",
"for... | [
385,
4
] | [
397,
17
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict.__get_constant_timer | (self, element) |
think-time option
:param element:
:return:
|
think-time option
:param element:
:return:
| def __get_constant_timer(self, element):
"""
think-time option
:param element:
:return:
"""
timer = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
timer_element = [element for element in hashtree.iterchi... | [
"def",
"__get_constant_timer",
"(",
"self",
",",
"element",
")",
":",
"timer",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":",
"timer_el... | [
399,
4
] | [
414,
20
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_http_request_defaults | (self, element) |
timeout
default-address
keepalive
retrieve-resources
concurrent-pool-size
:param element:
:return:
|
timeout
default-address
keepalive
retrieve-resources
concurrent-pool-size
:param element:
:return:
| def _get_http_request_defaults(self, element):
"""
timeout
default-address
keepalive
retrieve-resources
concurrent-pool-size
:param element:
:return:
"""
request_defaults = {}
hashtree = element.getnext()
if hashtree is not ... | [
"def",
"_get_http_request_defaults",
"(",
"self",
",",
"element",
")",
":",
"request_defaults",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
... | [
416,
4
] | [
447,
31
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._make_url | (url_info) |
:type url_info: urllib.ParseResults
:return: string
|
:type url_info: urllib.ParseResults
:return: string
| def _make_url(url_info):
"""
:type url_info: urllib.ParseResults
:return: string
"""
path = "/" if not url_info.path else url_info.path
port = "" if not url_info.port or url_info.port == "80" else ":" + url_info.port
protocol = "http" if not url_info.protocol else... | [
"def",
"_make_url",
"(",
"url_info",
")",
":",
"path",
"=",
"\"/\"",
"if",
"not",
"url_info",
".",
"path",
"else",
"url_info",
".",
"path",
"port",
"=",
"\"\"",
"if",
"not",
"url_info",
".",
"port",
"or",
"url_info",
".",
"port",
"==",
"\"80\"",
"else"... | [
450,
4
] | [
460,
19
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._extract_url_info | (self, element) |
extracts domain, port, etc from element
:return:
|
extracts domain, port, etc from element
:return:
| def _extract_url_info(self, element):
"""
extracts domain, port, etc from element
:return:
"""
http_sampler_info = namedtuple("http_sampler_info",
["domain", "port", "timeout", "protocol", "path", "method", "retrieve_resources",
... | [
"def",
"_extract_url_info",
"(",
"self",
",",
"element",
")",
":",
"http_sampler_info",
"=",
"namedtuple",
"(",
"\"http_sampler_info\"",
",",
"[",
"\"domain\"",
",",
"\"port\"",
",",
"\"timeout\"",
",",
"\"protocol\"",
",",
"\"path\"",
",",
"\"method\"",
",",
"\... | [
462,
4
] | [
483,
19
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_request_base | (self, element) |
Base request settings
:return:
|
Base request settings
:return:
| def _get_request_base(self, element):
"""
Base request settings
:return:
"""
base_settings = {}
url_info = self._extract_url_info(element)
if url_info is not None:
full_url = self._make_url(url_info)
base_settings["url"] = full_url
... | [
"def",
"_get_request_base",
"(",
"self",
",",
"element",
")",
":",
"base_settings",
"=",
"{",
"}",
"url_info",
"=",
"self",
".",
"_extract_url_info",
"(",
"element",
")",
"if",
"url_info",
"is",
"not",
"None",
":",
"full_url",
"=",
"self",
".",
"_make_url"... | [
485,
4
] | [
502,
28
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_data_sources | (self, element, recursive=False) |
data-sources option
:param element:
:return: list of dicts
|
data-sources option
:param element:
:return: list of dicts
| def _get_data_sources(self, element, recursive=False):
"""
data-sources option
:param element:
:return: list of dicts
"""
data_sources = []
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
if recursive:
... | [
"def",
"_get_data_sources",
"(",
"self",
",",
"element",
",",
"recursive",
"=",
"False",
")",
":",
"data_sources",
"=",
"[",
"]",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
... | [
557,
4
] | [
620,
21
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_extractors | (self, element) |
Gets xpath, jsonpath, regexp and html extractors
:param element:
:return:
|
Gets xpath, jsonpath, regexp and html extractors
:param element:
:return:
| def _get_extractors(self, element):
"""
Gets xpath, jsonpath, regexp and html extractors
:param element:
:return:
"""
extractors = {}
regexp_extractors = self._get_regexp_extractor(element)
if regexp_extractors:
extractors.update({"extract-rege... | [
"def",
"_get_extractors",
"(",
"self",
",",
"element",
")",
":",
"extractors",
"=",
"{",
"}",
"regexp_extractors",
"=",
"self",
".",
"_get_regexp_extractor",
"(",
"element",
")",
"if",
"regexp_extractors",
":",
"extractors",
".",
"update",
"(",
"{",
"\"extract... | [
642,
4
] | [
665,
25
] | python | en | ['en', 'error', 'th'] | False |
JMXasDict._get_regexp_extractor | (self, element) |
extract-regexp option
:param element:
:return:
|
extract-regexp option
:param element:
:return:
| def _get_regexp_extractor(self, element):
"""
extract-regexp option
:param element:
:return:
"""
regexp_extractors = {}
hashtree = element.getnext()
if hashtree is not None and hashtree.tag == "hashTree":
extractor_elements = [element for eleme... | [
"def",
"_get_regexp_extractor",
"(",
"self",
",",
"element",
")",
":",
"regexp_extractors",
"=",
"{",
"}",
"hashtree",
"=",
"element",
".",
"getnext",
"(",
")",
"if",
"hashtree",
"is",
"not",
"None",
"and",
"hashtree",
".",
"tag",
"==",
"\"hashTree\"",
":"... | [
667,
4
] | [
722,
32
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.