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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | git_tag_list | Return a list of all the tags in the git repo matching a regex passed in
`pattern`. If `pattern` is None, return all the tags. | datadog_checks_dev/datadog_checks/dev/tooling/git.py | def git_tag_list(pattern=None):
"""
Return a list of all the tags in the git repo matching a regex passed in
`pattern`. If `pattern` is None, return all the tags.
"""
with chdir(get_root()):
result = run_command('git tag', capture=True).stdout
result = result.splitlines()
if not... | def git_tag_list(pattern=None):
"""
Return a list of all the tags in the git repo matching a regex passed in
`pattern`. If `pattern` is None, return all the tags.
"""
with chdir(get_root()):
result = run_command('git tag', capture=True).stdout
result = result.splitlines()
if not... | [
"Return",
"a",
"list",
"of",
"all",
"the",
"tags",
"in",
"the",
"git",
"repo",
"matching",
"a",
"regex",
"passed",
"in",
"pattern",
".",
"If",
"pattern",
"is",
"None",
"return",
"all",
"the",
"tags",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/git.py#L89-L102 | [
"def",
"git_tag_list",
"(",
"pattern",
"=",
"None",
")",
":",
"with",
"chdir",
"(",
"get_root",
"(",
")",
")",
":",
"result",
"=",
"run_command",
"(",
"'git tag'",
",",
"capture",
"=",
"True",
")",
".",
"stdout",
"result",
"=",
"result",
".",
"splitlin... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | git_ls_files | Return a boolean value for whether the given file is tracked by git. | datadog_checks_dev/datadog_checks/dev/tooling/git.py | def git_ls_files(filename):
"""
Return a boolean value for whether the given file is tracked by git.
"""
with chdir(get_root()):
# https://stackoverflow.com/a/2406813
result = run_command('git ls-files --error-unmatch {}'.format(filename), capture=True)
return result.code == 0 | def git_ls_files(filename):
"""
Return a boolean value for whether the given file is tracked by git.
"""
with chdir(get_root()):
# https://stackoverflow.com/a/2406813
result = run_command('git ls-files --error-unmatch {}'.format(filename), capture=True)
return result.code == 0 | [
"Return",
"a",
"boolean",
"value",
"for",
"whether",
"the",
"given",
"file",
"is",
"tracked",
"by",
"git",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/git.py#L105-L112 | [
"def",
"git_ls_files",
"(",
"filename",
")",
":",
"with",
"chdir",
"(",
"get_root",
"(",
")",
")",
":",
"# https://stackoverflow.com/a/2406813",
"result",
"=",
"run_command",
"(",
"'git ls-files --error-unmatch {}'",
".",
"format",
"(",
"filename",
")",
",",
"capt... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WinPDHCounter._make_counter_path | When handling non english versions, the counters don't work quite as documented.
This is because strings like "Bytes Sent/sec" might appear multiple times in the
english master, and might not have mappings for each index.
Search each index, and make sure the requested counter name actually appe... | datadog_checks_base/datadog_checks/base/checks/win/winpdh.py | def _make_counter_path(self, machine_name, counter_name, instance_name, counters):
"""
When handling non english versions, the counters don't work quite as documented.
This is because strings like "Bytes Sent/sec" might appear multiple times in the
english master, and might not have mapp... | def _make_counter_path(self, machine_name, counter_name, instance_name, counters):
"""
When handling non english versions, the counters don't work quite as documented.
This is because strings like "Bytes Sent/sec" might appear multiple times in the
english master, and might not have mapp... | [
"When",
"handling",
"non",
"english",
"versions",
"the",
"counters",
"don",
"t",
"work",
"quite",
"as",
"documented",
".",
"This",
"is",
"because",
"strings",
"like",
"Bytes",
"Sent",
"/",
"sec",
"might",
"appear",
"multiple",
"times",
"in",
"the",
"english"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/winpdh.py#L142-L193 | [
"def",
"_make_counter_path",
"(",
"self",
",",
"machine_name",
",",
"counter_name",
",",
"instance_name",
",",
"counters",
")",
":",
"path",
"=",
"\"\"",
"if",
"WinPDHCounter",
".",
"_use_en_counter_names",
":",
"'''\n In this case, we don't have any translatio... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Nagios.gauge | Compatability wrapper for Agents that do not submit gauge metrics with custom timestamps | nagios/datadog_checks/nagios/nagios.py | def gauge(self, *args, **kwargs):
"""
Compatability wrapper for Agents that do not submit gauge metrics with custom timestamps
"""
orig_gauge = super(Nagios, self).gauge
# remove 'timestamp' arg if the base class' gauge function does not accept a 'timestamp' arg
if 'times... | def gauge(self, *args, **kwargs):
"""
Compatability wrapper for Agents that do not submit gauge metrics with custom timestamps
"""
orig_gauge = super(Nagios, self).gauge
# remove 'timestamp' arg if the base class' gauge function does not accept a 'timestamp' arg
if 'times... | [
"Compatability",
"wrapper",
"for",
"Agents",
"that",
"do",
"not",
"submit",
"gauge",
"metrics",
"with",
"custom",
"timestamps"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/nagios/datadog_checks/nagios/nagios.py#L85-L94 | [
"def",
"gauge",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"orig_gauge",
"=",
"super",
"(",
"Nagios",
",",
"self",
")",
".",
"gauge",
"# remove 'timestamp' arg if the base class' gauge function does not accept a 'timestamp' arg",
"if",
"'times... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Nagios.check | Parse until the end of each tailer associated with this instance.
We match instance and tailers based on the path to the Nagios configuration file
Special case: Compatibility with the old conf when no conf file is specified
but the path to the event_log is given | nagios/datadog_checks/nagios/nagios.py | def check(self, instance):
"""
Parse until the end of each tailer associated with this instance.
We match instance and tailers based on the path to the Nagios configuration file
Special case: Compatibility with the old conf when no conf file is specified
but the path to the even... | def check(self, instance):
"""
Parse until the end of each tailer associated with this instance.
We match instance and tailers based on the path to the Nagios configuration file
Special case: Compatibility with the old conf when no conf file is specified
but the path to the even... | [
"Parse",
"until",
"the",
"end",
"of",
"each",
"tailer",
"associated",
"with",
"this",
"instance",
".",
"We",
"match",
"instance",
"and",
"tailers",
"based",
"on",
"the",
"path",
"to",
"the",
"Nagios",
"configuration",
"file"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/nagios/datadog_checks/nagios/nagios.py#L207-L221 | [
"def",
"check",
"(",
"self",
",",
"instance",
")",
":",
"instance_key",
"=",
"instance",
".",
"get",
"(",
"'nagios_conf'",
",",
"instance",
".",
"get",
"(",
"'nagios_perf_cfg'",
",",
"instance",
".",
"get",
"(",
"'nagios_log'",
",",
"None",
")",
")",
")"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | NagiosEventLogTailer._parse_line | Actual nagios parsing
Return True if we found an event, False otherwise | nagios/datadog_checks/nagios/nagios.py | def _parse_line(self, line):
"""
Actual nagios parsing
Return True if we found an event, False otherwise
"""
# first isolate the timestamp and the event type
try:
self._line_parsed = self._line_parsed + 1
m = RE_LINE_REG.match(line)
if... | def _parse_line(self, line):
"""
Actual nagios parsing
Return True if we found an event, False otherwise
"""
# first isolate the timestamp and the event type
try:
self._line_parsed = self._line_parsed + 1
m = RE_LINE_REG.match(line)
if... | [
"Actual",
"nagios",
"parsing",
"Return",
"True",
"if",
"we",
"found",
"an",
"event",
"False",
"otherwise"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/nagios/datadog_checks/nagios/nagios.py#L298-L342 | [
"def",
"_parse_line",
"(",
"self",
",",
"line",
")",
":",
"# first isolate the timestamp and the event type",
"try",
":",
"self",
".",
"_line_parsed",
"=",
"self",
".",
"_line_parsed",
"+",
"1",
"m",
"=",
"RE_LINE_REG",
".",
"match",
"(",
"line",
")",
"if",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | NagiosEventLogTailer.create_event | Factory method called by the parsers | nagios/datadog_checks/nagios/nagios.py | def create_event(self, timestamp, event_type, hostname, fields, tags=None):
"""Factory method called by the parsers
"""
# Agent6 expects a specific set of fields, so we need to place all
# extra fields in the msg_title and let the Datadog backend separate them
# Any remaining fie... | def create_event(self, timestamp, event_type, hostname, fields, tags=None):
"""Factory method called by the parsers
"""
# Agent6 expects a specific set of fields, so we need to place all
# extra fields in the msg_title and let the Datadog backend separate them
# Any remaining fie... | [
"Factory",
"method",
"called",
"by",
"the",
"parsers"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/nagios/datadog_checks/nagios/nagios.py#L344-L379 | [
"def",
"create_event",
"(",
"self",
",",
"timestamp",
",",
"event_type",
",",
"hostname",
",",
"fields",
",",
"tags",
"=",
"None",
")",
":",
"# Agent6 expects a specific set of fields, so we need to place all",
"# extra fields in the msg_title and let the Datadog backend separa... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.create_snmp_engine | Create a command generator to perform all the snmp query.
If mibs_path is not None, load the mibs present in the custom mibs
folder. (Need to be in pysnmp format) | snmp/datadog_checks/snmp/snmp.py | def create_snmp_engine(self, mibs_path):
'''
Create a command generator to perform all the snmp query.
If mibs_path is not None, load the mibs present in the custom mibs
folder. (Need to be in pysnmp format)
'''
snmp_engine = hlapi.SnmpEngine()
mib_builder = snmp_... | def create_snmp_engine(self, mibs_path):
'''
Create a command generator to perform all the snmp query.
If mibs_path is not None, load the mibs present in the custom mibs
folder. (Need to be in pysnmp format)
'''
snmp_engine = hlapi.SnmpEngine()
mib_builder = snmp_... | [
"Create",
"a",
"command",
"generator",
"to",
"perform",
"all",
"the",
"snmp",
"query",
".",
"If",
"mibs_path",
"is",
"not",
"None",
"load",
"the",
"mibs",
"present",
"in",
"the",
"custom",
"mibs",
"folder",
".",
"(",
"Need",
"to",
"be",
"in",
"pysnmp",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L99-L112 | [
"def",
"create_snmp_engine",
"(",
"self",
",",
"mibs_path",
")",
":",
"snmp_engine",
"=",
"hlapi",
".",
"SnmpEngine",
"(",
")",
"mib_builder",
"=",
"snmp_engine",
".",
"getMibBuilder",
"(",
")",
"if",
"mibs_path",
"is",
"not",
"None",
":",
"mib_builder",
"."... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.get_auth_data | Generate a Security Parameters object based on the instance's
configuration.
See http://pysnmp.sourceforge.net/docs/current/security-configuration.html | snmp/datadog_checks/snmp/snmp.py | def get_auth_data(cls, instance):
'''
Generate a Security Parameters object based on the instance's
configuration.
See http://pysnmp.sourceforge.net/docs/current/security-configuration.html
'''
if "community_string" in instance:
# SNMP v1 - SNMP v2
... | def get_auth_data(cls, instance):
'''
Generate a Security Parameters object based on the instance's
configuration.
See http://pysnmp.sourceforge.net/docs/current/security-configuration.html
'''
if "community_string" in instance:
# SNMP v1 - SNMP v2
... | [
"Generate",
"a",
"Security",
"Parameters",
"object",
"based",
"on",
"the",
"instance",
"s",
"configuration",
".",
"See",
"http",
":",
"//",
"pysnmp",
".",
"sourceforge",
".",
"net",
"/",
"docs",
"/",
"current",
"/",
"security",
"-",
"configuration",
".",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L115-L149 | [
"def",
"get_auth_data",
"(",
"cls",
",",
"instance",
")",
":",
"if",
"\"community_string\"",
"in",
"instance",
":",
"# SNMP v1 - SNMP v2",
"# See http://pysnmp.sourceforge.net/docs/current/security-configuration.html",
"if",
"int",
"(",
"instance",
".",
"get",
"(",
"\"snm... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.get_context_data | Generate a Context Parameters object based on the instance's
configuration.
We do not use the hlapi currently, but the rfc3413.oneliner.cmdgen
accepts Context Engine Id (always None for now) and Context Name parameters. | snmp/datadog_checks/snmp/snmp.py | def get_context_data(cls, instance):
'''
Generate a Context Parameters object based on the instance's
configuration.
We do not use the hlapi currently, but the rfc3413.oneliner.cmdgen
accepts Context Engine Id (always None for now) and Context Name parameters.
'''
... | def get_context_data(cls, instance):
'''
Generate a Context Parameters object based on the instance's
configuration.
We do not use the hlapi currently, but the rfc3413.oneliner.cmdgen
accepts Context Engine Id (always None for now) and Context Name parameters.
'''
... | [
"Generate",
"a",
"Context",
"Parameters",
"object",
"based",
"on",
"the",
"instance",
"s",
"configuration",
".",
"We",
"do",
"not",
"use",
"the",
"hlapi",
"currently",
"but",
"the",
"rfc3413",
".",
"oneliner",
".",
"cmdgen",
"accepts",
"Context",
"Engine",
"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L152-L169 | [
"def",
"get_context_data",
"(",
"cls",
",",
"instance",
")",
":",
"context_engine_id",
"=",
"None",
"context_name",
"=",
"''",
"if",
"\"user\"",
"in",
"instance",
":",
"if",
"'context_engine_id'",
"in",
"instance",
":",
"context_engine_id",
"=",
"OctetString",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.get_transport_target | Generate a Transport target object based on the instance's configuration | snmp/datadog_checks/snmp/snmp.py | def get_transport_target(cls, instance, timeout, retries):
'''
Generate a Transport target object based on the instance's configuration
'''
if "ip_address" not in instance:
raise Exception("An IP address needs to be specified")
ip_address = instance["ip_address"]
... | def get_transport_target(cls, instance, timeout, retries):
'''
Generate a Transport target object based on the instance's configuration
'''
if "ip_address" not in instance:
raise Exception("An IP address needs to be specified")
ip_address = instance["ip_address"]
... | [
"Generate",
"a",
"Transport",
"target",
"object",
"based",
"on",
"the",
"instance",
"s",
"configuration"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L172-L180 | [
"def",
"get_transport_target",
"(",
"cls",
",",
"instance",
",",
"timeout",
",",
"retries",
")",
":",
"if",
"\"ip_address\"",
"not",
"in",
"instance",
":",
"raise",
"Exception",
"(",
"\"An IP address needs to be specified\"",
")",
"ip_address",
"=",
"instance",
"[... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.check_table | Perform a snmpwalk on the domain specified by the oids, on the device
configured in instance.
lookup_names is a boolean to specify whether or not to use the mibs to
resolve the name and values.
Returns a dictionary:
dict[oid/metric_name][row index] = value
In case of sca... | snmp/datadog_checks/snmp/snmp.py | def check_table(
self,
instance,
snmp_engine,
mib_view_controller,
oids,
lookup_names,
timeout,
retries,
enforce_constraints=False,
mibs_to_load=None,
):
'''
Perform a snmpwalk on the domain specified by the oids, on the... | def check_table(
self,
instance,
snmp_engine,
mib_view_controller,
oids,
lookup_names,
timeout,
retries,
enforce_constraints=False,
mibs_to_load=None,
):
'''
Perform a snmpwalk on the domain specified by the oids, on the... | [
"Perform",
"a",
"snmpwalk",
"on",
"the",
"domain",
"specified",
"by",
"the",
"oids",
"on",
"the",
"device",
"configured",
"in",
"instance",
".",
"lookup_names",
"is",
"a",
"boolean",
"to",
"specify",
"whether",
"or",
"not",
"to",
"use",
"the",
"mibs",
"to"... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L188-L320 | [
"def",
"check_table",
"(",
"self",
",",
"instance",
",",
"snmp_engine",
",",
"mib_view_controller",
",",
"oids",
",",
"lookup_names",
",",
"timeout",
",",
"retries",
",",
"enforce_constraints",
"=",
"False",
",",
"mibs_to_load",
"=",
"None",
",",
")",
":",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck._check | Perform two series of SNMP requests, one for all that have MIB asociated
and should be looked up and one for those specified by oids | snmp/datadog_checks/snmp/snmp.py | def _check(self, instance):
'''
Perform two series of SNMP requests, one for all that have MIB asociated
and should be looked up and one for those specified by oids
'''
(
snmp_engine,
mib_view_controller,
ip_address,
tags,
... | def _check(self, instance):
'''
Perform two series of SNMP requests, one for all that have MIB asociated
and should be looked up and one for those specified by oids
'''
(
snmp_engine,
mib_view_controller,
ip_address,
tags,
... | [
"Perform",
"two",
"series",
"of",
"SNMP",
"requests",
"one",
"for",
"all",
"that",
"have",
"MIB",
"asociated",
"and",
"should",
"be",
"looked",
"up",
"and",
"one",
"for",
"those",
"specified",
"by",
"oids"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L374-L435 | [
"def",
"_check",
"(",
"self",
",",
"instance",
")",
":",
"(",
"snmp_engine",
",",
"mib_view_controller",
",",
"ip_address",
",",
"tags",
",",
"metrics",
",",
"timeout",
",",
"retries",
",",
"enforce_constraints",
",",
")",
"=",
"self",
".",
"_load_conf",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.report_raw_metrics | For all the metrics that are specified as oid,
the conf oid is going to exactly match or be a prefix of the oid sent back by the device
Use the instance configuration to find the name to give to the metric
Submit the results to the aggregator. | snmp/datadog_checks/snmp/snmp.py | def report_raw_metrics(self, metrics, results, tags):
'''
For all the metrics that are specified as oid,
the conf oid is going to exactly match or be a prefix of the oid sent back by the device
Use the instance configuration to find the name to give to the metric
Submit the resu... | def report_raw_metrics(self, metrics, results, tags):
'''
For all the metrics that are specified as oid,
the conf oid is going to exactly match or be a prefix of the oid sent back by the device
Use the instance configuration to find the name to give to the metric
Submit the resu... | [
"For",
"all",
"the",
"metrics",
"that",
"are",
"specified",
"as",
"oid",
"the",
"conf",
"oid",
"is",
"going",
"to",
"exactly",
"match",
"or",
"be",
"a",
"prefix",
"of",
"the",
"oid",
"sent",
"back",
"by",
"the",
"device",
"Use",
"the",
"instance",
"con... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L444-L471 | [
"def",
"report_raw_metrics",
"(",
"self",
",",
"metrics",
",",
"results",
",",
"tags",
")",
":",
"for",
"metric",
"in",
"metrics",
":",
"forced_type",
"=",
"metric",
".",
"get",
"(",
"'forced_type'",
")",
"if",
"'OID'",
"in",
"metric",
":",
"queried_oid",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.report_table_metrics | For each of the metrics specified as needing to be resolved with mib,
gather the tags requested in the instance conf for each row.
Submit the results to the aggregator. | snmp/datadog_checks/snmp/snmp.py | def report_table_metrics(self, metrics, results, tags):
'''
For each of the metrics specified as needing to be resolved with mib,
gather the tags requested in the instance conf for each row.
Submit the results to the aggregator.
'''
for metric in metrics:
fo... | def report_table_metrics(self, metrics, results, tags):
'''
For each of the metrics specified as needing to be resolved with mib,
gather the tags requested in the instance conf for each row.
Submit the results to the aggregator.
'''
for metric in metrics:
fo... | [
"For",
"each",
"of",
"the",
"metrics",
"specified",
"as",
"needing",
"to",
"be",
"resolved",
"with",
"mib",
"gather",
"the",
"tags",
"requested",
"in",
"the",
"instance",
"conf",
"for",
"each",
"row",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L473-L514 | [
"def",
"report_table_metrics",
"(",
"self",
",",
"metrics",
",",
"results",
",",
"tags",
")",
":",
"for",
"metric",
"in",
"metrics",
":",
"forced_type",
"=",
"metric",
".",
"get",
"(",
"'forced_type'",
")",
"if",
"'table'",
"in",
"metric",
":",
"index_base... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.get_index_tags | Gather the tags for this row of the table (index) based on the
results (all the results from the query).
index_tags and column_tags are the tags to gather.
- Those specified in index_tags contain the tag_group name and the
index of the value we want to extract from the index tuple.
... | snmp/datadog_checks/snmp/snmp.py | def get_index_tags(self, index, results, index_tags, column_tags):
'''
Gather the tags for this row of the table (index) based on the
results (all the results from the query).
index_tags and column_tags are the tags to gather.
- Those specified in index_tags contain the tag_grou... | def get_index_tags(self, index, results, index_tags, column_tags):
'''
Gather the tags for this row of the table (index) based on the
results (all the results from the query).
index_tags and column_tags are the tags to gather.
- Those specified in index_tags contain the tag_grou... | [
"Gather",
"the",
"tags",
"for",
"this",
"row",
"of",
"the",
"table",
"(",
"index",
")",
"based",
"on",
"the",
"results",
"(",
"all",
"the",
"results",
"from",
"the",
"query",
")",
".",
"index_tags",
"and",
"column_tags",
"are",
"the",
"tags",
"to",
"ga... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L516-L549 | [
"def",
"get_index_tags",
"(",
"self",
",",
"index",
",",
"results",
",",
"index_tags",
",",
"column_tags",
")",
":",
"tags",
"=",
"[",
"]",
"for",
"idx_tag",
"in",
"index_tags",
":",
"tag_group",
"=",
"idx_tag",
"[",
"0",
"]",
"try",
":",
"tag_value",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | SnmpCheck.submit_metric | Convert the values reported as pysnmp-Managed Objects to values and
report them to the aggregator | snmp/datadog_checks/snmp/snmp.py | def submit_metric(self, name, snmp_value, forced_type, tags=None):
'''
Convert the values reported as pysnmp-Managed Objects to values and
report them to the aggregator
'''
tags = [] if tags is None else tags
if reply_invalid(snmp_value):
# Metrics not present... | def submit_metric(self, name, snmp_value, forced_type, tags=None):
'''
Convert the values reported as pysnmp-Managed Objects to values and
report them to the aggregator
'''
tags = [] if tags is None else tags
if reply_invalid(snmp_value):
# Metrics not present... | [
"Convert",
"the",
"values",
"reported",
"as",
"pysnmp",
"-",
"Managed",
"Objects",
"to",
"values",
"and",
"report",
"them",
"to",
"the",
"aggregator"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/snmp/datadog_checks/snmp/snmp.py#L551-L591 | [
"def",
"submit_metric",
"(",
"self",
",",
"name",
",",
"snmp_value",
",",
"forced_type",
",",
"tags",
"=",
"None",
")",
":",
"tags",
"=",
"[",
"]",
"if",
"tags",
"is",
"None",
"else",
"tags",
"if",
"reply_invalid",
"(",
"snmp_value",
")",
":",
"# Metri... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Debugger.set_trace | See https://github.com/python/cpython/blob/b02774f42108aaf18eb19865472c8d5cd95b5f11/Lib/bdb.py#L319-L332 | datadog_checks_base/datadog_checks/base/utils/agent/debug.py | def set_trace(self, frame=None):
"""See https://github.com/python/cpython/blob/b02774f42108aaf18eb19865472c8d5cd95b5f11/Lib/bdb.py#L319-L332"""
self.reset()
if frame is None:
frame = sys._getframe().f_back
while frame:
frame.f_trace = self.trace_dispatch
... | def set_trace(self, frame=None):
"""See https://github.com/python/cpython/blob/b02774f42108aaf18eb19865472c8d5cd95b5f11/Lib/bdb.py#L319-L332"""
self.reset()
if frame is None:
frame = sys._getframe().f_back
while frame:
frame.f_trace = self.trace_dispatch
... | [
"See",
"https",
":",
"//",
"github",
".",
"com",
"/",
"python",
"/",
"cpython",
"/",
"blob",
"/",
"b02774f42108aaf18eb19865472c8d5cd95b5f11",
"/",
"Lib",
"/",
"bdb",
".",
"py#L319",
"-",
"L332"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/utils/agent/debug.py#L12-L27 | [
"def",
"set_trace",
"(",
"self",
",",
"frame",
"=",
"None",
")",
":",
"self",
".",
"reset",
"(",
")",
"if",
"frame",
"is",
"None",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
")",
".",
"f_back",
"while",
"frame",
":",
"frame",
".",
"f_trace",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ServerDescription.round_trip_time | The current average latency or None. | tokumx/datadog_checks/tokumx/vendor/pymongo/server_description.py | def round_trip_time(self):
"""The current average latency or None."""
# This override is for unittesting only!
if self._address in self._host_to_round_trip_time:
return self._host_to_round_trip_time[self._address]
return self._round_trip_time | def round_trip_time(self):
"""The current average latency or None."""
# This override is for unittesting only!
if self._address in self._host_to_round_trip_time:
return self._host_to_round_trip_time[self._address]
return self._round_trip_time | [
"The",
"current",
"average",
"latency",
"or",
"None",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/server_description.py#L168-L174 | [
"def",
"round_trip_time",
"(",
"self",
")",
":",
"# This override is for unittesting only!",
"if",
"self",
".",
"_address",
"in",
"self",
".",
"_host_to_round_trip_time",
":",
"return",
"self",
".",
"_host_to_round_trip_time",
"[",
"self",
".",
"_address",
"]",
"ret... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OpenStackControllerCheck.collect_networks_metrics | Collect stats for all reachable networks | openstack_controller/datadog_checks/openstack_controller/openstack_controller.py | def collect_networks_metrics(self, tags, network_ids, exclude_network_id_rules):
"""
Collect stats for all reachable networks
"""
networks = self.get_networks()
filtered_networks = []
if not network_ids:
# Filter out excluded networks
filtered_netw... | def collect_networks_metrics(self, tags, network_ids, exclude_network_id_rules):
"""
Collect stats for all reachable networks
"""
networks = self.get_networks()
filtered_networks = []
if not network_ids:
# Filter out excluded networks
filtered_netw... | [
"Collect",
"stats",
"for",
"all",
"reachable",
"networks"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/openstack_controller.py#L145-L178 | [
"def",
"collect_networks_metrics",
"(",
"self",
",",
"tags",
",",
"network_ids",
",",
"exclude_network_id_rules",
")",
":",
"networks",
"=",
"self",
".",
"get_networks",
"(",
")",
"filtered_networks",
"=",
"[",
"]",
"if",
"not",
"network_ids",
":",
"# Filter out... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OpenStackControllerCheck._parse_uptime_string | Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n' | openstack_controller/datadog_checks/openstack_controller/openstack_controller.py | def _parse_uptime_string(self, uptime):
""" Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n' """
uptime = uptime.strip()
load_averages = uptime[uptime.find('load average:') :].split(':')[1].strip().split(',')
load_averages = [float(load_avg) for load_avg in... | def _parse_uptime_string(self, uptime):
""" Parse u' 16:53:48 up 1 day, 21:34, 3 users, load average: 0.04, 0.14, 0.19\n' """
uptime = uptime.strip()
load_averages = uptime[uptime.find('load average:') :].split(':')[1].strip().split(',')
load_averages = [float(load_avg) for load_avg in... | [
"Parse",
"u",
"16",
":",
"53",
":",
"48",
"up",
"1",
"day",
"21",
":",
"34",
"3",
"users",
"load",
"average",
":",
"0",
".",
"04",
"0",
".",
"14",
"0",
".",
"19",
"\\",
"n"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/openstack_controller.py#L181-L186 | [
"def",
"_parse_uptime_string",
"(",
"self",
",",
"uptime",
")",
":",
"uptime",
"=",
"uptime",
".",
"strip",
"(",
")",
"load_averages",
"=",
"uptime",
"[",
"uptime",
".",
"find",
"(",
"'load average:'",
")",
":",
"]",
".",
"split",
"(",
"':'",
")",
"[",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OpenStackControllerCheck.collect_hypervisors_metrics | Submits stats for all hypervisors registered to this control plane
Raises specific exceptions based on response code | openstack_controller/datadog_checks/openstack_controller/openstack_controller.py | def collect_hypervisors_metrics(
self,
servers,
custom_tags=None,
use_shortname=False,
collect_hypervisor_metrics=True,
collect_hypervisor_load=False,
):
"""
Submits stats for all hypervisors registered to this control plane
Raises specific exc... | def collect_hypervisors_metrics(
self,
servers,
custom_tags=None,
use_shortname=False,
collect_hypervisor_metrics=True,
collect_hypervisor_load=False,
):
"""
Submits stats for all hypervisors registered to this control plane
Raises specific exc... | [
"Submits",
"stats",
"for",
"all",
"hypervisors",
"registered",
"to",
"this",
"control",
"plane",
"Raises",
"specific",
"exceptions",
"based",
"on",
"response",
"code"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/openstack_controller.py#L209-L244 | [
"def",
"collect_hypervisors_metrics",
"(",
"self",
",",
"servers",
",",
"custom_tags",
"=",
"None",
",",
"use_shortname",
"=",
"False",
",",
"collect_hypervisor_metrics",
"=",
"True",
",",
"collect_hypervisor_load",
"=",
"False",
",",
")",
":",
"# Create a dictionar... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | OpenStackControllerCheck.init_api | Guarantees a valid auth scope for this instance, and returns it
Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly
removed due to token expiry | openstack_controller/datadog_checks/openstack_controller/openstack_controller.py | def init_api(self, instance_config, custom_tags):
"""
Guarantees a valid auth scope for this instance, and returns it
Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly
removed due to token expiry
"""
custom_tags = ... | def init_api(self, instance_config, custom_tags):
"""
Guarantees a valid auth scope for this instance, and returns it
Communicates with the identity server and initializes a new scope when one is absent, or has been forcibly
removed due to token expiry
"""
custom_tags = ... | [
"Guarantees",
"a",
"valid",
"auth",
"scope",
"for",
"this",
"instance",
"and",
"returns",
"it"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/openstack_controller.py#L601-L669 | [
"def",
"init_api",
"(",
"self",
",",
"instance_config",
",",
"custom_tags",
")",
":",
"custom_tags",
"=",
"custom_tags",
"or",
"[",
"]",
"keystone_server_url",
"=",
"instance_config",
".",
"get",
"(",
"\"keystone_server_url\"",
")",
"proxy_config",
"=",
"self",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CadvisorScraper.detect_cadvisor | Tries to connect to the cadvisor endpoint, with given params
:return: url if OK, raises exception if NOK | kubelet/datadog_checks/kubelet/cadvisor.py | def detect_cadvisor(kubelet_url, cadvisor_port):
"""
Tries to connect to the cadvisor endpoint, with given params
:return: url if OK, raises exception if NOK
"""
if cadvisor_port == 0:
raise ValueError("cAdvisor port set to 0 in configuration")
kubelet_hostnam... | def detect_cadvisor(kubelet_url, cadvisor_port):
"""
Tries to connect to the cadvisor endpoint, with given params
:return: url if OK, raises exception if NOK
"""
if cadvisor_port == 0:
raise ValueError("cAdvisor port set to 0 in configuration")
kubelet_hostnam... | [
"Tries",
"to",
"connect",
"to",
"the",
"cadvisor",
"endpoint",
"with",
"given",
"params",
":",
"return",
":",
"url",
"if",
"OK",
"raises",
"exception",
"if",
"NOK"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/cadvisor.py#L48-L64 | [
"def",
"detect_cadvisor",
"(",
"kubelet_url",
",",
"cadvisor_port",
")",
":",
"if",
"cadvisor_port",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"cAdvisor port set to 0 in configuration\"",
")",
"kubelet_hostname",
"=",
"urlparse",
"(",
"kubelet_url",
")",
".",
"h... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CadvisorScraper.process_cadvisor | Scrape and submit metrics from cadvisor
:param: instance: check instance object
:param: cadvisor_url: valid cadvisor url, as returned by detect_cadvisor()
:param: pod_list: fresh podlist object from the kubelet
:param: pod_list_utils: already initialised PodListUtils object | kubelet/datadog_checks/kubelet/cadvisor.py | def process_cadvisor(self, instance, cadvisor_url, pod_list, pod_list_utils):
"""
Scrape and submit metrics from cadvisor
:param: instance: check instance object
:param: cadvisor_url: valid cadvisor url, as returned by detect_cadvisor()
:param: pod_list: fresh podlist object from... | def process_cadvisor(self, instance, cadvisor_url, pod_list, pod_list_utils):
"""
Scrape and submit metrics from cadvisor
:param: instance: check instance object
:param: cadvisor_url: valid cadvisor url, as returned by detect_cadvisor()
:param: pod_list: fresh podlist object from... | [
"Scrape",
"and",
"submit",
"metrics",
"from",
"cadvisor",
":",
"param",
":",
"instance",
":",
"check",
"instance",
"object",
":",
"param",
":",
"cadvisor_url",
":",
"valid",
"cadvisor",
"url",
"as",
"returned",
"by",
"detect_cadvisor",
"()",
":",
"param",
":... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/cadvisor.py#L66-L82 | [
"def",
"process_cadvisor",
"(",
"self",
",",
"instance",
",",
"cadvisor_url",
",",
"pod_list",
",",
"pod_list_utils",
")",
":",
"self",
".",
"max_depth",
"=",
"instance",
".",
"get",
"(",
"'max_depth'",
",",
"DEFAULT_MAX_DEPTH",
")",
"enabled_gauges",
"=",
"in... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | CadvisorScraper._publish_raw_metrics | Recusively parses and submit metrics for a given entity, until
reaching self.max_depth.
Nested metric names are flattened: memory/usage -> memory.usage
:param: metric: parent's metric name (check namespace for root stat objects)
:param: dat: metric dictionnary to parse
:param: ta... | kubelet/datadog_checks/kubelet/cadvisor.py | def _publish_raw_metrics(self, metric, dat, tags, is_pod, depth=0):
"""
Recusively parses and submit metrics for a given entity, until
reaching self.max_depth.
Nested metric names are flattened: memory/usage -> memory.usage
:param: metric: parent's metric name (check namespace fo... | def _publish_raw_metrics(self, metric, dat, tags, is_pod, depth=0):
"""
Recusively parses and submit metrics for a given entity, until
reaching self.max_depth.
Nested metric names are flattened: memory/usage -> memory.usage
:param: metric: parent's metric name (check namespace fo... | [
"Recusively",
"parses",
"and",
"submit",
"metrics",
"for",
"a",
"given",
"entity",
"until",
"reaching",
"self",
".",
"max_depth",
".",
"Nested",
"metric",
"names",
"are",
"flattened",
":",
"memory",
"/",
"usage",
"-",
">",
"memory",
".",
"usage",
":",
"par... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/kubelet/datadog_checks/kubelet/cadvisor.py#L105-L139 | [
"def",
"_publish_raw_metrics",
"(",
"self",
",",
"metric",
",",
"dat",
",",
"tags",
",",
"is_pod",
",",
"depth",
"=",
"0",
")",
":",
"if",
"depth",
">=",
"self",
".",
"max_depth",
":",
"self",
".",
"log",
".",
"warning",
"(",
"'Reached max depth on metri... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | stats_for_version | Get the proper set of stats metrics for the specified ES version | elastic/datadog_checks/elastic/metrics.py | def stats_for_version(version):
"""
Get the proper set of stats metrics for the specified ES version
"""
metrics = dict(STATS_METRICS)
# JVM additional metrics
if version >= [0, 90, 10]:
metrics.update(JVM_METRICS_POST_0_90_10)
else:
metrics.update(JVM_METRICS_PRE_0_90_10)
... | def stats_for_version(version):
"""
Get the proper set of stats metrics for the specified ES version
"""
metrics = dict(STATS_METRICS)
# JVM additional metrics
if version >= [0, 90, 10]:
metrics.update(JVM_METRICS_POST_0_90_10)
else:
metrics.update(JVM_METRICS_PRE_0_90_10)
... | [
"Get",
"the",
"proper",
"set",
"of",
"stats",
"metrics",
"for",
"the",
"specified",
"ES",
"version"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/elastic/datadog_checks/elastic/metrics.py#L452-L509 | [
"def",
"stats_for_version",
"(",
"version",
")",
":",
"metrics",
"=",
"dict",
"(",
"STATS_METRICS",
")",
"# JVM additional metrics",
"if",
"version",
">=",
"[",
"0",
",",
"90",
",",
"10",
"]",
":",
"metrics",
".",
"update",
"(",
"JVM_METRICS_POST_0_90_10",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | pshard_stats_for_version | Get the proper set of pshard metrics for the specified ES version | elastic/datadog_checks/elastic/metrics.py | def pshard_stats_for_version(version):
"""
Get the proper set of pshard metrics for the specified ES version
"""
pshard_stats_metrics = dict(PRIMARY_SHARD_METRICS)
if version >= [1, 0, 0]:
pshard_stats_metrics.update(PRIMARY_SHARD_METRICS_POST_1_0)
return pshard_stats_metrics | def pshard_stats_for_version(version):
"""
Get the proper set of pshard metrics for the specified ES version
"""
pshard_stats_metrics = dict(PRIMARY_SHARD_METRICS)
if version >= [1, 0, 0]:
pshard_stats_metrics.update(PRIMARY_SHARD_METRICS_POST_1_0)
return pshard_stats_metrics | [
"Get",
"the",
"proper",
"set",
"of",
"pshard",
"metrics",
"for",
"the",
"specified",
"ES",
"version"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/elastic/datadog_checks/elastic/metrics.py#L512-L520 | [
"def",
"pshard_stats_for_version",
"(",
"version",
")",
":",
"pshard_stats_metrics",
"=",
"dict",
"(",
"PRIMARY_SHARD_METRICS",
")",
"if",
"version",
">=",
"[",
"1",
",",
"0",
",",
"0",
"]",
":",
"pshard_stats_metrics",
".",
"update",
"(",
"PRIMARY_SHARD_METRICS... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | health_stats_for_version | Get the proper set of health metrics for the specified ES version | elastic/datadog_checks/elastic/metrics.py | def health_stats_for_version(version):
"""
Get the proper set of health metrics for the specified ES version
"""
cluster_health_metrics = dict(CLUSTER_HEALTH_METRICS)
if version >= [2, 4, 0]:
cluster_health_metrics.update(CLUSTER_HEALTH_METRICS_POST_2_4)
return cluster_health_metrics | def health_stats_for_version(version):
"""
Get the proper set of health metrics for the specified ES version
"""
cluster_health_metrics = dict(CLUSTER_HEALTH_METRICS)
if version >= [2, 4, 0]:
cluster_health_metrics.update(CLUSTER_HEALTH_METRICS_POST_2_4)
return cluster_health_metrics | [
"Get",
"the",
"proper",
"set",
"of",
"health",
"metrics",
"for",
"the",
"specified",
"ES",
"version"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/elastic/datadog_checks/elastic/metrics.py#L523-L531 | [
"def",
"health_stats_for_version",
"(",
"version",
")",
":",
"cluster_health_metrics",
"=",
"dict",
"(",
"CLUSTER_HEALTH_METRICS",
")",
"if",
"version",
">=",
"[",
"2",
",",
"4",
",",
"0",
"]",
":",
"cluster_health_metrics",
".",
"update",
"(",
"CLUSTER_HEALTH_M... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | ready | Show all the checks that can be released. | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def ready(ctx, quiet):
"""Show all the checks that can be released."""
user_config = ctx.obj
cached_prs = {}
for target in sorted(get_valid_checks()):
# get the name of the current release tag
cur_version = get_version_string(target)
target_tag = get_release_tag_string(target, c... | def ready(ctx, quiet):
"""Show all the checks that can be released."""
user_config = ctx.obj
cached_prs = {}
for target in sorted(get_valid_checks()):
# get the name of the current release tag
cur_version = get_version_string(target)
target_tag = get_release_tag_string(target, c... | [
"Show",
"all",
"the",
"checks",
"that",
"can",
"be",
"released",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L120-L175 | [
"def",
"ready",
"(",
"ctx",
",",
"quiet",
")",
":",
"user_config",
"=",
"ctx",
".",
"obj",
"cached_prs",
"=",
"{",
"}",
"for",
"target",
"in",
"sorted",
"(",
"get_valid_checks",
"(",
")",
")",
":",
"# get the name of the current release tag",
"cur_version",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | changes | Show all the pending PRs for a given check. | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def changes(ctx, check, dry_run):
"""Show all the pending PRs for a given check."""
if not dry_run and check not in get_valid_checks():
abort('Check `{}` is not an Agent-based Integration'.format(check))
# get the name of the current release tag
cur_version = get_version_string(check)
targe... | def changes(ctx, check, dry_run):
"""Show all the pending PRs for a given check."""
if not dry_run and check not in get_valid_checks():
abort('Check `{}` is not an Agent-based Integration'.format(check))
# get the name of the current release tag
cur_version = get_version_string(check)
targe... | [
"Show",
"all",
"the",
"pending",
"PRs",
"for",
"a",
"given",
"check",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L182-L240 | [
"def",
"changes",
"(",
"ctx",
",",
"check",
",",
"dry_run",
")",
":",
"if",
"not",
"dry_run",
"and",
"check",
"not",
"in",
"get_valid_checks",
"(",
")",
":",
"abort",
"(",
"'Check `{}` is not an Agent-based Integration'",
".",
"format",
"(",
"check",
")",
")... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | tag | Tag the HEAD of the git repo with the current release number for a
specific check. The tag is pushed to origin by default.
You can tag everything at once by setting the check to `all`.
Notice: specifying a different version than the one in __about__.py is
a maintenance task that should be run under ve... | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def tag(check, version, push, dry_run):
"""Tag the HEAD of the git repo with the current release number for a
specific check. The tag is pushed to origin by default.
You can tag everything at once by setting the check to `all`.
Notice: specifying a different version than the one in __about__.py is
... | def tag(check, version, push, dry_run):
"""Tag the HEAD of the git repo with the current release number for a
specific check. The tag is pushed to origin by default.
You can tag everything at once by setting the check to `all`.
Notice: specifying a different version than the one in __about__.py is
... | [
"Tag",
"the",
"HEAD",
"of",
"the",
"git",
"repo",
"with",
"the",
"current",
"release",
"number",
"for",
"a",
"specific",
"check",
".",
"The",
"tag",
"is",
"pushed",
"to",
"origin",
"by",
"default",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L487-L543 | [
"def",
"tag",
"(",
"check",
",",
"version",
",",
"push",
",",
"dry_run",
")",
":",
"tagging_all",
"=",
"check",
"==",
"'all'",
"valid_checks",
"=",
"get_valid_checks",
"(",
")",
"if",
"not",
"tagging_all",
"and",
"check",
"not",
"in",
"valid_checks",
":",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | make | Perform a set of operations needed to release a single check:
\b
* update the version in __about__.py
* update the changelog
* update the requirements-agent-release.txt file
* update in-toto metadata
* commit the above changes
You can release everything at once by setting the che... | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def make(ctx, check, version, initial_release, skip_sign, sign_only):
"""Perform a set of operations needed to release a single check:
\b
* update the version in __about__.py
* update the changelog
* update the requirements-agent-release.txt file
* update in-toto metadata
* commit... | def make(ctx, check, version, initial_release, skip_sign, sign_only):
"""Perform a set of operations needed to release a single check:
\b
* update the version in __about__.py
* update the changelog
* update the requirements-agent-release.txt file
* update in-toto metadata
* commit... | [
"Perform",
"a",
"set",
"of",
"operations",
"needed",
"to",
"release",
"a",
"single",
"check",
":"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L553-L690 | [
"def",
"make",
"(",
"ctx",
",",
"check",
",",
"version",
",",
"initial_release",
",",
"skip_sign",
",",
"sign_only",
")",
":",
"# Import lazily since in-toto runs a subprocess to check for gpg2 on load",
"from",
".",
".",
"signing",
"import",
"update_link_metadata",
","... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | changelog | Perform the operations needed to update the changelog.
This method is supposed to be used by other tasks and not directly. | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def changelog(ctx, check, version, old_version, initial, quiet, dry_run):
"""Perform the operations needed to update the changelog.
This method is supposed to be used by other tasks and not directly.
"""
if check not in get_valid_checks():
abort('Check `{}` is not an Agent-based Integration'.fo... | def changelog(ctx, check, version, old_version, initial, quiet, dry_run):
"""Perform the operations needed to update the changelog.
This method is supposed to be used by other tasks and not directly.
"""
if check not in get_valid_checks():
abort('Check `{}` is not an Agent-based Integration'.fo... | [
"Perform",
"the",
"operations",
"needed",
"to",
"update",
"the",
"changelog",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L701-L802 | [
"def",
"changelog",
"(",
"ctx",
",",
"check",
",",
"version",
",",
"old_version",
",",
"initial",
",",
"quiet",
",",
"dry_run",
")",
":",
"if",
"check",
"not",
"in",
"get_valid_checks",
"(",
")",
":",
"abort",
"(",
"'Check `{}` is not an Agent-based Integratio... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | build | Build a wheel for a check as it is on the repo HEAD | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def build(check, sdist):
"""Build a wheel for a check as it is on the repo HEAD"""
if check in get_valid_checks():
check_dir = os.path.join(get_root(), check)
else:
check_dir = resolve_path(check)
if not dir_exists(check_dir):
abort('`{}` is not an Agent-based Integration... | def build(check, sdist):
"""Build a wheel for a check as it is on the repo HEAD"""
if check in get_valid_checks():
check_dir = os.path.join(get_root(), check)
else:
check_dir = resolve_path(check)
if not dir_exists(check_dir):
abort('`{}` is not an Agent-based Integration... | [
"Build",
"a",
"wheel",
"for",
"a",
"check",
"as",
"it",
"is",
"on",
"the",
"repo",
"HEAD"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L808-L829 | [
"def",
"build",
"(",
"check",
",",
"sdist",
")",
":",
"if",
"check",
"in",
"get_valid_checks",
"(",
")",
":",
"check_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_root",
"(",
")",
",",
"check",
")",
"else",
":",
"check_dir",
"=",
"resolve_path... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | upload | Release a specific check to PyPI as it is on the repo HEAD. | datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py | def upload(ctx, check, sdist, dry_run):
"""Release a specific check to PyPI as it is on the repo HEAD."""
if check in get_valid_checks():
check_dir = os.path.join(get_root(), check)
else:
check_dir = resolve_path(check)
if not dir_exists(check_dir):
abort('`{}` is not an ... | def upload(ctx, check, sdist, dry_run):
"""Release a specific check to PyPI as it is on the repo HEAD."""
if check in get_valid_checks():
check_dir = os.path.join(get_root(), check)
else:
check_dir = resolve_path(check)
if not dir_exists(check_dir):
abort('`{}` is not an ... | [
"Release",
"a",
"specific",
"check",
"to",
"PyPI",
"as",
"it",
"is",
"on",
"the",
"repo",
"HEAD",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/release.py#L837-L868 | [
"def",
"upload",
"(",
"ctx",
",",
"check",
",",
"sdist",
",",
"dry_run",
")",
":",
"if",
"check",
"in",
"get_valid_checks",
"(",
")",
":",
"check_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"get_root",
"(",
")",
",",
"check",
")",
"else",
":",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.metrics | Return the metrics received under the given name | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def metrics(self, name):
"""
Return the metrics received under the given name
"""
return [
MetricStub(
ensure_unicode(stub.name),
stub.type,
stub.value,
normalize_tags(stub.tags),
ensure_unicode(s... | def metrics(self, name):
"""
Return the metrics received under the given name
"""
return [
MetricStub(
ensure_unicode(stub.name),
stub.type,
stub.value,
normalize_tags(stub.tags),
ensure_unicode(s... | [
"Return",
"the",
"metrics",
"received",
"under",
"the",
"given",
"name"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L56-L69 | [
"def",
"metrics",
"(",
"self",
",",
"name",
")",
":",
"return",
"[",
"MetricStub",
"(",
"ensure_unicode",
"(",
"stub",
".",
"name",
")",
",",
"stub",
".",
"type",
",",
"stub",
".",
"value",
",",
"normalize_tags",
"(",
"stub",
".",
"tags",
")",
",",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.service_checks | Return the service checks received under the given name | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def service_checks(self, name):
"""
Return the service checks received under the given name
"""
return [
ServiceCheckStub(
ensure_unicode(stub.check_id),
ensure_unicode(stub.name),
stub.status,
normalize_tags(stu... | def service_checks(self, name):
"""
Return the service checks received under the given name
"""
return [
ServiceCheckStub(
ensure_unicode(stub.check_id),
ensure_unicode(stub.name),
stub.status,
normalize_tags(stu... | [
"Return",
"the",
"service",
"checks",
"received",
"under",
"the",
"given",
"name"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L71-L85 | [
"def",
"service_checks",
"(",
"self",
",",
"name",
")",
":",
"return",
"[",
"ServiceCheckStub",
"(",
"ensure_unicode",
"(",
"stub",
".",
"check_id",
")",
",",
"ensure_unicode",
"(",
"stub",
".",
"name",
")",
",",
"stub",
".",
"status",
",",
"normalize_tags... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.events | Return all events | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def events(self):
"""
Return all events
"""
all_events = [{ensure_unicode(key): value for key, value in iteritems(ev)} for ev in self._events]
for ev in all_events:
to_decode = []
for key, value in iteritems(ev):
if isinstance(value, binar... | def events(self):
"""
Return all events
"""
all_events = [{ensure_unicode(key): value for key, value in iteritems(ev)} for ev in self._events]
for ev in all_events:
to_decode = []
for key, value in iteritems(ev):
if isinstance(value, binar... | [
"Return",
"all",
"events"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L88-L105 | [
"def",
"events",
"(",
"self",
")",
":",
"all_events",
"=",
"[",
"{",
"ensure_unicode",
"(",
"key",
")",
":",
"value",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"ev",
")",
"}",
"for",
"ev",
"in",
"self",
".",
"_events",
"]",
"for",
"ev",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.assert_metric_has_tag | Assert a metric is tagged with tag | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def assert_metric_has_tag(self, metric_name, tag, count=None, at_least=1):
"""
Assert a metric is tagged with tag
"""
self._asserted.add(metric_name)
candidates = []
for metric in self.metrics(metric_name):
if tag in metric.tags:
candidates.ap... | def assert_metric_has_tag(self, metric_name, tag, count=None, at_least=1):
"""
Assert a metric is tagged with tag
"""
self._asserted.add(metric_name)
candidates = []
for metric in self.metrics(metric_name):
if tag in metric.tags:
candidates.ap... | [
"Assert",
"a",
"metric",
"is",
"tagged",
"with",
"tag"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L107-L121 | [
"def",
"assert_metric_has_tag",
"(",
"self",
",",
"metric_name",
",",
"tag",
",",
"count",
"=",
"None",
",",
"at_least",
"=",
"1",
")",
":",
"self",
".",
"_asserted",
".",
"add",
"(",
"metric_name",
")",
"candidates",
"=",
"[",
"]",
"for",
"metric",
"i... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.assert_metric | Assert a metric was processed by this stub | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def assert_metric(self, name, value=None, tags=None, count=None, at_least=1, hostname=None, metric_type=None):
"""
Assert a metric was processed by this stub
"""
self._asserted.add(name)
tags = normalize_tags(tags, sort=True)
candidates = []
for metric in self.me... | def assert_metric(self, name, value=None, tags=None, count=None, at_least=1, hostname=None, metric_type=None):
"""
Assert a metric was processed by this stub
"""
self._asserted.add(name)
tags = normalize_tags(tags, sort=True)
candidates = []
for metric in self.me... | [
"Assert",
"a",
"metric",
"was",
"processed",
"by",
"this",
"stub"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L146-L179 | [
"def",
"assert_metric",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"count",
"=",
"None",
",",
"at_least",
"=",
"1",
",",
"hostname",
"=",
"None",
",",
"metric_type",
"=",
"None",
")",
":",
"self",
".",
"_ass... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.assert_service_check | Assert a service check was processed by this stub | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def assert_service_check(self, name, status=None, tags=None, count=None, at_least=1, hostname=None, message=None):
"""
Assert a service check was processed by this stub
"""
tags = normalize_tags(tags, sort=True)
candidates = []
for sc in self.service_checks(name):
... | def assert_service_check(self, name, status=None, tags=None, count=None, at_least=1, hostname=None, message=None):
"""
Assert a service check was processed by this stub
"""
tags = normalize_tags(tags, sort=True)
candidates = []
for sc in self.service_checks(name):
... | [
"Assert",
"a",
"service",
"check",
"was",
"processed",
"by",
"this",
"stub"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L181-L207 | [
"def",
"assert_service_check",
"(",
"self",
",",
"name",
",",
"status",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"count",
"=",
"None",
",",
"at_least",
"=",
"1",
",",
"hostname",
"=",
"None",
",",
"message",
"=",
"None",
")",
":",
"tags",
"=",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | AggregatorStub.metrics_asserted_pct | Return the metrics assertion coverage | datadog_checks_base/datadog_checks/base/stubs/aggregator.py | def metrics_asserted_pct(self):
"""
Return the metrics assertion coverage
"""
num_metrics = len(self._metrics)
num_asserted = len(self._asserted)
if num_metrics == 0:
if num_asserted == 0:
return 100
else:
return 0
... | def metrics_asserted_pct(self):
"""
Return the metrics assertion coverage
"""
num_metrics = len(self._metrics)
num_asserted = len(self._asserted)
if num_metrics == 0:
if num_asserted == 0:
return 100
else:
return 0
... | [
"Return",
"the",
"metrics",
"assertion",
"coverage"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/stubs/aggregator.py#L248-L261 | [
"def",
"metrics_asserted_pct",
"(",
"self",
")",
":",
"num_metrics",
"=",
"len",
"(",
"self",
".",
"_metrics",
")",
"num_asserted",
"=",
"len",
"(",
"self",
".",
"_asserted",
")",
"if",
"num_metrics",
"==",
"0",
":",
"if",
"num_asserted",
"==",
"0",
":",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Memcache._process_response | Examine the response and raise an error is something is off | mcache/datadog_checks/mcache/mcache.py | def _process_response(cls, response):
"""
Examine the response and raise an error is something is off
"""
if len(response) != 1:
raise BadResponseError("Malformed response: {}".format(response))
stats = list(itervalues(response))[0]
if not len(stats):
... | def _process_response(cls, response):
"""
Examine the response and raise an error is something is off
"""
if len(response) != 1:
raise BadResponseError("Malformed response: {}".format(response))
stats = list(itervalues(response))[0]
if not len(stats):
... | [
"Examine",
"the",
"response",
"and",
"raise",
"an",
"error",
"is",
"something",
"is",
"off"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mcache/datadog_checks/mcache/mcache.py#L112-L123 | [
"def",
"_process_response",
"(",
"cls",
",",
"response",
")",
":",
"if",
"len",
"(",
"response",
")",
"!=",
"1",
":",
"raise",
"BadResponseError",
"(",
"\"Malformed response: {}\"",
".",
"format",
"(",
"response",
")",
")",
"stats",
"=",
"list",
"(",
"iter... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Memcache.get_items_stats | Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value | mcache/datadog_checks/mcache/mcache.py | def get_items_stats(key, value):
"""
Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value
"""
itemized_key = key.split(':')
slab_id = i... | def get_items_stats(key, value):
"""
Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value
"""
itemized_key = key.split(':')
slab_id = i... | [
"Optional",
"metric",
"handler",
"for",
"items",
"stats"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mcache/datadog_checks/mcache/mcache.py#L206-L221 | [
"def",
"get_items_stats",
"(",
"key",
",",
"value",
")",
":",
"itemized_key",
"=",
"key",
".",
"split",
"(",
"':'",
")",
"slab_id",
"=",
"itemized_key",
"[",
"1",
"]",
"metric",
"=",
"itemized_key",
"[",
"2",
"]",
"tags",
"=",
"[",
"\"slab:{}\"",
".",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Memcache.get_slabs_stats | Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value | mcache/datadog_checks/mcache/mcache.py | def get_slabs_stats(key, value):
"""
Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value
"""
slabbed_key = key.split(':')
tags = []
... | def get_slabs_stats(key, value):
"""
Optional metric handler for 'items' stats
key: "items:<slab_id>:<metric_name>" format
value: return untouched
Like all optional metric handlers returns metric, tags, value
"""
slabbed_key = key.split(':')
tags = []
... | [
"Optional",
"metric",
"handler",
"for",
"items",
"stats"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/mcache/datadog_checks/mcache/mcache.py#L224-L242 | [
"def",
"get_slabs_stats",
"(",
"key",
",",
"value",
")",
":",
"slabbed_key",
"=",
"key",
".",
"split",
"(",
"':'",
")",
"tags",
"=",
"[",
"]",
"if",
"len",
"(",
"slabbed_key",
")",
"==",
"2",
":",
"slab_id",
"=",
"slabbed_key",
"[",
"0",
"]",
"metr... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | RabbitMQ.get_stats | instance: the check instance
base_url: the url of the rabbitmq management api (e.g. http://localhost:15672/api)
object_type: either QUEUE_TYPE or NODE_TYPE or EXCHANGE_TYPE
max_detailed: the limit of objects to collect for this type
filters: explicit or regexes filters of specified queue... | rabbitmq/datadog_checks/rabbitmq/rabbitmq.py | def get_stats(
self,
instance,
base_url,
object_type,
max_detailed,
filters,
limit_vhosts,
custom_tags,
auth=None,
ssl_verify=True,
):
"""
instance: the check instance
base_url: the url of the rabbitmq management... | def get_stats(
self,
instance,
base_url,
object_type,
max_detailed,
filters,
limit_vhosts,
custom_tags,
auth=None,
ssl_verify=True,
):
"""
instance: the check instance
base_url: the url of the rabbitmq management... | [
"instance",
":",
"the",
"check",
"instance",
"base_url",
":",
"the",
"url",
"of",
"the",
"rabbitmq",
"management",
"api",
"(",
"e",
".",
"g",
".",
"http",
":",
"//",
"localhost",
":",
"15672",
"/",
"api",
")",
"object_type",
":",
"either",
"QUEUE_TYPE",
... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/rabbitmq/datadog_checks/rabbitmq/rabbitmq.py#L375-L549 | [
"def",
"get_stats",
"(",
"self",
",",
"instance",
",",
"base_url",
",",
"object_type",
",",
"max_detailed",
",",
"filters",
",",
"limit_vhosts",
",",
"custom_tags",
",",
"auth",
"=",
"None",
",",
"ssl_verify",
"=",
"True",
",",
")",
":",
"instance_proxy",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | RabbitMQ.get_connections_stat | Collect metrics on currently open connection per vhost. | rabbitmq/datadog_checks/rabbitmq/rabbitmq.py | def get_connections_stat(
self, instance, base_url, object_type, vhosts, limit_vhosts, custom_tags, auth=None, ssl_verify=True
):
"""
Collect metrics on currently open connection per vhost.
"""
instance_proxy = self.get_instance_proxy(instance, base_url)
grab_all_dat... | def get_connections_stat(
self, instance, base_url, object_type, vhosts, limit_vhosts, custom_tags, auth=None, ssl_verify=True
):
"""
Collect metrics on currently open connection per vhost.
"""
instance_proxy = self.get_instance_proxy(instance, base_url)
grab_all_dat... | [
"Collect",
"metrics",
"on",
"currently",
"open",
"connection",
"per",
"vhost",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/rabbitmq/datadog_checks/rabbitmq/rabbitmq.py#L591-L636 | [
"def",
"get_connections_stat",
"(",
"self",
",",
"instance",
",",
"base_url",
",",
"object_type",
",",
"vhosts",
",",
"limit_vhosts",
",",
"custom_tags",
",",
"auth",
"=",
"None",
",",
"ssl_verify",
"=",
"True",
")",
":",
"instance_proxy",
"=",
"self",
".",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | RabbitMQ._check_aliveness | Check the aliveness API against all or a subset of vhosts. The API
will return {"status": "ok"} and a 200 response code in the case
that the check passes. | rabbitmq/datadog_checks/rabbitmq/rabbitmq.py | def _check_aliveness(self, instance, base_url, vhosts, custom_tags, auth=None, ssl_verify=True):
"""
Check the aliveness API against all or a subset of vhosts. The API
will return {"status": "ok"} and a 200 response code in the case
that the check passes.
"""
for vhost i... | def _check_aliveness(self, instance, base_url, vhosts, custom_tags, auth=None, ssl_verify=True):
"""
Check the aliveness API against all or a subset of vhosts. The API
will return {"status": "ok"} and a 200 response code in the case
that the check passes.
"""
for vhost i... | [
"Check",
"the",
"aliveness",
"API",
"against",
"all",
"or",
"a",
"subset",
"of",
"vhosts",
".",
"The",
"API",
"will",
"return",
"{",
"status",
":",
"ok",
"}",
"and",
"a",
"200",
"response",
"code",
"in",
"the",
"case",
"that",
"the",
"check",
"passes",... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/rabbitmq/datadog_checks/rabbitmq/rabbitmq.py#L676-L699 | [
"def",
"_check_aliveness",
"(",
"self",
",",
"instance",
",",
"base_url",
",",
"vhosts",
",",
"custom_tags",
",",
"auth",
"=",
"None",
",",
"ssl_verify",
"=",
"True",
")",
":",
"for",
"vhost",
"in",
"vhosts",
":",
"tags",
"=",
"[",
"'vhost:{}'",
".",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _grid_in_property | Create a GridIn property. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def _grid_in_property(field_name, docstring, read_only=False,
closed_only=False):
"""Create a GridIn property."""
def getter(self):
if closed_only and not self._closed:
raise AttributeError("can only get %r on a closed file" %
field_name... | def _grid_in_property(field_name, docstring, read_only=False,
closed_only=False):
"""Create a GridIn property."""
def getter(self):
if closed_only and not self._closed:
raise AttributeError("can only get %r on a closed file" %
field_name... | [
"Create",
"a",
"GridIn",
"property",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L56-L83 | [
"def",
"_grid_in_property",
"(",
"field_name",
",",
"docstring",
",",
"read_only",
"=",
"False",
",",
"closed_only",
"=",
"False",
")",
":",
"def",
"getter",
"(",
"self",
")",
":",
"if",
"closed_only",
"and",
"not",
"self",
".",
"_closed",
":",
"raise",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | _grid_out_property | Create a GridOut property. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def _grid_out_property(field_name, docstring):
"""Create a GridOut property."""
def getter(self):
self._ensure_file()
# Protect against PHP-237
if field_name == 'length':
return self._file.get(field_name, 0)
return self._file.get(field_name, None)
docstring += "... | def _grid_out_property(field_name, docstring):
"""Create a GridOut property."""
def getter(self):
self._ensure_file()
# Protect against PHP-237
if field_name == 'length':
return self._file.get(field_name, 0)
return self._file.get(field_name, None)
docstring += "... | [
"Create",
"a",
"GridOut",
"property",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L86-L97 | [
"def",
"_grid_out_property",
"(",
"field_name",
",",
"docstring",
")",
":",
"def",
"getter",
"(",
"self",
")",
":",
"self",
".",
"_ensure_file",
"(",
")",
"# Protect against PHP-237",
"if",
"field_name",
"==",
"'length'",
":",
"return",
"self",
".",
"_file",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridIn.__flush_data | Flush `data` to a chunk. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def __flush_data(self, data):
"""Flush `data` to a chunk.
"""
# Ensure the index, even if there's nothing to write, so
# the filemd5 command always succeeds.
self.__ensure_indexes()
self._file['md5'].update(data)
if not data:
return
assert(len... | def __flush_data(self, data):
"""Flush `data` to a chunk.
"""
# Ensure the index, even if there's nothing to write, so
# the filemd5 command always succeeds.
self.__ensure_indexes()
self._file['md5'].update(data)
if not data:
return
assert(len... | [
"Flush",
"data",
"to",
"a",
"chunk",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L241-L262 | [
"def",
"__flush_data",
"(",
"self",
",",
"data",
")",
":",
"# Ensure the index, even if there's nothing to write, so",
"# the filemd5 command always succeeds.",
"self",
".",
"__ensure_indexes",
"(",
")",
"self",
".",
"_file",
"[",
"'md5'",
"]",
".",
"update",
"(",
"da... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridIn.__flush_buffer | Flush the buffer contents out to a chunk. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def __flush_buffer(self):
"""Flush the buffer contents out to a chunk.
"""
self.__flush_data(self._buffer.getvalue())
self._buffer.close()
self._buffer = StringIO() | def __flush_buffer(self):
"""Flush the buffer contents out to a chunk.
"""
self.__flush_data(self._buffer.getvalue())
self._buffer.close()
self._buffer = StringIO() | [
"Flush",
"the",
"buffer",
"contents",
"out",
"to",
"a",
"chunk",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L264-L269 | [
"def",
"__flush_buffer",
"(",
"self",
")",
":",
"self",
".",
"__flush_data",
"(",
"self",
".",
"_buffer",
".",
"getvalue",
"(",
")",
")",
"self",
".",
"_buffer",
".",
"close",
"(",
")",
"self",
".",
"_buffer",
"=",
"StringIO",
"(",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridIn.__flush | Flush the file to the database. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def __flush(self):
"""Flush the file to the database.
"""
try:
self.__flush_buffer()
self._file['md5'] = self._file["md5"].hexdigest()
self._file["length"] = self._position
self._file["uploadDate"] = datetime.datetime.utcnow()
return ... | def __flush(self):
"""Flush the file to the database.
"""
try:
self.__flush_buffer()
self._file['md5'] = self._file["md5"].hexdigest()
self._file["length"] = self._position
self._file["uploadDate"] = datetime.datetime.utcnow()
return ... | [
"Flush",
"the",
"file",
"to",
"the",
"database",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L271-L283 | [
"def",
"__flush",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"__flush_buffer",
"(",
")",
"self",
".",
"_file",
"[",
"'md5'",
"]",
"=",
"self",
".",
"_file",
"[",
"\"md5\"",
"]",
".",
"hexdigest",
"(",
")",
"self",
".",
"_file",
"[",
"\"length\... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridIn.close | Flush the file and close it.
A closed file cannot be written any more. Calling
:meth:`close` more than once is allowed. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def close(self):
"""Flush the file and close it.
A closed file cannot be written any more. Calling
:meth:`close` more than once is allowed.
"""
if not self._closed:
self.__flush()
object.__setattr__(self, "_closed", True) | def close(self):
"""Flush the file and close it.
A closed file cannot be written any more. Calling
:meth:`close` more than once is allowed.
"""
if not self._closed:
self.__flush()
object.__setattr__(self, "_closed", True) | [
"Flush",
"the",
"file",
"and",
"close",
"it",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L289-L297 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"__flush",
"(",
")",
"object",
".",
"__setattr__",
"(",
"self",
",",
"\"_closed\"",
",",
"True",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridIn.write | Write data to the file. There is no return value.
`data` can be either a string of bytes or a file-like object
(implementing :meth:`read`). If the file has an
:attr:`encoding` attribute, `data` can also be a
:class:`unicode` (:class:`str` in python 3) instance, which
will be enc... | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def write(self, data):
"""Write data to the file. There is no return value.
`data` can be either a string of bytes or a file-like object
(implementing :meth:`read`). If the file has an
:attr:`encoding` attribute, `data` can also be a
:class:`unicode` (:class:`str` in python 3) i... | def write(self, data):
"""Write data to the file. There is no return value.
`data` can be either a string of bytes or a file-like object
(implementing :meth:`read`). If the file has an
:attr:`encoding` attribute, `data` can also be a
:class:`unicode` (:class:`str` in python 3) i... | [
"Write",
"data",
"to",
"the",
"file",
".",
"There",
"is",
"no",
"return",
"value",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L299-L356 | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"ValueError",
"(",
"\"cannot write to a closed file\"",
")",
"try",
":",
"# file-like",
"read",
"=",
"data",
".",
"read",
"except",
"AttributeError",
":",
"# stri... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridOut.readchunk | Reads a chunk at a time. If the current position is within a
chunk the remainder of the chunk is returned. | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def readchunk(self):
"""Reads a chunk at a time. If the current position is within a
chunk the remainder of the chunk is returned.
"""
received = len(self.__buffer)
chunk_data = EMPTY
chunk_size = int(self.chunk_size)
if received > 0:
chunk_data = sel... | def readchunk(self):
"""Reads a chunk at a time. If the current position is within a
chunk the remainder of the chunk is returned.
"""
received = len(self.__buffer)
chunk_data = EMPTY
chunk_size = int(self.chunk_size)
if received > 0:
chunk_data = sel... | [
"Reads",
"a",
"chunk",
"at",
"a",
"time",
".",
"If",
"the",
"current",
"position",
"is",
"within",
"a",
"chunk",
"the",
"remainder",
"of",
"the",
"chunk",
"is",
"returned",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L444-L468 | [
"def",
"readchunk",
"(",
"self",
")",
":",
"received",
"=",
"len",
"(",
"self",
".",
"__buffer",
")",
"chunk_data",
"=",
"EMPTY",
"chunk_size",
"=",
"int",
"(",
"self",
".",
"chunk_size",
")",
"if",
"received",
">",
"0",
":",
"chunk_data",
"=",
"self",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridOut.read | Read at most `size` bytes from the file (less if there
isn't enough data).
The bytes are returned as an instance of :class:`str` (:class:`bytes`
in python 3). If `size` is negative or omitted all data is read.
:Parameters:
- `size` (optional): the number of bytes to read | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def read(self, size=-1):
"""Read at most `size` bytes from the file (less if there
isn't enough data).
The bytes are returned as an instance of :class:`str` (:class:`bytes`
in python 3). If `size` is negative or omitted all data is read.
:Parameters:
- `size` (optiona... | def read(self, size=-1):
"""Read at most `size` bytes from the file (less if there
isn't enough data).
The bytes are returned as an instance of :class:`str` (:class:`bytes`
in python 3). If `size` is negative or omitted all data is read.
:Parameters:
- `size` (optiona... | [
"Read",
"at",
"most",
"size",
"bytes",
"from",
"the",
"file",
"(",
"less",
"if",
"there",
"isn",
"t",
"enough",
"data",
")",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L470-L512 | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"self",
".",
"_ensure_file",
"(",
")",
"if",
"size",
"==",
"0",
":",
"return",
"EMPTY",
"remainder",
"=",
"int",
"(",
"self",
".",
"length",
")",
"-",
"self",
".",
"__position",
"i... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | GridOut.seek | Set the current position of this file.
:Parameters:
- `pos`: the position (or offset if using relative
positioning) to seek to
- `whence` (optional): where to seek
from. :attr:`os.SEEK_SET` (``0``) for absolute file
positioning, :attr:`os.SEEK_CUR` (``1``) to ... | tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py | def seek(self, pos, whence=_SEEK_SET):
"""Set the current position of this file.
:Parameters:
- `pos`: the position (or offset if using relative
positioning) to seek to
- `whence` (optional): where to seek
from. :attr:`os.SEEK_SET` (``0``) for absolute file
... | def seek(self, pos, whence=_SEEK_SET):
"""Set the current position of this file.
:Parameters:
- `pos`: the position (or offset if using relative
positioning) to seek to
- `whence` (optional): where to seek
from. :attr:`os.SEEK_SET` (``0``) for absolute file
... | [
"Set",
"the",
"current",
"position",
"of",
"this",
"file",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/gridfs/grid_file.py#L553-L578 | [
"def",
"seek",
"(",
"self",
",",
"pos",
",",
"whence",
"=",
"_SEEK_SET",
")",
":",
"if",
"whence",
"==",
"_SEEK_SET",
":",
"new_pos",
"=",
"pos",
"elif",
"whence",
"==",
"_SEEK_CUR",
":",
"new_pos",
"=",
"self",
".",
"__position",
"+",
"pos",
"elif",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.provider | Validate and set a WMI provider. Default to `ProviderArchitecture.DEFAULT` | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def provider(self, value):
"""
Validate and set a WMI provider. Default to `ProviderArchitecture.DEFAULT`
"""
result = None
# `None` defaults to `ProviderArchitecture.DEFAULT`
defaulted_value = value or ProviderArchitecture.DEFAULT
try:
parsed_value ... | def provider(self, value):
"""
Validate and set a WMI provider. Default to `ProviderArchitecture.DEFAULT`
"""
result = None
# `None` defaults to `ProviderArchitecture.DEFAULT`
defaulted_value = value or ProviderArchitecture.DEFAULT
try:
parsed_value ... | [
"Validate",
"and",
"set",
"a",
"WMI",
"provider",
".",
"Default",
"to",
"ProviderArchitecture",
".",
"DEFAULT"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L155-L175 | [
"def",
"provider",
"(",
"self",
",",
"value",
")",
":",
"result",
"=",
"None",
"# `None` defaults to `ProviderArchitecture.DEFAULT`",
"defaulted_value",
"=",
"value",
"or",
"ProviderArchitecture",
".",
"DEFAULT",
"try",
":",
"parsed_value",
"=",
"int",
"(",
"default... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.connection | A property to retrieve the sampler connection information. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def connection(self):
"""
A property to retrieve the sampler connection information.
"""
return {'host': self.host, 'namespace': self.namespace, 'username': self.username, 'password': self.password} | def connection(self):
"""
A property to retrieve the sampler connection information.
"""
return {'host': self.host, 'namespace': self.namespace, 'username': self.username, 'password': self.password} | [
"A",
"property",
"to",
"retrieve",
"the",
"sampler",
"connection",
"information",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L178-L182 | [
"def",
"connection",
"(",
"self",
")",
":",
"return",
"{",
"'host'",
":",
"self",
".",
"host",
",",
"'namespace'",
":",
"self",
".",
"namespace",
",",
"'username'",
":",
"self",
".",
"username",
",",
"'password'",
":",
"self",
".",
"password",
"}"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.connection_key | Return an index key used to cache the sampler connection. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def connection_key(self):
"""
Return an index key used to cache the sampler connection.
"""
return "{host}:{namespace}:{username}".format(host=self.host, namespace=self.namespace, username=self.username) | def connection_key(self):
"""
Return an index key used to cache the sampler connection.
"""
return "{host}:{namespace}:{username}".format(host=self.host, namespace=self.namespace, username=self.username) | [
"Return",
"an",
"index",
"key",
"used",
"to",
"cache",
"the",
"sampler",
"connection",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L185-L189 | [
"def",
"connection_key",
"(",
"self",
")",
":",
"return",
"\"{host}:{namespace}:{username}\"",
".",
"format",
"(",
"host",
"=",
"self",
".",
"host",
",",
"namespace",
"=",
"self",
".",
"namespace",
",",
"username",
"=",
"self",
".",
"username",
")"
] | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.formatted_filters | Cache and return filters as a comprehensive WQL clause. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def formatted_filters(self):
"""
Cache and return filters as a comprehensive WQL clause.
"""
if not self._formatted_filters:
filters = deepcopy(self.filters)
self._formatted_filters = self._format_filter(filters, self._and_props)
return self._formatted_fil... | def formatted_filters(self):
"""
Cache and return filters as a comprehensive WQL clause.
"""
if not self._formatted_filters:
filters = deepcopy(self.filters)
self._formatted_filters = self._format_filter(filters, self._and_props)
return self._formatted_fil... | [
"Cache",
"and",
"return",
"filters",
"as",
"a",
"comprehensive",
"WQL",
"clause",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L192-L199 | [
"def",
"formatted_filters",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_formatted_filters",
":",
"filters",
"=",
"deepcopy",
"(",
"self",
".",
"filters",
")",
"self",
".",
"_formatted_filters",
"=",
"self",
".",
"_format_filter",
"(",
"filters",
",",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.sample | Compute new samples. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def sample(self):
"""
Compute new samples.
"""
self._sampling = True
try:
if self.is_raw_perf_class and not self._previous_sample:
self._current_sample = self._query()
self._previous_sample = self._current_sample
self._current... | def sample(self):
"""
Compute new samples.
"""
self._sampling = True
try:
if self.is_raw_perf_class and not self._previous_sample:
self._current_sample = self._query()
self._previous_sample = self._current_sample
self._current... | [
"Compute",
"new",
"samples",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L206-L222 | [
"def",
"sample",
"(",
"self",
")",
":",
"self",
".",
"_sampling",
"=",
"True",
"try",
":",
"if",
"self",
".",
"is_raw_perf_class",
"and",
"not",
"self",
".",
"_previous_sample",
":",
"self",
".",
"_current_sample",
"=",
"self",
".",
"_query",
"(",
")",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler._get_property_calculator | Return the calculator for the given `counter_type`.
Fallback with `get_raw`. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def _get_property_calculator(self, counter_type):
"""
Return the calculator for the given `counter_type`.
Fallback with `get_raw`.
"""
calculator = get_raw
try:
calculator = get_calculator(counter_type)
except UndefinedCalculator:
self.logg... | def _get_property_calculator(self, counter_type):
"""
Return the calculator for the given `counter_type`.
Fallback with `get_raw`.
"""
calculator = get_raw
try:
calculator = get_calculator(counter_type)
except UndefinedCalculator:
self.logg... | [
"Return",
"the",
"calculator",
"for",
"the",
"given",
"counter_type",
".",
"Fallback",
"with",
"get_raw",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L276-L290 | [
"def",
"_get_property_calculator",
"(",
"self",
",",
"counter_type",
")",
":",
"calculator",
"=",
"get_raw",
"try",
":",
"calculator",
"=",
"get_calculator",
"(",
"counter_type",
")",
"except",
"UndefinedCalculator",
":",
"self",
".",
"logger",
".",
"warning",
"... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler._format_property_values | Format WMI Object's RAW data based on the previous sample.
Do not override the original WMI Object ! | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def _format_property_values(self, previous, current):
"""
Format WMI Object's RAW data based on the previous sample.
Do not override the original WMI Object !
"""
formatted_wmi_object = CaseInsensitiveDict()
for property_name, property_raw_value in iteritems(current):
... | def _format_property_values(self, previous, current):
"""
Format WMI Object's RAW data based on the previous sample.
Do not override the original WMI Object !
"""
formatted_wmi_object = CaseInsensitiveDict()
for property_name, property_raw_value in iteritems(current):
... | [
"Format",
"WMI",
"Object",
"s",
"RAW",
"data",
"based",
"on",
"the",
"previous",
"sample",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L292-L310 | [
"def",
"_format_property_values",
"(",
"self",
",",
"previous",
",",
"current",
")",
":",
"formatted_wmi_object",
"=",
"CaseInsensitiveDict",
"(",
")",
"for",
"property_name",
",",
"property_raw_value",
"in",
"iteritems",
"(",
"current",
")",
":",
"counter_type",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler.get_connection | Create a new WMI connection | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def get_connection(self):
"""
Create a new WMI connection
"""
self.logger.debug(
u"Connecting to WMI server "
u"(host={host}, namespace={namespace}, provider={provider}, username={username}).".format(
host=self.host, namespace=self.namespace, provi... | def get_connection(self):
"""
Create a new WMI connection
"""
self.logger.debug(
u"Connecting to WMI server "
u"(host={host}, namespace={namespace}, provider={provider}, username={username}).".format(
host=self.host, namespace=self.namespace, provi... | [
"Create",
"a",
"new",
"WMI",
"connection"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L312-L339 | [
"def",
"get_connection",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"u\"Connecting to WMI server \"",
"u\"(host={host}, namespace={namespace}, provider={provider}, username={username}).\"",
".",
"format",
"(",
"host",
"=",
"self",
".",
"host",
",",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler._format_filter | Transform filters to a comprehensive WQL `WHERE` clause.
Builds filter from a filter list.
- filters: expects a list of dicts, typically:
- [{'Property': value},...] or
- [{'Property': (comparison_op, value)},...]
NOTE: If we just provide a value we defa... | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def _format_filter(filters, and_props=[]):
"""
Transform filters to a comprehensive WQL `WHERE` clause.
Builds filter from a filter list.
- filters: expects a list of dicts, typically:
- [{'Property': value},...] or
- [{'Property': (comparison_op, value)}... | def _format_filter(filters, and_props=[]):
"""
Transform filters to a comprehensive WQL `WHERE` clause.
Builds filter from a filter list.
- filters: expects a list of dicts, typically:
- [{'Property': value},...] or
- [{'Property': (comparison_op, value)}... | [
"Transform",
"filters",
"to",
"a",
"comprehensive",
"WQL",
"WHERE",
"clause",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L342-L421 | [
"def",
"_format_filter",
"(",
"filters",
",",
"and_props",
"=",
"[",
"]",
")",
":",
"def",
"build_where_clause",
"(",
"fltr",
")",
":",
"f",
"=",
"fltr",
".",
"pop",
"(",
")",
"wql",
"=",
"\"\"",
"while",
"f",
":",
"prop",
",",
"value",
"=",
"f",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler._query | Query WMI using WMI Query Language (WQL) & parse the results.
Returns: List of WMI objects or `TimeoutException`. | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def _query(self): # pylint: disable=E0202
"""
Query WMI using WMI Query Language (WQL) & parse the results.
Returns: List of WMI objects or `TimeoutException`.
"""
formated_property_names = ",".join(self.property_names)
wql = "Select {property_names} from {class_name}{f... | def _query(self): # pylint: disable=E0202
"""
Query WMI using WMI Query Language (WQL) & parse the results.
Returns: List of WMI objects or `TimeoutException`.
"""
formated_property_names = ",".join(self.property_names)
wql = "Select {property_names} from {class_name}{f... | [
"Query",
"WMI",
"using",
"WMI",
"Query",
"Language",
"(",
"WQL",
")",
"&",
"parse",
"the",
"results",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L423-L458 | [
"def",
"_query",
"(",
"self",
")",
":",
"# pylint: disable=E0202",
"formated_property_names",
"=",
"\",\"",
".",
"join",
"(",
"self",
".",
"property_names",
")",
"wql",
"=",
"\"Select {property_names} from {class_name}{filters}\"",
".",
"format",
"(",
"property_names",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | WMISampler._parse_results | Parse WMI query results in a more comprehensive form.
Returns: List of WMI objects
```
[
{
'freemegabytes': 19742.0,
'name': 'C:',
'avgdiskbytesperwrite': 1536.0
}, {
'freemegabytes': 19742.0,
... | datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py | def _parse_results(self, raw_results, includes_qualifiers):
"""
Parse WMI query results in a more comprehensive form.
Returns: List of WMI objects
```
[
{
'freemegabytes': 19742.0,
'name': 'C:',
'avgdiskbytesperwrite': ... | def _parse_results(self, raw_results, includes_qualifiers):
"""
Parse WMI query results in a more comprehensive form.
Returns: List of WMI objects
```
[
{
'freemegabytes': 19742.0,
'name': 'C:',
'avgdiskbytesperwrite': ... | [
"Parse",
"WMI",
"query",
"results",
"in",
"a",
"more",
"comprehensive",
"form",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/win/wmi/sampler.py#L460-L526 | [
"def",
"_parse_results",
"(",
"self",
",",
"raw_results",
",",
"includes_qualifiers",
")",
":",
"results",
"=",
"[",
"]",
"for",
"res",
"in",
"raw_results",
":",
"# Ensure all properties are available. Use case-insensitivity",
"# because some properties are returned with diff... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | Monitor._check_with_socket | Return (IsMaster, round_trip_time).
Can raise ConnectionFailure or OperationFailure. | tokumx/datadog_checks/tokumx/vendor/pymongo/monitor.py | def _check_with_socket(self, sock_info, metadata=None):
"""Return (IsMaster, round_trip_time).
Can raise ConnectionFailure or OperationFailure.
"""
cmd = SON([('ismaster', 1)])
if metadata is not None:
cmd['client'] = metadata
start = _time()
request_... | def _check_with_socket(self, sock_info, metadata=None):
"""Return (IsMaster, round_trip_time).
Can raise ConnectionFailure or OperationFailure.
"""
cmd = SON([('ismaster', 1)])
if metadata is not None:
cmd['client'] = metadata
start = _time()
request_... | [
"Return",
"(",
"IsMaster",
"round_trip_time",
")",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/monitor.py#L175-L192 | [
"def",
"_check_with_socket",
"(",
"self",
",",
"sock_info",
",",
"metadata",
"=",
"None",
")",
":",
"cmd",
"=",
"SON",
"(",
"[",
"(",
"'ismaster'",
",",
"1",
")",
"]",
")",
"if",
"metadata",
"is",
"not",
"None",
":",
"cmd",
"[",
"'client'",
"]",
"=... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | agent_reqs | Verify that the checks versions are in sync with the requirements-agent-release.txt file | datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/agent_reqs.py | def agent_reqs():
"""Verify that the checks versions are in sync with the requirements-agent-release.txt file"""
echo_info("Validating requirements-agent-release.txt...")
agent_reqs_content = parse_agent_req_file(read_file(get_agent_release_requirements()))
ok_checks = 0
unreleased_checks = 0
f... | def agent_reqs():
"""Verify that the checks versions are in sync with the requirements-agent-release.txt file"""
echo_info("Validating requirements-agent-release.txt...")
agent_reqs_content = parse_agent_req_file(read_file(get_agent_release_requirements()))
ok_checks = 0
unreleased_checks = 0
f... | [
"Verify",
"that",
"the",
"checks",
"versions",
"are",
"in",
"sync",
"with",
"the",
"requirements",
"-",
"agent",
"-",
"release",
".",
"txt",
"file"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/agent_reqs.py#L18-L46 | [
"def",
"agent_reqs",
"(",
")",
":",
"echo_info",
"(",
"\"Validating requirements-agent-release.txt...\"",
")",
"agent_reqs_content",
"=",
"parse_agent_req_file",
"(",
"read_file",
"(",
"get_agent_release_requirements",
"(",
")",
")",
")",
"ok_checks",
"=",
"0",
"unrelea... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy3._log_deprecation | Logs a deprecation notice at most once per AgentCheck instance, for the pre-defined `deprecation_key` | datadog_checks_base/datadog_checks/base/checks/base.py | def _log_deprecation(self, deprecation_key):
"""
Logs a deprecation notice at most once per AgentCheck instance, for the pre-defined `deprecation_key`
"""
if not self._deprecations[deprecation_key][0]:
self.log.warning(self._deprecations[deprecation_key][1])
self.... | def _log_deprecation(self, deprecation_key):
"""
Logs a deprecation notice at most once per AgentCheck instance, for the pre-defined `deprecation_key`
"""
if not self._deprecations[deprecation_key][0]:
self.log.warning(self._deprecations[deprecation_key][1])
self.... | [
"Logs",
"a",
"deprecation",
"notice",
"at",
"most",
"once",
"per",
"AgentCheck",
"instance",
"for",
"the",
"pre",
"-",
"defined",
"deprecation_key"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L267-L273 | [
"def",
"_log_deprecation",
"(",
"self",
",",
"deprecation_key",
")",
":",
"if",
"not",
"self",
".",
"_deprecations",
"[",
"deprecation_key",
"]",
"[",
"0",
"]",
":",
"self",
".",
"log",
".",
"warning",
"(",
"self",
".",
"_deprecations",
"[",
"deprecation_k... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy3.convert_to_underscore_separated | Convert from CamelCase to camel_case
And substitute illegal metric characters | datadog_checks_base/datadog_checks/base/checks/base.py | def convert_to_underscore_separated(self, name):
"""
Convert from CamelCase to camel_case
And substitute illegal metric characters
"""
metric_name = self.FIRST_CAP_RE.sub(br'\1_\2', ensure_bytes(name))
metric_name = self.ALL_CAP_RE.sub(br'\1_\2', metric_name).lower()
... | def convert_to_underscore_separated(self, name):
"""
Convert from CamelCase to camel_case
And substitute illegal metric characters
"""
metric_name = self.FIRST_CAP_RE.sub(br'\1_\2', ensure_bytes(name))
metric_name = self.ALL_CAP_RE.sub(br'\1_\2', metric_name).lower()
... | [
"Convert",
"from",
"CamelCase",
"to",
"camel_case",
"And",
"substitute",
"illegal",
"metric",
"characters"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L364-L372 | [
"def",
"convert_to_underscore_separated",
"(",
"self",
",",
"name",
")",
":",
"metric_name",
"=",
"self",
".",
"FIRST_CAP_RE",
".",
"sub",
"(",
"br'\\1_\\2'",
",",
"ensure_bytes",
"(",
"name",
")",
")",
"metric_name",
"=",
"self",
".",
"ALL_CAP_RE",
".",
"su... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy3._normalize_tags_type | Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list | datadog_checks_base/datadog_checks/base/checks/base.py | def _normalize_tags_type(self, tags, device_name=None, metric_name=None):
"""
Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list
"""
normalized_tags = []
if ... | def _normalize_tags_type(self, tags, device_name=None, metric_name=None):
"""
Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list
"""
normalized_tags = []
if ... | [
"Normalize",
"tags",
"contents",
"and",
"type",
":",
"-",
"append",
"device_name",
"as",
"device",
":",
"tag",
"-",
"normalize",
"tags",
"type",
"-",
"doesn",
"t",
"mutate",
"the",
"passed",
"list",
"returns",
"a",
"new",
"list"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L374-L402 | [
"def",
"_normalize_tags_type",
"(",
"self",
",",
"tags",
",",
"device_name",
"=",
"None",
",",
"metric_name",
"=",
"None",
")",
":",
"normalized_tags",
"=",
"[",
"]",
"if",
"device_name",
":",
"self",
".",
"_log_deprecation",
"(",
"'device_name'",
")",
"norm... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy2.normalize | Turn a metric into a well-formed metric name
prefix.b.c
:param metric The metric name to normalize
:param prefix A prefix to to add to the normalized name, default None
:param fix_case A boolean, indicating whether to make sure that the metric name returned is in "snake_case" | datadog_checks_base/datadog_checks/base/checks/base.py | def normalize(self, metric, prefix=None, fix_case=False):
"""
Turn a metric into a well-formed metric name
prefix.b.c
:param metric The metric name to normalize
:param prefix A prefix to to add to the normalized name, default None
:param fix_case A boolean, indicating whe... | def normalize(self, metric, prefix=None, fix_case=False):
"""
Turn a metric into a well-formed metric name
prefix.b.c
:param metric The metric name to normalize
:param prefix A prefix to to add to the normalized name, default None
:param fix_case A boolean, indicating whe... | [
"Turn",
"a",
"metric",
"into",
"a",
"well",
"-",
"formed",
"metric",
"name",
"prefix",
".",
"b",
".",
"c",
":",
"param",
"metric",
"The",
"metric",
"name",
"to",
"normalize",
":",
"param",
"prefix",
"A",
"prefix",
"to",
"to",
"add",
"to",
"the",
"nor... | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L707-L736 | [
"def",
"normalize",
"(",
"self",
",",
"metric",
",",
"prefix",
"=",
"None",
",",
"fix_case",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"metric",
",",
"text_type",
")",
":",
"metric",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"met... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy2._normalize_tags_type | Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list | datadog_checks_base/datadog_checks/base/checks/base.py | def _normalize_tags_type(self, tags, device_name=None, metric_name=None):
"""
Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list
"""
normalized_tags = []
if ... | def _normalize_tags_type(self, tags, device_name=None, metric_name=None):
"""
Normalize tags contents and type:
- append `device_name` as `device:` tag
- normalize tags type
- doesn't mutate the passed list, returns a new list
"""
normalized_tags = []
if ... | [
"Normalize",
"tags",
"contents",
"and",
"type",
":",
"-",
"append",
"device_name",
"as",
"device",
":",
"tag",
"-",
"normalize",
"tags",
"type",
"-",
"doesn",
"t",
"mutate",
"the",
"passed",
"list",
"returns",
"a",
"new",
"list"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L769-L802 | [
"def",
"_normalize_tags_type",
"(",
"self",
",",
"tags",
",",
"device_name",
"=",
"None",
",",
"metric_name",
"=",
"None",
")",
":",
"normalized_tags",
"=",
"[",
"]",
"if",
"device_name",
":",
"self",
".",
"_log_deprecation",
"(",
"\"device_name\"",
")",
"de... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | __AgentCheckPy2._to_bytes | Normalize a text data to bytes (type `bytes`) so that the go bindings can
handle it easily. | datadog_checks_base/datadog_checks/base/checks/base.py | def _to_bytes(self, data):
"""
Normalize a text data to bytes (type `bytes`) so that the go bindings can
handle it easily.
"""
# TODO: On Python 3, move this `if` line to the `except` branch
# as the common case will indeed no longer be bytes.
if not isinstance(da... | def _to_bytes(self, data):
"""
Normalize a text data to bytes (type `bytes`) so that the go bindings can
handle it easily.
"""
# TODO: On Python 3, move this `if` line to the `except` branch
# as the common case will indeed no longer be bytes.
if not isinstance(da... | [
"Normalize",
"a",
"text",
"data",
"to",
"bytes",
"(",
"type",
"bytes",
")",
"so",
"that",
"the",
"go",
"bindings",
"can",
"handle",
"it",
"easily",
"."
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/checks/base.py#L804-L817 | [
"def",
"_to_bytes",
"(",
"self",
",",
"data",
")",
":",
"# TODO: On Python 3, move this `if` line to the `except` branch",
"# as the common case will indeed no longer be bytes.",
"if",
"not",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"try",
":",
"return",
"data",... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | from_instance | Create a config object from an instance dictionary | elastic/datadog_checks/elastic/config.py | def from_instance(instance):
"""
Create a config object from an instance dictionary
"""
url = instance.get('url')
if not url:
raise ConfigurationError("A URL must be specified in the instance")
pshard_stats = is_affirmative(instance.get('pshard_stats', False))
pshard_graceful_to = i... | def from_instance(instance):
"""
Create a config object from an instance dictionary
"""
url = instance.get('url')
if not url:
raise ConfigurationError("A URL must be specified in the instance")
pshard_stats = is_affirmative(instance.get('pshard_stats', False))
pshard_graceful_to = i... | [
"Create",
"a",
"config",
"object",
"from",
"an",
"instance",
"dictionary"
] | DataDog/integrations-core | python | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/elastic/datadog_checks/elastic/config.py#L37-L93 | [
"def",
"from_instance",
"(",
"instance",
")",
":",
"url",
"=",
"instance",
".",
"get",
"(",
"'url'",
")",
"if",
"not",
"url",
":",
"raise",
"ConfigurationError",
"(",
"\"A URL must be specified in the instance\"",
")",
"pshard_stats",
"=",
"is_affirmative",
"(",
... | ebd41c873cf9f97a8c51bf9459bc6a7536af8acd |
train | BaseDataset.download | Download the dataset from the hosted Yellowbrick data store and save
it to the location specified by ``get_data_home``. The downloader
verifies the download completed successfully and safely by comparing
the expected signature with the SHA 256 signature of the downloaded
archive file.
... | yellowbrick/datasets/base.py | def download(self, replace=False):
"""
Download the dataset from the hosted Yellowbrick data store and save
it to the location specified by ``get_data_home``. The downloader
verifies the download completed successfully and safely by comparing
the expected signature with the SHA 2... | def download(self, replace=False):
"""
Download the dataset from the hosted Yellowbrick data store and save
it to the location specified by ``get_data_home``. The downloader
verifies the download completed successfully and safely by comparing
the expected signature with the SHA 2... | [
"Download",
"the",
"dataset",
"from",
"the",
"hosted",
"Yellowbrick",
"data",
"store",
"and",
"save",
"it",
"to",
"the",
"location",
"specified",
"by",
"get_data_home",
".",
"The",
"downloader",
"verifies",
"the",
"download",
"completed",
"successfully",
"and",
... | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L54-L71 | [
"def",
"download",
"(",
"self",
",",
"replace",
"=",
"False",
")",
":",
"download_data",
"(",
"self",
".",
"url",
",",
"self",
".",
"signature",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"replace",
"=",
"replace",
",",
"extract",
"=",
"True... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | BaseDataset.contents | Contents returns a list of the files in the data directory. | yellowbrick/datasets/base.py | def contents(self):
"""
Contents returns a list of the files in the data directory.
"""
data = find_dataset_path(
self.name, data_home=self.data_home, ext=None
)
return os.listdir(data) | def contents(self):
"""
Contents returns a list of the files in the data directory.
"""
data = find_dataset_path(
self.name, data_home=self.data_home, ext=None
)
return os.listdir(data) | [
"Contents",
"returns",
"a",
"list",
"of",
"the",
"files",
"in",
"the",
"data",
"directory",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L73-L80 | [
"def",
"contents",
"(",
"self",
")",
":",
"data",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"ext",
"=",
"None",
")",
"return",
"os",
".",
"listdir",
"(",
"data",
")"
] | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | BaseDataset.README | Returns the contents of the README.md file that describes the dataset
in detail and contains attribution information. | yellowbrick/datasets/base.py | def README(self):
"""
Returns the contents of the README.md file that describes the dataset
in detail and contains attribution information.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="README.md"
)
with open(path, 'r') as f... | def README(self):
"""
Returns the contents of the README.md file that describes the dataset
in detail and contains attribution information.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="README.md"
)
with open(path, 'r') as f... | [
"Returns",
"the",
"contents",
"of",
"the",
"README",
".",
"md",
"file",
"that",
"describes",
"the",
"dataset",
"in",
"detail",
"and",
"contains",
"attribution",
"information",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L83-L92 | [
"def",
"README",
"(",
"self",
")",
":",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"fname",
"=",
"\"README.md\"",
")",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":"... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | BaseDataset.meta | Returns the contents of the meta.json file that describes important
attributes about the dataset and modifies the behavior of the loader. | yellowbrick/datasets/base.py | def meta(self):
"""
Returns the contents of the meta.json file that describes important
attributes about the dataset and modifies the behavior of the loader.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="meta.json", raises=False
)
... | def meta(self):
"""
Returns the contents of the meta.json file that describes important
attributes about the dataset and modifies the behavior of the loader.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="meta.json", raises=False
)
... | [
"Returns",
"the",
"contents",
"of",
"the",
"meta",
".",
"json",
"file",
"that",
"describes",
"important",
"attributes",
"about",
"the",
"dataset",
"and",
"modifies",
"the",
"behavior",
"of",
"the",
"loader",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L95-L107 | [
"def",
"meta",
"(",
"self",
")",
":",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"fname",
"=",
"\"meta.json\"",
",",
"raises",
"=",
"False",
")",
"if",
"path",
"is",
"None",
":",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | BaseDataset.citation | Returns the contents of the citation.bib file that describes the source
and provenance of the dataset or to cite for academic work. | yellowbrick/datasets/base.py | def citation(self):
"""
Returns the contents of the citation.bib file that describes the source
and provenance of the dataset or to cite for academic work.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="meta.json", raises=False
)
... | def citation(self):
"""
Returns the contents of the citation.bib file that describes the source
and provenance of the dataset or to cite for academic work.
"""
path = find_dataset_path(
self.name, data_home=self.data_home, fname="meta.json", raises=False
)
... | [
"Returns",
"the",
"contents",
"of",
"the",
"citation",
".",
"bib",
"file",
"that",
"describes",
"the",
"source",
"and",
"provenance",
"of",
"the",
"dataset",
"or",
"to",
"cite",
"for",
"academic",
"work",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L110-L122 | [
"def",
"citation",
"(",
"self",
")",
":",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"data_home",
"=",
"self",
".",
"data_home",
",",
"fname",
"=",
"\"meta.json\"",
",",
"raises",
"=",
"False",
")",
"if",
"path",
"is",
"None",
":"... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Dataset.to_numpy | Returns the dataset as two numpy arrays: X and y.
Returns
-------
X : array-like with shape (n_instances, n_features)
A numpy array describing the instance features.
y : array-like with shape (n_instances,)
A numpy array describing the target vector. | yellowbrick/datasets/base.py | def to_numpy(self):
"""
Returns the dataset as two numpy arrays: X and y.
Returns
-------
X : array-like with shape (n_instances, n_features)
A numpy array describing the instance features.
y : array-like with shape (n_instances,)
A numpy array d... | def to_numpy(self):
"""
Returns the dataset as two numpy arrays: X and y.
Returns
-------
X : array-like with shape (n_instances, n_features)
A numpy array describing the instance features.
y : array-like with shape (n_instances,)
A numpy array d... | [
"Returns",
"the",
"dataset",
"as",
"two",
"numpy",
"arrays",
":",
"X",
"and",
"y",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L177-L198 | [
"def",
"to_numpy",
"(",
"self",
")",
":",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"ext",
"=",
"\".npz\"",
",",
"data_home",
"=",
"self",
".",
"data_home",
")",
"with",
"np",
".",
"load",
"(",
"path",
",",
"allow_pickle",
"=",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Dataset.to_pandas | Returns the dataset as two pandas objects: X and y.
Returns
-------
X : DataFrame with shape (n_instances, n_features)
A pandas DataFrame containing feature data and named columns.
y : Series with shape (n_instances,)
A pandas Series containing target data and a... | yellowbrick/datasets/base.py | def to_pandas(self):
"""
Returns the dataset as two pandas objects: X and y.
Returns
-------
X : DataFrame with shape (n_instances, n_features)
A pandas DataFrame containing feature data and named columns.
y : Series with shape (n_instances,)
A p... | def to_pandas(self):
"""
Returns the dataset as two pandas objects: X and y.
Returns
-------
X : DataFrame with shape (n_instances, n_features)
A pandas DataFrame containing feature data and named columns.
y : Series with shape (n_instances,)
A p... | [
"Returns",
"the",
"dataset",
"as",
"two",
"pandas",
"objects",
":",
"X",
"and",
"y",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L200-L229 | [
"def",
"to_pandas",
"(",
"self",
")",
":",
"# Ensure the metadata is valid before continuing",
"if",
"self",
".",
"meta",
"is",
"None",
":",
"raise",
"DatasetsError",
"(",
"(",
"\"the downloaded dataset was improperly packaged without meta.json \"",
"\"- please report this bug ... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Dataset.to_dataframe | Returns the entire dataset as a single pandas DataFrame.
Returns
-------
df : DataFrame with shape (n_instances, n_columns)
A pandas DataFrame containing the complete original data table
including all targets (specified by the meta data) and all
features (inc... | yellowbrick/datasets/base.py | def to_dataframe(self):
"""
Returns the entire dataset as a single pandas DataFrame.
Returns
-------
df : DataFrame with shape (n_instances, n_columns)
A pandas DataFrame containing the complete original data table
including all targets (specified by the ... | def to_dataframe(self):
"""
Returns the entire dataset as a single pandas DataFrame.
Returns
-------
df : DataFrame with shape (n_instances, n_columns)
A pandas DataFrame containing the complete original data table
including all targets (specified by the ... | [
"Returns",
"the",
"entire",
"dataset",
"as",
"a",
"single",
"pandas",
"DataFrame",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L232-L249 | [
"def",
"to_dataframe",
"(",
"self",
")",
":",
"if",
"pd",
"is",
"None",
":",
"raise",
"DatasetsError",
"(",
"\"pandas is required to load DataFrame, it can be installed with pip\"",
")",
"path",
"=",
"find_dataset_path",
"(",
"self",
".",
"name",
",",
"ext",
"=",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Corpus.labels | Return the unique labels assigned to the documents. | yellowbrick/datasets/base.py | def labels(self):
"""
Return the unique labels assigned to the documents.
"""
return [
name for name in os.listdir(self.root)
if os.path.isdir(os.path.join(self.root, name))
] | def labels(self):
"""
Return the unique labels assigned to the documents.
"""
return [
name for name in os.listdir(self.root)
if os.path.isdir(os.path.join(self.root, name))
] | [
"Return",
"the",
"unique",
"labels",
"assigned",
"to",
"the",
"documents",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L288-L295 | [
"def",
"labels",
"(",
"self",
")",
":",
"return",
"[",
"name",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"root",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"root",
",",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Corpus.files | Returns the list of file names for all documents. | yellowbrick/datasets/base.py | def files(self):
"""
Returns the list of file names for all documents.
"""
return [
os.path.join(self.root, label, name)
for label in self.labels
for name in os.listdir(os.path.join(self.root, label))
] | def files(self):
"""
Returns the list of file names for all documents.
"""
return [
os.path.join(self.root, label, name)
for label in self.labels
for name in os.listdir(os.path.join(self.root, label))
] | [
"Returns",
"the",
"list",
"of",
"file",
"names",
"for",
"all",
"documents",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L298-L306 | [
"def",
"files",
"(",
"self",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"root",
",",
"label",
",",
"name",
")",
"for",
"label",
"in",
"self",
".",
"labels",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"os",
"... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Corpus.data | Read all of the documents from disk into an in-memory list. | yellowbrick/datasets/base.py | def data(self):
"""
Read all of the documents from disk into an in-memory list.
"""
def read(path):
with open(path, 'r', encoding='UTF-8') as f:
return f.read()
return [
read(f) for f in self.files
] | def data(self):
"""
Read all of the documents from disk into an in-memory list.
"""
def read(path):
with open(path, 'r', encoding='UTF-8') as f:
return f.read()
return [
read(f) for f in self.files
] | [
"Read",
"all",
"of",
"the",
"documents",
"from",
"disk",
"into",
"an",
"in",
"-",
"memory",
"list",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L309-L319 | [
"def",
"data",
"(",
"self",
")",
":",
"def",
"read",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
",",
"encoding",
"=",
"'UTF-8'",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
")",
"return",
"[",
"read",
"(",
"f",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | Corpus.target | Returns the label associated with each item in data. | yellowbrick/datasets/base.py | def target(self):
"""
Returns the label associated with each item in data.
"""
return [
os.path.basename(os.path.dirname(f)) for f in self.files
] | def target(self):
"""
Returns the label associated with each item in data.
"""
return [
os.path.basename(os.path.dirname(f)) for f in self.files
] | [
"Returns",
"the",
"label",
"associated",
"with",
"each",
"item",
"in",
"data",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/base.py#L322-L328 | [
"def",
"target",
"(",
"self",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"f",
")",
")",
"for",
"f",
"in",
"self",
".",
"files",
"]"
] | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | SilhouetteVisualizer.fit | Fits the model and generates the silhouette visualization. | yellowbrick/cluster/silhouette.py | def fit(self, X, y=None, **kwargs):
"""
Fits the model and generates the silhouette visualization.
"""
# TODO: decide to use this method or the score method to draw.
# NOTE: Probably this would be better in score, but the standard score
# is a little different and I'm not... | def fit(self, X, y=None, **kwargs):
"""
Fits the model and generates the silhouette visualization.
"""
# TODO: decide to use this method or the score method to draw.
# NOTE: Probably this would be better in score, but the standard score
# is a little different and I'm not... | [
"Fits",
"the",
"model",
"and",
"generates",
"the",
"silhouette",
"visualization",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/cluster/silhouette.py#L108-L132 | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: decide to use this method or the score method to draw.",
"# NOTE: Probably this would be better in score, but the standard score",
"# is a little different and I'm not sure how... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | SilhouetteVisualizer.draw | Draw the silhouettes for each sample and the average score.
Parameters
----------
labels : array-like
An array with the cluster label for each silhouette sample,
usually computed with ``predict()``. Labels are not stored on the
visualizer so that the figure ... | yellowbrick/cluster/silhouette.py | def draw(self, labels):
"""
Draw the silhouettes for each sample and the average score.
Parameters
----------
labels : array-like
An array with the cluster label for each silhouette sample,
usually computed with ``predict()``. Labels are not stored on th... | def draw(self, labels):
"""
Draw the silhouettes for each sample and the average score.
Parameters
----------
labels : array-like
An array with the cluster label for each silhouette sample,
usually computed with ``predict()``. Labels are not stored on th... | [
"Draw",
"the",
"silhouettes",
"for",
"each",
"sample",
"and",
"the",
"average",
"score",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/cluster/silhouette.py#L134-L182 | [
"def",
"draw",
"(",
"self",
",",
"labels",
")",
":",
"# Track the positions of the lines being drawn",
"y_lower",
"=",
"10",
"# The bottom of the silhouette",
"# Get the colors from the various properties",
"# TODO: Use resolve_colors instead of this",
"colors",
"=",
"color_palette... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | SilhouetteVisualizer.finalize | Prepare the figure for rendering by setting the title and adjusting
the limits on the axes, adding labels and a legend. | yellowbrick/cluster/silhouette.py | def finalize(self):
"""
Prepare the figure for rendering by setting the title and adjusting
the limits on the axes, adding labels and a legend.
"""
# Set the title
self.set_title((
"Silhouette Plot of {} Clustering for {} Samples in {} Centers"
).form... | def finalize(self):
"""
Prepare the figure for rendering by setting the title and adjusting
the limits on the axes, adding labels and a legend.
"""
# Set the title
self.set_title((
"Silhouette Plot of {} Clustering for {} Samples in {} Centers"
).form... | [
"Prepare",
"the",
"figure",
"for",
"rendering",
"by",
"setting",
"the",
"title",
"and",
"adjusting",
"the",
"limits",
"on",
"the",
"axes",
"adding",
"labels",
"and",
"a",
"legend",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/cluster/silhouette.py#L184-L217 | [
"def",
"finalize",
"(",
"self",
")",
":",
"# Set the title",
"self",
".",
"set_title",
"(",
"(",
"\"Silhouette Plot of {} Clustering for {} Samples in {} Centers\"",
")",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"n_samples_",
",",
"self",
".",
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | sha256sum | Computes the SHA256 signature of a file to verify that the file has not
been modified in transit and that it is the correct version of the data. | yellowbrick/datasets/signature.py | def sha256sum(path, blocksize=65536):
"""
Computes the SHA256 signature of a file to verify that the file has not
been modified in transit and that it is the correct version of the data.
"""
sig = hashlib.sha256()
with open(path, 'rb') as f:
buf = f.read(blocksize)
while len(buf)... | def sha256sum(path, blocksize=65536):
"""
Computes the SHA256 signature of a file to verify that the file has not
been modified in transit and that it is the correct version of the data.
"""
sig = hashlib.sha256()
with open(path, 'rb') as f:
buf = f.read(blocksize)
while len(buf)... | [
"Computes",
"the",
"SHA256",
"signature",
"of",
"a",
"file",
"to",
"verify",
"that",
"the",
"file",
"has",
"not",
"been",
"modified",
"in",
"transit",
"and",
"that",
"it",
"is",
"the",
"correct",
"version",
"of",
"the",
"data",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/signature.py#L23-L34 | [
"def",
"sha256sum",
"(",
"path",
",",
"blocksize",
"=",
"65536",
")",
":",
"sig",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"buf",
"=",
"f",
".",
"read",
"(",
"blocksize",
")",
"while"... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | draw_best_fit | Uses Scikit-Learn to fit a model to X and y then uses the resulting model
to predict the curve based on the X values. This curve is drawn to the ax
(matplotlib axis) which must be passed as the third variable.
The estimator function can be one of the following:
- ``'linear'``: Uses OLS to fit the... | yellowbrick/bestfit.py | def draw_best_fit(X, y, ax, estimator='linear', **kwargs):
"""
Uses Scikit-Learn to fit a model to X and y then uses the resulting model
to predict the curve based on the X values. This curve is drawn to the ax
(matplotlib axis) which must be passed as the third variable.
The estimator function can... | def draw_best_fit(X, y, ax, estimator='linear', **kwargs):
"""
Uses Scikit-Learn to fit a model to X and y then uses the resulting model
to predict the curve based on the X values. This curve is drawn to the ax
(matplotlib axis) which must be passed as the third variable.
The estimator function can... | [
"Uses",
"Scikit",
"-",
"Learn",
"to",
"fit",
"a",
"model",
"to",
"X",
"and",
"y",
"then",
"uses",
"the",
"resulting",
"model",
"to",
"predict",
"the",
"curve",
"based",
"on",
"the",
"X",
"values",
".",
"This",
"curve",
"is",
"drawn",
"to",
"the",
"ax... | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/bestfit.py#L49-L157 | [
"def",
"draw_best_fit",
"(",
"X",
",",
"y",
",",
"ax",
",",
"estimator",
"=",
"'linear'",
",",
"*",
"*",
"kwargs",
")",
":",
"# Estimators are the types of best fit lines that can be drawn.",
"estimators",
"=",
"{",
"LINEAR",
":",
"fit_linear",
",",
"# Uses OLS to... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | fit_select_best | Selects the best fit of the estimators already implemented by choosing the
model with the smallest mean square error metric for the trained values. | yellowbrick/bestfit.py | def fit_select_best(X, y):
"""
Selects the best fit of the estimators already implemented by choosing the
model with the smallest mean square error metric for the trained values.
"""
models = [fit(X,y) for fit in [fit_linear, fit_quadratic]]
errors = map(lambda model: mse(y, model.predict(X)), m... | def fit_select_best(X, y):
"""
Selects the best fit of the estimators already implemented by choosing the
model with the smallest mean square error metric for the trained values.
"""
models = [fit(X,y) for fit in [fit_linear, fit_quadratic]]
errors = map(lambda model: mse(y, model.predict(X)), m... | [
"Selects",
"the",
"best",
"fit",
"of",
"the",
"estimators",
"already",
"implemented",
"by",
"choosing",
"the",
"model",
"with",
"the",
"smallest",
"mean",
"square",
"error",
"metric",
"for",
"the",
"trained",
"values",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/bestfit.py#L164-L172 | [
"def",
"fit_select_best",
"(",
"X",
",",
"y",
")",
":",
"models",
"=",
"[",
"fit",
"(",
"X",
",",
"y",
")",
"for",
"fit",
"in",
"[",
"fit_linear",
",",
"fit_quadratic",
"]",
"]",
"errors",
"=",
"map",
"(",
"lambda",
"model",
":",
"mse",
"(",
"y",... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | fit_linear | Uses OLS to fit the regression. | yellowbrick/bestfit.py | def fit_linear(X, y):
"""
Uses OLS to fit the regression.
"""
model = linear_model.LinearRegression()
model.fit(X, y)
return model | def fit_linear(X, y):
"""
Uses OLS to fit the regression.
"""
model = linear_model.LinearRegression()
model.fit(X, y)
return model | [
"Uses",
"OLS",
"to",
"fit",
"the",
"regression",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/bestfit.py#L175-L181 | [
"def",
"fit_linear",
"(",
"X",
",",
"y",
")",
":",
"model",
"=",
"linear_model",
".",
"LinearRegression",
"(",
")",
"model",
".",
"fit",
"(",
"X",
",",
"y",
")",
"return",
"model"
] | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | fit_quadratic | Uses OLS with Polynomial order 2. | yellowbrick/bestfit.py | def fit_quadratic(X, y):
"""
Uses OLS with Polynomial order 2.
"""
model = make_pipeline(
PolynomialFeatures(2), linear_model.LinearRegression()
)
model.fit(X, y)
return model | def fit_quadratic(X, y):
"""
Uses OLS with Polynomial order 2.
"""
model = make_pipeline(
PolynomialFeatures(2), linear_model.LinearRegression()
)
model.fit(X, y)
return model | [
"Uses",
"OLS",
"with",
"Polynomial",
"order",
"2",
"."
] | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/bestfit.py#L184-L192 | [
"def",
"fit_quadratic",
"(",
"X",
",",
"y",
")",
":",
"model",
"=",
"make_pipeline",
"(",
"PolynomialFeatures",
"(",
"2",
")",
",",
"linear_model",
".",
"LinearRegression",
"(",
")",
")",
"model",
".",
"fit",
"(",
"X",
",",
"y",
")",
"return",
"model"
... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
train | draw_identity_line | Draws a 45 degree identity line such that y=x for all points within the
given axes x and y limits. This function also registeres a callback so
that as the figure is modified, the axes are updated and the line remains
drawn correctly.
Parameters
----------
ax : matplotlib Axes, default: None
... | yellowbrick/bestfit.py | def draw_identity_line(ax=None, dynamic=True, **kwargs):
"""
Draws a 45 degree identity line such that y=x for all points within the
given axes x and y limits. This function also registeres a callback so
that as the figure is modified, the axes are updated and the line remains
drawn correctly.
... | def draw_identity_line(ax=None, dynamic=True, **kwargs):
"""
Draws a 45 degree identity line such that y=x for all points within the
given axes x and y limits. This function also registeres a callback so
that as the figure is modified, the axes are updated and the line remains
drawn correctly.
... | [
"Draws",
"a",
"45",
"degree",
"identity",
"line",
"such",
"that",
"y",
"=",
"x",
"for",
"all",
"points",
"within",
"the",
"given",
"axes",
"x",
"and",
"y",
"limits",
".",
"This",
"function",
"also",
"registeres",
"a",
"callback",
"so",
"that",
"as",
"t... | DistrictDataLabs/yellowbrick | python | https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/bestfit.py#L213-L281 | [
"def",
"draw_identity_line",
"(",
"ax",
"=",
"None",
",",
"dynamic",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get the current working axes",
"ax",
"=",
"ax",
"or",
"plt",
".",
"gca",
"(",
")",
"# Define the standard line color",
"if",
"'c'",
"not",... | 59b67236a3862c73363e8edad7cd86da5b69e3b2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.