partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
QuantumChannel._init_transformer
Convert input into a QuantumChannel subclass object or Operator object
qiskit/quantum_info/operators/channel/quantum_channel.py
def _init_transformer(cls, data): """Convert input into a QuantumChannel subclass object or Operator object""" # This handles common conversion for all QuantumChannel subclasses. # If the input is already a QuantumChannel subclass it will return # the original object if isinstanc...
def _init_transformer(cls, data): """Convert input into a QuantumChannel subclass object or Operator object""" # This handles common conversion for all QuantumChannel subclasses. # If the input is already a QuantumChannel subclass it will return # the original object if isinstanc...
[ "Convert", "input", "into", "a", "QuantumChannel", "subclass", "object", "or", "Operator", "object" ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/channel/quantum_channel.py#L130-L152
[ "def", "_init_transformer", "(", "cls", ",", "data", ")", ":", "# This handles common conversion for all QuantumChannel subclasses.", "# If the input is already a QuantumChannel subclass it will return", "# the original object", "if", "isinstance", "(", "data", ",", "QuantumChannel",...
d4f58d903bc96341b816f7c35df936d6421267d1
test
CheckCnotDirection.run
If `dag` is mapped and the direction is correct the property `is_direction_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to check.
qiskit/transpiler/passes/mapping/check_cnot_direction.py
def run(self, dag): """ If `dag` is mapped and the direction is correct the property `is_direction_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to check. """ if self.layout is None: if self.property_set["layout"]: ...
def run(self, dag): """ If `dag` is mapped and the direction is correct the property `is_direction_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to check. """ if self.layout is None: if self.property_set["layout"]: ...
[ "If", "dag", "is", "mapped", "and", "the", "direction", "is", "correct", "the", "property", "is_direction_mapped", "is", "set", "to", "True", "(", "or", "to", "False", "otherwise", ")", "." ]
Qiskit/qiskit-terra
python
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/transpiler/passes/mapping/check_cnot_direction.py#L37-L61
[ "def", "run", "(", "self", ",", "dag", ")", ":", "if", "self", ".", "layout", "is", "None", ":", "if", "self", ".", "property_set", "[", "\"layout\"", "]", ":", "self", ".", "layout", "=", "self", ".", "property_set", "[", "\"layout\"", "]", "else", ...
d4f58d903bc96341b816f7c35df936d6421267d1
test
sort_enum_for_model
Create Graphene Enum for sorting a SQLAlchemy class query Parameters - cls : Sqlalchemy model class Model used to create the sort enumerator - name : str, optional, default None Name to use for the enumerator. If not provided it will be set to `cls.__name__ + 'SortEnum'` - symbol_name :...
graphene_sqlalchemy/utils.py
def sort_enum_for_model(cls, name=None, symbol_name=_symbol_name): """Create Graphene Enum for sorting a SQLAlchemy class query Parameters - cls : Sqlalchemy model class Model used to create the sort enumerator - name : str, optional, default None Name to use for the enumerator. If not ...
def sort_enum_for_model(cls, name=None, symbol_name=_symbol_name): """Create Graphene Enum for sorting a SQLAlchemy class query Parameters - cls : Sqlalchemy model class Model used to create the sort enumerator - name : str, optional, default None Name to use for the enumerator. If not ...
[ "Create", "Graphene", "Enum", "for", "sorting", "a", "SQLAlchemy", "class", "query" ]
graphql-python/graphene-sqlalchemy
python
https://github.com/graphql-python/graphene-sqlalchemy/blob/e362e3fc4993d7e95873044bb4d00185b1d3dd8b/graphene_sqlalchemy/utils.py#L82-L100
[ "def", "sort_enum_for_model", "(", "cls", ",", "name", "=", "None", ",", "symbol_name", "=", "_symbol_name", ")", ":", "enum", ",", "_", "=", "_sort_enum_for_model", "(", "cls", ",", "name", ",", "symbol_name", ")", "return", "enum" ]
e362e3fc4993d7e95873044bb4d00185b1d3dd8b
test
sort_argument_for_model
Returns a Graphene argument for the sort field that accepts a list of sorting directions for a model. If `has_default` is True (the default) it will sort the result by the primary key(s)
graphene_sqlalchemy/utils.py
def sort_argument_for_model(cls, has_default=True): """Returns a Graphene argument for the sort field that accepts a list of sorting directions for a model. If `has_default` is True (the default) it will sort the result by the primary key(s) """ enum, default = _sort_enum_for_model(cls) if not has_d...
def sort_argument_for_model(cls, has_default=True): """Returns a Graphene argument for the sort field that accepts a list of sorting directions for a model. If `has_default` is True (the default) it will sort the result by the primary key(s) """ enum, default = _sort_enum_for_model(cls) if not has_d...
[ "Returns", "a", "Graphene", "argument", "for", "the", "sort", "field", "that", "accepts", "a", "list", "of", "sorting", "directions", "for", "a", "model", ".", "If", "has_default", "is", "True", "(", "the", "default", ")", "it", "will", "sort", "the", "r...
graphql-python/graphene-sqlalchemy
python
https://github.com/graphql-python/graphene-sqlalchemy/blob/e362e3fc4993d7e95873044bb4d00185b1d3dd8b/graphene_sqlalchemy/utils.py#L103-L110
[ "def", "sort_argument_for_model", "(", "cls", ",", "has_default", "=", "True", ")", ":", "enum", ",", "default", "=", "_sort_enum_for_model", "(", "cls", ")", "if", "not", "has_default", ":", "default", "=", "None", "return", "Argument", "(", "List", "(", ...
e362e3fc4993d7e95873044bb4d00185b1d3dd8b
test
search_dates
Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|unicode :param languages: A list of two letters language codes.e.g. ['en'...
dateparser/search/__init__.py
def search_dates(text, languages=None, settings=None, add_detected_language=False): """Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|uni...
def search_dates(text, languages=None, settings=None, add_detected_language=False): """Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|uni...
[ "Find", "all", "substrings", "of", "the", "given", "string", "which", "represent", "date", "and", "/", "or", "time", "and", "parse", "them", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/search/__init__.py#L9-L56
[ "def", "search_dates", "(", "text", ",", "languages", "=", "None", ",", "settings", "=", "None", ",", "add_detected_language", "=", "False", ")", ":", "result", "=", "_search_with_detection", ".", "search_dates", "(", "text", "=", "text", ",", "languages", "...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
patch_strptime
Monkey patching _strptime to avoid problems related with non-english locale changes on the system. For example, if system's locale is set to fr_FR. Parser won't recognize any date since all languages are translated to english dates.
dateparser/utils/strptime.py
def patch_strptime(): """Monkey patching _strptime to avoid problems related with non-english locale changes on the system. For example, if system's locale is set to fr_FR. Parser won't recognize any date since all languages are translated to english dates. """ _strptime = imp.load_module( ...
def patch_strptime(): """Monkey patching _strptime to avoid problems related with non-english locale changes on the system. For example, if system's locale is set to fr_FR. Parser won't recognize any date since all languages are translated to english dates. """ _strptime = imp.load_module( ...
[ "Monkey", "patching", "_strptime", "to", "avoid", "problems", "related", "with", "non", "-", "english", "locale", "changes", "on", "the", "system", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/utils/strptime.py#L17-L52
[ "def", "patch_strptime", "(", ")", ":", "_strptime", "=", "imp", ".", "load_module", "(", "'strptime_patched'", ",", "*", "imp", ".", "find_module", "(", "'_strptime'", ")", ")", "_calendar", "=", "imp", ".", "load_module", "(", "'calendar_patched'", ",", "*...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
LocaleDataLoader.get_locale_map
Get an ordered mapping with locale codes as keys and corresponding locale instances as values. :param languages: A list of language codes, e.g. ['en', 'es', 'zh-Hant']. If locales are not given, languages and region are used to construct locales to load. :typ...
dateparser/languages/loader.py
def get_locale_map(self, languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False): """ Get an ordered mapping with locale codes as keys and corresponding locale instances as values. :param languages: A list of ...
def get_locale_map(self, languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False): """ Get an ordered mapping with locale codes as keys and corresponding locale instances as values. :param languages: A list of ...
[ "Get", "an", "ordered", "mapping", "with", "locale", "codes", "as", "keys", "and", "corresponding", "locale", "instances", "as", "values", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/loader.py#L48-L83
[ "def", "get_locale_map", "(", "self", ",", "languages", "=", "None", ",", "locales", "=", "None", ",", "region", "=", "None", ",", "use_given_order", "=", "False", ",", "allow_conflicting_locales", "=", "False", ")", ":", "return", "OrderedDict", "(", "self"...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
LocaleDataLoader.get_locales
Yield locale instances. :param languages: A list of language codes, e.g. ['en', 'es', 'zh-Hant']. If locales are not given, languages and region are used to construct locales to load. :type languages: list :param locales: A list of codes of local...
dateparser/languages/loader.py
def get_locales(self, languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False): """ Yield locale instances. :param languages: A list of language codes, e.g. ['en', 'es', 'zh-Hant']. If locales are not given, l...
def get_locales(self, languages=None, locales=None, region=None, use_given_order=False, allow_conflicting_locales=False): """ Yield locale instances. :param languages: A list of language codes, e.g. ['en', 'es', 'zh-Hant']. If locales are not given, l...
[ "Yield", "locale", "instances", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/loader.py#L85-L121
[ "def", "get_locales", "(", "self", ",", "languages", "=", "None", ",", "locales", "=", "None", ",", "region", "=", "None", ",", "use_given_order", "=", "False", ",", "allow_conflicting_locales", "=", "False", ")", ":", "for", "_", ",", "locale", "in", "s...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
Dictionary.are_tokens_valid
Check if tokens are valid tokens for the locale. :param tokens: a list of string or unicode tokens. :type tokens: list :return: True if tokens are valid, False otherwise.
dateparser/languages/dictionary.py
def are_tokens_valid(self, tokens): """ Check if tokens are valid tokens for the locale. :param tokens: a list of string or unicode tokens. :type tokens: list :return: True if tokens are valid, False otherwise. """ match_relative_regex = self._get_ma...
def are_tokens_valid(self, tokens): """ Check if tokens are valid tokens for the locale. :param tokens: a list of string or unicode tokens. :type tokens: list :return: True if tokens are valid, False otherwise. """ match_relative_regex = self._get_ma...
[ "Check", "if", "tokens", "are", "valid", "tokens", "for", "the", "locale", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/dictionary.py#L96-L114
[ "def", "are_tokens_valid", "(", "self", ",", "tokens", ")", ":", "match_relative_regex", "=", "self", ".", "_get_match_relative_regex_cache", "(", ")", "for", "token", "in", "tokens", ":", "if", "any", "(", "[", "match_relative_regex", ".", "match", "(", "toke...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
Dictionary.split
Split the date string using translations in locale info. :param string: Date string to be splitted. :type string: str|unicode :param keep_formatting: If True, retain formatting of the date string. :type keep_formatting: bool :return: A list ...
dateparser/languages/dictionary.py
def split(self, string, keep_formatting=False): """ Split the date string using translations in locale info. :param string: Date string to be splitted. :type string: str|unicode :param keep_formatting: If True, retain formatting of the date s...
def split(self, string, keep_formatting=False): """ Split the date string using translations in locale info. :param string: Date string to be splitted. :type string: str|unicode :param keep_formatting: If True, retain formatting of the date s...
[ "Split", "the", "date", "string", "using", "translations", "in", "locale", "info", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/dictionary.py#L116-L145
[ "def", "split", "(", "self", ",", "string", ",", "keep_formatting", "=", "False", ")", ":", "if", "not", "string", ":", "return", "string", "split_relative_regex", "=", "self", ".", "_get_split_relative_regex_cache", "(", ")", "match_relative_regex", "=", "self"...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
DateSearchWithDetection.search_dates
Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|unicode :param languages: A list of two letters language codes.e.g. ['en',...
dateparser/search/search.py
def search_dates(self, text, languages=None, settings=None): """ Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|unicode ...
def search_dates(self, text, languages=None, settings=None): """ Find all substrings of the given string which represent date and/or time and parse them. :param text: A string in a natural language which may contain date and/or time expressions. :type text: str|unicode ...
[ "Find", "all", "substrings", "of", "the", "given", "string", "which", "represent", "date", "and", "/", "or", "time", "and", "parse", "them", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/search/search.py#L202-L230
[ "def", "search_dates", "(", "self", ",", "text", ",", "languages", "=", "None", ",", "settings", "=", "None", ")", ":", "language_shortname", "=", "self", ".", "detect_language", "(", "text", "=", "text", ",", "languages", "=", "languages", ")", "if", "n...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
parse
Parse date and time from given date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param date_formats: A list of format strings using directives as given `here <https://docs.python.org/2/library/dat...
dateparser/__init__.py
def parse(date_string, date_formats=None, languages=None, locales=None, region=None, settings=None): """Parse date and time from given date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param date_formats: ...
def parse(date_string, date_formats=None, languages=None, locales=None, region=None, settings=None): """Parse date and time from given date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param date_formats: ...
[ "Parse", "date", "and", "time", "from", "given", "date", "string", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/__init__.py#L11-L56
[ "def", "parse", "(", "date_string", ",", "date_formats", "=", "None", ",", "languages", "=", "None", ",", "locales", "=", "None", ",", "region", "=", "None", ",", "settings", "=", "None", ")", ":", "parser", "=", "_default_parser", "if", "any", "(", "[...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
FreshnessDateDataParser._parse_time
Attemps to parse time part of date strings like '1 day ago, 2 PM'
dateparser/freshness_date_parser.py
def _parse_time(self, date_string, settings): """Attemps to parse time part of date strings like '1 day ago, 2 PM' """ date_string = PATTERN.sub('', date_string) date_string = re.sub(r'\b(?:ago|in)\b', '', date_string) try: return time_parser(date_string) except: ...
def _parse_time(self, date_string, settings): """Attemps to parse time part of date strings like '1 day ago, 2 PM' """ date_string = PATTERN.sub('', date_string) date_string = re.sub(r'\b(?:ago|in)\b', '', date_string) try: return time_parser(date_string) except: ...
[ "Attemps", "to", "parse", "time", "part", "of", "date", "strings", "like", "1", "day", "ago", "2", "PM" ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/freshness_date_parser.py#L36-L43
[ "def", "_parse_time", "(", "self", ",", "date_string", ",", "settings", ")", ":", "date_string", "=", "PATTERN", ".", "sub", "(", "''", ",", "date_string", ")", "date_string", "=", "re", ".", "sub", "(", "r'\\b(?:ago|in)\\b'", ",", "''", ",", "date_string"...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
Locale.is_applicable
Check if the locale is applicable to translate date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param strip_timezone: If True, timezone is stripped from date string. :type str...
dateparser/languages/locale.py
def is_applicable(self, date_string, strip_timezone=False, settings=None): """ Check if the locale is applicable to translate date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :para...
def is_applicable(self, date_string, strip_timezone=False, settings=None): """ Check if the locale is applicable to translate date string. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :para...
[ "Check", "if", "the", "locale", "is", "applicable", "to", "translate", "date", "string", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/locale.py#L53-L77
[ "def", "is_applicable", "(", "self", ",", "date_string", ",", "strip_timezone", "=", "False", ",", "settings", "=", "None", ")", ":", "if", "strip_timezone", ":", "date_string", ",", "_", "=", "pop_tz_offset_from_string", "(", "date_string", ",", "as_offset", ...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
Locale.translate
Translate the date string to its English equivalent. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param keep_formatting: If True, retain formatting of the date string after translation. ...
dateparser/languages/locale.py
def translate(self, date_string, keep_formatting=False, settings=None): """ Translate the date string to its English equivalent. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param keep_for...
def translate(self, date_string, keep_formatting=False, settings=None): """ Translate the date string to its English equivalent. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param keep_for...
[ "Translate", "the", "date", "string", "to", "its", "English", "equivalent", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/languages/locale.py#L114-L149
[ "def", "translate", "(", "self", ",", "date_string", ",", "keep_formatting", "=", "False", ",", "settings", "=", "None", ")", ":", "date_string", "=", "self", ".", "_translate_numerals", "(", "date_string", ")", "if", "settings", ".", "NORMALIZE", ":", "date...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
parse_with_formats
Parse with formats and return a dictionary with 'period' and 'obj_date'. :returns: :class:`datetime.datetime`, dict or None
dateparser/date.py
def parse_with_formats(date_string, date_formats, settings): """ Parse with formats and return a dictionary with 'period' and 'obj_date'. :returns: :class:`datetime.datetime`, dict or None """ period = 'day' for date_format in date_formats: try: date_obj = datetime.strptime(dat...
def parse_with_formats(date_string, date_formats, settings): """ Parse with formats and return a dictionary with 'period' and 'obj_date'. :returns: :class:`datetime.datetime`, dict or None """ period = 'day' for date_format in date_formats: try: date_obj = datetime.strptime(dat...
[ "Parse", "with", "formats", "and", "return", "a", "dictionary", "with", "period", "and", "obj_date", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/date.py#L133-L161
[ "def", "parse_with_formats", "(", "date_string", ",", "date_formats", ",", "settings", ")", ":", "period", "=", "'day'", "for", "date_format", "in", "date_formats", ":", "try", ":", "date_obj", "=", "datetime", ".", "strptime", "(", "date_string", ",", "date_f...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
DateDataParser.get_date_data
Parse string representing date and/or time in recognizable localized formats. Supports parsing multiple languages and timezones. :param date_string: A string representing date and/or time in a recognizably valid format. :type date_string: str|unicode :param date_formats: ...
dateparser/date.py
def get_date_data(self, date_string, date_formats=None): """ Parse string representing date and/or time in recognizable localized formats. Supports parsing multiple languages and timezones. :param date_string: A string representing date and/or time in a recognizably valid fo...
def get_date_data(self, date_string, date_formats=None): """ Parse string representing date and/or time in recognizable localized formats. Supports parsing multiple languages and timezones. :param date_string: A string representing date and/or time in a recognizably valid fo...
[ "Parse", "string", "representing", "date", "and", "/", "or", "time", "in", "recognizable", "localized", "formats", ".", "Supports", "parsing", "multiple", "languages", "and", "timezones", "." ]
scrapinghub/dateparser
python
https://github.com/scrapinghub/dateparser/blob/11a761c99d3ee522a3c63756b70c106a579e8b5c/dateparser/date.py#L354-L418
[ "def", "get_date_data", "(", "self", ",", "date_string", ",", "date_formats", "=", "None", ")", ":", "if", "not", "(", "isinstance", "(", "date_string", ",", "six", ".", "text_type", ")", "or", "isinstance", "(", "date_string", ",", "six", ".", "string_typ...
11a761c99d3ee522a3c63756b70c106a579e8b5c
test
ComponentFactory.get_load_plan
return load plan (timestamps generator)
yandextank/stepper/config.py
def get_load_plan(self): """ return load plan (timestamps generator) """ if self.rps_schedule and self.instances_schedule: raise StepperConfigurationError( 'Both rps and instances schedules specified. You must specify only one of them' ) el...
def get_load_plan(self): """ return load plan (timestamps generator) """ if self.rps_schedule and self.instances_schedule: raise StepperConfigurationError( 'Both rps and instances schedules specified. You must specify only one of them' ) el...
[ "return", "load", "plan", "(", "timestamps", "generator", ")" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/config.py#L56-L73
[ "def", "get_load_plan", "(", "self", ")", ":", "if", "self", ".", "rps_schedule", "and", "self", ".", "instances_schedule", ":", "raise", "StepperConfigurationError", "(", "'Both rps and instances schedules specified. You must specify only one of them'", ")", "elif", "self"...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ComponentFactory.get_ammo_generator
return ammo generator
yandextank/stepper/config.py
def get_ammo_generator(self): """ return ammo generator """ af_readers = { 'phantom': missile.AmmoFileReader, 'slowlog': missile.SlowLogReader, 'line': missile.LineReader, 'uri': missile.UriReader, 'uripost': missile.UriPostRead...
def get_ammo_generator(self): """ return ammo generator """ af_readers = { 'phantom': missile.AmmoFileReader, 'slowlog': missile.SlowLogReader, 'line': missile.LineReader, 'uri': missile.UriReader, 'uripost': missile.UriPostRead...
[ "return", "ammo", "generator" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/config.py#L75-L124
[ "def", "get_ammo_generator", "(", "self", ")", ":", "af_readers", "=", "{", "'phantom'", ":", "missile", ".", "AmmoFileReader", ",", "'slowlog'", ":", "missile", ".", "SlowLogReader", ",", "'line'", ":", "missile", ".", "LineReader", ",", "'uri'", ":", "miss...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
_exc_to_net
translate http code to net code. if accertion failed, set net code to 314
yandextank/plugins/JMeter/reader.py
def _exc_to_net(param1, success): """ translate http code to net code. if accertion failed, set net code to 314 """ if len(param1) <= 3: # FIXME: we're unable to use better logic here, because we should support non-http codes # but, we should look for core.util.HTTP or some other common logic ...
def _exc_to_net(param1, success): """ translate http code to net code. if accertion failed, set net code to 314 """ if len(param1) <= 3: # FIXME: we're unable to use better logic here, because we should support non-http codes # but, we should look for core.util.HTTP or some other common logic ...
[ "translate", "http", "code", "to", "net", "code", ".", "if", "accertion", "failed", "set", "net", "code", "to", "314" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/JMeter/reader.py#L35-L53
[ "def", "_exc_to_net", "(", "param1", ",", "success", ")", ":", "if", "len", "(", "param1", ")", "<=", "3", ":", "# FIXME: we're unable to use better logic here, because we should support non-http codes", "# but, we should look for core.util.HTTP or some other common logic", "# he...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
_exc_to_http
translate exception str to http code
yandextank/plugins/JMeter/reader.py
def _exc_to_http(param1): """ translate exception str to http code""" if len(param1) <= 3: try: int(param1) except BaseException: logger.error( "JMeter wrote some strange data into codes column: %s", param1) else: return int(param1) ...
def _exc_to_http(param1): """ translate exception str to http code""" if len(param1) <= 3: try: int(param1) except BaseException: logger.error( "JMeter wrote some strange data into codes column: %s", param1) else: return int(param1) ...
[ "translate", "exception", "str", "to", "http", "code" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/JMeter/reader.py#L56-L72
[ "def", "_exc_to_http", "(", "param1", ")", ":", "if", "len", "(", "param1", ")", "<=", "3", ":", "try", ":", "int", "(", "param1", ")", "except", "BaseException", ":", "logger", ".", "error", "(", "\"JMeter wrote some strange data into codes column: %s\"", ","...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
PhantomConfig.read_config
Read phantom tool specific options
yandextank/plugins/Phantom/utils.py
def read_config(self): """ Read phantom tool specific options """ self.threads = self.cfg["threads"] or str(int(multiprocessing.cpu_count() / 2) + 1) self.phantom_modules_path = self.cfg["phantom_modules_path"] self.additional_libs = ' '.join(self.cfg["additional_libs"]) ...
def read_config(self): """ Read phantom tool specific options """ self.threads = self.cfg["threads"] or str(int(multiprocessing.cpu_count() / 2) + 1) self.phantom_modules_path = self.cfg["phantom_modules_path"] self.additional_libs = ' '.join(self.cfg["additional_libs"]) ...
[ "Read", "phantom", "tool", "specific", "options" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Phantom/utils.py#L59-L98
[ "def", "read_config", "(", "self", ")", ":", "self", ".", "threads", "=", "self", ".", "cfg", "[", "\"threads\"", "]", "or", "str", "(", "int", "(", "multiprocessing", ".", "cpu_count", "(", ")", "/", "2", ")", "+", "1", ")", "self", ".", "phantom_...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
PhantomConfig.compose_config
Generate phantom tool run config
yandextank/plugins/Phantom/utils.py
def compose_config(self): """ Generate phantom tool run config """ streams_config = '' stat_benchmarks = '' for stream in self.streams: streams_config += stream.compose_config() if not stream.is_main: stat_benchmarks += " " + "benchma...
def compose_config(self): """ Generate phantom tool run config """ streams_config = '' stat_benchmarks = '' for stream in self.streams: streams_config += stream.compose_config() if not stream.is_main: stat_benchmarks += " " + "benchma...
[ "Generate", "phantom", "tool", "run", "config" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Phantom/utils.py#L109-L135
[ "def", "compose_config", "(", "self", ")", ":", "streams_config", "=", "''", "stat_benchmarks", "=", "''", "for", "stream", "in", "self", ".", "streams", ":", "streams_config", "+=", "stream", ".", "compose_config", "(", ")", "if", "not", "stream", ".", "i...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
PhantomConfig.get_info
get merged info about phantom conf
yandextank/plugins/Phantom/utils.py
def get_info(self): """ get merged info about phantom conf """ result = copy.copy(self.streams[0]) result.stat_log = self.stat_log result.steps = [] result.ammo_file = '' result.rps_schedule = None result.ammo_count = 0 result.duration = 0 result....
def get_info(self): """ get merged info about phantom conf """ result = copy.copy(self.streams[0]) result.stat_log = self.stat_log result.steps = [] result.ammo_file = '' result.rps_schedule = None result.ammo_count = 0 result.duration = 0 result....
[ "get", "merged", "info", "about", "phantom", "conf" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Phantom/utils.py#L142-L192
[ "def", "get_info", "(", "self", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ".", "streams", "[", "0", "]", ")", "result", ".", "stat_log", "=", "self", ".", "stat_log", "result", ".", "steps", "=", "[", "]", "result", ".", "ammo_file...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StreamConfig.read_config
reads config
yandextank/plugins/Phantom/utils.py
def read_config(self): """ reads config """ # multi-options self.ssl = self.get_option("ssl") self.tank_type = self.get_option("tank_type") # TODO: refactor. Maybe we should decide how to interact with # StepperWrapper here. # self.instances = self.get_option('ins...
def read_config(self): """ reads config """ # multi-options self.ssl = self.get_option("ssl") self.tank_type = self.get_option("tank_type") # TODO: refactor. Maybe we should decide how to interact with # StepperWrapper here. # self.instances = self.get_option('ins...
[ "reads", "config" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Phantom/utils.py#L253-L283
[ "def", "read_config", "(", "self", ")", ":", "# multi-options", "self", ".", "ssl", "=", "self", ".", "get_option", "(", "\"ssl\"", ")", "self", ".", "tank_type", "=", "self", ".", "get_option", "(", "\"tank_type\"", ")", "# TODO: refactor. Maybe we should decid...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StreamConfig.compose_config
compose benchmark block
yandextank/plugins/Phantom/utils.py
def compose_config(self): """ compose benchmark block """ # step file self.stepper_wrapper.prepare_stepper() self.stpd = self.stepper_wrapper.stpd if self.stepper_wrapper.instances: self.instances = self.stepper_wrapper.instances if not self.stpd: ...
def compose_config(self): """ compose benchmark block """ # step file self.stepper_wrapper.prepare_stepper() self.stpd = self.stepper_wrapper.stpd if self.stepper_wrapper.instances: self.instances = self.stepper_wrapper.instances if not self.stpd: ...
[ "compose", "benchmark", "block" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Phantom/utils.py#L285-L363
[ "def", "compose_config", "(", "self", ")", ":", "# step file", "self", ".", "stepper_wrapper", ".", "prepare_stepper", "(", ")", "self", ".", "stpd", "=", "self", ".", "stepper_wrapper", ".", "stpd", "if", "self", ".", "stepper_wrapper", ".", "instances", ":...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.patch_config
download remote resources, replace links with local filenames add result file section :param dict config: pandora config
yandextank/plugins/Pandora/plugin.py
def patch_config(self, config): """ download remote resources, replace links with local filenames add result file section :param dict config: pandora config """ # get expvar parameters if config.get("monitoring"): if config["monitoring"].get("expvar"):...
def patch_config(self, config): """ download remote resources, replace links with local filenames add result file section :param dict config: pandora config """ # get expvar parameters if config.get("monitoring"): if config["monitoring"].get("expvar"):...
[ "download", "remote", "resources", "replace", "links", "with", "local", "filenames", "add", "result", "file", "section", ":", "param", "dict", "config", ":", "pandora", "config" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Pandora/plugin.py#L94-L132
[ "def", "patch_config", "(", "self", ",", "config", ")", ":", "# get expvar parameters", "if", "config", ".", "get", "(", "\"monitoring\"", ")", ":", "if", "config", "[", "\"monitoring\"", "]", ".", "get", "(", "\"expvar\"", ")", ":", "self", ".", "expvar",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
PatchedValidator.validate_duration
2h 2h5m 5m 180 1h4m3 :param duration: :return:
yandextank/validator/validator.py
def validate_duration(self, field, duration): ''' 2h 2h5m 5m 180 1h4m3 :param duration: :return: ''' DURATION_RE = r'^(\d+d)?(\d+h)?(\d+m)?(\d+s?)?$' if not re.match(DURATION_RE, duration): self._error(field, 'Load durat...
def validate_duration(self, field, duration): ''' 2h 2h5m 5m 180 1h4m3 :param duration: :return: ''' DURATION_RE = r'^(\d+d)?(\d+h)?(\d+m)?(\d+s?)?$' if not re.match(DURATION_RE, duration): self._error(field, 'Load durat...
[ "2h", "2h5m", "5m", "180", "1h4m3", ":", "param", "duration", ":", ":", "return", ":" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/validator/validator.py#L97-L109
[ "def", "validate_duration", "(", "self", ",", "field", ",", "duration", ")", ":", "DURATION_RE", "=", "r'^(\\d+d)?(\\d+h)?(\\d+m)?(\\d+s?)?$'", "if", "not", "re", ".", "match", "(", "DURATION_RE", ",", "duration", ")", ":", "self", ".", "_error", "(", "field",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
PatchedValidator._validator_load_scheme
step(10,200,5,180) step(5,50,2.5,5m) line(22,154,2h5m) step(5,50,2.5,5m) line(22,154,2h5m) const(10,1h4m3s) :param field: :param value: :return:
yandextank/validator/validator.py
def _validator_load_scheme(self, field, value): ''' step(10,200,5,180) step(5,50,2.5,5m) line(22,154,2h5m) step(5,50,2.5,5m) line(22,154,2h5m) const(10,1h4m3s) :param field: :param value: :return: ''' # stpd file can be any value ...
def _validator_load_scheme(self, field, value): ''' step(10,200,5,180) step(5,50,2.5,5m) line(22,154,2h5m) step(5,50,2.5,5m) line(22,154,2h5m) const(10,1h4m3s) :param field: :param value: :return: ''' # stpd file can be any value ...
[ "step", "(", "10", "200", "5", "180", ")", "step", "(", "5", "50", "2", ".", "5", "5m", ")", "line", "(", "22", "154", "2h5m", ")", "step", "(", "5", "50", "2", ".", "5", "5m", ")", "line", "(", "22", "154", "2h5m", ")", "const", "(", "10...
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/validator/validator.py#L111-L148
[ "def", "_validator_load_scheme", "(", "self", ",", "field", ",", "value", ")", ":", "# stpd file can be any value", "if", "self", ".", "document", "[", "'load_type'", "]", "in", "'stpd_file'", ":", "return", "PRIMARY_RE", "=", "r'(step|line|const)\\((.+?)\\)'", "N_O...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
TankConfig.__parse_enabled_plugins
:returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple
yandextank/validator/validator.py
def __parse_enabled_plugins(self): """ :returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple """ return [ ( plugin_name, plugin['package'], plugin) for plugin_name, plugin in sel...
def __parse_enabled_plugins(self): """ :returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple """ return [ ( plugin_name, plugin['package'], plugin) for plugin_name, plugin in sel...
[ ":", "returns", ":", "[", "(", "plugin_name", "plugin_package", "plugin_config", ")", "...", "]", ":", "rtype", ":", "list", "of", "tuple" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/validator/validator.py#L228-L241
[ "def", "__parse_enabled_plugins", "(", "self", ")", ":", "return", "[", "(", "plugin_name", ",", "plugin", "[", "'package'", "]", ",", "plugin", ")", "for", "plugin_name", ",", "plugin", "in", "self", ".", "raw_config_dict", ".", "items", "(", ")", "if", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ValidatedConfig.plugins
:returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple
yandextank/validator/validator.py
def plugins(self): """ :returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple """ if not self._plugins: self._plugins = [ (plugin_name, plugin_cfg['package'], plugin_cfg) for plugin...
def plugins(self): """ :returns: [(plugin_name, plugin_package, plugin_config), ...] :rtype: list of tuple """ if not self._plugins: self._plugins = [ (plugin_name, plugin_cfg['package'], plugin_cfg) for plugin...
[ ":", "returns", ":", "[", "(", "plugin_name", "plugin_package", "plugin_config", ")", "...", "]", ":", "rtype", ":", "list", "of", "tuple" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/validator/validator.py#L307-L318
[ "def", "plugins", "(", "self", ")", ":", "if", "not", "self", ".", "_plugins", ":", "self", ".", "_plugins", "=", "[", "(", "plugin_name", ",", "plugin_cfg", "[", "'package'", "]", ",", "plugin_cfg", ")", "for", "plugin_name", ",", "plugin_cfg", "in", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
log_stdout_stderr
This function polls stdout and stderr streams and writes their contents to log
yandextank/common/util.py
def log_stdout_stderr(log, stdout, stderr, comment=""): """ This function polls stdout and stderr streams and writes their contents to log """ readable = select.select([stdout], [], [], 0)[0] if stderr: exceptional = select.select([stderr], [], [], 0)[0] else: exceptional = [...
def log_stdout_stderr(log, stdout, stderr, comment=""): """ This function polls stdout and stderr streams and writes their contents to log """ readable = select.select([stdout], [], [], 0)[0] if stderr: exceptional = select.select([stderr], [], [], 0)[0] else: exceptional = [...
[ "This", "function", "polls", "stdout", "and", "stderr", "streams", "and", "writes", "their", "contents", "to", "log" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/util.py#L344-L367
[ "def", "log_stdout_stderr", "(", "log", ",", "stdout", ",", "stderr", ",", "comment", "=", "\"\"", ")", ":", "readable", "=", "select", ".", "select", "(", "[", "stdout", "]", ",", "[", "]", ",", "[", "]", ",", "0", ")", "[", "0", "]", "if", "s...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
expand_time
helper for above functions
yandextank/common/util.py
def expand_time(str_time, default_unit='s', multiplier=1): """ helper for above functions """ parser = re.compile(r'(\d+)([a-zA-Z]*)') parts = parser.findall(str_time) result = 0.0 for value, unit in parts: value = int(value) unit = unit.lower() if unit == '': ...
def expand_time(str_time, default_unit='s', multiplier=1): """ helper for above functions """ parser = re.compile(r'(\d+)([a-zA-Z]*)') parts = parser.findall(str_time) result = 0.0 for value, unit in parts: value = int(value) unit = unit.lower() if unit == '': ...
[ "helper", "for", "above", "functions" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/util.py#L384-L418
[ "def", "expand_time", "(", "str_time", ",", "default_unit", "=", "'s'", ",", "multiplier", "=", "1", ")", ":", "parser", "=", "re", ".", "compile", "(", "r'(\\d+)([a-zA-Z]*)'", ")", "parts", "=", "parser", ".", "findall", "(", "str_time", ")", "result", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
pid_exists
Check whether pid exists in the current process table.
yandextank/common/util.py
def pid_exists(pid): """Check whether pid exists in the current process table.""" if pid < 0: return False try: os.kill(pid, 0) except OSError as exc: logging.debug("No process[%s]: %s", exc.errno, exc) return exc.errno == errno.EPERM else: p = psutil.Process(...
def pid_exists(pid): """Check whether pid exists in the current process table.""" if pid < 0: return False try: os.kill(pid, 0) except OSError as exc: logging.debug("No process[%s]: %s", exc.errno, exc) return exc.errno == errno.EPERM else: p = psutil.Process(...
[ "Check", "whether", "pid", "exists", "in", "the", "current", "process", "table", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/util.py#L421-L432
[ "def", "pid_exists", "(", "pid", ")", ":", "if", "pid", "<", "0", ":", "return", "False", "try", ":", "os", ".", "kill", "(", "pid", ",", "0", ")", "except", "OSError", "as", "exc", ":", "logging", ".", "debug", "(", "\"No process[%s]: %s\"", ",", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
splitstring
>>> string = 'apple orange "banana tree" green' >>> splitstring(string) ['apple', 'orange', 'green', '"banana tree"']
yandextank/common/util.py
def splitstring(string): """ >>> string = 'apple orange "banana tree" green' >>> splitstring(string) ['apple', 'orange', 'green', '"banana tree"'] """ patt = re.compile(r'"[\w ]+"') if patt.search(string): quoted_item = patt.search(string).group() newstring = patt.sub('', str...
def splitstring(string): """ >>> string = 'apple orange "banana tree" green' >>> splitstring(string) ['apple', 'orange', 'green', '"banana tree"'] """ patt = re.compile(r'"[\w ]+"') if patt.search(string): quoted_item = patt.search(string).group() newstring = patt.sub('', str...
[ ">>>", "string", "=", "apple", "orange", "banana", "tree", "green", ">>>", "splitstring", "(", "string", ")", "[", "apple", "orange", "green", "banana", "tree", "]" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/util.py#L435-L447
[ "def", "splitstring", "(", "string", ")", ":", "patt", "=", "re", ".", "compile", "(", "r'\"[\\w ]+\"'", ")", "if", "patt", ".", "search", "(", "string", ")", ":", "quoted_item", "=", "patt", ".", "search", "(", "string", ")", ".", "group", "(", ")",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
FileMultiReader.read_with_lock
Reads {_len} characters if _len is not None else reads line :param pos: start reading position :param _len: number of characters to read :rtype: (string, int)
yandextank/common/util.py
def read_with_lock(self, pos, _len=None): """ Reads {_len} characters if _len is not None else reads line :param pos: start reading position :param _len: number of characters to read :rtype: (string, int) """ self.wait_lock() try: self._opened_...
def read_with_lock(self, pos, _len=None): """ Reads {_len} characters if _len is not None else reads line :param pos: start reading position :param _len: number of characters to read :rtype: (string, int) """ self.wait_lock() try: self._opened_...
[ "Reads", "{", "_len", "}", "characters", "if", "_len", "is", "not", "None", "else", "reads", "line", ":", "param", "pos", ":", "start", "reading", "position", ":", "param", "_len", ":", "number", "of", "characters", "to", "read", ":", "rtype", ":", "("...
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/util.py#L664-L680
[ "def", "read_with_lock", "(", "self", ",", "pos", ",", "_len", "=", "None", ")", ":", "self", ".", "wait_lock", "(", ")", "try", ":", "self", ".", "_opened_file", ".", "seek", "(", "pos", ")", "result", "=", "self", ".", "_opened_file", ".", "read", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.get_option
get_option wrapper
yandextank/stepper/main.py
def get_option(self, option, param2=None): ''' get_option wrapper''' result = self.cfg[option] self.log.debug( "Option %s = %s", option, result) return result
def get_option(self, option, param2=None): ''' get_option wrapper''' result = self.cfg[option] self.log.debug( "Option %s = %s", option, result) return result
[ "get_option", "wrapper" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L136-L141
[ "def", "get_option", "(", "self", ",", "option", ",", "param2", "=", "None", ")", ":", "result", "=", "self", ".", "cfg", "[", "option", "]", "self", ".", "log", ".", "debug", "(", "\"Option %s = %s\"", ",", "option", ",", "result", ")", "return", "r...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.read_config
stepper part of reading options
yandextank/stepper/main.py
def read_config(self): ''' stepper part of reading options ''' self.log.info("Configuring StepperWrapper...") self.ammo_file = self.get_option(self.OPTION_AMMOFILE) self.ammo_type = self.get_option('ammo_type') if self.ammo_file: self.ammo_file = os.path.expanduser(se...
def read_config(self): ''' stepper part of reading options ''' self.log.info("Configuring StepperWrapper...") self.ammo_file = self.get_option(self.OPTION_AMMOFILE) self.ammo_type = self.get_option('ammo_type') if self.ammo_file: self.ammo_file = os.path.expanduser(se...
[ "stepper", "part", "of", "reading", "options" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L159-L191
[ "def", "read_config", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Configuring StepperWrapper...\"", ")", "self", ".", "ammo_file", "=", "self", ".", "get_option", "(", "self", ".", "OPTION_AMMOFILE", ")", "self", ".", "ammo_type", "=", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.prepare_stepper
Generate test data if necessary
yandextank/stepper/main.py
def prepare_stepper(self): ''' Generate test data if necessary ''' def publish_info(stepper_info): info.status.publish('loadscheme', stepper_info.loadscheme) info.status.publish('loop_count', stepper_info.loop_count) info.status.publish('steps', stepper_info.steps) ...
def prepare_stepper(self): ''' Generate test data if necessary ''' def publish_info(stepper_info): info.status.publish('loadscheme', stepper_info.loadscheme) info.status.publish('loop_count', stepper_info.loop_count) info.status.publish('steps', stepper_info.steps) ...
[ "Generate", "test", "data", "if", "necessary" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L193-L240
[ "def", "prepare_stepper", "(", "self", ")", ":", "def", "publish_info", "(", "stepper_info", ")", ":", "info", ".", "status", ".", "publish", "(", "'loadscheme'", ",", "stepper_info", ".", "loadscheme", ")", "info", ".", "status", ".", "publish", "(", "'lo...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.__get_stpd_filename
Choose the name for stepped data file
yandextank/stepper/main.py
def __get_stpd_filename(self): ''' Choose the name for stepped data file ''' if self.use_caching: sep = "|" hasher = hashlib.md5() hashed_str = "cache version 6" + sep + \ ';'.join(self.load_profile.schedule) + sep + str(self.loop_limit) ha...
def __get_stpd_filename(self): ''' Choose the name for stepped data file ''' if self.use_caching: sep = "|" hasher = hashlib.md5() hashed_str = "cache version 6" + sep + \ ';'.join(self.load_profile.schedule) + sep + str(self.loop_limit) ha...
[ "Choose", "the", "name", "for", "stepped", "data", "file" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L246-L279
[ "def", "__get_stpd_filename", "(", "self", ")", ":", "if", "self", ".", "use_caching", ":", "sep", "=", "\"|\"", "hasher", "=", "hashlib", ".", "md5", "(", ")", "hashed_str", "=", "\"cache version 6\"", "+", "sep", "+", "';'", ".", "join", "(", "self", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.__read_cached_options
Read stepper info from json
yandextank/stepper/main.py
def __read_cached_options(self): ''' Read stepper info from json ''' self.log.debug("Reading cached stepper info: %s", self.__si_filename()) with open(self.__si_filename(), 'r') as si_file: si = info.StepperInfo(**json.load(si_file)) return si
def __read_cached_options(self): ''' Read stepper info from json ''' self.log.debug("Reading cached stepper info: %s", self.__si_filename()) with open(self.__si_filename(), 'r') as si_file: si = info.StepperInfo(**json.load(si_file)) return si
[ "Read", "stepper", "info", "from", "json" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L281-L288
[ "def", "__read_cached_options", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Reading cached stepper info: %s\"", ",", "self", ".", "__si_filename", "(", ")", ")", "with", "open", "(", "self", ".", "__si_filename", "(", ")", ",", "'r'", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.__write_cached_options
Write stepper info to json
yandextank/stepper/main.py
def __write_cached_options(self, si): ''' Write stepper info to json ''' self.log.debug("Saving stepper info: %s", self.__si_filename()) with open(self.__si_filename(), 'w') as si_file: json.dump(si._asdict(), si_file, indent=4)
def __write_cached_options(self, si): ''' Write stepper info to json ''' self.log.debug("Saving stepper info: %s", self.__si_filename()) with open(self.__si_filename(), 'w') as si_file: json.dump(si._asdict(), si_file, indent=4)
[ "Write", "stepper", "info", "to", "json" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L290-L296
[ "def", "__write_cached_options", "(", "self", ",", "si", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Saving stepper info: %s\"", ",", "self", ".", "__si_filename", "(", ")", ")", "with", "open", "(", "self", ".", "__si_filename", "(", ")", ",", "...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
StepperWrapper.__make_stpd_file
stpd generation using Stepper class
yandextank/stepper/main.py
def __make_stpd_file(self): ''' stpd generation using Stepper class ''' self.log.info("Making stpd-file: %s", self.stpd) stepper = Stepper( self.core, rps_schedule=self.load_profile.schedule if self.load_profile.is_rps() else None, http_ver=self.http_ver, ...
def __make_stpd_file(self): ''' stpd generation using Stepper class ''' self.log.info("Making stpd-file: %s", self.stpd) stepper = Stepper( self.core, rps_schedule=self.load_profile.schedule if self.load_profile.is_rps() else None, http_ver=self.http_ver, ...
[ "stpd", "generation", "using", "Stepper", "class" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/main.py#L298-L318
[ "def", "__make_stpd_file", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Making stpd-file: %s\"", ",", "self", ".", "stpd", ")", "stepper", "=", "Stepper", "(", "self", ".", "core", ",", "rps_schedule", "=", "self", ".", "load_profile", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
create
Create Load Plan as defined in schedule. Publish info about its duration.
yandextank/stepper/load_plan.py
def create(rps_schedule): """ Create Load Plan as defined in schedule. Publish info about its duration. """ if len(rps_schedule) > 1: lp = Composite( [StepFactory.produce(step_config) for step_config in rps_schedule]) else: lp = StepFactory.produce(rps_schedule[0]) in...
def create(rps_schedule): """ Create Load Plan as defined in schedule. Publish info about its duration. """ if len(rps_schedule) > 1: lp = Composite( [StepFactory.produce(step_config) for step_config in rps_schedule]) else: lp = StepFactory.produce(rps_schedule[0]) in...
[ "Create", "Load", "Plan", "as", "defined", "in", "schedule", ".", "Publish", "info", "about", "its", "duration", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L207-L219
[ "def", "create", "(", "rps_schedule", ")", ":", "if", "len", "(", "rps_schedule", ")", ">", "1", ":", "lp", "=", "Composite", "(", "[", "StepFactory", ".", "produce", "(", "step_config", ")", "for", "step_config", "in", "rps_schedule", "]", ")", "else", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Line.ts
:param n: number of charge :return: when to shoot nth charge, milliseconds
yandextank/stepper/load_plan.py
def ts(self, n): """ :param n: number of charge :return: when to shoot nth charge, milliseconds """ try: root1, root2 = solve_quadratic(self.slope / 2.0, self.minrps, -n) except ZeroDivisionError: root2 = float(n) / self.minrps return int(r...
def ts(self, n): """ :param n: number of charge :return: when to shoot nth charge, milliseconds """ try: root1, root2 = solve_quadratic(self.slope / 2.0, self.minrps, -n) except ZeroDivisionError: root2 = float(n) / self.minrps return int(r...
[ ":", "param", "n", ":", "number", "of", "charge", ":", "return", ":", "when", "to", "shoot", "nth", "charge", "milliseconds" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L65-L74
[ "def", "ts", "(", "self", ",", "n", ")", ":", "try", ":", "root1", ",", "root2", "=", "solve_quadratic", "(", "self", ".", "slope", "/", "2.0", ",", "self", ".", "minrps", ",", "-", "n", ")", "except", "ZeroDivisionError", ":", "root2", "=", "float...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Line.rps_at
Return rps for second t
yandextank/stepper/load_plan.py
def rps_at(self, t): '''Return rps for second t''' if 0 <= t <= self.duration: return self.minrps + \ float(self.maxrps - self.minrps) * t / self.duration else: return 0
def rps_at(self, t): '''Return rps for second t''' if 0 <= t <= self.duration: return self.minrps + \ float(self.maxrps - self.minrps) * t / self.duration else: return 0
[ "Return", "rps", "for", "second", "t" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L83-L89
[ "def", "rps_at", "(", "self", ",", "t", ")", ":", "if", "0", "<=", "t", "<=", "self", ".", "duration", ":", "return", "self", ".", "minrps", "+", "float", "(", "self", ".", "maxrps", "-", "self", ".", "minrps", ")", "*", "t", "/", "self", ".", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Line.get_float_rps_list
get list of constant load parts (we have no constant load at all, but tank will think so), with parts durations (float)
yandextank/stepper/load_plan.py
def get_float_rps_list(self): ''' get list of constant load parts (we have no constant load at all, but tank will think so), with parts durations (float) ''' int_rps = range(int(self.minrps), int(self.maxrps) + 1) step_duration = float(self.duration) / len(int_rps) ...
def get_float_rps_list(self): ''' get list of constant load parts (we have no constant load at all, but tank will think so), with parts durations (float) ''' int_rps = range(int(self.minrps), int(self.maxrps) + 1) step_duration = float(self.duration) / len(int_rps) ...
[ "get", "list", "of", "constant", "load", "parts", "(", "we", "have", "no", "constant", "load", "at", "all", "but", "tank", "will", "think", "so", ")", "with", "parts", "durations", "(", "float", ")" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L99-L107
[ "def", "get_float_rps_list", "(", "self", ")", ":", "int_rps", "=", "range", "(", "int", "(", "self", ".", "minrps", ")", ",", "int", "(", "self", ".", "maxrps", ")", "+", "1", ")", "step_duration", "=", "float", "(", "self", ".", "duration", ")", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Line.get_rps_list
get list of each second's rps :returns: list of tuples (rps, duration of corresponding rps in seconds) :rtype: list
yandextank/stepper/load_plan.py
def get_rps_list(self): """ get list of each second's rps :returns: list of tuples (rps, duration of corresponding rps in seconds) :rtype: list """ seconds = range(0, int(self.duration) + 1) rps_groups = groupby([proper_round(self.rps_at(t)) for t in seconds], ...
def get_rps_list(self): """ get list of each second's rps :returns: list of tuples (rps, duration of corresponding rps in seconds) :rtype: list """ seconds = range(0, int(self.duration) + 1) rps_groups = groupby([proper_round(self.rps_at(t)) for t in seconds], ...
[ "get", "list", "of", "each", "second", "s", "rps", ":", "returns", ":", "list", "of", "tuples", "(", "rps", "duration", "of", "corresponding", "rps", "in", "seconds", ")", ":", "rtype", ":", "list" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/load_plan.py#L109-L119
[ "def", "get_rps_list", "(", "self", ")", ":", "seconds", "=", "range", "(", "0", ",", "int", "(", "self", ".", "duration", ")", "+", "1", ")", "rps_groups", "=", "groupby", "(", "[", "proper_round", "(", "self", ".", "rps_at", "(", "t", ")", ")", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.execute
Execute and check exit code
yandextank/plugins/ShellExec/plugin.py
def execute(self, cmd): """ Execute and check exit code """ self.log.info("Executing: %s", cmd) retcode = execute( cmd, shell=True, poll_period=0.1, catch_out=self.catch_out)[0] if retcode: raise RuntimeError("Subprocess returned %s" % retcode) ...
def execute(self, cmd): """ Execute and check exit code """ self.log.info("Executing: %s", cmd) retcode = execute( cmd, shell=True, poll_period=0.1, catch_out=self.catch_out)[0] if retcode: raise RuntimeError("Subprocess returned %s" % retcode) ...
[ "Execute", "and", "check", "exit", "code" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/ShellExec/plugin.py#L71-L80
[ "def", "execute", "(", "self", ",", "cmd", ")", ":", "self", ".", "log", ".", "info", "(", "\"Executing: %s\"", ",", "cmd", ")", "retcode", "=", "execute", "(", "cmd", ",", "shell", "=", "True", ",", "poll_period", "=", "0.1", ",", "catch_out", "=", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Decoder.decode_monitoring
The reason why we have two separate methods for monitoring and aggregates is a strong difference in incoming data.
yandextank/plugins/InfluxUploader/decoder.py
def decode_monitoring(self, data): """ The reason why we have two separate methods for monitoring and aggregates is a strong difference in incoming data. """ points = list() for second_data in data: for host, host_data in second_data["data"].iteritems(): ...
def decode_monitoring(self, data): """ The reason why we have two separate methods for monitoring and aggregates is a strong difference in incoming data. """ points = list() for second_data in data: for host, host_data in second_data["data"].iteritems(): ...
[ "The", "reason", "why", "we", "have", "two", "separate", "methods", "for", "monitoring", "and", "aggregates", "is", "a", "strong", "difference", "in", "incoming", "data", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/InfluxUploader/decoder.py#L38-L57
[ "def", "decode_monitoring", "(", "self", ",", "data", ")", ":", "points", "=", "list", "(", ")", "for", "second_data", "in", "data", ":", "for", "host", ",", "host_data", "in", "second_data", "[", "\"data\"", "]", ".", "iteritems", "(", ")", ":", "poin...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Decoder.__make_points_for_label
x Make a set of points for `this` label overall_quantiles, overall_meta, net_codes, proto_codes, histograms
yandextank/plugins/InfluxUploader/decoder.py
def __make_points_for_label(self, ts, data, label, prefix, gun_stats): """x Make a set of points for `this` label overall_quantiles, overall_meta, net_codes, proto_codes, histograms """ label_points = list() label_points.extend( ( # overall q...
def __make_points_for_label(self, ts, data, label, prefix, gun_stats): """x Make a set of points for `this` label overall_quantiles, overall_meta, net_codes, proto_codes, histograms """ label_points = list() label_points.extend( ( # overall q...
[ "x", "Make", "a", "set", "of", "points", "for", "this", "label" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/InfluxUploader/decoder.py#L82-L134
[ "def", "__make_points_for_label", "(", "self", ",", "ts", ",", "data", ",", "label", ",", "prefix", ",", "gun_stats", ")", ":", "label_points", "=", "list", "(", ")", "label_points", ".", "extend", "(", "(", "# overall quantiles for label", "self", ".", "__m...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Decoder.__make_points
Parameters ---------- measurement : string measurement type (e.g. monitoring, overall_meta, net_codes, proto_codes, overall_quantiles) additional_tags : dict custom additional tags for this points ts : integer timestamp fields : dict ...
yandextank/plugins/InfluxUploader/decoder.py
def __make_points(self, measurement, additional_tags, ts, fields): """ Parameters ---------- measurement : string measurement type (e.g. monitoring, overall_meta, net_codes, proto_codes, overall_quantiles) additional_tags : dict custom additional tags for ...
def __make_points(self, measurement, additional_tags, ts, fields): """ Parameters ---------- measurement : string measurement type (e.g. monitoring, overall_meta, net_codes, proto_codes, overall_quantiles) additional_tags : dict custom additional tags for ...
[ "Parameters", "----------", "measurement", ":", "string", "measurement", "type", "(", "e", ".", "g", ".", "monitoring", "overall_meta", "net_codes", "proto_codes", "overall_quantiles", ")", "additional_tags", ":", "dict", "custom", "additional", "tags", "for", "this...
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/InfluxUploader/decoder.py#L166-L191
[ "def", "__make_points", "(", "self", ",", "measurement", ",", "additional_tags", ",", "ts", ",", "fields", ")", ":", "tags", "=", "self", ".", "tags", ".", "copy", "(", ")", "tags", ".", "update", "(", "additional_tags", ")", "return", "{", "\"measuremen...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
AbstractPlugin.publish
publish value to status
yandextank/common/interfaces.py
def publish(self, key, value): """publish value to status""" self.log.debug( "Publishing status: %s/%s: %s", self.__class__.__name__, key, value) self.core.publish(self.__class__.__name__, key, value)
def publish(self, key, value): """publish value to status""" self.log.debug( "Publishing status: %s/%s: %s", self.__class__.__name__, key, value) self.core.publish(self.__class__.__name__, key, value)
[ "publish", "value", "to", "status" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/interfaces.py#L98-L102
[ "def", "publish", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Publishing status: %s/%s: %s\"", ",", "self", ".", "__class__", ".", "__name__", ",", "key", ",", "value", ")", "self", ".", "core", ".", "publ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
AbstractCriterion.count_matched_codes
helper to aggregate codes by mask
yandextank/common/interfaces.py
def count_matched_codes(codes_regex, codes_dict): """ helper to aggregate codes by mask """ total = 0 for code, count in codes_dict.items(): if codes_regex.match(str(code)): total += count return total
def count_matched_codes(codes_regex, codes_dict): """ helper to aggregate codes by mask """ total = 0 for code, count in codes_dict.items(): if codes_regex.match(str(code)): total += count return total
[ "helper", "to", "aggregate", "codes", "by", "mask" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/common/interfaces.py#L171-L177
[ "def", "count_matched_codes", "(", "codes_regex", ",", "codes_dict", ")", ":", "total", "=", "0", "for", "code", ",", "count", "in", "codes_dict", ".", "items", "(", ")", ":", "if", "codes_regex", ".", "match", "(", "str", "(", "code", ")", ")", ":", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
BFGBase.stop
Say the workers to finish their jobs and quit.
yandextank/plugins/Bfg/worker.py
def stop(self): """ Say the workers to finish their jobs and quit. """ self.quit.set() # yapf:disable while sorted([ self.pool[i].is_alive() for i in xrange(len(self.pool))])[-1]: time.sleep(1) # yapf:enable try:...
def stop(self): """ Say the workers to finish their jobs and quit. """ self.quit.set() # yapf:disable while sorted([ self.pool[i].is_alive() for i in xrange(len(self.pool))])[-1]: time.sleep(1) # yapf:enable try:...
[ "Say", "the", "workers", "to", "finish", "their", "jobs", "and", "quit", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Bfg/worker.py#L62-L79
[ "def", "stop", "(", "self", ")", ":", "self", ".", "quit", ".", "set", "(", ")", "# yapf:disable", "while", "sorted", "(", "[", "self", ".", "pool", "[", "i", "]", ".", "is_alive", "(", ")", "for", "i", "in", "xrange", "(", "len", "(", "self", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
BFGBase._feed
A feeder that runs in distinct thread in main process.
yandextank/plugins/Bfg/worker.py
def _feed(self): """ A feeder that runs in distinct thread in main process. """ self.plan = StpdReader(self.stpd_filename) if self.cached_stpd: self.plan = list(self.plan) for task in self.plan: if self.quit.is_set(): logger.info("S...
def _feed(self): """ A feeder that runs in distinct thread in main process. """ self.plan = StpdReader(self.stpd_filename) if self.cached_stpd: self.plan = list(self.plan) for task in self.plan: if self.quit.is_set(): logger.info("S...
[ "A", "feeder", "that", "runs", "in", "distinct", "thread", "in", "main", "process", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Bfg/worker.py#L81-L132
[ "def", "_feed", "(", "self", ")", ":", "self", ".", "plan", "=", "StpdReader", "(", "self", ".", "stpd_filename", ")", "if", "self", ".", "cached_stpd", ":", "self", ".", "plan", "=", "list", "(", "self", ".", "plan", ")", "for", "task", "in", "sel...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
BFGMultiprocessing._worker
A worker that does actual jobs
yandextank/plugins/Bfg/worker.py
def _worker(self): """ A worker that does actual jobs """ logger.debug("Init shooter process") try: self.gun.setup() except Exception: logger.exception("Couldn't initialize gun. Exit shooter process") return while not self.quit....
def _worker(self): """ A worker that does actual jobs """ logger.debug("Init shooter process") try: self.gun.setup() except Exception: logger.exception("Couldn't initialize gun. Exit shooter process") return while not self.quit....
[ "A", "worker", "that", "does", "actual", "jobs" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Bfg/worker.py#L140-L186
[ "def", "_worker", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Init shooter process\"", ")", "try", ":", "self", ".", "gun", ".", "setup", "(", ")", "except", "Exception", ":", "logger", ".", "exception", "(", "\"Couldn't initialize gun. Exit shooter...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
BFGGreen._green_worker
A worker that does actual jobs
yandextank/plugins/Bfg/worker.py
def _green_worker(self): """ A worker that does actual jobs """ while not self.quit.is_set(): try: task = self.green_queue.get(timeout=1) timestamp, missile, marker = task planned_time = self.start_time + (timestamp / 1000.0) ...
def _green_worker(self): """ A worker that does actual jobs """ while not self.quit.is_set(): try: task = self.green_queue.get(timeout=1) timestamp, missile, marker = task planned_time = self.start_time + (timestamp / 1000.0) ...
[ "A", "worker", "that", "does", "actual", "jobs" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Bfg/worker.py#L241-L274
[ "def", "_green_worker", "(", "self", ")", ":", "while", "not", "self", ".", "quit", ".", "is_set", "(", ")", ":", "try", ":", "task", "=", "self", ".", "green_queue", ".", "get", "(", "timeout", "=", "1", ")", "timestamp", ",", "missile", ",", "mar...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ApiWorker.init_logging
Set up logging
yandextank/api/apiworker.py
def init_logging(self, log_filename="tank.log"): """ Set up logging """ logger = logging.getLogger('') self.log_filename = log_filename self.core.add_artifact_file(self.log_filename) file_handler = logging.FileHandler(self.log_filename) file_handler.setLevel(logging.DEBU...
def init_logging(self, log_filename="tank.log"): """ Set up logging """ logger = logging.getLogger('') self.log_filename = log_filename self.core.add_artifact_file(self.log_filename) file_handler = logging.FileHandler(self.log_filename) file_handler.setLevel(logging.DEBU...
[ "Set", "up", "logging" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/api/apiworker.py#L22-L58
[ "def", "init_logging", "(", "self", ",", "log_filename", "=", "\"tank.log\"", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "''", ")", "self", ".", "log_filename", "=", "log_filename", "self", ".", "core", ".", "add_artifact_file", "(", "self", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ApiWorker.__add_user_options
override config options with user specified options
yandextank/api/apiworker.py
def __add_user_options(self): """ override config options with user specified options""" if self.options.get('user_options', None): self.core.apply_shorthand_options(self.options['user_options'])
def __add_user_options(self): """ override config options with user specified options""" if self.options.get('user_options', None): self.core.apply_shorthand_options(self.options['user_options'])
[ "override", "config", "options", "with", "user", "specified", "options" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/api/apiworker.py#L60-L63
[ "def", "__add_user_options", "(", "self", ")", ":", "if", "self", ".", "options", ".", "get", "(", "'user_options'", ",", "None", ")", ":", "self", ".", "core", ".", "apply_shorthand_options", "(", "self", ".", "options", "[", "'user_options'", "]", ")" ]
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ApiWorker.configure
Make preparations before running Tank
yandextank/api/apiworker.py
def configure(self, options): """ Make preparations before running Tank """ self.options = options if self.options.get('lock_dir', None): self.core.set_option(self.core.SECTION, "lock_dir", self.options['lock_dir']) if self.options.get('ignore_lock', None): self.c...
def configure(self, options): """ Make preparations before running Tank """ self.options = options if self.options.get('lock_dir', None): self.core.set_option(self.core.SECTION, "lock_dir", self.options['lock_dir']) if self.options.get('ignore_lock', None): self.c...
[ "Make", "preparations", "before", "running", "Tank" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/api/apiworker.py#L65-L93
[ "def", "configure", "(", "self", ",", "options", ")", ":", "self", ".", "options", "=", "options", "if", "self", ".", "options", ".", "get", "(", "'lock_dir'", ",", "None", ")", ":", "self", ".", "core", ".", "set_option", "(", "self", ".", "core", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ApiWorker.get_default_configs
returns default configs list, from /etc, home dir and package_data
yandextank/api/apiworker.py
def get_default_configs(self): """ returns default configs list, from /etc, home dir and package_data""" # initialize basic defaults configs = [resource_filename(__name__, 'config/00-base.ini')] try: conf_files = sorted(os.listdir(self.baseconfigs_location)) for f...
def get_default_configs(self): """ returns default configs list, from /etc, home dir and package_data""" # initialize basic defaults configs = [resource_filename(__name__, 'config/00-base.ini')] try: conf_files = sorted(os.listdir(self.baseconfigs_location)) for f...
[ "returns", "default", "configs", "list", "from", "/", "etc", "home", "dir", "and", "package_data" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/api/apiworker.py#L135-L152
[ "def", "get_default_configs", "(", "self", ")", ":", "# initialize basic defaults", "configs", "=", "[", "resource_filename", "(", "__name__", ",", "'config/00-base.ini'", ")", "]", "try", ":", "conf_files", "=", "sorted", "(", "os", ".", "listdir", "(", "self",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ApiWorker.__graceful_shutdown
call shutdown routines
yandextank/api/apiworker.py
def __graceful_shutdown(self): """ call shutdown routines """ retcode = 1 self.log.info("Trying to shutdown gracefully...") retcode = self.core.plugins_end_test(retcode) retcode = self.core.plugins_post_process(retcode) self.log.info("Done graceful shutdown") retu...
def __graceful_shutdown(self): """ call shutdown routines """ retcode = 1 self.log.info("Trying to shutdown gracefully...") retcode = self.core.plugins_end_test(retcode) retcode = self.core.plugins_post_process(retcode) self.log.info("Done graceful shutdown") retu...
[ "call", "shutdown", "routines" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/api/apiworker.py#L154-L161
[ "def", "__graceful_shutdown", "(", "self", ")", ":", "retcode", "=", "1", "self", ".", "log", ".", "info", "(", "\"Trying to shutdown gracefully...\"", ")", "retcode", "=", "self", ".", "core", ".", "plugins_end_test", "(", "retcode", ")", "retcode", "=", "s...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
TankAggregator._collect_data
Collect data, cache it and send to listeners
yandextank/aggregator/tank_aggregator.py
def _collect_data(self, end=False): """ Collect data, cache it and send to listeners """ data = get_nowait_from_queue(self.results) stats = get_nowait_from_queue(self.stats_results) logger.debug("Data timestamps: %s" % [d.get('ts') for d in data]) logger.debug("St...
def _collect_data(self, end=False): """ Collect data, cache it and send to listeners """ data = get_nowait_from_queue(self.results) stats = get_nowait_from_queue(self.stats_results) logger.debug("Data timestamps: %s" % [d.get('ts') for d in data]) logger.debug("St...
[ "Collect", "data", "cache", "it", "and", "send", "to", "listeners" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/aggregator/tank_aggregator.py#L81-L111
[ "def", "_collect_data", "(", "self", ",", "end", "=", "False", ")", ":", "data", "=", "get_nowait_from_queue", "(", "self", ".", "results", ")", "stats", "=", "get_nowait_from_queue", "(", "self", ".", "stats_results", ")", "logger", ".", "debug", "(", "\"...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
TankAggregator.__notify_listeners
notify all listeners about aggregate data and stats
yandextank/aggregator/tank_aggregator.py
def __notify_listeners(self, data, stats): """ notify all listeners about aggregate data and stats """ for listener in self.listeners: listener.on_aggregated_data(data, stats)
def __notify_listeners(self, data, stats): """ notify all listeners about aggregate data and stats """ for listener in self.listeners: listener.on_aggregated_data(data, stats)
[ "notify", "all", "listeners", "about", "aggregate", "data", "and", "stats" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/aggregator/tank_aggregator.py#L137-L140
[ "def", "__notify_listeners", "(", "self", ",", "data", ",", "stats", ")", ":", "for", "listener", "in", "self", ".", "listeners", ":", "listener", ".", "on_aggregated_data", "(", "data", ",", "stats", ")" ]
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
get_marker
Returns a marker function of the requested marker_type >>> marker = get_marker('uniq')(__test_missile) >>> type(marker) <type 'str'> >>> len(marker) 32 >>> get_marker('uri')(__test_missile) '_example_search_hello_help_us' >>> marker = get_marker('non-existent')(__test_missile) Tra...
yandextank/stepper/mark.py
def get_marker(marker_type, enum_ammo=False): ''' Returns a marker function of the requested marker_type >>> marker = get_marker('uniq')(__test_missile) >>> type(marker) <type 'str'> >>> len(marker) 32 >>> get_marker('uri')(__test_missile) '_example_search_hello_help_us' >>> m...
def get_marker(marker_type, enum_ammo=False): ''' Returns a marker function of the requested marker_type >>> marker = get_marker('uniq')(__test_missile) >>> type(marker) <type 'str'> >>> len(marker) 32 >>> get_marker('uri')(__test_missile) '_example_search_hello_help_us' >>> m...
[ "Returns", "a", "marker", "function", "of", "the", "requested", "marker_type" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/mark.py#L54-L98
[ "def", "get_marker", "(", "marker_type", ",", "enum_ammo", "=", "False", ")", ":", "try", ":", "limit", "=", "int", "(", "marker_type", ")", "if", "limit", ":", "marker", "=", "__UriMarker", "(", "limit", ")", "else", ":", "def", "marker", "(", "m", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
get_uploader
:type column_mapping: dict :type data_session: DataSession
yandextank/plugins/NeUploader/plugin.py
def get_uploader(data_session, column_mapping, overall_only=False): """ :type column_mapping: dict :type data_session: DataSession """ overall = {col_name: data_session.new_aggregated_metric(name + ' overall') for col_name, name in column_mapping.items()} def upload_df(df): ...
def get_uploader(data_session, column_mapping, overall_only=False): """ :type column_mapping: dict :type data_session: DataSession """ overall = {col_name: data_session.new_aggregated_metric(name + ' overall') for col_name, name in column_mapping.items()} def upload_df(df): ...
[ ":", "type", "column_mapping", ":", "dict", ":", "type", "data_session", ":", "DataSession" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/NeUploader/plugin.py#L81-L93
[ "def", "get_uploader", "(", "data_session", ",", "column_mapping", ",", "overall_only", "=", "False", ")", ":", "overall", "=", "{", "col_name", ":", "data_session", ".", "new_aggregated_metric", "(", "name", "+", "' overall'", ")", "for", "col_name", ",", "na...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
cfg_folder_loader
:type path: str
yandextank/core/consoleworker.py
def cfg_folder_loader(path): """ :type path: str """ CFG_WILDCARD = '*.yaml' return [load_cfg(filename) for filename in sorted(glob.glob(os.path.join(path, CFG_WILDCARD)))]
def cfg_folder_loader(path): """ :type path: str """ CFG_WILDCARD = '*.yaml' return [load_cfg(filename) for filename in sorted(glob.glob(os.path.join(path, CFG_WILDCARD)))]
[ ":", "type", "path", ":", "str" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/core/consoleworker.py#L81-L86
[ "def", "cfg_folder_loader", "(", "path", ")", ":", "CFG_WILDCARD", "=", "'*.yaml'", "return", "[", "load_cfg", "(", "filename", ")", "for", "filename", "in", "sorted", "(", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "path", ",", "CF...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
parse_options
:type options: list of str :rtype: list of dict
yandextank/core/consoleworker.py
def parse_options(options): """ :type options: list of str :rtype: list of dict """ if options is None: return [] else: return [ convert_single_option(key.strip(), value.strip()) for key, value in [option.split('=', 1) for option in options] ...
def parse_options(options): """ :type options: list of str :rtype: list of dict """ if options is None: return [] else: return [ convert_single_option(key.strip(), value.strip()) for key, value in [option.split('=', 1) for option in options] ...
[ ":", "type", "options", ":", "list", "of", "str", ":", "rtype", ":", "list", "of", "dict" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/core/consoleworker.py#L97-L109
[ "def", "parse_options", "(", "options", ")", ":", "if", "options", "is", "None", ":", "return", "[", "]", "else", ":", "return", "[", "convert_single_option", "(", "key", ".", "strip", "(", ")", ",", "value", ".", "strip", "(", ")", ")", "for", "key"...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
get_default_configs
returns default configs list, from /etc and home dir
yandextank/core/consoleworker.py
def get_default_configs(): """ returns default configs list, from /etc and home dir """ # initialize basic defaults configs = [resource_filename(__name__, 'config/00-base.ini')] baseconfigs_location = '/etc/yandex-tank' try: conf_files = sorted(os.listdir(baseconfigs_location)) for f...
def get_default_configs(): """ returns default configs list, from /etc and home dir """ # initialize basic defaults configs = [resource_filename(__name__, 'config/00-base.ini')] baseconfigs_location = '/etc/yandex-tank' try: conf_files = sorted(os.listdir(baseconfigs_location)) for f...
[ "returns", "default", "configs", "list", "from", "/", "etc", "and", "home", "dir" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/core/consoleworker.py#L149-L167
[ "def", "get_default_configs", "(", ")", ":", "# initialize basic defaults", "configs", "=", "[", "resource_filename", "(", "__name__", ",", "'config/00-base.ini'", ")", "]", "baseconfigs_location", "=", "'/etc/yandex-tank'", "try", ":", "conf_files", "=", "sorted", "(...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
RealConsoleMarkup.clean_markup
clean markup from string
yandextank/core/consoleworker.py
def clean_markup(self, orig_str): ''' clean markup from string ''' for val in [ self.YELLOW, self.RED, self.RESET, self.CYAN, self.BG_MAGENTA, self.WHITE, self.BG_GREEN, self.GREEN, self.BG_BROWN, self.RED_DARK, self.MAGENTA, self.BG_CYAN ]: orig_s...
def clean_markup(self, orig_str): ''' clean markup from string ''' for val in [ self.YELLOW, self.RED, self.RESET, self.CYAN, self.BG_MAGENTA, self.WHITE, self.BG_GREEN, self.GREEN, self.BG_BROWN, self.RED_DARK, self.MAGENTA, self.BG_CYAN ]: orig_s...
[ "clean", "markup", "from", "string" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/core/consoleworker.py#L49-L57
[ "def", "clean_markup", "(", "self", ",", "orig_str", ")", ":", "for", "val", "in", "[", "self", ".", "YELLOW", ",", "self", ".", "RED", ",", "self", ".", "RESET", ",", "self", ".", "CYAN", ",", "self", ".", "BG_MAGENTA", ",", "self", ".", "WHITE", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
parse_duration
Parse duration string, such as '3h2m3s' into milliseconds >>> parse_duration('3h2m3s') 10923000 >>> parse_duration('0.3s') 300 >>> parse_duration('5') 5000
yandextank/stepper/util.py
def parse_duration(duration): ''' Parse duration string, such as '3h2m3s' into milliseconds >>> parse_duration('3h2m3s') 10923000 >>> parse_duration('0.3s') 300 >>> parse_duration('5') 5000 ''' _re_token = re.compile("([0-9.]+)([dhms]?)") def parse_token(time, multiplier)...
def parse_duration(duration): ''' Parse duration string, such as '3h2m3s' into milliseconds >>> parse_duration('3h2m3s') 10923000 >>> parse_duration('0.3s') 300 >>> parse_duration('5') 5000 ''' _re_token = re.compile("([0-9.]+)([dhms]?)") def parse_token(time, multiplier)...
[ "Parse", "duration", "string", "such", "as", "3h2m3s", "into", "milliseconds" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/util.py#L18-L49
[ "def", "parse_duration", "(", "duration", ")", ":", "_re_token", "=", "re", ".", "compile", "(", "\"([0-9.]+)([dhms]?)\"", ")", "def", "parse_token", "(", "time", ",", "multiplier", ")", ":", "multipliers", "=", "{", "'d'", ":", "86400", ",", "'h'", ":", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
solve_quadratic
>>> solve_quadratic(1.0, 2.0, 1.0) (-1.0, -1.0)
yandextank/stepper/util.py
def solve_quadratic(a, b, c): ''' >>> solve_quadratic(1.0, 2.0, 1.0) (-1.0, -1.0) ''' discRoot = math.sqrt((b * b) - 4 * a * c) root1 = (-b - discRoot) / (2 * a) root2 = (-b + discRoot) / (2 * a) return (root1, root2)
def solve_quadratic(a, b, c): ''' >>> solve_quadratic(1.0, 2.0, 1.0) (-1.0, -1.0) ''' discRoot = math.sqrt((b * b) - 4 * a * c) root1 = (-b - discRoot) / (2 * a) root2 = (-b + discRoot) / (2 * a) return (root1, root2)
[ ">>>", "solve_quadratic", "(", "1", ".", "0", "2", ".", "0", "1", ".", "0", ")", "(", "-", "1", ".", "0", "-", "1", ".", "0", ")" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/util.py#L52-L60
[ "def", "solve_quadratic", "(", "a", ",", "b", ",", "c", ")", ":", "discRoot", "=", "math", ".", "sqrt", "(", "(", "b", "*", "b", ")", "-", "4", "*", "a", "*", "c", ")", "root1", "=", "(", "-", "b", "-", "discRoot", ")", "/", "(", "2", "*"...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
proper_round
rounds float to closest int :rtype: int :param n: float
yandextank/stepper/util.py
def proper_round(n): """ rounds float to closest int :rtype: int :param n: float """ return int(n) + (n / abs(n)) * int(abs(n - int(n)) >= 0.5) if n != 0 else 0
def proper_round(n): """ rounds float to closest int :rtype: int :param n: float """ return int(n) + (n / abs(n)) * int(abs(n - int(n)) >= 0.5) if n != 0 else 0
[ "rounds", "float", "to", "closest", "int", ":", "rtype", ":", "int", ":", "param", "n", ":", "float" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/util.py#L67-L73
[ "def", "proper_round", "(", "n", ")", ":", "return", "int", "(", "n", ")", "+", "(", "n", "/", "abs", "(", "n", ")", ")", "*", "int", "(", "abs", "(", "n", "-", "int", "(", "n", ")", ")", ">=", "0.5", ")", "if", "n", "!=", "0", "else", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
LocalhostClient.start
Start local agent
yandextank/plugins/Telegraf/client.py
def start(self): """Start local agent""" logger.info('Starting agent on localhost') args = self.python.split() + [ os.path.join( self.workdir, self.AGENT_FILENAME), '--telegraf', self.path['TELEGRAF_LOCAL_PATH'], '--...
def start(self): """Start local agent""" logger.info('Starting agent on localhost') args = self.python.split() + [ os.path.join( self.workdir, self.AGENT_FILENAME), '--telegraf', self.path['TELEGRAF_LOCAL_PATH'], '--...
[ "Start", "local", "agent" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/client.py#L105-L121
[ "def", "start", "(", "self", ")", ":", "logger", ".", "info", "(", "'Starting agent on localhost'", ")", "args", "=", "self", ".", "python", ".", "split", "(", ")", "+", "[", "os", ".", "path", ".", "join", "(", "self", ".", "workdir", ",", "self", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
LocalhostClient.uninstall
Remove agent's files from remote host
yandextank/plugins/Telegraf/client.py
def uninstall(self): """ Remove agent's files from remote host """ if self.session: logger.info('Waiting monitoring data...') self.session.terminate() self.session.wait() self.session = None log_filename = "agent_{host}.log".format(...
def uninstall(self): """ Remove agent's files from remote host """ if self.session: logger.info('Waiting monitoring data...') self.session.terminate() self.session.wait() self.session = None log_filename = "agent_{host}.log".format(...
[ "Remove", "agent", "s", "files", "from", "remote", "host" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/client.py#L141-L162
[ "def", "uninstall", "(", "self", ")", ":", "if", "self", ".", "session", ":", "logger", ".", "info", "(", "'Waiting monitoring data...'", ")", "self", ".", "session", ".", "terminate", "(", ")", "self", ".", "session", ".", "wait", "(", ")", "self", "....
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
SSHClient.install
Create folder and copy agent and metrics scripts to remote host
yandextank/plugins/Telegraf/client.py
def install(self): """Create folder and copy agent and metrics scripts to remote host""" logger.info( "Installing monitoring agent at %s@%s...", self.username, self.host) # create remote temp dir cmd = self.python + ' -c "import tempfile; print tempfi...
def install(self): """Create folder and copy agent and metrics scripts to remote host""" logger.info( "Installing monitoring agent at %s@%s...", self.username, self.host) # create remote temp dir cmd = self.python + ' -c "import tempfile; print tempfi...
[ "Create", "folder", "and", "copy", "agent", "and", "metrics", "scripts", "to", "remote", "host" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/client.py#L198-L309
[ "def", "install", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Installing monitoring agent at %s@%s...\"", ",", "self", ".", "username", ",", "self", ".", "host", ")", "# create remote temp dir", "cmd", "=", "self", ".", "python", "+", "' -c \"import te...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
SSHClient.start
Start remote agent
yandextank/plugins/Telegraf/client.py
def start(self): """Start remote agent""" logger.info('Starting agent: %s', self.host) command = "{python} {agent_path} --telegraf {telegraf_path} --host {host} {kill_old}".format( python=self.python, agent_path=os.path.join( self.path['AGENT_REMOTE_FOLDER...
def start(self): """Start remote agent""" logger.info('Starting agent: %s', self.host) command = "{python} {agent_path} --telegraf {telegraf_path} --host {host} {kill_old}".format( python=self.python, agent_path=os.path.join( self.path['AGENT_REMOTE_FOLDER...
[ "Start", "remote", "agent" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/client.py#L311-L326
[ "def", "start", "(", "self", ")", ":", "logger", ".", "info", "(", "'Starting agent: %s'", ",", "self", ".", "host", ")", "command", "=", "\"{python} {agent_path} --telegraf {telegraf_path} --host {host} {kill_old}\"", ".", "format", "(", "python", "=", "self", ".",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
SSHClient.uninstall
Remove agent's files from remote host
yandextank/plugins/Telegraf/client.py
def uninstall(self): """ Remove agent's files from remote host """ log_filename = "agent_{host}.log".format(host=self.host) data_filename = "agent_{host}.rawdata".format(host=self.host) try: if self.session: self.session.send("stop\n") ...
def uninstall(self): """ Remove agent's files from remote host """ log_filename = "agent_{host}.log".format(host=self.host) data_filename = "agent_{host}.rawdata".format(host=self.host) try: if self.session: self.session.send("stop\n") ...
[ "Remove", "agent", "s", "files", "from", "remote", "host" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/client.py#L342-L375
[ "def", "uninstall", "(", "self", ")", ":", "log_filename", "=", "\"agent_{host}.log\"", ".", "format", "(", "host", "=", "self", ".", "host", ")", "data_filename", "=", "\"agent_{host}.rawdata\"", ".", "format", "(", "host", "=", "self", ".", "host", ")", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
parse_sections
:type cfg_ini: ConfigParser
yandextank/config_converter/converter.py
def parse_sections(cfg_ini): """ :type cfg_ini: ConfigParser """ return [Section(section.lower(), guess_plugin(section.lower()), without_defaults(cfg_ini, section)) for section in cfg_ini.sections() if not re.match(CORE_SECTION_PATTERN, sec...
def parse_sections(cfg_ini): """ :type cfg_ini: ConfigParser """ return [Section(section.lower(), guess_plugin(section.lower()), without_defaults(cfg_ini, section)) for section in cfg_ini.sections() if not re.match(CORE_SECTION_PATTERN, sec...
[ ":", "type", "cfg_ini", ":", "ConfigParser" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L381-L389
[ "def", "parse_sections", "(", "cfg_ini", ")", ":", "return", "[", "Section", "(", "section", ".", "lower", "(", ")", ",", "guess_plugin", "(", "section", ".", "lower", "(", ")", ")", ",", "without_defaults", "(", "cfg_ini", ",", "section", ")", ")", "f...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
combine_sections
:type sections: list of Section :rtype: list of Section
yandextank/config_converter/converter.py
def combine_sections(sections): """ :type sections: list of Section :rtype: list of Section """ PLUGINS_TO_COMBINE = { 'Phantom': ('phantom', 'multi', True), 'Bfg': ('bfg', 'gun_config', False) } plugins = {} ready_sections = [] for section in sections: if sec...
def combine_sections(sections): """ :type sections: list of Section :rtype: list of Section """ PLUGINS_TO_COMBINE = { 'Phantom': ('phantom', 'multi', True), 'Bfg': ('bfg', 'gun_config', False) } plugins = {} ready_sections = [] for section in sections: if sec...
[ ":", "type", "sections", ":", "list", "of", "Section", ":", "rtype", ":", "list", "of", "Section" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L467-L491
[ "def", "combine_sections", "(", "sections", ")", ":", "PLUGINS_TO_COMBINE", "=", "{", "'Phantom'", ":", "(", "'phantom'", ",", "'multi'", ",", "True", ")", ",", "'Bfg'", ":", "(", "'bfg'", ",", "'gun_config'", ",", "False", ")", "}", "plugins", "=", "{",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Option.converted
:rtype: {str: object}
yandextank/config_converter/converter.py
def converted(self): """ :rtype: {str: object} """ if self._converted is None: self._converted = self.converter(self.name, self.value) return self._converted
def converted(self): """ :rtype: {str: object} """ if self._converted is None: self._converted = self.converter(self.name, self.value) return self._converted
[ ":", "rtype", ":", "{", "str", ":", "object", "}" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L252-L258
[ "def", "converted", "(", "self", ")", ":", "if", "self", ".", "_converted", "is", "None", ":", "self", ".", "_converted", "=", "self", ".", "converter", "(", "self", ".", "name", ",", "self", ".", "value", ")", "return", "self", ".", "_converted" ]
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Option.as_tuple
:rtype: (str, object)
yandextank/config_converter/converter.py
def as_tuple(self): """ :rtype: (str, object) """ if self._as_tuple is None: self._as_tuple = self.converted.items()[0] return self._as_tuple
def as_tuple(self): """ :rtype: (str, object) """ if self._as_tuple is None: self._as_tuple = self.converted.items()[0] return self._as_tuple
[ ":", "rtype", ":", "(", "str", "object", ")" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L261-L267
[ "def", "as_tuple", "(", "self", ")", ":", "if", "self", ".", "_as_tuple", "is", "None", ":", "self", ".", "_as_tuple", "=", "self", ".", "converted", ".", "items", "(", ")", "[", "0", "]", "return", "self", ".", "_as_tuple" ]
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Option.converter
:rtype: callable
yandextank/config_converter/converter.py
def converter(self): """ :rtype: callable """ if self._converter is None: try: self._converter = self.SPECIAL_CONVERTERS[self.plugin][self.name] except KeyError: try: self._converter = self._get_scheme_converter(...
def converter(self): """ :rtype: callable """ if self._converter is None: try: self._converter = self.SPECIAL_CONVERTERS[self.plugin][self.name] except KeyError: try: self._converter = self._get_scheme_converter(...
[ ":", "rtype", ":", "callable" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L270-L282
[ "def", "converter", "(", "self", ")", ":", "if", "self", ".", "_converter", "is", "None", ":", "try", ":", "self", ".", "_converter", "=", "self", ".", "SPECIAL_CONVERTERS", "[", "self", ".", "plugin", "]", "[", "self", ".", "name", "]", "except", "K...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Section.from_multiple
:type parent_name: str :type sections: list of Section
yandextank/config_converter/converter.py
def from_multiple(cls, sections, parent_name=None, child_name=None, is_list=True): """ :type parent_name: str :type sections: list of Section """ if len(sections) == 1: return sections[0] if parent_name: master_section = filter(lambda section: sect...
def from_multiple(cls, sections, parent_name=None, child_name=None, is_list=True): """ :type parent_name: str :type sections: list of Section """ if len(sections) == 1: return sections[0] if parent_name: master_section = filter(lambda section: sect...
[ ":", "type", "parent_name", ":", "str", ":", "type", "sections", ":", "list", "of", "Section" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/config_converter/converter.py#L333-L350
[ "def", "from_multiple", "(", "cls", ",", "sections", ",", "parent_name", "=", "None", ",", "child_name", "=", "None", ",", "is_list", "=", "True", ")", ":", "if", "len", "(", "sections", ")", "==", "1", ":", "return", "sections", "[", "0", "]", "if",...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
RSTRenderer.title
Underlines content with '='. New lines and tabs will be replaced :param str content: :param str new_line_replacement: :param str tab_replacement: :return: unicode
yandextank/validator/docs_gen.py
def title(content, new_line_replacement=' ', tab_replacement=' '): """ Underlines content with '='. New lines and tabs will be replaced :param str content: :param str new_line_replacement: :param str tab_replacement: :return: unicode """ prepared_content ...
def title(content, new_line_replacement=' ', tab_replacement=' '): """ Underlines content with '='. New lines and tabs will be replaced :param str content: :param str new_line_replacement: :param str tab_replacement: :return: unicode """ prepared_content ...
[ "Underlines", "content", "with", "=", ".", "New", "lines", "and", "tabs", "will", "be", "replaced", ":", "param", "str", "content", ":", ":", "param", "str", "new_line_replacement", ":", ":", "param", "str", "tab_replacement", ":", ":", "return", ":", "uni...
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/validator/docs_gen.py#L113-L122
[ "def", "title", "(", "content", ",", "new_line_replacement", "=", "' '", ",", "tab_replacement", "=", "' '", ")", ":", "prepared_content", "=", "content", ".", "strip", "(", ")", ".", "replace", "(", "'\\n'", ",", "new_line_replacement", ")", ".", "replace"...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__discover_jmeter_udp_port
Searching for line in jmeter.log such as Waiting for possible shutdown message on port 4445
yandextank/plugins/JMeter/plugin.py
def __discover_jmeter_udp_port(self): """Searching for line in jmeter.log such as Waiting for possible shutdown message on port 4445 """ r = re.compile(self.DISCOVER_PORT_PATTERN) with open(self.process_stderr.name, 'r') as f: cnt = 0 while self.process.pi...
def __discover_jmeter_udp_port(self): """Searching for line in jmeter.log such as Waiting for possible shutdown message on port 4445 """ r = re.compile(self.DISCOVER_PORT_PATTERN) with open(self.process_stderr.name, 'r') as f: cnt = 0 while self.process.pi...
[ "Searching", "for", "line", "in", "jmeter", ".", "log", "such", "as", "Waiting", "for", "possible", "shutdown", "message", "on", "port", "4445" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/JMeter/plugin.py#L169-L187
[ "def", "__discover_jmeter_udp_port", "(", "self", ")", ":", "r", "=", "re", ".", "compile", "(", "self", ".", "DISCOVER_PORT_PATTERN", ")", "with", "open", "(", "self", ".", "process_stderr", ".", "name", ",", "'r'", ")", "as", "f", ":", "cnt", "=", "0...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__add_jmeter_components
Genius idea by Alexey Lavrenyuk
yandextank/plugins/JMeter/plugin.py
def __add_jmeter_components(self, jmx, jtl, variables): """ Genius idea by Alexey Lavrenyuk """ logger.debug("Original JMX: %s", os.path.realpath(jmx)) with open(jmx, 'r') as src_jmx: source_lines = src_jmx.readlines() try: # In new Jmeter version (3.2 as example...
def __add_jmeter_components(self, jmx, jtl, variables): """ Genius idea by Alexey Lavrenyuk """ logger.debug("Original JMX: %s", os.path.realpath(jmx)) with open(jmx, 'r') as src_jmx: source_lines = src_jmx.readlines() try: # In new Jmeter version (3.2 as example...
[ "Genius", "idea", "by", "Alexey", "Lavrenyuk" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/JMeter/plugin.py#L199-L263
[ "def", "__add_jmeter_components", "(", "self", ",", "jmx", ",", "jtl", ",", "variables", ")", ":", "logger", ".", "debug", "(", "\"Original JMX: %s\"", ",", "os", ".", "path", ".", "realpath", "(", "jmx", ")", ")", "with", "open", "(", "jmx", ",", "'r'...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__terminate
Gracefull termination of running process
yandextank/plugins/ShootExec/plugin.py
def __terminate(self): """Gracefull termination of running process""" if self.__stderr_file: self.__stderr_file.close() if not self.__process: return waitfor = time.time() + _PROCESS_KILL_TIMEOUT while time.time() < waitfor: try: ...
def __terminate(self): """Gracefull termination of running process""" if self.__stderr_file: self.__stderr_file.close() if not self.__process: return waitfor = time.time() + _PROCESS_KILL_TIMEOUT while time.time() < waitfor: try: ...
[ "Gracefull", "termination", "of", "running", "process" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/ShootExec/plugin.py#L153-L177
[ "def", "__terminate", "(", "self", ")", ":", "if", "self", ".", "__stderr_file", ":", "self", ".", "__stderr_file", ".", "close", "(", ")", "if", "not", "self", ".", "__process", ":", "return", "waitfor", "=", "time", ".", "time", "(", ")", "+", "_PR...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
_FileStatsReader._read_data
Parse lines and return stats
yandextank/plugins/ShootExec/plugin.py
def _read_data(self, lines): """ Parse lines and return stats """ results = [] for line in lines: timestamp, rps, instances = line.split("\t") curr_ts = int(float(timestamp)) # We allow floats here, but tank expects only seconds if self.__las...
def _read_data(self, lines): """ Parse lines and return stats """ results = [] for line in lines: timestamp, rps, instances = line.split("\t") curr_ts = int(float(timestamp)) # We allow floats here, but tank expects only seconds if self.__las...
[ "Parse", "lines", "and", "return", "stats" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/ShootExec/plugin.py#L210-L222
[ "def", "_read_data", "(", "self", ",", "lines", ")", ":", "results", "=", "[", "]", "for", "line", "in", "lines", ":", "timestamp", ",", "rps", ",", "instances", "=", "line", ".", "split", "(", "\"\\t\"", ")", "curr_ts", "=", "int", "(", "float", "...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__create_criterion
instantiate criterion from config string
yandextank/plugins/Autostop/plugin.py
def __create_criterion(self, criterion_str): """ instantiate criterion from config string """ parsed = criterion_str.split("(") type_str = parsed[0].strip().lower() parsed[1] = parsed[1].split(")")[0].strip() for criterion_class in self.custom_criterions: if criterio...
def __create_criterion(self, criterion_str): """ instantiate criterion from config string """ parsed = criterion_str.split("(") type_str = parsed[0].strip().lower() parsed[1] = parsed[1].split(")")[0].strip() for criterion_class in self.custom_criterions: if criterio...
[ "instantiate", "criterion", "from", "config", "string" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Autostop/plugin.py#L98-L108
[ "def", "__create_criterion", "(", "self", ",", "criterion_str", ")", ":", "parsed", "=", "criterion_str", ".", "split", "(", "\"(\"", ")", "type_str", "=", "parsed", "[", "0", "]", ".", "strip", "(", ")", ".", "lower", "(", ")", "parsed", "[", "1", "...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
ConfigManager.getconfig
Prepare config data.
yandextank/plugins/Telegraf/config.py
def getconfig(self, filename, target_hint): """Prepare config data.""" try: tree = self.parse_xml(filename) except IOError as exc: logger.error("Error loading config: %s", exc) raise RuntimeError("Can't read monitoring config %s" % filename) hosts = tr...
def getconfig(self, filename, target_hint): """Prepare config data.""" try: tree = self.parse_xml(filename) except IOError as exc: logger.error("Error loading config: %s", exc) raise RuntimeError("Can't read monitoring config %s" % filename) hosts = tr...
[ "Prepare", "config", "data", "." ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/config.py#L30-L42
[ "def", "getconfig", "(", "self", ",", "filename", ",", "target_hint", ")", ":", "try", ":", "tree", "=", "self", ".", "parse_xml", "(", "filename", ")", "except", "IOError", "as", "exc", ":", "logger", ".", "error", "(", "\"Error loading config: %s\"", ","...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
AgentConfig.create_startup_config
Startup and shutdown commands config Used by agent.py on the target
yandextank/plugins/Telegraf/config.py
def create_startup_config(self): """ Startup and shutdown commands config Used by agent.py on the target """ cfg_path = "agent_startup_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( 'Found agent startup config file in working dire...
def create_startup_config(self): """ Startup and shutdown commands config Used by agent.py on the target """ cfg_path = "agent_startup_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( 'Found agent startup config file in working dire...
[ "Startup", "and", "shutdown", "commands", "config", "Used", "by", "agent", ".", "py", "on", "the", "target" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/config.py#L185-L225
[ "def", "create_startup_config", "(", "self", ")", ":", "cfg_path", "=", "\"agent_startup_{}.cfg\"", ".", "format", "(", "self", ".", "host", ")", "if", "os", ".", "path", ".", "isfile", "(", "cfg_path", ")", ":", "logger", ".", "info", "(", "'Found agent s...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
AgentConfig.create_custom_exec_script
bash script w/ custom commands inside inspired by half a night trying to avoid escaping bash special characters
yandextank/plugins/Telegraf/config.py
def create_custom_exec_script(self): """ bash script w/ custom commands inside inspired by half a night trying to avoid escaping bash special characters """ cfg_path = "agent_customs_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( ...
def create_custom_exec_script(self): """ bash script w/ custom commands inside inspired by half a night trying to avoid escaping bash special characters """ cfg_path = "agent_customs_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( ...
[ "bash", "script", "w", "/", "custom", "commands", "inside", "inspired", "by", "half", "a", "night", "trying", "to", "avoid", "escaping", "bash", "special", "characters" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/config.py#L227-L258
[ "def", "create_custom_exec_script", "(", "self", ")", ":", "cfg_path", "=", "\"agent_customs_{}.cfg\"", ".", "format", "(", "self", ".", "host", ")", "if", "os", ".", "path", ".", "isfile", "(", "cfg_path", ")", ":", "logger", ".", "info", "(", "'Found age...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
AgentConfig.create_collector_config
Telegraf collector config, toml format
yandextank/plugins/Telegraf/config.py
def create_collector_config(self, workdir): """ Telegraf collector config, toml format """ cfg_path = "agent_collector_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( 'Found agent config file in working directory with the same name...
def create_collector_config(self, workdir): """ Telegraf collector config, toml format """ cfg_path = "agent_collector_{}.cfg".format(self.host) if os.path.isfile(cfg_path): logger.info( 'Found agent config file in working directory with the same name...
[ "Telegraf", "collector", "config", "toml", "format" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Telegraf/config.py#L260-L366
[ "def", "create_collector_config", "(", "self", ",", "workdir", ")", ":", "cfg_path", "=", "\"agent_collector_{}.cfg\"", ".", "format", "(", "self", ".", "host", ")", "if", "os", ".", "path", ".", "isfile", "(", "cfg_path", ")", ":", "logger", ".", "info", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__check_disk
raise exception on disk space exceeded
yandextank/plugins/ResourceCheck/plugin.py
def __check_disk(self): ''' raise exception on disk space exceeded ''' cmd = "sh -c \"df --no-sync -m -P -l -x fuse -x tmpfs -x devtmpfs -x davfs -x nfs " cmd += self.core.artifacts_base_dir cmd += " | tail -n 1 | awk '{print \$4}' \"" res = execute(cmd, True, 0.1, True) ...
def __check_disk(self): ''' raise exception on disk space exceeded ''' cmd = "sh -c \"df --no-sync -m -P -l -x fuse -x tmpfs -x devtmpfs -x davfs -x nfs " cmd += self.core.artifacts_base_dir cmd += " | tail -n 1 | awk '{print \$4}' \"" res = execute(cmd, True, 0.1, True) ...
[ "raise", "exception", "on", "disk", "space", "exceeded" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/ResourceCheck/plugin.py#L52-L70
[ "def", "__check_disk", "(", "self", ")", ":", "cmd", "=", "\"sh -c \\\"df --no-sync -m -P -l -x fuse -x tmpfs -x devtmpfs -x davfs -x nfs \"", "cmd", "+=", "self", ".", "core", ".", "artifacts_base_dir", "cmd", "+=", "\" | tail -n 1 | awk '{print \\$4}' \\\"\"", "res", "=", ...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Plugin.__check_mem
raise exception on RAM exceeded
yandextank/plugins/ResourceCheck/plugin.py
def __check_mem(self): ''' raise exception on RAM exceeded ''' mem_free = psutil.virtual_memory().available / 2**20 self.log.debug("Memory free: %s/%s", mem_free, self.mem_limit) if mem_free < self.mem_limit: raise RuntimeError( "Not enough resources: free mem...
def __check_mem(self): ''' raise exception on RAM exceeded ''' mem_free = psutil.virtual_memory().available / 2**20 self.log.debug("Memory free: %s/%s", mem_free, self.mem_limit) if mem_free < self.mem_limit: raise RuntimeError( "Not enough resources: free mem...
[ "raise", "exception", "on", "RAM", "exceeded" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/ResourceCheck/plugin.py#L72-L79
[ "def", "__check_mem", "(", "self", ")", ":", "mem_free", "=", "psutil", ".", "virtual_memory", "(", ")", ".", "available", "/", "2", "**", "20", "self", ".", "log", ".", "debug", "(", "\"Memory free: %s/%s\"", ",", "mem_free", ",", "self", ".", "mem_limi...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
get_terminal_size
Gets width and height of terminal viewport
yandextank/plugins/Console/screen.py
def get_terminal_size(): ''' Gets width and height of terminal viewport ''' default_size = (30, 120) env = os.environ def ioctl_gwinsz(file_d): ''' Helper to get console size ''' try: sizes = struct.unpack( 'hh', fcntl.ioctl(file_d, te...
def get_terminal_size(): ''' Gets width and height of terminal viewport ''' default_size = (30, 120) env = os.environ def ioctl_gwinsz(file_d): ''' Helper to get console size ''' try: sizes = struct.unpack( 'hh', fcntl.ioctl(file_d, te...
[ "Gets", "width", "and", "height", "of", "terminal", "viewport" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Console/screen.py#L16-L47
[ "def", "get_terminal_size", "(", ")", ":", "default_size", "=", "(", "30", ",", "120", ")", "env", "=", "os", ".", "environ", "def", "ioctl_gwinsz", "(", "file_d", ")", ":", "'''\n Helper to get console size\n '''", "try", ":", "sizes", "=", "str...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Screen.__get_right_line
Gets next line for right panel
yandextank/plugins/Console/screen.py
def __get_right_line(self, widget_output): ''' Gets next line for right panel ''' right_line = '' if widget_output: right_line = widget_output.pop(0) if len(right_line) > self.right_panel_width: right_line_plain = self.markup.clean_markup(rig...
def __get_right_line(self, widget_output): ''' Gets next line for right panel ''' right_line = '' if widget_output: right_line = widget_output.pop(0) if len(right_line) > self.right_panel_width: right_line_plain = self.markup.clean_markup(rig...
[ "Gets", "next", "line", "for", "right", "panel" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Console/screen.py#L318-L327
[ "def", "__get_right_line", "(", "self", ",", "widget_output", ")", ":", "right_line", "=", "''", "if", "widget_output", ":", "right_line", "=", "widget_output", ".", "pop", "(", "0", ")", "if", "len", "(", "right_line", ")", ">", "self", ".", "right_panel_...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b
test
Screen.__truncate
Cut tuple of line chunks according to it's wisible lenght
yandextank/plugins/Console/screen.py
def __truncate(self, line_arr, max_width): ''' Cut tuple of line chunks according to it's wisible lenght ''' def is_space(chunk): return all([True if i == ' ' else False for i in chunk]) def is_empty(chunks, markups): result = [] for chunk in chunks: ...
def __truncate(self, line_arr, max_width): ''' Cut tuple of line chunks according to it's wisible lenght ''' def is_space(chunk): return all([True if i == ' ' else False for i in chunk]) def is_empty(chunks, markups): result = [] for chunk in chunks: ...
[ "Cut", "tuple", "of", "line", "chunks", "according", "to", "it", "s", "wisible", "lenght" ]
yandex/yandex-tank
python
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/plugins/Console/screen.py#L329-L363
[ "def", "__truncate", "(", "self", ",", "line_arr", ",", "max_width", ")", ":", "def", "is_space", "(", "chunk", ")", ":", "return", "all", "(", "[", "True", "if", "i", "==", "' '", "else", "False", "for", "i", "in", "chunk", "]", ")", "def", "is_em...
d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b