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
valid
sentences
Return random sentences.
forgery_py/forgery/lorem_ipsum.py
def sentences(quantity=2, as_list=False): """Return random sentences.""" result = [sntc.strip() for sntc in random.sample(get_dictionary('lorem_ipsum'), quantity)] if as_list: return result else: return ' '.join(result)
def sentences(quantity=2, as_list=False): """Return random sentences.""" result = [sntc.strip() for sntc in random.sample(get_dictionary('lorem_ipsum'), quantity)] if as_list: return result else: return ' '.join(result)
[ "Return", "random", "sentences", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L77-L85
[ "def", "sentences", "(", "quantity", "=", "2", ",", "as_list", "=", "False", ")", ":", "result", "=", "[", "sntc", ".", "strip", "(", ")", "for", "sntc", "in", "random", ".", "sample", "(", "get_dictionary", "(", "'lorem_ipsum'", ")", ",", "quantity", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
paragraph
Return a random paragraph.
forgery_py/forgery/lorem_ipsum.py
def paragraph(separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3): """Return a random paragraph.""" return paragraphs(quantity=1, separator=separator, wrap_start=wrap_start, wrap_end=wrap_end, html=html, sentences_quantity=sen...
def paragraph(separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3): """Return a random paragraph.""" return paragraphs(quantity=1, separator=separator, wrap_start=wrap_start, wrap_end=wrap_end, html=html, sentences_quantity=sen...
[ "Return", "a", "random", "paragraph", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L88-L93
[ "def", "paragraph", "(", "separator", "=", "'\\n\\n'", ",", "wrap_start", "=", "''", ",", "wrap_end", "=", "''", ",", "html", "=", "False", ",", "sentences_quantity", "=", "3", ")", ":", "return", "paragraphs", "(", "quantity", "=", "1", ",", "separator"...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
paragraphs
Return random paragraphs.
forgery_py/forgery/lorem_ipsum.py
def paragraphs(quantity=2, separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3, as_list=False): """Return random paragraphs.""" if html: wrap_start = '<p>' wrap_end = '</p>' separator = '\n\n' result = [] try: for _ in xrange(0, ...
def paragraphs(quantity=2, separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3, as_list=False): """Return random paragraphs.""" if html: wrap_start = '<p>' wrap_end = '</p>' separator = '\n\n' result = [] try: for _ in xrange(0, ...
[ "Return", "random", "paragraphs", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L96-L120
[ "def", "paragraphs", "(", "quantity", "=", "2", ",", "separator", "=", "'\\n\\n'", ",", "wrap_start", "=", "''", ",", "wrap_end", "=", "''", ",", "html", "=", "False", ",", "sentences_quantity", "=", "3", ",", "as_list", "=", "False", ")", ":", "if", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
_to_lower_alpha_only
Return a lowercased string with non alphabetic chars removed. White spaces are not to be removed.
forgery_py/forgery/lorem_ipsum.py
def _to_lower_alpha_only(s): """Return a lowercased string with non alphabetic chars removed. White spaces are not to be removed.""" s = re.sub(r'\n', ' ', s.lower()) return re.sub(r'[^a-z\s]', '', s)
def _to_lower_alpha_only(s): """Return a lowercased string with non alphabetic chars removed. White spaces are not to be removed.""" s = re.sub(r'\n', ' ', s.lower()) return re.sub(r'[^a-z\s]', '', s)
[ "Return", "a", "lowercased", "string", "with", "non", "alphabetic", "chars", "removed", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L123-L128
[ "def", "_to_lower_alpha_only", "(", "s", ")", ":", "s", "=", "re", ".", "sub", "(", "r'\\n'", ",", "' '", ",", "s", ".", "lower", "(", ")", ")", "return", "re", ".", "sub", "(", "r'[^a-z\\s]'", ",", "''", ",", "s", ")" ]
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
characters
Return random characters.
forgery_py/forgery/lorem_ipsum.py
def characters(quantity=10): """Return random characters.""" line = map(_to_lower_alpha_only, ''.join(random.sample(get_dictionary('lorem_ipsum'), quantity))) return ''.join(line)[:quantity]
def characters(quantity=10): """Return random characters.""" line = map(_to_lower_alpha_only, ''.join(random.sample(get_dictionary('lorem_ipsum'), quantity))) return ''.join(line)[:quantity]
[ "Return", "random", "characters", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L131-L135
[ "def", "characters", "(", "quantity", "=", "10", ")", ":", "line", "=", "map", "(", "_to_lower_alpha_only", ",", "''", ".", "join", "(", "random", ".", "sample", "(", "get_dictionary", "(", "'lorem_ipsum'", ")", ",", "quantity", ")", ")", ")", "return", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
text
An aggregator for all above defined public methods.
forgery_py/forgery/lorem_ipsum.py
def text(what="sentence", *args, **kwargs): """An aggregator for all above defined public methods.""" if what == "character": return character(*args, **kwargs) elif what == "characters": return characters(*args, **kwargs) elif what == "word": return word(*args, **kwargs) eli...
def text(what="sentence", *args, **kwargs): """An aggregator for all above defined public methods.""" if what == "character": return character(*args, **kwargs) elif what == "characters": return characters(*args, **kwargs) elif what == "word": return word(*args, **kwargs) eli...
[ "An", "aggregator", "for", "all", "above", "defined", "public", "methods", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L143-L165
[ "def", "text", "(", "what", "=", "\"sentence\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "what", "==", "\"character\"", ":", "return", "character", "(", "*", "args", ",", "*", "*", "kwargs", ")", "elif", "what", "==", "\"characters...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
user_name
Return a random user name. Basically it's lowercased result of :py:func:`~forgery_py.forgery.name.first_name()` with a number appended if `with_num`.
forgery_py/forgery/internet.py
def user_name(with_num=False): """Return a random user name. Basically it's lowercased result of :py:func:`~forgery_py.forgery.name.first_name()` with a number appended if `with_num`. """ result = first_name() if with_num: result += str(random.randint(63, 94)) return result.low...
def user_name(with_num=False): """Return a random user name. Basically it's lowercased result of :py:func:`~forgery_py.forgery.name.first_name()` with a number appended if `with_num`. """ result = first_name() if with_num: result += str(random.randint(63, 94)) return result.low...
[ "Return", "a", "random", "user", "name", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/internet.py#L41-L52
[ "def", "user_name", "(", "with_num", "=", "False", ")", ":", "result", "=", "first_name", "(", ")", "if", "with_num", ":", "result", "+=", "str", "(", "random", ".", "randint", "(", "63", ",", "94", ")", ")", "return", "result", ".", "lower", "(", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
domain_name
Return a random domain name. Lowercased result of :py:func:`~forgery_py.forgery.name.company_name()` plus :py:func:`~top_level_domain()`.
forgery_py/forgery/internet.py
def domain_name(): """Return a random domain name. Lowercased result of :py:func:`~forgery_py.forgery.name.company_name()` plus :py:func:`~top_level_domain()`. """ result = random.choice(get_dictionary('company_names')).strip() result += '.' + top_level_domain() return result.lower()
def domain_name(): """Return a random domain name. Lowercased result of :py:func:`~forgery_py.forgery.name.company_name()` plus :py:func:`~top_level_domain()`. """ result = random.choice(get_dictionary('company_names')).strip() result += '.' + top_level_domain() return result.lower()
[ "Return", "a", "random", "domain", "name", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/internet.py#L60-L69
[ "def", "domain_name", "(", ")", ":", "result", "=", "random", ".", "choice", "(", "get_dictionary", "(", "'company_names'", ")", ")", ".", "strip", "(", ")", "result", "+=", "'.'", "+", "top_level_domain", "(", ")", "return", "result", ".", "lower", "(",...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
email_address
Return random e-mail address in a hopefully imaginary domain. If `user` is ``None`` :py:func:`~user_name()` will be used. Otherwise it will be lowercased and will have spaces replaced with ``_``. Domain name is created using :py:func:`~domain_name()`.
forgery_py/forgery/internet.py
def email_address(user=None): """Return random e-mail address in a hopefully imaginary domain. If `user` is ``None`` :py:func:`~user_name()` will be used. Otherwise it will be lowercased and will have spaces replaced with ``_``. Domain name is created using :py:func:`~domain_name()`. """ if no...
def email_address(user=None): """Return random e-mail address in a hopefully imaginary domain. If `user` is ``None`` :py:func:`~user_name()` will be used. Otherwise it will be lowercased and will have spaces replaced with ``_``. Domain name is created using :py:func:`~domain_name()`. """ if no...
[ "Return", "random", "e", "-", "mail", "address", "in", "a", "hopefully", "imaginary", "domain", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/internet.py#L72-L85
[ "def", "email_address", "(", "user", "=", "None", ")", ":", "if", "not", "user", ":", "user", "=", "user_name", "(", ")", "else", ":", "user", "=", "user", ".", "strip", "(", ")", ".", "replace", "(", "' '", ",", "'_'", ")", ".", "lower", "(", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
account_number
Return a random bank account number.
forgery_py/forgery/russian_tax.py
def account_number(): """Return a random bank account number.""" account = [random.randint(1, 9) for _ in range(20)] return "".join(map(str, account))
def account_number(): """Return a random bank account number.""" account = [random.randint(1, 9) for _ in range(20)] return "".join(map(str, account))
[ "Return", "a", "random", "bank", "account", "number", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/russian_tax.py#L47-L50
[ "def", "account_number", "(", ")", ":", "account", "=", "[", "random", ".", "randint", "(", "1", ",", "9", ")", "for", "_", "in", "range", "(", "20", ")", "]", "return", "\"\"", ".", "join", "(", "map", "(", "str", ",", "account", ")", ")" ]
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
bik
Return a random bank identification number.
forgery_py/forgery/russian_tax.py
def bik(): """Return a random bank identification number.""" return '04' + \ ''.join([str(random.randint(1, 9)) for _ in range(5)]) + \ str(random.randint(0, 49) + 50)
def bik(): """Return a random bank identification number.""" return '04' + \ ''.join([str(random.randint(1, 9)) for _ in range(5)]) + \ str(random.randint(0, 49) + 50)
[ "Return", "a", "random", "bank", "identification", "number", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/russian_tax.py#L53-L57
[ "def", "bik", "(", ")", ":", "return", "'04'", "+", "''", ".", "join", "(", "[", "str", "(", "random", ".", "randint", "(", "1", ",", "9", ")", ")", "for", "_", "in", "range", "(", "5", ")", "]", ")", "+", "str", "(", "random", ".", "randin...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
legal_inn
Return a random taxation ID number for a company.
forgery_py/forgery/russian_tax.py
def legal_inn(): """Return a random taxation ID number for a company.""" mask = [2, 4, 10, 3, 5, 9, 4, 6, 8] inn = [random.randint(1, 9) for _ in range(10)] weighted = [v * mask[i] for i, v in enumerate(inn[:-1])] inn[9] = sum(weighted) % 11 % 10 return "".join(map(str, inn))
def legal_inn(): """Return a random taxation ID number for a company.""" mask = [2, 4, 10, 3, 5, 9, 4, 6, 8] inn = [random.randint(1, 9) for _ in range(10)] weighted = [v * mask[i] for i, v in enumerate(inn[:-1])] inn[9] = sum(weighted) % 11 % 10 return "".join(map(str, inn))
[ "Return", "a", "random", "taxation", "ID", "number", "for", "a", "company", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/russian_tax.py#L72-L78
[ "def", "legal_inn", "(", ")", ":", "mask", "=", "[", "2", ",", "4", ",", "10", ",", "3", ",", "5", ",", "9", ",", "4", ",", "6", ",", "8", "]", "inn", "=", "[", "random", ".", "randint", "(", "1", ",", "9", ")", "for", "_", "in", "range...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
legal_ogrn
Return a random government registration ID for a company.
forgery_py/forgery/russian_tax.py
def legal_ogrn(): """Return a random government registration ID for a company.""" ogrn = "".join(map(str, [random.randint(1, 9) for _ in range(12)])) ogrn += str((int(ogrn) % 11 % 10)) return ogrn
def legal_ogrn(): """Return a random government registration ID for a company.""" ogrn = "".join(map(str, [random.randint(1, 9) for _ in range(12)])) ogrn += str((int(ogrn) % 11 % 10)) return ogrn
[ "Return", "a", "random", "government", "registration", "ID", "for", "a", "company", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/russian_tax.py#L81-L85
[ "def", "legal_ogrn", "(", ")", ":", "ogrn", "=", "\"\"", ".", "join", "(", "map", "(", "str", ",", "[", "random", ".", "randint", "(", "1", ",", "9", ")", "for", "_", "in", "range", "(", "12", ")", "]", ")", ")", "ogrn", "+=", "str", "(", "...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
person_inn
Return a random taxation ID number for a natural person.
forgery_py/forgery/russian_tax.py
def person_inn(): """Return a random taxation ID number for a natural person.""" mask11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8] mask12 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8] inn = [random.randint(1, 9) for _ in range(12)] # get the 11th digit of the INN weighted11 = [v * mask11[i] for i, v in enumerate...
def person_inn(): """Return a random taxation ID number for a natural person.""" mask11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8] mask12 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8] inn = [random.randint(1, 9) for _ in range(12)] # get the 11th digit of the INN weighted11 = [v * mask11[i] for i, v in enumerate...
[ "Return", "a", "random", "taxation", "ID", "number", "for", "a", "natural", "person", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/russian_tax.py#L100-L114
[ "def", "person_inn", "(", ")", ":", "mask11", "=", "[", "7", ",", "2", ",", "4", ",", "10", ",", "3", ",", "5", ",", "9", ",", "4", ",", "6", ",", "8", "]", "mask12", "=", "[", "3", ",", "7", ",", "2", ",", "4", ",", "10", ",", "3", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
encrypt
Return SHA1 hexdigest of a password (optionally salted with a string).
forgery_py/forgery/basic.py
def encrypt(password='password', salt=None): """ Return SHA1 hexdigest of a password (optionally salted with a string). """ if not salt: salt = str(datetime.utcnow()) try: # available for python 2.7.8 and python 3.4+ dk = hashlib.pbkdf2_hmac('sha1', password.encode(), sal...
def encrypt(password='password', salt=None): """ Return SHA1 hexdigest of a password (optionally salted with a string). """ if not salt: salt = str(datetime.utcnow()) try: # available for python 2.7.8 and python 3.4+ dk = hashlib.pbkdf2_hmac('sha1', password.encode(), sal...
[ "Return", "SHA1", "hexdigest", "of", "a", "password", "(", "optionally", "salted", "with", "a", "string", ")", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/basic.py#L105-L124
[ "def", "encrypt", "(", "password", "=", "'password'", ",", "salt", "=", "None", ")", ":", "if", "not", "salt", ":", "salt", "=", "str", "(", "datetime", ".", "utcnow", "(", ")", ")", "try", ":", "# available for python 2.7.8 and python 3.4+", "dk", "=", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
password
Return a random string for use as a password.
forgery_py/forgery/basic.py
def password(at_least=6, at_most=12, lowercase=True, uppercase=True, digits=True, spaces=False, punctuation=False): """Return a random string for use as a password.""" return text(at_least=at_least, at_most=at_most, lowercase=lowercase, uppercase=uppercase, digits=digits, spaces=spa...
def password(at_least=6, at_most=12, lowercase=True, uppercase=True, digits=True, spaces=False, punctuation=False): """Return a random string for use as a password.""" return text(at_least=at_least, at_most=at_most, lowercase=lowercase, uppercase=uppercase, digits=digits, spaces=spa...
[ "Return", "a", "random", "string", "for", "use", "as", "a", "password", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/basic.py#L139-L144
[ "def", "password", "(", "at_least", "=", "6", ",", "at_most", "=", "12", ",", "lowercase", "=", "True", ",", "uppercase", "=", "True", ",", "digits", "=", "True", ",", "spaces", "=", "False", ",", "punctuation", "=", "False", ")", ":", "return", "tex...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
Migration.forwards
Write your forwards methods here.
teryt/south_migrations/0003_ustaw_aktywny.py
def forwards(self, orm): "Write your forwards methods here." # Note: Don't use "from appname.models import ModelName". # Use orm.ModelName to refer to models in this application, # and orm['appname.ModelName'] for models in other applications. print("Updating: JednostkaAdministr...
def forwards(self, orm): "Write your forwards methods here." # Note: Don't use "from appname.models import ModelName". # Use orm.ModelName to refer to models in this application, # and orm['appname.ModelName'] for models in other applications. print("Updating: JednostkaAdministr...
[ "Write", "your", "forwards", "methods", "here", "." ]
scibi/django-teryt
python
https://github.com/scibi/django-teryt/blob/a4a6c981d58a2e5fdd0ffdcdc938e9de4f434b99/teryt/south_migrations/0003_ustaw_aktywny.py#L12-L35
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "# Note: Don't use \"from appname.models import ModelName\". ", "# Use orm.ModelName to refer to models in this application,", "# and orm['appname.ModelName'] for models in other applications.", "print", "(", "\"Updating: JednostkaAdmin...
a4a6c981d58a2e5fdd0ffdcdc938e9de4f434b99
valid
Migration.forwards
Write your forwards methods here.
teryt/south_migrations/0007_update_JednostkaAdministracyjna_typ.py
def forwards(self, orm): "Write your forwards methods here." # Note: Don't use "from appname.models import ModelName". # Use orm.ModelName to refer to models in this application, # and orm['appname.ModelName'] for models in other applications. LEN_TYPE = { 7: 'GMI', ...
def forwards(self, orm): "Write your forwards methods here." # Note: Don't use "from appname.models import ModelName". # Use orm.ModelName to refer to models in this application, # and orm['appname.ModelName'] for models in other applications. LEN_TYPE = { 7: 'GMI', ...
[ "Write", "your", "forwards", "methods", "here", "." ]
scibi/django-teryt
python
https://github.com/scibi/django-teryt/blob/a4a6c981d58a2e5fdd0ffdcdc938e9de4f434b99/teryt/south_migrations/0007_update_JednostkaAdministracyjna_typ.py#L9-L21
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "# Note: Don't use \"from appname.models import ModelName\". ", "# Use orm.ModelName to refer to models in this application,", "# and orm['appname.ModelName'] for models in other applications.", "LEN_TYPE", "=", "{", "7", ":", "'G...
a4a6c981d58a2e5fdd0ffdcdc938e9de4f434b99
valid
case
Converts an identifier from one case type to another. An identifier is an ASCII string consisting of letters, digits and underscores, not starting with a digit. The supported case types are camelCase, PascalCase, snake_case, and CONSTANT_CASE, identified as camel, pascal, snake, and constant. The input ...
gsl/strings.py
def case(*, to, **kwargs): """Converts an identifier from one case type to another. An identifier is an ASCII string consisting of letters, digits and underscores, not starting with a digit. The supported case types are camelCase, PascalCase, snake_case, and CONSTANT_CASE, identified as camel, pascal, s...
def case(*, to, **kwargs): """Converts an identifier from one case type to another. An identifier is an ASCII string consisting of letters, digits and underscores, not starting with a digit. The supported case types are camelCase, PascalCase, snake_case, and CONSTANT_CASE, identified as camel, pascal, s...
[ "Converts", "an", "identifier", "from", "one", "case", "type", "to", "another", ".", "An", "identifier", "is", "an", "ASCII", "string", "consisting", "of", "letters", "digits", "and", "underscores", "not", "starting", "with", "a", "digit", ".", "The", "suppo...
SillyFreak/gsl
python
https://github.com/SillyFreak/gsl/blob/9107b1e142e1c2766b323022ab4bbf97c32e4707/gsl/strings.py#L4-L54
[ "def", "case", "(", "*", ",", "to", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "kwargs", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"expect exactly one source string argument\"", ")", "[", "(", "typ", ",", "string", ")", "]", "=", "...
9107b1e142e1c2766b323022ab4bbf97c32e4707
valid
read_stream
Using a schema, deserialize a stream of consecutive Avro values. :param str schema: json string representing the Avro schema :param file-like stream: a buffered stream of binary input :param int buffer_size: size of bytes to read from the stream each time :return: yields a sequence of python data struc...
lancaster/__init__.py
def read_stream(schema, stream, *, buffer_size=io.DEFAULT_BUFFER_SIZE): """Using a schema, deserialize a stream of consecutive Avro values. :param str schema: json string representing the Avro schema :param file-like stream: a buffered stream of binary input :param int buffer_size: size of bytes to rea...
def read_stream(schema, stream, *, buffer_size=io.DEFAULT_BUFFER_SIZE): """Using a schema, deserialize a stream of consecutive Avro values. :param str schema: json string representing the Avro schema :param file-like stream: a buffered stream of binary input :param int buffer_size: size of bytes to rea...
[ "Using", "a", "schema", "deserialize", "a", "stream", "of", "consecutive", "Avro", "values", "." ]
twosigma/lancaster
python
https://github.com/twosigma/lancaster/blob/7fc756addf04d7a8cdee612cbe7627f008365adf/lancaster/__init__.py#L36-L61
[ "def", "read_stream", "(", "schema", ",", "stream", ",", "*", ",", "buffer_size", "=", "io", ".", "DEFAULT_BUFFER_SIZE", ")", ":", "reader", "=", "_lancaster", ".", "Reader", "(", "schema", ")", "buf", "=", "stream", ".", "read", "(", "buffer_size", ")",...
7fc756addf04d7a8cdee612cbe7627f008365adf
valid
parse_user_defined_metric_classes
Parse the user defined metric class information :param config_obj: ConfigParser object :param metric_classes: list of metric classes to be updated :return:
src/naarad/utils.py
def parse_user_defined_metric_classes(config_obj, metric_classes): """ Parse the user defined metric class information :param config_obj: ConfigParser object :param metric_classes: list of metric classes to be updated :return: """ user_defined_metric_list = config_obj.get('GLOBAL', 'user_defined_metrics')...
def parse_user_defined_metric_classes(config_obj, metric_classes): """ Parse the user defined metric class information :param config_obj: ConfigParser object :param metric_classes: list of metric classes to be updated :return: """ user_defined_metric_list = config_obj.get('GLOBAL', 'user_defined_metrics')...
[ "Parse", "the", "user", "defined", "metric", "class", "information", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "metric_classes", ":", "list", "of", "metric", "classes", "to", "be", "updated", ":", "return", ":" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L58-L81
[ "def", "parse_user_defined_metric_classes", "(", "config_obj", ",", "metric_classes", ")", ":", "user_defined_metric_list", "=", "config_obj", ".", "get", "(", "'GLOBAL'", ",", "'user_defined_metrics'", ")", ".", "split", "(", ")", "for", "udm_string", "in", "user_d...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
is_valid_url
Check if a given string is in the correct URL format or not :param str url: :return: True or False
src/naarad/utils.py
def is_valid_url(url): """ Check if a given string is in the correct URL format or not :param str url: :return: True or False """ regex = re.compile(r'^(?:http|ftp)s?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' r'localho...
def is_valid_url(url): """ Check if a given string is in the correct URL format or not :param str url: :return: True or False """ regex = re.compile(r'^(?:http|ftp)s?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' r'localho...
[ "Check", "if", "a", "given", "string", "is", "in", "the", "correct", "URL", "format", "or", "not" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L84-L101
[ "def", "is_valid_url", "(", "url", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'^(?:http|ftp)s?://'", "r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|'", "r'localhost|'", "r'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})'", "r'(?::\\d+)?'",...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
download_file
Download a file pointed to by url to a temp file on local disk :param str url: :return: local_file
src/naarad/utils.py
def download_file(url): """ Download a file pointed to by url to a temp file on local disk :param str url: :return: local_file """ try: (local_file, headers) = urllib.urlretrieve(url) except: sys.exit("ERROR: Problem downloading config file. Please check the URL (" + url + "). Exiting...") retu...
def download_file(url): """ Download a file pointed to by url to a temp file on local disk :param str url: :return: local_file """ try: (local_file, headers) = urllib.urlretrieve(url) except: sys.exit("ERROR: Problem downloading config file. Please check the URL (" + url + "). Exiting...") retu...
[ "Download", "a", "file", "pointed", "to", "by", "url", "to", "a", "temp", "file", "on", "local", "disk" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L104-L115
[ "def", "download_file", "(", "url", ")", ":", "try", ":", "(", "local_file", ",", "headers", ")", "=", "urllib", ".", "urlretrieve", "(", "url", ")", "except", ":", "sys", ".", "exit", "(", "\"ERROR: Problem downloading config file. Please check the URL (\"", "+...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
is_valid_metric_name
check the validity of metric_name in config; the metric_name will be used for creation of sub-dir, so only contains: alphabet, digits , '.', '-' and '_' :param str metric_name: metric_name :return: True if valid
src/naarad/utils.py
def is_valid_metric_name(metric_name): """ check the validity of metric_name in config; the metric_name will be used for creation of sub-dir, so only contains: alphabet, digits , '.', '-' and '_' :param str metric_name: metric_name :return: True if valid """ reg = re.compile('^[a-zA-Z0-9\.\-\_]+$') if reg...
def is_valid_metric_name(metric_name): """ check the validity of metric_name in config; the metric_name will be used for creation of sub-dir, so only contains: alphabet, digits , '.', '-' and '_' :param str metric_name: metric_name :return: True if valid """ reg = re.compile('^[a-zA-Z0-9\.\-\_]+$') if reg...
[ "check", "the", "validity", "of", "metric_name", "in", "config", ";", "the", "metric_name", "will", "be", "used", "for", "creation", "of", "sub", "-", "dir", "so", "only", "contains", ":", "alphabet", "digits", ".", "-", "and", "_", ":", "param", "str", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L124-L134
[ "def", "is_valid_metric_name", "(", "metric_name", ")", ":", "reg", "=", "re", ".", "compile", "(", "'^[a-zA-Z0-9\\.\\-\\_]+$'", ")", "if", "reg", ".", "match", "(", "metric_name", ")", "and", "not", "metric_name", ".", "startswith", "(", "'.'", ")", ":", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_run_time_period
This method finds the time range which covers all the Run_Steps :param run_steps: list of Run_Step objects :return: tuple of start and end timestamps
src/naarad/utils.py
def get_run_time_period(run_steps): """ This method finds the time range which covers all the Run_Steps :param run_steps: list of Run_Step objects :return: tuple of start and end timestamps """ init_ts_start = get_standardized_timestamp('now', None) ts_start = init_ts_start ts_end = '0' for run_step ...
def get_run_time_period(run_steps): """ This method finds the time range which covers all the Run_Steps :param run_steps: list of Run_Step objects :return: tuple of start and end timestamps """ init_ts_start = get_standardized_timestamp('now', None) ts_start = init_ts_start ts_end = '0' for run_step ...
[ "This", "method", "finds", "the", "time", "range", "which", "covers", "all", "the", "Run_Steps" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L137-L158
[ "def", "get_run_time_period", "(", "run_steps", ")", ":", "init_ts_start", "=", "get_standardized_timestamp", "(", "'now'", ",", "None", ")", "ts_start", "=", "init_ts_start", "ts_end", "=", "'0'", "for", "run_step", "in", "run_steps", ":", "if", "run_step", "."...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_rule_strings
Extract rule strings from a section :param config_obj: ConfigParser object :param section: Section name :return: the rule strings
src/naarad/utils.py
def get_rule_strings(config_obj, section): """ Extract rule strings from a section :param config_obj: ConfigParser object :param section: Section name :return: the rule strings """ rule_strings = {} kwargs = dict(config_obj.items(section)) for key in kwargs.keys(): if key.endswith('.sla'): r...
def get_rule_strings(config_obj, section): """ Extract rule strings from a section :param config_obj: ConfigParser object :param section: Section name :return: the rule strings """ rule_strings = {} kwargs = dict(config_obj.items(section)) for key in kwargs.keys(): if key.endswith('.sla'): r...
[ "Extract", "rule", "strings", "from", "a", "section", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "section", ":", "Section", "name", ":", "return", ":", "the", "rule", "strings" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L161-L174
[ "def", "get_rule_strings", "(", "config_obj", ",", "section", ")", ":", "rule_strings", "=", "{", "}", "kwargs", "=", "dict", "(", "config_obj", ".", "items", "(", "section", ")", ")", "for", "key", "in", "kwargs", ".", "keys", "(", ")", ":", "if", "...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
extract_diff_sla_from_config_file
Helper function to parse diff config file, which contains SLA rules for diff comparisons
src/naarad/utils.py
def extract_diff_sla_from_config_file(obj, options_file): """ Helper function to parse diff config file, which contains SLA rules for diff comparisons """ rule_strings = {} config_obj = ConfigParser.ConfigParser() config_obj.optionxform = str config_obj.read(options_file) for section in config_obj.secti...
def extract_diff_sla_from_config_file(obj, options_file): """ Helper function to parse diff config file, which contains SLA rules for diff comparisons """ rule_strings = {} config_obj = ConfigParser.ConfigParser() config_obj.optionxform = str config_obj.read(options_file) for section in config_obj.secti...
[ "Helper", "function", "to", "parse", "diff", "config", "file", "which", "contains", "SLA", "rules", "for", "diff", "comparisons" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L177-L188
[ "def", "extract_diff_sla_from_config_file", "(", "obj", ",", "options_file", ")", ":", "rule_strings", "=", "{", "}", "config_obj", "=", "ConfigParser", ".", "ConfigParser", "(", ")", "config_obj", ".", "optionxform", "=", "str", "config_obj", ".", "read", "(", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_basic_metric_options
Parse basic options from metric sections of the config :param config_obj: ConfigParser object :param section: Section name :return: all the parsed options
src/naarad/utils.py
def parse_basic_metric_options(config_obj, section): """ Parse basic options from metric sections of the config :param config_obj: ConfigParser object :param section: Section name :return: all the parsed options """ infile = {} aggr_hosts = None aggr_metrics = None ts_start = None ts_end = None ...
def parse_basic_metric_options(config_obj, section): """ Parse basic options from metric sections of the config :param config_obj: ConfigParser object :param section: Section name :return: all the parsed options """ infile = {} aggr_hosts = None aggr_metrics = None ts_start = None ts_end = None ...
[ "Parse", "basic", "options", "from", "metric", "sections", "of", "the", "config", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "section", ":", "Section", "name", ":", "return", ":", "all", "the", "parsed", "options" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L191-L249
[ "def", "parse_basic_metric_options", "(", "config_obj", ",", "section", ")", ":", "infile", "=", "{", "}", "aggr_hosts", "=", "None", "aggr_metrics", "=", "None", "ts_start", "=", "None", "ts_end", "=", "None", "precision", "=", "None", "hostname", "=", "\"l...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_metric_section
Parse a metric section and create a Metric object :param config_obj: ConfigParser object :param section: Section name :param metric_classes: List of valid metric types :param metrics: List of all regular metric objects (used by aggregate metric) :param aggregate_metric_classes: List of all valid aggregate met...
src/naarad/utils.py
def parse_metric_section(config_obj, section, metric_classes, metrics, aggregate_metric_classes, outdir_default, resource_path): """ Parse a metric section and create a Metric object :param config_obj: ConfigParser object :param section: Section name :param metric_classes: List of valid metric types :param ...
def parse_metric_section(config_obj, section, metric_classes, metrics, aggregate_metric_classes, outdir_default, resource_path): """ Parse a metric section and create a Metric object :param config_obj: ConfigParser object :param section: Section name :param metric_classes: List of valid metric types :param ...
[ "Parse", "a", "metric", "section", "and", "create", "a", "Metric", "object", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "section", ":", "Section", "name", ":", "param", "metric_classes", ":", "List", "of", "valid", "metric", "ty...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L252-L280
[ "def", "parse_metric_section", "(", "config_obj", ",", "section", ",", "metric_classes", ",", "metrics", ",", "aggregate_metric_classes", ",", "outdir_default", ",", "resource_path", ")", ":", "(", "hostname", ",", "infile", ",", "aggr_hosts", ",", "aggr_metrics", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_global_section
Parse GLOBAL section in the config to return global settings :param config_obj: ConfigParser object :param section: Section name :return: ts_start and ts_end time
src/naarad/utils.py
def parse_global_section(config_obj, section): """ Parse GLOBAL section in the config to return global settings :param config_obj: ConfigParser object :param section: Section name :return: ts_start and ts_end time """ ts_start = None ts_end = None if config_obj.has_option(section, 'ts_start'): ts_...
def parse_global_section(config_obj, section): """ Parse GLOBAL section in the config to return global settings :param config_obj: ConfigParser object :param section: Section name :return: ts_start and ts_end time """ ts_start = None ts_end = None if config_obj.has_option(section, 'ts_start'): ts_...
[ "Parse", "GLOBAL", "section", "in", "the", "config", "to", "return", "global", "settings", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "section", ":", "Section", "name", ":", "return", ":", "ts_start", "and", "ts_end", "time" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L283-L298
[ "def", "parse_global_section", "(", "config_obj", ",", "section", ")", ":", "ts_start", "=", "None", "ts_end", "=", "None", "if", "config_obj", ".", "has_option", "(", "section", ",", "'ts_start'", ")", ":", "ts_start", "=", "get_standardized_timestamp", "(", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_run_step_section
Parse a RUN-STEP section in the config to return a Run_Step object :param config_obj: ConfigParser objection :param section: Section name :return: an initialized Run_Step object
src/naarad/utils.py
def parse_run_step_section(config_obj, section): """ Parse a RUN-STEP section in the config to return a Run_Step object :param config_obj: ConfigParser objection :param section: Section name :return: an initialized Run_Step object """ kill_after_seconds = None try: run_cmd = config_obj.get(section, ...
def parse_run_step_section(config_obj, section): """ Parse a RUN-STEP section in the config to return a Run_Step object :param config_obj: ConfigParser objection :param section: Section name :return: an initialized Run_Step object """ kill_after_seconds = None try: run_cmd = config_obj.get(section, ...
[ "Parse", "a", "RUN", "-", "STEP", "section", "in", "the", "config", "to", "return", "a", "Run_Step", "object", ":", "param", "config_obj", ":", "ConfigParser", "objection", ":", "param", "section", ":", "Section", "name", ":", "return", ":", "an", "initial...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L301-L341
[ "def", "parse_run_step_section", "(", "config_obj", ",", "section", ")", ":", "kill_after_seconds", "=", "None", "try", ":", "run_cmd", "=", "config_obj", ".", "get", "(", "section", ",", "'run_cmd'", ")", "run_rank", "=", "int", "(", "config_obj", ".", "get...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_graph_section
Parse the GRAPH section of the config to extract useful values :param config_obj: ConfigParser object :param section: Section name :param outdir_default: Default output directory passed in args :param indir_default: Default input directory passed in args :return: List of options extracted from the GRAPH secti...
src/naarad/utils.py
def parse_graph_section(config_obj, section, outdir_default, indir_default): """ Parse the GRAPH section of the config to extract useful values :param config_obj: ConfigParser object :param section: Section name :param outdir_default: Default output directory passed in args :param indir_default: Default inp...
def parse_graph_section(config_obj, section, outdir_default, indir_default): """ Parse the GRAPH section of the config to extract useful values :param config_obj: ConfigParser object :param section: Section name :param outdir_default: Default output directory passed in args :param indir_default: Default inp...
[ "Parse", "the", "GRAPH", "section", "of", "the", "config", "to", "extract", "useful", "values", ":", "param", "config_obj", ":", "ConfigParser", "object", ":", "param", "section", ":", "Section", "name", ":", "param", "outdir_default", ":", "Default", "output"...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L344-L374
[ "def", "parse_graph_section", "(", "config_obj", ",", "section", ",", "outdir_default", ",", "indir_default", ")", ":", "graph_timezone", "=", "None", "graphing_library", "=", "CONSTANTS", ".", "DEFAULT_GRAPHING_LIBRARY", "crossplots", "=", "[", "]", "if", "config_o...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
parse_report_section
parse the [REPORT] section of a config file to extract various reporting options to be passed to the Report object :param: config_obj : configparser object for the config file passed in to naarad :param: section: name of the section. 'REPORT' should be passed in here :return: report_kwargs: dictionary of Reportin...
src/naarad/utils.py
def parse_report_section(config_obj, section): """ parse the [REPORT] section of a config file to extract various reporting options to be passed to the Report object :param: config_obj : configparser object for the config file passed in to naarad :param: section: name of the section. 'REPORT' should be passed i...
def parse_report_section(config_obj, section): """ parse the [REPORT] section of a config file to extract various reporting options to be passed to the Report object :param: config_obj : configparser object for the config file passed in to naarad :param: section: name of the section. 'REPORT' should be passed i...
[ "parse", "the", "[", "REPORT", "]", "section", "of", "a", "config", "file", "to", "extract", "various", "reporting", "options", "to", "be", "passed", "to", "the", "Report", "object", ":", "param", ":", "config_obj", ":", "configparser", "object", "for", "t...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L377-L405
[ "def", "parse_report_section", "(", "config_obj", ",", "section", ")", ":", "report_kwargs", "=", "{", "}", "if", "config_obj", ".", "has_option", "(", "section", ",", "'stylesheet_includes'", ")", ":", "report_kwargs", "[", "'stylesheet_includes'", "]", "=", "c...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
calculate_stats
Calculate statistics for given data. :param list data_list: List of floats :param list stats_to_calculate: List of strings with statistics to calculate. Supported stats are defined in constant stats_to_numpy_method_map :param list percentiles_to_calculate: List of floats that defined which percentiles to calcula...
src/naarad/utils.py
def calculate_stats(data_list, stats_to_calculate=['mean', 'std'], percentiles_to_calculate=[]): """ Calculate statistics for given data. :param list data_list: List of floats :param list stats_to_calculate: List of strings with statistics to calculate. Supported stats are defined in constant stats_to_numpy_me...
def calculate_stats(data_list, stats_to_calculate=['mean', 'std'], percentiles_to_calculate=[]): """ Calculate statistics for given data. :param list data_list: List of floats :param list stats_to_calculate: List of strings with statistics to calculate. Supported stats are defined in constant stats_to_numpy_me...
[ "Calculate", "statistics", "for", "given", "data", "." ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L619-L651
[ "def", "calculate_stats", "(", "data_list", ",", "stats_to_calculate", "=", "[", "'mean'", ",", "'std'", "]", ",", "percentiles_to_calculate", "=", "[", "]", ")", ":", "stats_to_numpy_method_map", "=", "{", "'mean'", ":", "numpy", ".", "mean", ",", "'avg'", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
is_valid_file
Check if the specifed file exists and is not empty :param filename: full path to the file that needs to be checked :return: Status, Message
src/naarad/utils.py
def is_valid_file(filename): """ Check if the specifed file exists and is not empty :param filename: full path to the file that needs to be checked :return: Status, Message """ if os.path.exists(filename): if not os.path.getsize(filename): logger.warning('%s : file is empty.', filename) ret...
def is_valid_file(filename): """ Check if the specifed file exists and is not empty :param filename: full path to the file that needs to be checked :return: Status, Message """ if os.path.exists(filename): if not os.path.getsize(filename): logger.warning('%s : file is empty.', filename) ret...
[ "Check", "if", "the", "specifed", "file", "exists", "and", "is", "not", "empty" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L654-L668
[ "def", "is_valid_file", "(", "filename", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "getsize", "(", "filename", ")", ":", "logger", ".", "warning", "(", "'%s : file is empty.'", ","...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
detect_timestamp_format
Given an input timestamp string, determine what format is it likely in. :param string timestamp: the timestamp string for which we need to determine format :return: best guess timestamp format
src/naarad/utils.py
def detect_timestamp_format(timestamp): """ Given an input timestamp string, determine what format is it likely in. :param string timestamp: the timestamp string for which we need to determine format :return: best guess timestamp format """ time_formats = { 'epoch': re.compile(r'^[0-9]{10}$'), ...
def detect_timestamp_format(timestamp): """ Given an input timestamp string, determine what format is it likely in. :param string timestamp: the timestamp string for which we need to determine format :return: best guess timestamp format """ time_formats = { 'epoch': re.compile(r'^[0-9]{10}$'), ...
[ "Given", "an", "input", "timestamp", "string", "determine", "what", "format", "is", "it", "likely", "in", "." ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L671-L701
[ "def", "detect_timestamp_format", "(", "timestamp", ")", ":", "time_formats", "=", "{", "'epoch'", ":", "re", ".", "compile", "(", "r'^[0-9]{10}$'", ")", ",", "'epoch_ms'", ":", "re", ".", "compile", "(", "r'^[0-9]{13}$'", ")", ",", "'epoch_fraction'", ":", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_standardized_timestamp
Given a timestamp string, return a time stamp in the epoch ms format. If no date is present in timestamp then today's date will be added as a prefix before conversion to epoch ms
src/naarad/utils.py
def get_standardized_timestamp(timestamp, ts_format): """ Given a timestamp string, return a time stamp in the epoch ms format. If no date is present in timestamp then today's date will be added as a prefix before conversion to epoch ms """ if not timestamp: return None if timestamp == 'now': timest...
def get_standardized_timestamp(timestamp, ts_format): """ Given a timestamp string, return a time stamp in the epoch ms format. If no date is present in timestamp then today's date will be added as a prefix before conversion to epoch ms """ if not timestamp: return None if timestamp == 'now': timest...
[ "Given", "a", "timestamp", "string", "return", "a", "time", "stamp", "in", "the", "epoch", "ms", "format", ".", "If", "no", "date", "is", "present", "in", "timestamp", "then", "today", "s", "date", "will", "be", "added", "as", "a", "prefix", "before", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L704-L734
[ "def", "get_standardized_timestamp", "(", "timestamp", ",", "ts_format", ")", ":", "if", "not", "timestamp", ":", "return", "None", "if", "timestamp", "==", "'now'", ":", "timestamp", "=", "str", "(", "datetime", ".", "datetime", ".", "now", "(", ")", ")",...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
set_sla
Extract SLAs from a set of rules
src/naarad/utils.py
def set_sla(obj, metric, sub_metric, rules): """ Extract SLAs from a set of rules """ if not hasattr(obj, 'sla_map'): return False rules_list = rules.split() for rule in rules_list: if '<' in rule: stat, threshold = rule.split('<') sla = SLA(metric, sub_metric, stat, threshold, 'lt') ...
def set_sla(obj, metric, sub_metric, rules): """ Extract SLAs from a set of rules """ if not hasattr(obj, 'sla_map'): return False rules_list = rules.split() for rule in rules_list: if '<' in rule: stat, threshold = rule.split('<') sla = SLA(metric, sub_metric, stat, threshold, 'lt') ...
[ "Extract", "SLAs", "from", "a", "set", "of", "rules" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L737-L758
[ "def", "set_sla", "(", "obj", ",", "metric", ",", "sub_metric", ",", "rules", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'sla_map'", ")", ":", "return", "False", "rules_list", "=", "rules", ".", "split", "(", ")", "for", "rule", "in", "rules...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
check_slas
Check if all SLAs pass :return: 0 (if all SLAs pass) or the number of SLAs failures
src/naarad/utils.py
def check_slas(metric): """ Check if all SLAs pass :return: 0 (if all SLAs pass) or the number of SLAs failures """ if not hasattr(metric, 'sla_map'): return for metric_label in metric.sla_map.keys(): for sub_metric in metric.sla_map[metric_label].keys(): for stat_name in metric.sla_map[metric...
def check_slas(metric): """ Check if all SLAs pass :return: 0 (if all SLAs pass) or the number of SLAs failures """ if not hasattr(metric, 'sla_map'): return for metric_label in metric.sla_map.keys(): for sub_metric in metric.sla_map[metric_label].keys(): for stat_name in metric.sla_map[metric...
[ "Check", "if", "all", "SLAs", "pass", ":", "return", ":", "0", "(", "if", "all", "SLAs", "pass", ")", "or", "the", "number", "of", "SLAs", "failures" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L761-L792
[ "def", "check_slas", "(", "metric", ")", ":", "if", "not", "hasattr", "(", "metric", ",", "'sla_map'", ")", ":", "return", "for", "metric_label", "in", "metric", ".", "sla_map", ".", "keys", "(", ")", ":", "for", "sub_metric", "in", "metric", ".", "sla...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
init_logging
Initialize the naarad logger. :param: logger: logger object to initialize :param: log_file: log file name :param: log_level: log level (debug, info, warn, error)
src/naarad/utils.py
def init_logging(logger, log_file, log_level): """ Initialize the naarad logger. :param: logger: logger object to initialize :param: log_file: log file name :param: log_level: log level (debug, info, warn, error) """ with open(log_file, 'w'): pass numeric_level = getattr(logging, log_level.upper(), ...
def init_logging(logger, log_file, log_level): """ Initialize the naarad logger. :param: logger: logger object to initialize :param: log_file: log file name :param: log_level: log level (debug, info, warn, error) """ with open(log_file, 'w'): pass numeric_level = getattr(logging, log_level.upper(), ...
[ "Initialize", "the", "naarad", "logger", ".", ":", "param", ":", "logger", ":", "logger", "object", "to", "initialize", ":", "param", ":", "log_file", ":", "log", "file", "name", ":", "param", ":", "log_level", ":", "log", "level", "(", "debug", "info", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L825-L847
[ "def", "init_logging", "(", "logger", ",", "log_file", ",", "log_level", ")", ":", "with", "open", "(", "log_file", ",", "'w'", ")", ":", "pass", "numeric_level", "=", "getattr", "(", "logging", ",", "log_level", ".", "upper", "(", ")", ",", "None", ")...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_argument_parser
Initialize list of valid arguments accepted by Naarad CLI :return: arg_parser: argeparse.ArgumentParser object initialized with naarad CLI parameters
src/naarad/utils.py
def get_argument_parser(): """ Initialize list of valid arguments accepted by Naarad CLI :return: arg_parser: argeparse.ArgumentParser object initialized with naarad CLI parameters """ arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-c', '--config', help="file with specifications for each me...
def get_argument_parser(): """ Initialize list of valid arguments accepted by Naarad CLI :return: arg_parser: argeparse.ArgumentParser object initialized with naarad CLI parameters """ arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-c', '--config', help="file with specifications for each me...
[ "Initialize", "list", "of", "valid", "arguments", "accepted", "by", "Naarad", "CLI", ":", "return", ":", "arg_parser", ":", "argeparse", ".", "ArgumentParser", "object", "initialized", "with", "naarad", "CLI", "parameters" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L850-L875
[ "def", "get_argument_parser", "(", ")", ":", "arg_parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "arg_parser", ".", "add_argument", "(", "'-c'", ",", "'--config'", ",", "help", "=", "\"file with specifications for each metric and graphs\"", ")", "arg_parse...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_variables
Return a dictionary of variables specified at CLI :param: args: Command Line Arguments namespace
src/naarad/utils.py
def get_variables(args): """ Return a dictionary of variables specified at CLI :param: args: Command Line Arguments namespace """ variables_dict = {} if args.variables: for var in args.variables: words = var.split('=') variables_dict[words[0]] = words[1] return variables_dict
def get_variables(args): """ Return a dictionary of variables specified at CLI :param: args: Command Line Arguments namespace """ variables_dict = {} if args.variables: for var in args.variables: words = var.split('=') variables_dict[words[0]] = words[1] return variables_dict
[ "Return", "a", "dictionary", "of", "variables", "specified", "at", "CLI", ":", "param", ":", "args", ":", "Command", "Line", "Arguments", "namespace" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L878-L888
[ "def", "get_variables", "(", "args", ")", ":", "variables_dict", "=", "{", "}", "if", "args", ".", "variables", ":", "for", "var", "in", "args", ".", "variables", ":", "words", "=", "var", ".", "split", "(", "'='", ")", "variables_dict", "[", "words", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
validate_arguments
Validate that the necessary argument for normal or diff analysis are specified. :param: args: Command line arguments namespace
src/naarad/utils.py
def validate_arguments(args): """ Validate that the necessary argument for normal or diff analysis are specified. :param: args: Command line arguments namespace """ if args.diff: if not args.output_dir: logger.error('No Output location specified') print_usage() sys.exit(0) # elif not (...
def validate_arguments(args): """ Validate that the necessary argument for normal or diff analysis are specified. :param: args: Command line arguments namespace """ if args.diff: if not args.output_dir: logger.error('No Output location specified') print_usage() sys.exit(0) # elif not (...
[ "Validate", "that", "the", "necessary", "argument", "for", "normal", "or", "diff", "analysis", "are", "specified", ".", ":", "param", ":", "args", ":", "Command", "line", "arguments", "namespace" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L891-L904
[ "def", "validate_arguments", "(", "args", ")", ":", "if", "args", ".", "diff", ":", "if", "not", "args", ".", "output_dir", ":", "logger", ".", "error", "(", "'No Output location specified'", ")", "print_usage", "(", ")", "sys", ".", "exit", "(", "0", ")...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
discover_by_name
Auto discover metric types from the files that exist in input_directory and return a list of metrics :param: input_directory: The location to scan for log files :param: output_directory: The location for the report
src/naarad/utils.py
def discover_by_name(input_directory, output_directory): """ Auto discover metric types from the files that exist in input_directory and return a list of metrics :param: input_directory: The location to scan for log files :param: output_directory: The location for the report """ metric_list = [] log_files...
def discover_by_name(input_directory, output_directory): """ Auto discover metric types from the files that exist in input_directory and return a list of metrics :param: input_directory: The location to scan for log files :param: output_directory: The location for the report """ metric_list = [] log_files...
[ "Auto", "discover", "metric", "types", "from", "the", "files", "that", "exist", "in", "input_directory", "and", "return", "a", "list", "of", "metrics", ":", "param", ":", "input_directory", ":", "The", "location", "to", "scan", "for", "log", "files", ":", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L917-L931
[ "def", "discover_by_name", "(", "input_directory", ",", "output_directory", ")", ":", "metric_list", "=", "[", "]", "log_files", "=", "os", ".", "listdir", "(", "input_directory", ")", "for", "log_file", "in", "log_files", ":", "if", "log_file", "in", "CONSTAN...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
initialize_metric
Initialize appropriate metric based on type of metric. :param: section: config section name or auto discovered metric type :param: infile_list: list of input log files for the metric :param: hostname: hostname associated with the logs origin :param: output_directory: report location :param: resource_path: res...
src/naarad/utils.py
def initialize_metric(section, infile_list, hostname, aggr_metrics, output_directory, resource_path, label, ts_start, ts_end, rule_strings, important_sub_metrics, anomaly_detection_metrics, other_options): """ Initialize appropriate metric based on type of metric. :param: section: config sec...
def initialize_metric(section, infile_list, hostname, aggr_metrics, output_directory, resource_path, label, ts_start, ts_end, rule_strings, important_sub_metrics, anomaly_detection_metrics, other_options): """ Initialize appropriate metric based on type of metric. :param: section: config sec...
[ "Initialize", "appropriate", "metric", "based", "on", "type", "of", "metric", ".", ":", "param", ":", "section", ":", "config", "section", "name", "or", "auto", "discovered", "metric", "type", ":", "param", ":", "infile_list", ":", "list", "of", "input", "...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L934-L964
[ "def", "initialize_metric", "(", "section", ",", "infile_list", ",", "hostname", ",", "aggr_metrics", ",", "output_directory", ",", "resource_path", ",", "label", ",", "ts_start", ",", "ts_end", ",", "rule_strings", ",", "important_sub_metrics", ",", "anomaly_detect...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
initialize_aggregate_metric
Initialize aggregate metric :param: section: config section name :param: aggr_hosts: list of hostnames to aggregate :param: aggr_metrics: list of metrics to aggregate :param: metrics: list of metric objects associated with the current naarad analysis :param: outdir_default: report location :param: resource_...
src/naarad/utils.py
def initialize_aggregate_metric(section, aggr_hosts, aggr_metrics, metrics, outdir_default, resource_path, label, ts_start, ts_end, rule_strings, important_sub_metrics, anomaly_detection_metrics, other_options): """ Initialize aggregate metric :param: section: config section name ...
def initialize_aggregate_metric(section, aggr_hosts, aggr_metrics, metrics, outdir_default, resource_path, label, ts_start, ts_end, rule_strings, important_sub_metrics, anomaly_detection_metrics, other_options): """ Initialize aggregate metric :param: section: config section name ...
[ "Initialize", "aggregate", "metric", ":", "param", ":", "section", ":", "config", "section", "name", ":", "param", ":", "aggr_hosts", ":", "list", "of", "hostnames", "to", "aggregate", ":", "param", ":", "aggr_metrics", ":", "list", "of", "metrics", "to", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/utils.py#L967-L989
[ "def", "initialize_aggregate_metric", "(", "section", ",", "aggr_hosts", ",", "aggr_metrics", ",", "metrics", ",", "outdir_default", ",", "resource_path", ",", "label", ",", "ts_start", ",", "ts_end", ",", "rule_strings", ",", "important_sub_metrics", ",", "anomaly_...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
graph_csv
Single metric graphing function
src/naarad/graphing/dygraphs.py
def graph_csv(output_directory, resource_path, csv_file, plot_title, output_filename, y_label=None, precision=None, graph_height="600", graph_width="1500"): """ Single metric graphing function """ if not os.path.getsize(csv_file): return False, "" y_label = y_label or plot_title div_id = str(random.random()...
def graph_csv(output_directory, resource_path, csv_file, plot_title, output_filename, y_label=None, precision=None, graph_height="600", graph_width="1500"): """ Single metric graphing function """ if not os.path.getsize(csv_file): return False, "" y_label = y_label or plot_title div_id = str(random.random()...
[ "Single", "metric", "graphing", "function" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/graphing/dygraphs.py#L25-L59
[ "def", "graph_csv", "(", "output_directory", ",", "resource_path", ",", "csv_file", ",", "plot_title", ",", "output_filename", ",", "y_label", "=", "None", ",", "precision", "=", "None", ",", "graph_height", "=", "\"600\"", ",", "graph_width", "=", "\"1500\"", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.aggregate_count_over_time
Organize and store the count of data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter log data :param dict line_data: dict with the extracted k:v from the log line :param list transaction_list: list...
src/naarad/metrics/jmeter_metric.py
def aggregate_count_over_time(self, metric_store, line_data, transaction_list, aggregate_timestamp): """ Organize and store the count of data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter log dat...
def aggregate_count_over_time(self, metric_store, line_data, transaction_list, aggregate_timestamp): """ Organize and store the count of data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter log dat...
[ "Organize", "and", "store", "the", "count", "of", "data", "from", "the", "log", "line", "into", "the", "metric", "store", "by", "metric", "type", "transaction", "timestamp" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L93-L113
[ "def", "aggregate_count_over_time", "(", "self", ",", "metric_store", ",", "line_data", ",", "transaction_list", ",", "aggregate_timestamp", ")", ":", "for", "transaction", "in", "transaction_list", ":", "if", "line_data", ".", "get", "(", "'s'", ")", "==", "'tr...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.aggregate_values_over_time
Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter log data :param dict line_data: dict with the extracted k:v from the log line :param list transaction_list: list of trans...
src/naarad/metrics/jmeter_metric.py
def aggregate_values_over_time(self, metric_store, line_data, transaction_list, metric_list, aggregate_timestamp): """ Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter lo...
def aggregate_values_over_time(self, metric_store, line_data, transaction_list, metric_list, aggregate_timestamp): """ Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed jmeter lo...
[ "Organize", "and", "store", "the", "data", "from", "the", "log", "line", "into", "the", "metric", "store", "by", "metric", "type", "transaction", "timestamp" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L115-L130
[ "def", "aggregate_values_over_time", "(", "self", ",", "metric_store", ",", "line_data", ",", "transaction_list", ",", "metric_list", ",", "aggregate_timestamp", ")", ":", "for", "metric", "in", "metric_list", ":", "for", "transaction", "in", "transaction_list", ":"...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.average_values_for_plot
Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed jmeter log data :param dict data: Dict with all the metric data to be output to csv :param float averaging_factor: averaging fact...
src/naarad/metrics/jmeter_metric.py
def average_values_for_plot(self, metric_store, data, averaging_factor): """ Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed jmeter log data :param dict data: Dict with all ...
def average_values_for_plot(self, metric_store, data, averaging_factor): """ Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed jmeter log data :param dict data: Dict with all ...
[ "Create", "the", "time", "series", "for", "the", "various", "metrics", "averaged", "over", "the", "aggregation", "period", "being", "used", "for", "plots" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L132-L151
[ "def", "average_values_for_plot", "(", "self", ",", "metric_store", ",", "data", ",", "averaging_factor", ")", ":", "for", "metric", ",", "transaction_store", "in", "metric_store", ".", "items", "(", ")", ":", "for", "transaction", ",", "time_store", "in", "tr...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.calculate_key_stats
Calculate key statistics for given data and store in the class variables calculated_stats and calculated_percentiles calculated_stats: 'mean', 'std', 'median', 'min', 'max' calculated_percentiles: range(5,101,5), 99 :param dict metric_store: The metric store used to store all the parsed jmeter l...
src/naarad/metrics/jmeter_metric.py
def calculate_key_stats(self, metric_store): """ Calculate key statistics for given data and store in the class variables calculated_stats and calculated_percentiles calculated_stats: 'mean', 'std', 'median', 'min', 'max' calculated_percentiles: range(5,101,5), 99 :param dict metric_stor...
def calculate_key_stats(self, metric_store): """ Calculate key statistics for given data and store in the class variables calculated_stats and calculated_percentiles calculated_stats: 'mean', 'std', 'median', 'min', 'max' calculated_percentiles: range(5,101,5), 99 :param dict metric_stor...
[ "Calculate", "key", "statistics", "for", "given", "data", "and", "store", "in", "the", "class", "variables", "calculated_stats", "and", "calculated_percentiles", "calculated_stats", ":", "mean", "std", "median", "min", "max", "calculated_percentiles", ":", "range", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L153-L196
[ "def", "calculate_key_stats", "(", "self", ",", "metric_store", ")", ":", "stats_to_calculate", "=", "[", "'mean'", ",", "'std'", ",", "'median'", ",", "'min'", ",", "'max'", "]", "# TODO: get input from user", "percentiles_to_calculate", "=", "range", "(", "5", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.parse
Parse the Jmeter file and calculate key stats :return: status of the metric parse
src/naarad/metrics/jmeter_metric.py
def parse(self): """ Parse the Jmeter file and calculate key stats :return: status of the metric parse """ file_status = True for infile in self.infile_list: file_status = file_status and naarad.utils.is_valid_file(infile) if not file_status: return False status = self....
def parse(self): """ Parse the Jmeter file and calculate key stats :return: status of the metric parse """ file_status = True for infile in self.infile_list: file_status = file_status and naarad.utils.is_valid_file(infile) if not file_status: return False status = self....
[ "Parse", "the", "Jmeter", "file", "and", "calculate", "key", "stats" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L198-L212
[ "def", "parse", "(", "self", ")", ":", "file_status", "=", "True", "for", "infile", "in", "self", ".", "infile_list", ":", "file_status", "=", "file_status", "and", "naarad", ".", "utils", ".", "is_valid_file", "(", "infile", ")", "if", "not", "file_status...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
JmeterMetric.parse_xml_jtl
Parse Jmeter workload output in XML format and extract overall and per transaction data and key statistics :param string granularity: The time period over which to aggregate and average the raw data. Valid values are 'hour', 'minute' or 'second' :return: status of the metric parse
src/naarad/metrics/jmeter_metric.py
def parse_xml_jtl(self, granularity): """ Parse Jmeter workload output in XML format and extract overall and per transaction data and key statistics :param string granularity: The time period over which to aggregate and average the raw data. Valid values are 'hour', 'minute' or 'second' :return: status...
def parse_xml_jtl(self, granularity): """ Parse Jmeter workload output in XML format and extract overall and per transaction data and key statistics :param string granularity: The time period over which to aggregate and average the raw data. Valid values are 'hour', 'minute' or 'second' :return: status...
[ "Parse", "Jmeter", "workload", "output", "in", "XML", "format", "and", "extract", "overall", "and", "per", "transaction", "data", "and", "key", "statistics" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/jmeter_metric.py#L217-L253
[ "def", "parse_xml_jtl", "(", "self", ",", "granularity", ")", ":", "data", "=", "defaultdict", "(", "list", ")", "processed_data", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "list", ")", ")", ")", "for", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.put_values_into_data
Take the (col, value) in 'values', append value into 'col' in self.data[]
src/naarad/metrics/top_metric.py
def put_values_into_data(self, values): """ Take the (col, value) in 'values', append value into 'col' in self.data[] """ for col, value in values.items(): if col in self.column_csv_map: out_csv = self.column_csv_map[col] else: out_csv = self.get_csv(col) # column_csv_map[]...
def put_values_into_data(self, values): """ Take the (col, value) in 'values', append value into 'col' in self.data[] """ for col, value in values.items(): if col in self.column_csv_map: out_csv = self.column_csv_map[col] else: out_csv = self.get_csv(col) # column_csv_map[]...
[ "Take", "the", "(", "col", "value", ")", "in", "values", "append", "value", "into", "col", "in", "self", ".", "data", "[]" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L84-L94
[ "def", "put_values_into_data", "(", "self", ",", "values", ")", ":", "for", "col", ",", "value", "in", "values", ".", "items", "(", ")", ":", "if", "col", "in", "self", ".", "column_csv_map", ":", "out_csv", "=", "self", ".", "column_csv_map", "[", "co...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.process_top_line
Process the line starting with "top" Example log: top - 00:00:02 up 32 days, 7:08, 19 users, load average: 0.00, 0.00, 0.00
src/naarad/metrics/top_metric.py
def process_top_line(self, words): """ Process the line starting with "top" Example log: top - 00:00:02 up 32 days, 7:08, 19 users, load average: 0.00, 0.00, 0.00 """ self.ts_time = words[2] self.ts = self.ts_date + ' ' + self.ts_time self.ts = ts = naarad.utils.get_standardized_timestam...
def process_top_line(self, words): """ Process the line starting with "top" Example log: top - 00:00:02 up 32 days, 7:08, 19 users, load average: 0.00, 0.00, 0.00 """ self.ts_time = words[2] self.ts = self.ts_date + ' ' + self.ts_time self.ts = ts = naarad.utils.get_standardized_timestam...
[ "Process", "the", "line", "starting", "with", "top", "Example", "log", ":", "top", "-", "00", ":", "00", ":", "02", "up", "32", "days", "7", ":", "08", "19", "users", "load", "average", ":", "0", ".", "00", "0", ".", "00", "0", ".", "00" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L96-L120
[ "def", "process_top_line", "(", "self", ",", "words", ")", ":", "self", ".", "ts_time", "=", "words", "[", "2", "]", "self", ".", "ts", "=", "self", ".", "ts_date", "+", "' '", "+", "self", ".", "ts_time", "self", ".", "ts", "=", "ts", "=", "naar...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.process_tasks_line
Process the line starting with "Tasks:" Example log: Tasks: 446 total, 1 running, 442 sleeping, 2 stopped, 1 zombie
src/naarad/metrics/top_metric.py
def process_tasks_line(self, words): """ Process the line starting with "Tasks:" Example log: Tasks: 446 total, 1 running, 442 sleeping, 2 stopped, 1 zombie """ words = words[1:] length = len(words) / 2 # The number of pairs values = {} for offset in range(length): k = wor...
def process_tasks_line(self, words): """ Process the line starting with "Tasks:" Example log: Tasks: 446 total, 1 running, 442 sleeping, 2 stopped, 1 zombie """ words = words[1:] length = len(words) / 2 # The number of pairs values = {} for offset in range(length): k = wor...
[ "Process", "the", "line", "starting", "with", "Tasks", ":", "Example", "log", ":", "Tasks", ":", "446", "total", "1", "running", "442", "sleeping", "2", "stopped", "1", "zombie" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L122-L134
[ "def", "process_tasks_line", "(", "self", ",", "words", ")", ":", "words", "=", "words", "[", "1", ":", "]", "length", "=", "len", "(", "words", ")", "/", "2", "# The number of pairs", "values", "=", "{", "}", "for", "offset", "in", "range", "(", "le...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.process_cpu_line
Process the line starting with "Cpu(s):" Example log: Cpu(s): 1.3%us, 0.5%sy, 0.0%ni, 98.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
src/naarad/metrics/top_metric.py
def process_cpu_line(self, words): """ Process the line starting with "Cpu(s):" Example log: Cpu(s): 1.3%us, 0.5%sy, 0.0%ni, 98.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st """ values = {} for word in words[1:]: val, key = word.split('%') values['cpu_' + key.strip(',')] = val sel...
def process_cpu_line(self, words): """ Process the line starting with "Cpu(s):" Example log: Cpu(s): 1.3%us, 0.5%sy, 0.0%ni, 98.2%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st """ values = {} for word in words[1:]: val, key = word.split('%') values['cpu_' + key.strip(',')] = val sel...
[ "Process", "the", "line", "starting", "with", "Cpu", "(", "s", ")", ":", "Example", "log", ":", "Cpu", "(", "s", ")", ":", "1", ".", "3%us", "0", ".", "5%sy", "0", ".", "0%ni", "98", ".", "2%id", "0", ".", "0%wa", "0", ".", "0%hi", "0", ".", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L136-L146
[ "def", "process_cpu_line", "(", "self", ",", "words", ")", ":", "values", "=", "{", "}", "for", "word", "in", "words", "[", "1", ":", "]", ":", "val", ",", "key", "=", "word", ".", "split", "(", "'%'", ")", "values", "[", "'cpu_'", "+", "key", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.convert_to_G
Given a size such as '2333M', return the converted value in G
src/naarad/metrics/top_metric.py
def convert_to_G(self, word): """ Given a size such as '2333M', return the converted value in G """ value = 0.0 if word[-1] == 'G' or word[-1] == 'g': value = float(word[:-1]) elif word[-1] == 'M' or word[-1] == 'm': value = float(word[:-1]) / 1000.0 elif word[-1] == 'K' or word[...
def convert_to_G(self, word): """ Given a size such as '2333M', return the converted value in G """ value = 0.0 if word[-1] == 'G' or word[-1] == 'g': value = float(word[:-1]) elif word[-1] == 'M' or word[-1] == 'm': value = float(word[:-1]) / 1000.0 elif word[-1] == 'K' or word[...
[ "Given", "a", "size", "such", "as", "2333M", "return", "the", "converted", "value", "in", "G" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L148-L161
[ "def", "convert_to_G", "(", "self", ",", "word", ")", ":", "value", "=", "0.0", "if", "word", "[", "-", "1", "]", "==", "'G'", "or", "word", "[", "-", "1", "]", "==", "'g'", ":", "value", "=", "float", "(", "word", "[", ":", "-", "1", "]", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.process_swap_line
Process the line starting with "Swap:" Example log: Swap: 63.998G total, 0.000k used, 63.998G free, 11.324G cached For each value, needs to convert to 'G' (needs to handle cases of K, M)
src/naarad/metrics/top_metric.py
def process_swap_line(self, words): """ Process the line starting with "Swap:" Example log: Swap: 63.998G total, 0.000k used, 63.998G free, 11.324G cached For each value, needs to convert to 'G' (needs to handle cases of K, M) """ words = words[1:] length = len(words) / 2 # The num...
def process_swap_line(self, words): """ Process the line starting with "Swap:" Example log: Swap: 63.998G total, 0.000k used, 63.998G free, 11.324G cached For each value, needs to convert to 'G' (needs to handle cases of K, M) """ words = words[1:] length = len(words) / 2 # The num...
[ "Process", "the", "line", "starting", "with", "Swap", ":", "Example", "log", ":", "Swap", ":", "63", ".", "998G", "total", "0", ".", "000k", "used", "63", ".", "998G", "free", "11", ".", "324G", "cached", "For", "each", "value", "needs", "to", "conve...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L178-L191
[ "def", "process_swap_line", "(", "self", ",", "words", ")", ":", "words", "=", "words", "[", "1", ":", "]", "length", "=", "len", "(", "words", ")", "/", "2", "# The number of pairs", "values", "=", "{", "}", "for", "offset", "in", "range", "(", "len...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.process_individual_command
process the individual lines like this: #PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29303 root 20 0 35300 2580 1664 R 3.9 0.0 0:00.02 top 11 root RT 0 0 0 0 S 1.9 0.0 0:18.87 migration/2 3702 root 20 0 34884 4192 1692 S 1.9 0.0 31:40.47 c...
src/naarad/metrics/top_metric.py
def process_individual_command(self, words): """ process the individual lines like this: #PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29303 root 20 0 35300 2580 1664 R 3.9 0.0 0:00.02 top 11 root RT 0 0 0 0 S 1.9 0.0 0:18.87 migration/2 3702...
def process_individual_command(self, words): """ process the individual lines like this: #PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 29303 root 20 0 35300 2580 1664 R 3.9 0.0 0:00.02 top 11 root RT 0 0 0 0 S 1.9 0.0 0:18.87 migration/2 3702...
[ "process", "the", "individual", "lines", "like", "this", ":", "#PID", "USER", "PR", "NI", "VIRT", "RES", "SHR", "S", "%CPU", "%MEM", "TIME", "+", "COMMAND", "29303", "root", "20", "0", "35300", "2580", "1664", "R", "3", ".", "9", "0", ".", "0", "0"...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L193-L222
[ "def", "process_individual_command", "(", "self", ",", "words", ")", ":", "pid_index", "=", "self", ".", "process_headers", ".", "index", "(", "'PID'", ")", "proces_index", "=", "self", ".", "process_headers", ".", "index", "(", "'COMMAND'", ")", "pid", "=",...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
TopMetric.parse
Parse the top output file Return status of the metric parse The raw log file is like the following: 2014-06-23 top - 00:00:02 up 18 days, 7:08, 19 users, load average: 0.05, 0.03, 0.00 Tasks: 447 total, 1 running, 443 sleeping, 2 stopped, 1 zombie Cpu(s): 1.6%us, 0.5%sy, 0.0%ni, 97.9...
src/naarad/metrics/top_metric.py
def parse(self): """ Parse the top output file Return status of the metric parse The raw log file is like the following: 2014-06-23 top - 00:00:02 up 18 days, 7:08, 19 users, load average: 0.05, 0.03, 0.00 Tasks: 447 total, 1 running, 443 sleeping, 2 stopped, 1 zombie Cpu(s): 1...
def parse(self): """ Parse the top output file Return status of the metric parse The raw log file is like the following: 2014-06-23 top - 00:00:02 up 18 days, 7:08, 19 users, load average: 0.05, 0.03, 0.00 Tasks: 447 total, 1 running, 443 sleeping, 2 stopped, 1 zombie Cpu(s): 1...
[ "Parse", "the", "top", "output", "file", "Return", "status", "of", "the", "metric", "parse" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/top_metric.py#L224-L287
[ "def", "parse", "(", "self", ")", ":", "for", "infile", "in", "self", ".", "infile_list", ":", "logger", ".", "info", "(", "'Processing : %s'", ",", "infile", ")", "status", "=", "True", "file_status", "=", "naarad", ".", "utils", ".", "is_valid_file", "...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
handle_single_url
Base function which takes a single url, download it to outdir/outfile :param str url: a full/absolute url, e.g. http://www.cnn.com/log.zip :param str outdir: the absolute local directory. e.g. /home/user1/tmp/ :param str outfile: (optional) filename stored in local directory. If outfile is not given, extract the ...
src/naarad/httpdownload.py
def handle_single_url(url, outdir, outfile=None): """ Base function which takes a single url, download it to outdir/outfile :param str url: a full/absolute url, e.g. http://www.cnn.com/log.zip :param str outdir: the absolute local directory. e.g. /home/user1/tmp/ :param str outfile: (optional) filename stored...
def handle_single_url(url, outdir, outfile=None): """ Base function which takes a single url, download it to outdir/outfile :param str url: a full/absolute url, e.g. http://www.cnn.com/log.zip :param str outdir: the absolute local directory. e.g. /home/user1/tmp/ :param str outfile: (optional) filename stored...
[ "Base", "function", "which", "takes", "a", "single", "url", "download", "it", "to", "outdir", "/", "outfile", ":", "param", "str", "url", ":", "a", "full", "/", "absolute", "url", "e", ".", "g", ".", "http", ":", "//", "www", ".", "cnn", ".", "com"...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L30-L67
[ "def", "handle_single_url", "(", "url", ",", "outdir", ",", "outfile", "=", "None", ")", ":", "if", "not", "url", "or", "type", "(", "url", ")", "!=", "str", "or", "not", "outdir", "or", "type", "(", "outdir", ")", "!=", "str", ":", "logger", ".", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
stream_url
Read response of specified url into memory and return to caller. No persistence to disk. :return: response content if accessing the URL succeeds, False otherwise
src/naarad/httpdownload.py
def stream_url(url): """ Read response of specified url into memory and return to caller. No persistence to disk. :return: response content if accessing the URL succeeds, False otherwise """ try: response = urllib2.urlopen(url) response_content = response.read() return response_content except (u...
def stream_url(url): """ Read response of specified url into memory and return to caller. No persistence to disk. :return: response content if accessing the URL succeeds, False otherwise """ try: response = urllib2.urlopen(url) response_content = response.read() return response_content except (u...
[ "Read", "response", "of", "specified", "url", "into", "memory", "and", "return", "to", "caller", ".", "No", "persistence", "to", "disk", ".", ":", "return", ":", "response", "content", "if", "accessing", "the", "URL", "succeeds", "False", "otherwise" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L70-L81
[ "def", "stream_url", "(", "url", ")", ":", "try", ":", "response", "=", "urllib2", ".", "urlopen", "(", "url", ")", "response_content", "=", "response", ".", "read", "(", ")", "return", "response_content", "except", "(", "urllib2", ".", "URLError", ",", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
get_urls_from_seed
get a list of urls from a seeding url, return a list of urls :param str url: a full/absolute url, e.g. http://www.cnn.com/logs/ :return: a list of full/absolute urls.
src/naarad/httpdownload.py
def get_urls_from_seed(url): """ get a list of urls from a seeding url, return a list of urls :param str url: a full/absolute url, e.g. http://www.cnn.com/logs/ :return: a list of full/absolute urls. """ if not url or type(url) != str or not naarad.utils.is_valid_url(url): logger.error("get_urls_from_...
def get_urls_from_seed(url): """ get a list of urls from a seeding url, return a list of urls :param str url: a full/absolute url, e.g. http://www.cnn.com/logs/ :return: a list of full/absolute urls. """ if not url or type(url) != str or not naarad.utils.is_valid_url(url): logger.error("get_urls_from_...
[ "get", "a", "list", "of", "urls", "from", "a", "seeding", "url", "return", "a", "list", "of", "urls" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L104-L138
[ "def", "get_urls_from_seed", "(", "url", ")", ":", "if", "not", "url", "or", "type", "(", "url", ")", "!=", "str", "or", "not", "naarad", ".", "utils", ".", "is_valid_url", "(", "url", ")", ":", "logger", ".", "error", "(", "\"get_urls_from_seed() does n...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
download_url_single
Downloads a http(s) url to a local file :param str inputs: the absolute url :param str outdir: Required. the local directory to put the downloadedfiles. :param str outfile: // Optional. If this is given, the downloaded url will be renated to outfile; If this is not given, then the local file will be the orig...
src/naarad/httpdownload.py
def download_url_single(inputs, outdir, outfile=None): """ Downloads a http(s) url to a local file :param str inputs: the absolute url :param str outdir: Required. the local directory to put the downloadedfiles. :param str outfile: // Optional. If this is given, the downloaded url will be renated to outfile;...
def download_url_single(inputs, outdir, outfile=None): """ Downloads a http(s) url to a local file :param str inputs: the absolute url :param str outdir: Required. the local directory to put the downloadedfiles. :param str outfile: // Optional. If this is given, the downloaded url will be renated to outfile;...
[ "Downloads", "a", "http", "(", "s", ")", "url", "to", "a", "local", "file", ":", "param", "str", "inputs", ":", "the", "absolute", "url", ":", "param", "str", "outdir", ":", "Required", ".", "the", "local", "directory", "to", "put", "the", "downloadedf...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L141-L159
[ "def", "download_url_single", "(", "inputs", ",", "outdir", ",", "outfile", "=", "None", ")", ":", "if", "not", "inputs", "or", "type", "(", "inputs", ")", "!=", "str", "or", "not", "outdir", "or", "type", "(", "outdir", ")", "!=", "str", ":", "loggi...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
download_url_regex
Downloads http(s) urls to a local files :param str inputs: Required, the seed url :param str outdir: Required. the local directory to put the downloadedfiles. :param str regex: Optional, a regex string. If not given, then all urls will be valid :return: A list of local full path names (downloaded from inputs)
src/naarad/httpdownload.py
def download_url_regex(inputs, outdir, regex=".*"): """ Downloads http(s) urls to a local files :param str inputs: Required, the seed url :param str outdir: Required. the local directory to put the downloadedfiles. :param str regex: Optional, a regex string. If not given, then all urls will be valid :return...
def download_url_regex(inputs, outdir, regex=".*"): """ Downloads http(s) urls to a local files :param str inputs: Required, the seed url :param str outdir: Required. the local directory to put the downloadedfiles. :param str regex: Optional, a regex string. If not given, then all urls will be valid :return...
[ "Downloads", "http", "(", "s", ")", "urls", "to", "a", "local", "files", ":", "param", "str", "inputs", ":", "Required", "the", "seed", "url", ":", "param", "str", "outdir", ":", "Required", ".", "the", "local", "directory", "to", "put", "the", "downlo...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/httpdownload.py#L162-L185
[ "def", "download_url_regex", "(", "inputs", ",", "outdir", ",", "regex", "=", "\".*\"", ")", ":", "if", "not", "inputs", "or", "type", "(", "inputs", ")", "!=", "str", "or", "not", "outdir", "or", "type", "(", "outdir", ")", "!=", "str", ":", "loggin...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
read_csv
Read data from a csv file into a dictionary. :param str csv_name: path to a csv file. :return dict: a dictionary represents the data in file.
lib/luminol/src/luminol/utils.py
def read_csv(csv_name): """ Read data from a csv file into a dictionary. :param str csv_name: path to a csv file. :return dict: a dictionary represents the data in file. """ data = {} if not isinstance(csv_name, (str, unicode)): raise exceptions.InvalidDataFormat('luminol.utils: csv_name has to be a s...
def read_csv(csv_name): """ Read data from a csv file into a dictionary. :param str csv_name: path to a csv file. :return dict: a dictionary represents the data in file. """ data = {} if not isinstance(csv_name, (str, unicode)): raise exceptions.InvalidDataFormat('luminol.utils: csv_name has to be a s...
[ "Read", "data", "from", "a", "csv", "file", "into", "a", "dictionary", ".", ":", "param", "str", "csv_name", ":", "path", "to", "a", "csv", "file", ".", ":", "return", "dict", ":", "a", "dictionary", "represents", "the", "data", "in", "file", "." ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/lib/luminol/src/luminol/utils.py#L40-L58
[ "def", "read_csv", "(", "csv_name", ")", ":", "data", "=", "{", "}", "if", "not", "isinstance", "(", "csv_name", ",", "(", "str", ",", "unicode", ")", ")", ":", "raise", "exceptions", ".", "InvalidDataFormat", "(", "'luminol.utils: csv_name has to be a string!...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Local_Cmd.run
Run the command, infer time period to be used in metric analysis phase. :return: None
src/naarad/run_steps/local_cmd.py
def run(self): """ Run the command, infer time period to be used in metric analysis phase. :return: None """ cmd_args = shlex.split(self.run_cmd) logger.info('Local command RUN-STEP starting with rank %d', self.run_rank) logger.info('Running subprocess command with following args: ' + str(cm...
def run(self): """ Run the command, infer time period to be used in metric analysis phase. :return: None """ cmd_args = shlex.split(self.run_cmd) logger.info('Local command RUN-STEP starting with rank %d', self.run_rank) logger.info('Running subprocess command with following args: ' + str(cm...
[ "Run", "the", "command", "infer", "time", "period", "to", "be", "used", "in", "metric", "analysis", "phase", ".", ":", "return", ":", "None" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/run_steps/local_cmd.py#L39-L68
[ "def", "run", "(", "self", ")", ":", "cmd_args", "=", "shlex", ".", "split", "(", "self", ".", "run_cmd", ")", "logger", ".", "info", "(", "'Local command RUN-STEP starting with rank %d'", ",", "self", ".", "run_rank", ")", "logger", ".", "info", "(", "'Ru...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Local_Cmd.kill
If run_step needs to be killed, this method will be called :return: None
src/naarad/run_steps/local_cmd.py
def kill(self): """ If run_step needs to be killed, this method will be called :return: None """ try: logger.info('Trying to terminating run_step...') self.process.terminate() time_waited_seconds = 0 while self.process.poll() is None and time_waited_seconds < CONSTANTS.SECOND...
def kill(self): """ If run_step needs to be killed, this method will be called :return: None """ try: logger.info('Trying to terminating run_step...') self.process.terminate() time_waited_seconds = 0 while self.process.poll() is None and time_waited_seconds < CONSTANTS.SECOND...
[ "If", "run_step", "needs", "to", "be", "killed", "this", "method", "will", "be", "called", ":", "return", ":", "None" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/run_steps/local_cmd.py#L70-L86
[ "def", "kill", "(", "self", ")", ":", "try", ":", "logger", ".", "info", "(", "'Trying to terminating run_step...'", ")", "self", ".", "process", ".", "terminate", "(", ")", "time_waited_seconds", "=", "0", "while", "self", ".", "process", ".", "poll", "("...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.copy_local_includes
Copy local js/css includes from naarad resources to the report/resources directory :return: None
src/naarad/reporting/diff.py
def copy_local_includes(self): """ Copy local js/css includes from naarad resources to the report/resources directory :return: None """ resource_folder = self.get_resources_location() for stylesheet in self.stylesheet_includes: if ('http' not in stylesheet) and naarad.utils.is_valid_file(o...
def copy_local_includes(self): """ Copy local js/css includes from naarad resources to the report/resources directory :return: None """ resource_folder = self.get_resources_location() for stylesheet in self.stylesheet_includes: if ('http' not in stylesheet) and naarad.utils.is_valid_file(o...
[ "Copy", "local", "js", "/", "css", "includes", "from", "naarad", "resources", "to", "the", "report", "/", "resources", "directory", ":", "return", ":", "None" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L73-L87
[ "def", "copy_local_includes", "(", "self", ")", ":", "resource_folder", "=", "self", ".", "get_resources_location", "(", ")", "for", "stylesheet", "in", "self", ".", "stylesheet_includes", ":", "if", "(", "'http'", "not", "in", "stylesheet", ")", "and", "naara...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.generate_client_charting_page
Create the client charting page for the diff report, with time series data from the two diffed reports. :return: generated html to be written to disk
src/naarad/reporting/diff.py
def generate_client_charting_page(self, data_sources): """ Create the client charting page for the diff report, with time series data from the two diffed reports. :return: generated html to be written to disk """ if not os.path.exists(self.resource_directory): os.makedirs(self.resource_directo...
def generate_client_charting_page(self, data_sources): """ Create the client charting page for the diff report, with time series data from the two diffed reports. :return: generated html to be written to disk """ if not os.path.exists(self.resource_directory): os.makedirs(self.resource_directo...
[ "Create", "the", "client", "charting", "page", "for", "the", "diff", "report", "with", "time", "series", "data", "from", "the", "two", "diffed", "reports", ".", ":", "return", ":", "generated", "html", "to", "be", "written", "to", "disk" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L89-L106
[ "def", "generate_client_charting_page", "(", "self", ",", "data_sources", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "resource_directory", ")", ":", "os", ".", "makedirs", "(", "self", ".", "resource_directory", ")", "self", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.generate_diff_html
Generate the summary diff report html from template :return: generated html to be written to disk
src/naarad/reporting/diff.py
def generate_diff_html(self): """ Generate the summary diff report html from template :return: generated html to be written to disk """ if not os.path.exists(self.resource_directory): os.makedirs(self.resource_directory) self.copy_local_includes() div_html = '' for plot_div in sort...
def generate_diff_html(self): """ Generate the summary diff report html from template :return: generated html to be written to disk """ if not os.path.exists(self.resource_directory): os.makedirs(self.resource_directory) self.copy_local_includes() div_html = '' for plot_div in sort...
[ "Generate", "the", "summary", "diff", "report", "html", "from", "template", ":", "return", ":", "generated", "html", "to", "be", "written", "to", "disk" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L108-L131
[ "def", "generate_diff_html", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "resource_directory", ")", ":", "os", ".", "makedirs", "(", "self", ".", "resource_directory", ")", "self", ".", "copy_local_includes", "("...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.discover
Determine what summary stats, time series, and CDF csv exist for the reports that need to be diffed. :return: boolean: return whether the summary stats / time series / CDF csv summary was successfully located
src/naarad/reporting/diff.py
def discover(self, metafile): """ Determine what summary stats, time series, and CDF csv exist for the reports that need to be diffed. :return: boolean: return whether the summary stats / time series / CDF csv summary was successfully located """ for report in self.reports: if report.remote_lo...
def discover(self, metafile): """ Determine what summary stats, time series, and CDF csv exist for the reports that need to be diffed. :return: boolean: return whether the summary stats / time series / CDF csv summary was successfully located """ for report in self.reports: if report.remote_lo...
[ "Determine", "what", "summary", "stats", "time", "series", "and", "CDF", "csv", "exist", "for", "the", "reports", "that", "need", "to", "be", "diffed", ".", ":", "return", ":", "boolean", ":", "return", "whether", "the", "summary", "stats", "/", "time", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L133-L169
[ "def", "discover", "(", "self", ",", "metafile", ")", ":", "for", "report", "in", "self", ".", "reports", ":", "if", "report", ".", "remote_location", "==", "'local'", ":", "if", "naarad", ".", "utils", ".", "is_valid_file", "(", "os", ".", "path", "."...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.collect_datasources
Identify what time series exist in both the diffed reports and download them to the diff report resources directory :return: True/False : return status of whether the download of time series resources succeeded.
src/naarad/reporting/diff.py
def collect_datasources(self): """ Identify what time series exist in both the diffed reports and download them to the diff report resources directory :return: True/False : return status of whether the download of time series resources succeeded. """ report_count = 0 if self.status != 'OK': ...
def collect_datasources(self): """ Identify what time series exist in both the diffed reports and download them to the diff report resources directory :return: True/False : return status of whether the download of time series resources succeeded. """ report_count = 0 if self.status != 'OK': ...
[ "Identify", "what", "time", "series", "exist", "in", "both", "the", "diffed", "reports", "and", "download", "them", "to", "the", "diff", "report", "resources", "directory", ":", "return", ":", "True", "/", "False", ":", "return", "status", "of", "whether", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L171-L205
[ "def", "collect_datasources", "(", "self", ")", ":", "report_count", "=", "0", "if", "self", ".", "status", "!=", "'OK'", ":", "return", "False", "diff_datasource", "=", "sorted", "(", "set", "(", "self", ".", "reports", "[", "0", "]", ".", "datasource",...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.plot_diff
Generate CDF diff plots of the submetrics
src/naarad/reporting/diff.py
def plot_diff(self, graphing_library='matplotlib'): """ Generate CDF diff plots of the submetrics """ diff_datasource = sorted(set(self.reports[0].datasource) & set(self.reports[1].datasource)) graphed = False for submetric in diff_datasource: baseline_csv = naarad.utils.get_default_csv(se...
def plot_diff(self, graphing_library='matplotlib'): """ Generate CDF diff plots of the submetrics """ diff_datasource = sorted(set(self.reports[0].datasource) & set(self.reports[1].datasource)) graphed = False for submetric in diff_datasource: baseline_csv = naarad.utils.get_default_csv(se...
[ "Generate", "CDF", "diff", "plots", "of", "the", "submetrics" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L275-L295
[ "def", "plot_diff", "(", "self", ",", "graphing_library", "=", "'matplotlib'", ")", ":", "diff_datasource", "=", "sorted", "(", "set", "(", "self", ".", "reports", "[", "0", "]", ".", "datasource", ")", "&", "set", "(", "self", ".", "reports", "[", "1"...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.check_sla
Check whether the SLA has passed or failed
src/naarad/reporting/diff.py
def check_sla(self, sla, diff_metric): """ Check whether the SLA has passed or failed """ try: if sla.display is '%': diff_val = float(diff_metric['percent_diff']) else: diff_val = float(diff_metric['absolute_diff']) except ValueError: return False if not (sla.c...
def check_sla(self, sla, diff_metric): """ Check whether the SLA has passed or failed """ try: if sla.display is '%': diff_val = float(diff_metric['percent_diff']) else: diff_val = float(diff_metric['absolute_diff']) except ValueError: return False if not (sla.c...
[ "Check", "whether", "the", "SLA", "has", "passed", "or", "failed" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L297-L311
[ "def", "check_sla", "(", "self", ",", "sla", ",", "diff_metric", ")", ":", "try", ":", "if", "sla", ".", "display", "is", "'%'", ":", "diff_val", "=", "float", "(", "diff_metric", "[", "'percent_diff'", "]", ")", "else", ":", "diff_val", "=", "float", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Diff.generate
Generate a diff report from the reports specified. :return: True/False : return status of whether the diff report generation succeeded.
src/naarad/reporting/diff.py
def generate(self): """ Generate a diff report from the reports specified. :return: True/False : return status of whether the diff report generation succeeded. """ if (self.discover(CONSTANTS.STATS_CSV_LIST_FILE) and self.discover(CONSTANTS.PLOTS_CSV_LIST_FILE) and self.discover(CONSTANTS.CDF_PLOTS_...
def generate(self): """ Generate a diff report from the reports specified. :return: True/False : return status of whether the diff report generation succeeded. """ if (self.discover(CONSTANTS.STATS_CSV_LIST_FILE) and self.discover(CONSTANTS.PLOTS_CSV_LIST_FILE) and self.discover(CONSTANTS.CDF_PLOTS_...
[ "Generate", "a", "diff", "report", "from", "the", "reports", "specified", ".", ":", "return", ":", "True", "/", "False", ":", "return", "status", "of", "whether", "the", "diff", "report", "generation", "succeeded", "." ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/reporting/diff.py#L313-L368
[ "def", "generate", "(", "self", ")", ":", "if", "(", "self", ".", "discover", "(", "CONSTANTS", ".", "STATS_CSV_LIST_FILE", ")", "and", "self", ".", "discover", "(", "CONSTANTS", ".", "PLOTS_CSV_LIST_FILE", ")", "and", "self", ".", "discover", "(", "CONSTA...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.get_aggregation_timestamp
Return a timestamp from the raw epoch time based on the granularity preferences passed in. :param string timestamp: timestamp from the log line :param string granularity: aggregation granularity used for plots. :return: string aggregate_timestamp: timestamp used for metrics aggregation in all functions
src/naarad/metrics/metric.py
def get_aggregation_timestamp(self, timestamp, granularity='second'): """ Return a timestamp from the raw epoch time based on the granularity preferences passed in. :param string timestamp: timestamp from the log line :param string granularity: aggregation granularity used for plots. :return: strin...
def get_aggregation_timestamp(self, timestamp, granularity='second'): """ Return a timestamp from the raw epoch time based on the granularity preferences passed in. :param string timestamp: timestamp from the log line :param string granularity: aggregation granularity used for plots. :return: strin...
[ "Return", "a", "timestamp", "from", "the", "raw", "epoch", "time", "based", "on", "the", "granularity", "preferences", "passed", "in", "." ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L185-L200
[ "def", "get_aggregation_timestamp", "(", "self", ",", "timestamp", ",", "granularity", "=", "'second'", ")", ":", "if", "granularity", "is", "None", "or", "granularity", ".", "lower", "(", ")", "==", "'none'", ":", "return", "int", "(", "timestamp", ")", "...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.aggregate_count_over_time
Organize and store the count of data from the log line into the metric store by columnm, group name, timestamp :param dict metric_store: The metric store used to store all the parsed the log data :param string groupby_name: the group name that the log line belongs to :param string aggregate_timestamp: time...
src/naarad/metrics/metric.py
def aggregate_count_over_time(self, metric_store, groupby_name, aggregate_timestamp): """ Organize and store the count of data from the log line into the metric store by columnm, group name, timestamp :param dict metric_store: The metric store used to store all the parsed the log data :param string gro...
def aggregate_count_over_time(self, metric_store, groupby_name, aggregate_timestamp): """ Organize and store the count of data from the log line into the metric store by columnm, group name, timestamp :param dict metric_store: The metric store used to store all the parsed the log data :param string gro...
[ "Organize", "and", "store", "the", "count", "of", "data", "from", "the", "log", "line", "into", "the", "metric", "store", "by", "columnm", "group", "name", "timestamp" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L202-L217
[ "def", "aggregate_count_over_time", "(", "self", ",", "metric_store", ",", "groupby_name", ",", "aggregate_timestamp", ")", ":", "all_qps", "=", "metric_store", "[", "'qps'", "]", "qps", "=", "all_qps", "[", "groupby_name", "]", "if", "aggregate_timestamp", "in", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.aggregate_values_over_time
Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed log data :param string data: column data in the log line :param string groupby_name: the group that the data belongs to :par...
src/naarad/metrics/metric.py
def aggregate_values_over_time(self, metric_store, data, groupby_name, column_name, aggregate_timestamp): """ Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed log data :para...
def aggregate_values_over_time(self, metric_store, data, groupby_name, column_name, aggregate_timestamp): """ Organize and store the data from the log line into the metric store by metric type, transaction, timestamp :param dict metric_store: The metric store used to store all the parsed log data :para...
[ "Organize", "and", "store", "the", "data", "from", "the", "log", "line", "into", "the", "metric", "store", "by", "metric", "type", "transaction", "timestamp" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L219-L236
[ "def", "aggregate_values_over_time", "(", "self", ",", "metric_store", ",", "data", ",", "groupby_name", ",", "column_name", ",", "aggregate_timestamp", ")", ":", "# To add overall_summary one", "if", "self", ".", "groupby", ":", "metric_data", "=", "reduce", "(", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.average_values_for_plot
Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed log data :param dict data: Dict with all the metric data to be output to csv :param float averaging_factor: averaging factor to b...
src/naarad/metrics/metric.py
def average_values_for_plot(self, metric_store, data, averaging_factor): """ Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed log data :param dict data: Dict with all the met...
def average_values_for_plot(self, metric_store, data, averaging_factor): """ Create the time series for the various metrics, averaged over the aggregation period being used for plots :param dict metric_store: The metric store used to store all the parsed log data :param dict data: Dict with all the met...
[ "Create", "the", "time", "series", "for", "the", "various", "metrics", "averaged", "over", "the", "aggregation", "period", "being", "used", "for", "plots" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L238-L260
[ "def", "average_values_for_plot", "(", "self", ",", "metric_store", ",", "data", ",", "averaging_factor", ")", ":", "for", "column", ",", "groups_store", "in", "metric_store", ".", "items", "(", ")", ":", "for", "group", ",", "time_store", "in", "groups_store"...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.calc_key_stats
Calculate stats such as percentile and mean :param dict metric_store: The metric store used to store all the parsed log data :return: None
src/naarad/metrics/metric.py
def calc_key_stats(self, metric_store): """ Calculate stats such as percentile and mean :param dict metric_store: The metric store used to store all the parsed log data :return: None """ stats_to_calculate = ['mean', 'std', 'min', 'max'] # TODO: get input from user percentiles_to_calculate...
def calc_key_stats(self, metric_store): """ Calculate stats such as percentile and mean :param dict metric_store: The metric store used to store all the parsed log data :return: None """ stats_to_calculate = ['mean', 'std', 'min', 'max'] # TODO: get input from user percentiles_to_calculate...
[ "Calculate", "stats", "such", "as", "percentile", "and", "mean" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L322-L343
[ "def", "calc_key_stats", "(", "self", ",", "metric_store", ")", ":", "stats_to_calculate", "=", "[", "'mean'", ",", "'std'", ",", "'min'", ",", "'max'", "]", "# TODO: get input from user", "percentiles_to_calculate", "=", "range", "(", "0", ",", "100", ",", "1...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.calculate_stats
Calculate stats with different function depending on the metric type: Data is recorded in memory for base metric type, and use calculate_base_metric_stats() Data is recorded in CSV file for other metric types, and use calculate_other_metric_stats()
src/naarad/metrics/metric.py
def calculate_stats(self): """ Calculate stats with different function depending on the metric type: Data is recorded in memory for base metric type, and use calculate_base_metric_stats() Data is recorded in CSV file for other metric types, and use calculate_other_metric_stats() """ metric_type...
def calculate_stats(self): """ Calculate stats with different function depending on the metric type: Data is recorded in memory for base metric type, and use calculate_base_metric_stats() Data is recorded in CSV file for other metric types, and use calculate_other_metric_stats() """ metric_type...
[ "Calculate", "stats", "with", "different", "function", "depending", "on", "the", "metric", "type", ":", "Data", "is", "recorded", "in", "memory", "for", "base", "metric", "type", "and", "use", "calculate_base_metric_stats", "()", "Data", "is", "recorded", "in", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L345-L356
[ "def", "calculate_stats", "(", "self", ")", ":", "metric_type", "=", "self", ".", "metric_type", ".", "split", "(", "'-'", ")", "[", "0", "]", "if", "metric_type", "in", "naarad", ".", "naarad_imports", ".", "metric_classes", "or", "metric_type", "in", "na...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.plot_timeseries
plot timeseries for sub-metrics
src/naarad/metrics/metric.py
def plot_timeseries(self, graphing_library='matplotlib'): """ plot timeseries for sub-metrics """ if self.groupby: plot_data = {} # plot time series data for submetrics for out_csv in sorted(self.csv_files, reverse=True): csv_filename = os.path.basename(out_csv) transac...
def plot_timeseries(self, graphing_library='matplotlib'): """ plot timeseries for sub-metrics """ if self.groupby: plot_data = {} # plot time series data for submetrics for out_csv in sorted(self.csv_files, reverse=True): csv_filename = os.path.basename(out_csv) transac...
[ "plot", "timeseries", "for", "sub", "-", "metrics" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L494-L547
[ "def", "plot_timeseries", "(", "self", ",", "graphing_library", "=", "'matplotlib'", ")", ":", "if", "self", ".", "groupby", ":", "plot_data", "=", "{", "}", "# plot time series data for submetrics", "for", "out_csv", "in", "sorted", "(", "self", ".", "csv_files...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.check_important_sub_metrics
check whether the given sub metric is in important_sub_metrics list
src/naarad/metrics/metric.py
def check_important_sub_metrics(self, sub_metric): """ check whether the given sub metric is in important_sub_metrics list """ if not self.important_sub_metrics: return False if sub_metric in self.important_sub_metrics: return True items = sub_metric.split('.') if items[-1] in se...
def check_important_sub_metrics(self, sub_metric): """ check whether the given sub metric is in important_sub_metrics list """ if not self.important_sub_metrics: return False if sub_metric in self.important_sub_metrics: return True items = sub_metric.split('.') if items[-1] in se...
[ "check", "whether", "the", "given", "sub", "metric", "is", "in", "important_sub_metrics", "list" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L549-L560
[ "def", "check_important_sub_metrics", "(", "self", ",", "sub_metric", ")", ":", "if", "not", "self", ".", "important_sub_metrics", ":", "return", "False", "if", "sub_metric", "in", "self", ".", "important_sub_metrics", ":", "return", "True", "items", "=", "sub_m...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.plot_cdf
plot CDF for important sub-metrics
src/naarad/metrics/metric.py
def plot_cdf(self, graphing_library='matplotlib'): """ plot CDF for important sub-metrics """ graphed = False for percentile_csv in self.percentiles_files: csv_filename = os.path.basename(percentile_csv) # The last element is .csv, don't need that in the name of the chart column = ...
def plot_cdf(self, graphing_library='matplotlib'): """ plot CDF for important sub-metrics """ graphed = False for percentile_csv in self.percentiles_files: csv_filename = os.path.basename(percentile_csv) # The last element is .csv, don't need that in the name of the chart column = ...
[ "plot", "CDF", "for", "important", "sub", "-", "metrics" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L562-L587
[ "def", "plot_cdf", "(", "self", ",", "graphing_library", "=", "'matplotlib'", ")", ":", "graphed", "=", "False", "for", "percentile_csv", "in", "self", ".", "percentiles_files", ":", "csv_filename", "=", "os", ".", "path", ".", "basename", "(", "percentile_csv...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.graph
graph generates two types of graphs 'time': generate a time-series plot for all submetrics (the x-axis is a time series) 'cdf': generate a CDF plot for important submetrics (the x-axis shows percentiles)
src/naarad/metrics/metric.py
def graph(self, graphing_library='matplotlib'): """ graph generates two types of graphs 'time': generate a time-series plot for all submetrics (the x-axis is a time series) 'cdf': generate a CDF plot for important submetrics (the x-axis shows percentiles) """ logger.info('Using graphing_library ...
def graph(self, graphing_library='matplotlib'): """ graph generates two types of graphs 'time': generate a time-series plot for all submetrics (the x-axis is a time series) 'cdf': generate a CDF plot for important submetrics (the x-axis shows percentiles) """ logger.info('Using graphing_library ...
[ "graph", "generates", "two", "types", "of", "graphs", "time", ":", "generate", "a", "time", "-", "series", "plot", "for", "all", "submetrics", "(", "the", "x", "-", "axis", "is", "a", "time", "series", ")", "cdf", ":", "generate", "a", "CDF", "plot", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L589-L598
[ "def", "graph", "(", "self", ",", "graphing_library", "=", "'matplotlib'", ")", ":", "logger", ".", "info", "(", "'Using graphing_library {lib} for metric {name}'", ".", "format", "(", "lib", "=", "graphing_library", ",", "name", "=", "self", ".", "label", ")", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
Metric.detect_anomaly
Detect anomalies in the timeseries data for the submetrics specified in the config file. Identified anomalies are stored in self.anomalies as well as written to .anomalies.csv file to be used by the client charting page. Anomaly detection uses the luminol library (http://pypi.python.org/pypi/luminol)
src/naarad/metrics/metric.py
def detect_anomaly(self): """ Detect anomalies in the timeseries data for the submetrics specified in the config file. Identified anomalies are stored in self.anomalies as well as written to .anomalies.csv file to be used by the client charting page. Anomaly detection uses the luminol library (http://py...
def detect_anomaly(self): """ Detect anomalies in the timeseries data for the submetrics specified in the config file. Identified anomalies are stored in self.anomalies as well as written to .anomalies.csv file to be used by the client charting page. Anomaly detection uses the luminol library (http://py...
[ "Detect", "anomalies", "in", "the", "timeseries", "data", "for", "the", "submetrics", "specified", "in", "the", "config", "file", ".", "Identified", "anomalies", "are", "stored", "in", "self", ".", "anomalies", "as", "well", "as", "written", "to", ".", "anom...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/metric.py#L600-L620
[ "def", "detect_anomaly", "(", "self", ")", ":", "if", "not", "self", ".", "anomaly_detection_metrics", "or", "len", "(", "self", ".", "anomaly_detection_metrics", ")", "<=", "0", ":", "return", "for", "submetric", "in", "self", ".", "anomaly_detection_metrics", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._get_tuple
:param fields: a list which contains either 0,1,or 2 values :return: a tuple with default values of '';
src/naarad/metrics/netstat_metric.py
def _get_tuple(self, fields): """ :param fields: a list which contains either 0,1,or 2 values :return: a tuple with default values of ''; """ v1 = '' v2 = '' if len(fields) > 0: v1 = fields[0] if len(fields) > 1: v2 = fields[1] return v1, v2
def _get_tuple(self, fields): """ :param fields: a list which contains either 0,1,or 2 values :return: a tuple with default values of ''; """ v1 = '' v2 = '' if len(fields) > 0: v1 = fields[0] if len(fields) > 1: v2 = fields[1] return v1, v2
[ ":", "param", "fields", ":", "a", "list", "which", "contains", "either", "0", "1", "or", "2", "values", ":", "return", ":", "a", "tuple", "with", "default", "values", "of", ";" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L53-L64
[ "def", "_get_tuple", "(", "self", ",", "fields", ")", ":", "v1", "=", "''", "v2", "=", "''", "if", "len", "(", "fields", ")", ">", "0", ":", "v1", "=", "fields", "[", "0", "]", "if", "len", "(", "fields", ")", ">", "1", ":", "v2", "=", "fie...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._extract_input_connections
Given user input of interested connections, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either host or port is optional - it may be just one end, - e.g., "host1<->host2 host3<-> host1:port1<->host2" :return: None
src/naarad/metrics/netstat_metric.py
def _extract_input_connections(self): """ Given user input of interested connections, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either host or port is optional - it may be just one end, - e.g., "host1<->host2 host3<-> host1:port1...
def _extract_input_connections(self): """ Given user input of interested connections, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either host or port is optional - it may be just one end, - e.g., "host1<->host2 host3<-> host1:port1...
[ "Given", "user", "input", "of", "interested", "connections", "it", "will", "extract", "the", "info", "and", "output", "a", "list", "of", "tuples", ".", "-", "input", "can", "be", "multiple", "values", "separated", "by", "space", ";", "-", "either", "host",...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L66-L86
[ "def", "_extract_input_connections", "(", "self", ")", ":", "for", "con", "in", "self", ".", "connections", ":", "ends", "=", "con", ".", "strip", "(", ")", ".", "split", "(", "'<->'", ")", "# [host1:port1->host2]", "ends", "=", "filter", "(", "None", ",...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._extract_input_processes
Given user input of interested processes, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either pid or process_name is optional - e.g., "10001/python 10002/java cpp" :return: None
src/naarad/metrics/netstat_metric.py
def _extract_input_processes(self): """ Given user input of interested processes, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either pid or process_name is optional - e.g., "10001/python 10002/java cpp" :return: None """ for...
def _extract_input_processes(self): """ Given user input of interested processes, it will extract the info and output a list of tuples. - input can be multiple values, separated by space; - either pid or process_name is optional - e.g., "10001/python 10002/java cpp" :return: None """ for...
[ "Given", "user", "input", "of", "interested", "processes", "it", "will", "extract", "the", "info", "and", "output", "a", "list", "of", "tuples", ".", "-", "input", "can", "be", "multiple", "values", "separated", "by", "space", ";", "-", "either", "pid", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L88-L99
[ "def", "_extract_input_processes", "(", "self", ")", ":", "for", "proc", "in", "self", ".", "processes", ":", "ends", "=", "proc", ".", "split", "(", "'/'", ")", "pid", ",", "name", "=", "self", ".", "_get_tuple", "(", "ends", ")", "self", ".", "inpu...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._match_host_port
Determine whether user-specified (host,port) matches current (cur_host, cur_port) :param host,port: The user input of (host,port) :param cur_host, cur_port: The current connection :return: True or Not
src/naarad/metrics/netstat_metric.py
def _match_host_port(self, host, port, cur_host, cur_port): """ Determine whether user-specified (host,port) matches current (cur_host, cur_port) :param host,port: The user input of (host,port) :param cur_host, cur_port: The current connection :return: True or Not """ # if host is '', true; ...
def _match_host_port(self, host, port, cur_host, cur_port): """ Determine whether user-specified (host,port) matches current (cur_host, cur_port) :param host,port: The user input of (host,port) :param cur_host, cur_port: The current connection :return: True or Not """ # if host is '', true; ...
[ "Determine", "whether", "user", "-", "specified", "(", "host", "port", ")", "matches", "current", "(", "cur_host", "cur_port", ")", ":", "param", "host", "port", ":", "The", "user", "input", "of", "(", "host", "port", ")", ":", "param", "cur_host", "cur_...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L101-L122
[ "def", "_match_host_port", "(", "self", ",", "host", ",", "port", ",", "cur_host", ",", "cur_port", ")", ":", "# if host is '', true; if not '', it should prefix-match cur_host", "host_match", "=", "False", "if", "not", "host", ":", "host_match", "=", "True", "elif...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._match_processes
Determine whether user-specified "pid/processes" contain this process :param pid: The user input of pid :param name: The user input of process name :param process: current process info :return: True or Not; (if both pid/process are given, then both of them need to match)
src/naarad/metrics/netstat_metric.py
def _match_processes(self, pid, name, cur_process): """ Determine whether user-specified "pid/processes" contain this process :param pid: The user input of pid :param name: The user input of process name :param process: current process info :return: True or Not; (if both pid/process are given, t...
def _match_processes(self, pid, name, cur_process): """ Determine whether user-specified "pid/processes" contain this process :param pid: The user input of pid :param name: The user input of process name :param process: current process info :return: True or Not; (if both pid/process are given, t...
[ "Determine", "whether", "user", "-", "specified", "pid", "/", "processes", "contain", "this", "process", ":", "param", "pid", ":", "The", "user", "input", "of", "pid", ":", "param", "name", ":", "The", "user", "input", "of", "process", "name", ":", "para...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L124-L146
[ "def", "_match_processes", "(", "self", ",", "pid", ",", "name", ",", "cur_process", ")", ":", "cur_pid", ",", "cur_name", "=", "self", ".", "_get_tuple", "(", "cur_process", ".", "split", "(", "'/'", ")", ")", "pid_match", "=", "False", "if", "not", "...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._check_connection
Check whether the connection is of interest or not :param local_end: Local connection end point, e.g., 'host1:port1' :param remote_end: Remote connection end point, e.g., 'host2:port2' :param process: Current connection 's process info, e.g., '1234/firefox' :return: a tuple of (local_end, remote_end, Tr...
src/naarad/metrics/netstat_metric.py
def _check_connection(self, local_end, remote_end, process): """ Check whether the connection is of interest or not :param local_end: Local connection end point, e.g., 'host1:port1' :param remote_end: Remote connection end point, e.g., 'host2:port2' :param process: Current connection 's process info...
def _check_connection(self, local_end, remote_end, process): """ Check whether the connection is of interest or not :param local_end: Local connection end point, e.g., 'host1:port1' :param remote_end: Remote connection end point, e.g., 'host2:port2' :param process: Current connection 's process info...
[ "Check", "whether", "the", "connection", "is", "of", "interest", "or", "not", ":", "param", "local_end", ":", "Local", "connection", "end", "point", "e", ".", "g", ".", "host1", ":", "port1", ":", "param", "remote_end", ":", "Remote", "connection", "end", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L148-L177
[ "def", "_check_connection", "(", "self", ",", "local_end", ",", "remote_end", ",", "process", ")", ":", "# check tcp end points", "cur_host1", ",", "cur_port1", "=", "self", ".", "_get_tuple", "(", "local_end", ".", "split", "(", "':'", ")", ")", "cur_host2", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric._add_data_line
Append the data point to the dictionary of "data" :param data: The dictionary containing all data :param col: The sub-metric name e.g. 'host1_port1.host2_port2.SendQ' :param value: integer :param ts: timestamp :return: None
src/naarad/metrics/netstat_metric.py
def _add_data_line(self, data, col, value, ts): """ Append the data point to the dictionary of "data" :param data: The dictionary containing all data :param col: The sub-metric name e.g. 'host1_port1.host2_port2.SendQ' :param value: integer :param ts: timestamp :return: None """ if c...
def _add_data_line(self, data, col, value, ts): """ Append the data point to the dictionary of "data" :param data: The dictionary containing all data :param col: The sub-metric name e.g. 'host1_port1.host2_port2.SendQ' :param value: integer :param ts: timestamp :return: None """ if c...
[ "Append", "the", "data", "point", "to", "the", "dictionary", "of", "data", ":", "param", "data", ":", "The", "dictionary", "containing", "all", "data", ":", "param", "col", ":", "The", "sub", "-", "metric", "name", "e", ".", "g", ".", "host1_port1", "....
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L179-L193
[ "def", "_add_data_line", "(", "self", ",", "data", ",", "col", ",", "value", ",", "ts", ")", ":", "if", "col", "in", "self", ".", "column_csv_map", ":", "out_csv", "=", "self", ".", "column_csv_map", "[", "col", "]", "else", ":", "out_csv", "=", "sel...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
NetstatMetric.parse
Parse the netstat output file :return: status of the metric parse
src/naarad/metrics/netstat_metric.py
def parse(self): """ Parse the netstat output file :return: status of the metric parse """ # sample netstat output: 2014-04-02 15:44:02.86612 tcp 9600 0 host1.localdomain.com.:21567 remote.remotedomain.com:51168 ESTABLISH pid/process data = {} # stores the data of each sub-metric f...
def parse(self): """ Parse the netstat output file :return: status of the metric parse """ # sample netstat output: 2014-04-02 15:44:02.86612 tcp 9600 0 host1.localdomain.com.:21567 remote.remotedomain.com:51168 ESTABLISH pid/process data = {} # stores the data of each sub-metric f...
[ "Parse", "the", "netstat", "output", "file", ":", "return", ":", "status", "of", "the", "metric", "parse" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/netstat_metric.py#L195-L230
[ "def", "parse", "(", "self", ")", ":", "# sample netstat output: 2014-04-02 15:44:02.86612\ttcp 9600 0 host1.localdomain.com.:21567 remote.remotedomain.com:51168 ESTABLISH pid/process", "data", "=", "{", "}", "# stores the data of each sub-metric", "for", "infile", "in", "self...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
ProcInterruptsMetric.get_csv
Returns the CSV file related to the given metric. The metric is determined by the cpu and device. The cpu is the CPU as in the interrupts file for example CPU12. The metric is a combination of the CPU and device. The device consists of IRQ #, the irq device ASCII name. CPU...
src/naarad/metrics/procinterrupts_metric.py
def get_csv(self, cpu, device=None): """ Returns the CSV file related to the given metric. The metric is determined by the cpu and device. The cpu is the CPU as in the interrupts file for example CPU12. The metric is a combination of the CPU and device. The device consists of IRQ #, the irq device ASCII...
def get_csv(self, cpu, device=None): """ Returns the CSV file related to the given metric. The metric is determined by the cpu and device. The cpu is the CPU as in the interrupts file for example CPU12. The metric is a combination of the CPU and device. The device consists of IRQ #, the irq device ASCII...
[ "Returns", "the", "CSV", "file", "related", "to", "the", "given", "metric", ".", "The", "metric", "is", "determined", "by", "the", "cpu", "and", "device", ".", "The", "cpu", "is", "the", "CPU", "as", "in", "the", "interrupts", "file", "for", "example", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/procinterrupts_metric.py#L59-L85
[ "def", "get_csv", "(", "self", ",", "cpu", ",", "device", "=", "None", ")", ":", "cpu", "=", "naarad", ".", "utils", ".", "sanitize_string", "(", "cpu", ")", "if", "device", "is", "None", ":", "outcsv", "=", "os", ".", "path", ".", "join", "(", "...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
ProcInterruptsMetric.find_header
Parses the file and tries to find the header line. The header line has format: 2014-10-29 00:28:42.15161 CPU0 CPU1 CPU2 CPU3 ... So should always have CPU# for each core. This function verifies a good header and returns the list of CPUs that exist from the header. :param infile: The o...
src/naarad/metrics/procinterrupts_metric.py
def find_header(self, infile): """ Parses the file and tries to find the header line. The header line has format: 2014-10-29 00:28:42.15161 CPU0 CPU1 CPU2 CPU3 ... So should always have CPU# for each core. This function verifies a good header and returns the list of CPUs that exist...
def find_header(self, infile): """ Parses the file and tries to find the header line. The header line has format: 2014-10-29 00:28:42.15161 CPU0 CPU1 CPU2 CPU3 ... So should always have CPU# for each core. This function verifies a good header and returns the list of CPUs that exist...
[ "Parses", "the", "file", "and", "tries", "to", "find", "the", "header", "line", ".", "The", "header", "line", "has", "format", ":" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/procinterrupts_metric.py#L99-L125
[ "def", "find_header", "(", "self", ",", "infile", ")", ":", "cpus", "=", "[", "]", "for", "line", "in", "infile", ":", "# Pre-processing - Try to find header", "if", "not", "self", ".", "is_header_line", "(", "line", ")", ":", "continue", "# Verifying correctn...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
ProcInterruptsMetric.parse
Processes the files for each IRQ and each CPU in terms of the differences. Also produces accumulated interrupt count differences for each set of Ethernet IRQs. Generally Ethernet has 8 TxRx IRQs thus all are combined so that one can see the overall interrupts being generated by the NIC. Simplified Interrup...
src/naarad/metrics/procinterrupts_metric.py
def parse(self): """ Processes the files for each IRQ and each CPU in terms of the differences. Also produces accumulated interrupt count differences for each set of Ethernet IRQs. Generally Ethernet has 8 TxRx IRQs thus all are combined so that one can see the overall interrupts being generated by the ...
def parse(self): """ Processes the files for each IRQ and each CPU in terms of the differences. Also produces accumulated interrupt count differences for each set of Ethernet IRQs. Generally Ethernet has 8 TxRx IRQs thus all are combined so that one can see the overall interrupts being generated by the ...
[ "Processes", "the", "files", "for", "each", "IRQ", "and", "each", "CPU", "in", "terms", "of", "the", "differences", ".", "Also", "produces", "accumulated", "interrupt", "count", "differences", "for", "each", "set", "of", "Ethernet", "IRQs", ".", "Generally", ...
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/procinterrupts_metric.py#L127-L233
[ "def", "parse", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "outdir", ")", ":", "os", ".", "makedirs", "(", "self", ".", "outdir", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", ...
261e2c0760fd6a6b0ee59064180bd8e3674311fe
valid
ProcMeminfoMetric.parse
Parse the vmstat file :return: status of the metric parse
src/naarad/metrics/procmeminfo_metric.py
def parse(self): """ Parse the vmstat file :return: status of the metric parse """ file_status = True for input_file in self.infile_list: file_status = file_status and naarad.utils.is_valid_file(input_file) if not file_status: return False status = True data = {} # s...
def parse(self): """ Parse the vmstat file :return: status of the metric parse """ file_status = True for input_file in self.infile_list: file_status = file_status and naarad.utils.is_valid_file(input_file) if not file_status: return False status = True data = {} # s...
[ "Parse", "the", "vmstat", "file", ":", "return", ":", "status", "of", "the", "metric", "parse" ]
linkedin/naarad
python
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/metrics/procmeminfo_metric.py#L56-L106
[ "def", "parse", "(", "self", ")", ":", "file_status", "=", "True", "for", "input_file", "in", "self", ".", "infile_list", ":", "file_status", "=", "file_status", "and", "naarad", ".", "utils", ".", "is_valid_file", "(", "input_file", ")", "if", "not", "fil...
261e2c0760fd6a6b0ee59064180bd8e3674311fe