Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ExperienceCollectionUtils.concat | (exp, is_single_source: bool = False, is_single_agent: bool = False) | Concatenate experiences from multiple sources, by agent ID.
The experience from each source is expected to be already grouped by agent ID. The result is a single dictionary
of experiences with keys being agent IDs and values being the concatenation of experiences from all sources
for each agent... | Concatenate experiences from multiple sources, by agent ID. | def concat(exp, is_single_source: bool = False, is_single_agent: bool = False) -> dict:
"""Concatenate experiences from multiple sources, by agent ID.
The experience from each source is expected to be already grouped by agent ID. The result is a single dictionary
of experiences with keys being ... | [
"def",
"concat",
"(",
"exp",
",",
"is_single_source",
":",
"bool",
"=",
"False",
",",
"is_single_agent",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"if",
"is_single_source",
":",
"return",
"exp",
"merged",
"=",
"defaultdict",
"(",
"list",
")",
"i... | [
8,
4
] | [
36,
21
] | python | en | ['en', 'en', 'en'] | True |
ExperienceCollectionUtils.stack | (exp, is_single_source: bool = False, is_single_agent: bool = False) | Collect each agent's trajectories from multiple sources.
Args:
exp: Experiences from one or more sources.
is_single_source (bool): If True, experiences are from a single (actor) source. Defaults to False.
is_single_agent (bool): If True, the experiences are from a single age... | Collect each agent's trajectories from multiple sources. | def stack(exp, is_single_source: bool = False, is_single_agent: bool = False) -> dict:
"""Collect each agent's trajectories from multiple sources.
Args:
exp: Experiences from one or more sources.
is_single_source (bool): If True, experiences are from a single (actor) source. Def... | [
"def",
"stack",
"(",
"exp",
",",
"is_single_source",
":",
"bool",
"=",
"False",
",",
"is_single_agent",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"if",
"is_single_source",
":",
"return",
"[",
"exp",
"]",
"if",
"is_single_agent",
"else",
"{",
"ag... | [
39,
4
] | [
61,
18
] | python | en | ['en', 'en', 'en'] | True |
CommandLineLoginFlow.async_step_init | (
self, user_input: Optional[Dict[str, str]] = None
) | Handle the step of the form. | Handle the step of the form. | async def async_step_init(
self, user_input: Optional[Dict[str, str]] = None
) -> Dict[str, Any]:
"""Handle the step of the form."""
errors = {}
if user_input is not None:
user_input["username"] = user_input["username"].strip()
try:
await cast... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
... | [
126,
4
] | [
151,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) | Set up discovered switches. | Set up discovered switches. | async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) -> None:
"""Set up discovered switches."""
devs = []
for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]:
devs.append(HassAqualinkSwitch(dev))
async_add_entities(devs, True) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"devs",
"=",
"[",
"]",
"for",
"dev",
"in",
"hass",
".",
"data",
"[",
"AQUALINK_DOMAIN",
"]... | [
11,
0
] | [
18,
34
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self) -> str:
"""Return the name of the switch."""
return self.dev.label | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"dev",
".",
"label"
] | [
25,
4
] | [
27,
29
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkSwitch.icon | (self) | Return an icon based on the switch type. | Return an icon based on the switch type. | def icon(self) -> str:
"""Return an icon based on the switch type."""
if self.name == "Cleaner":
return "mdi:robot-vacuum"
if self.name == "Waterfall" or self.name.endswith("Dscnt"):
return "mdi:fountain"
if self.name.endswith("Pump") or self.name.endswith("Blower... | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"name",
"==",
"\"Cleaner\"",
":",
"return",
"\"mdi:robot-vacuum\"",
"if",
"self",
".",
"name",
"==",
"\"Waterfall\"",
"or",
"self",
".",
"name",
".",
"endswith",
"(",
"\"Dscnt\"",
")",... | [
30,
4
] | [
39,
33
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkSwitch.is_on | (self) | Return whether the switch is on or not. | Return whether the switch is on or not. | def is_on(self) -> bool:
"""Return whether the switch is on or not."""
return self.dev.is_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"dev",
".",
"is_on"
] | [
42,
4
] | [
44,
29
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkSwitch.async_turn_on | (self, **kwargs) | Turn on the switch. | Turn on the switch. | async def async_turn_on(self, **kwargs) -> None:
"""Turn on the switch."""
await self.dev.turn_on() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"dev",
".",
"turn_on",
"(",
")"
] | [
47,
4
] | [
49,
32
] | python | en | ['en', 'en', 'en'] | True |
HassAqualinkSwitch.async_turn_off | (self, **kwargs) | Turn off the switch. | Turn off the switch. | async def async_turn_off(self, **kwargs) -> None:
"""Turn off the switch."""
await self.dev.turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"dev",
".",
"turn_off",
"(",
")"
] | [
52,
4
] | [
54,
33
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_host | (hass) | Test the failure when invalid host provided. | Test the failure when invalid host provided. | async def test_invalid_host(hass):
"""Test the failure when invalid host provided."""
result = await hass.config_entries.flow.async_init(
TWINKLY_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["step_id"] == "user"
assert result["er... | [
"async",
"def",
"test_invalid_host",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"TWINKLY_DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
... | [
15,
0
] | [
32,
66
] | python | en | ['en', 'en', 'en'] | True |
test_success_flow | (hass) | Test that an entity is created when the flow completes. | Test that an entity is created when the flow completes. | async def test_success_flow(hass):
"""Test that an entity is created when the flow completes."""
client = ClientMock()
with patch("twinkly_client.TwinklyClient", return_value=client):
result = await hass.config_entries.flow.async_init(
TWINKLY_DOMAIN, context={"source": config_entries.SO... | [
"async",
"def",
"test_success_flow",
"(",
"hass",
")",
":",
"client",
"=",
"ClientMock",
"(",
")",
"with",
"patch",
"(",
"\"twinkly_client.TwinklyClient\"",
",",
"return_value",
"=",
"client",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".... | [
35,
0
] | [
59,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities_callback, discovery_info=None) | Set up Kankun Wifi switches. | Set up Kankun Wifi switches. | def setup_platform(hass, config, add_entities_callback, discovery_info=None):
"""Set up Kankun Wifi switches."""
switches = config.get("switches", {})
devices = []
for dev_name, properties in switches.items():
devices.append(
KankunSwitch(
hass,
prope... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities_callback",
",",
"discovery_info",
"=",
"None",
")",
":",
"switches",
"=",
"config",
".",
"get",
"(",
"\"switches\"",
",",
"{",
"}",
")",
"devices",
"=",
"[",
"]",
"for",
"dev_name",
... | [
39,
0
] | [
57,
34
] | python | en | ['en', 'el-Latn', 'en'] | True |
KankunSwitch.__init__ | (self, hass, name, host, port, path, user, passwd) | Initialize the device. | Initialize the device. | def __init__(self, hass, name, host, port, path, user, passwd):
"""Initialize the device."""
self._hass = hass
self._name = name
self._state = False
self._url = f"http://{host}:{port}{path}"
if user is not None:
self._auth = (user, passwd)
else:
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"name",
",",
"host",
",",
"port",
",",
"path",
",",
"user",
",",
"passwd",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"False",
"sel... | [
63,
4
] | [
72,
29
] | python | en | ['en', 'en', 'en'] | True |
KankunSwitch._switch | (self, newstate) | Switch on or off. | Switch on or off. | def _switch(self, newstate):
"""Switch on or off."""
_LOGGER.info("Switching to state: %s", newstate)
try:
req = requests.get(
f"{self._url}?set={newstate}", auth=self._auth, timeout=5
)
return req.json()["ok"]
except requests.RequestE... | [
"def",
"_switch",
"(",
"self",
",",
"newstate",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Switching to state: %s\"",
",",
"newstate",
")",
"try",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"f\"{self._url}?set={newstate}\"",
",",
"auth",
"=",
"self",
".",
... | [
74,
4
] | [
84,
45
] | python | en | ['en', 'en', 'en'] | True |
KankunSwitch._query_state | (self) | Query switch state. | Query switch state. | def _query_state(self):
"""Query switch state."""
_LOGGER.info("Querying state from: %s", self._url)
try:
req = requests.get(f"{self._url}?get=state", auth=self._auth, timeout=5)
return req.json()["state"] == "on"
except requests.RequestException:
_LO... | [
"def",
"_query_state",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"Querying state from: %s\"",
",",
"self",
".",
"_url",
")",
"try",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"f\"{self._url}?get=state\"",
",",
"auth",
"=",
"self",
".",
"_aut... | [
86,
4
] | [
94,
47
] | python | en | ['en', 'en', 'en'] | True |
KankunSwitch.name | (self) | Return the name of the switch. | Return the name of the switch. | def name(self):
"""Return the name of the switch."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
KankunSwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
102,
4
] | [
104,
26
] | python | en | ['en', 'fy', 'en'] | True |
KankunSwitch.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
self._state = self._query_state() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_query_state",
"(",
")"
] | [
106,
4
] | [
108,
41
] | python | en | ['fr', 'en', 'en'] | True |
KankunSwitch.turn_on | (self, **kwargs) | Turn the device on. | Turn the device on. | def turn_on(self, **kwargs):
"""Turn the device on."""
if self._switch("on"):
self._state = True | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_switch",
"(",
"\"on\"",
")",
":",
"self",
".",
"_state",
"=",
"True"
] | [
110,
4
] | [
113,
30
] | python | en | ['en', 'en', 'en'] | True |
KankunSwitch.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
if self._switch("off"):
self._state = False | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_switch",
"(",
"\"off\"",
")",
":",
"self",
".",
"_state",
"=",
"False"
] | [
115,
4
] | [
118,
31
] | python | en | ['en', 'en', 'en'] | True |
accuracy | (output, target, topk=(1, 5)) | Computes the precision@k for the specified values of k | Computes the precision | def accuracy(output, target, topk=(1, 5)):
"""Computes the precision@k for the specified values of k"""
batch_size = target.size(0)
num = output.size(1)
target_topk = []
appendices = []
for k in topk:
if k <= num:
target_topk.append(k)
else:
appendices.app... | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
"5",
")",
")",
":",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"num",
"=",
"output",
".",
"size",
"(",
"1",
")",
"target_topk",
"=",
"[",
"]",
"appe... | [
32,
0
] | [
53,
27
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._init_redis | () | Create the redis service in the k8s cluster.
Returns:
None.
| Create the redis service in the k8s cluster. | def _init_redis():
"""Create the redis service in the k8s cluster.
Returns:
None.
"""
with open(f"{K8sPaths.ABS_MARO_K8S_LIB}/configs/redis/redis.yml", "r") as fr:
redis_deployment = yaml.safe_load(fr)
client.AppsV1Api().create_namespaced_deployment(body=... | [
"def",
"_init_redis",
"(",
")",
":",
"with",
"open",
"(",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/configs/redis/redis.yml\"",
",",
"\"r\"",
")",
"as",
"fr",
":",
"redis_deployment",
"=",
"yaml",
".",
"safe_load",
"(",
"fr",
")",
"client",
".",
"AppsV1Api",
"(",
")",
"... | [
37,
4
] | [
45,
99
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._init_nvidia_plugin | () | Init nvidia plugin for K8s Cluster.
Different providers may have different loading mechanisms.
Returns:
None.
| Init nvidia plugin for K8s Cluster. | def _init_nvidia_plugin():
""" Init nvidia plugin for K8s Cluster.
Different providers may have different loading mechanisms.
Returns:
None.
"""
pass | [
"def",
"_init_nvidia_plugin",
"(",
")",
":",
"pass"
] | [
49,
4
] | [
57,
12
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.start_job | (self, deployment_path: str) | Start a MARO Job with start_job_deployment.
Args:
deployment_path (str): path of the start_job_deployment.
Returns:
None.
| Start a MARO Job with start_job_deployment. | def start_job(self, deployment_path: str) -> None:
"""Start a MARO Job with start_job_deployment.
Args:
deployment_path (str): path of the start_job_deployment.
Returns:
None.
"""
# Load start_job_deployment.
with open(deployment_path, "r") as fr... | [
"def",
"start_job",
"(",
"self",
",",
"deployment_path",
":",
"str",
")",
"->",
"None",
":",
"# Load start_job_deployment.",
"with",
"open",
"(",
"deployment_path",
",",
"\"r\"",
")",
"as",
"fr",
":",
"start_job_deployment",
"=",
"yaml",
".",
"safe_load",
"(",... | [
66,
4
] | [
80,
66
] | python | en | ['en', 'hu', 'en'] | True |
K8sExecutor._start_job | (self, start_job_deployment: dict) | Start a MARO Job by converting the start_job_deployment to k8s job object and then execute it.
Args:
start_job_deployment (dict): raw start_job_deployment.
Returns:
None.
| Start a MARO Job by converting the start_job_deployment to k8s job object and then execute it. | def _start_job(self, start_job_deployment: dict) -> None:
"""Start a MARO Job by converting the start_job_deployment to k8s job object and then execute it.
Args:
start_job_deployment (dict): raw start_job_deployment.
Returns:
None.
"""
# Standardize star... | [
"def",
"_start_job",
"(",
"self",
",",
"start_job_deployment",
":",
"dict",
")",
"->",
"None",
":",
"# Standardize start job deployment.",
"job_details",
"=",
"K8sExecutor",
".",
"_standardize_job_details",
"(",
"start_job_deployment",
"=",
"start_job_deployment",
")",
... | [
82,
4
] | [
99,
84
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._standardize_job_details | (start_job_deployment: dict) | Standardize job_details with start_job_deployment.
Args:
start_job_deployment (dict): start_job_deployment of k8s/aks.
See lib/deployments/internal for reference.
Returns:
dict: standardized job_details.
| Standardize job_details with start_job_deployment. | def _standardize_job_details(start_job_deployment: dict) -> dict:
"""Standardize job_details with start_job_deployment.
Args:
start_job_deployment (dict): start_job_deployment of k8s/aks.
See lib/deployments/internal for reference.
Returns:
dict: standar... | [
"def",
"_standardize_job_details",
"(",
"start_job_deployment",
":",
"dict",
")",
"->",
"dict",
":",
"# Validate k8s_aks_start_job",
"with",
"open",
"(",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/deployments/internal/k8s_aks_start_job.yml\"",
")",
"as",
"fr",
":",
"start_job_template",
... | [
102,
4
] | [
137,
35
] | python | en | ['en', 'lb', 'en'] | True |
K8sExecutor._create_k8s_job | (self, job_details: dict) | Create k8s job object with job_details.
Args:
job_details (dict): details of the MARO Job.
Returns:
dict: k8s job object.
| Create k8s job object with job_details. | def _create_k8s_job(self, job_details: dict) -> dict:
"""Create k8s job object with job_details.
Args:
job_details (dict): details of the MARO Job.
Returns:
dict: k8s job object.
"""
# Load details
job_name = job_details["name"]
job_id = ... | [
"def",
"_create_k8s_job",
"(",
"self",
",",
"job_details",
":",
"dict",
")",
"->",
"dict",
":",
"# Load details",
"job_name",
"=",
"job_details",
"[",
"\"name\"",
"]",
"job_id",
"=",
"job_details",
"[",
"\"id\"",
"]",
"# Get config template",
"with",
"open",
"... | [
139,
4
] | [
174,
29
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._create_k8s_container_config | (
self,
job_details: dict,
k8s_container_config_template: dict,
component_type: str,
component_index: int
) | Create the container config in the k8s job object.
Args:
job_details (dict): details of the MARO Job.
k8s_container_config_template (dict): template of the k8s_container_config.
component_type (str): type of the component.
component_index (int): index of the comp... | Create the container config in the k8s job object. | def _create_k8s_container_config(
self,
job_details: dict,
k8s_container_config_template: dict,
component_type: str,
component_index: int
) -> dict:
"""Create the container config in the k8s job object.
Args:
job_details (dict): details of the MAR... | [
"def",
"_create_k8s_container_config",
"(",
"self",
",",
"job_details",
":",
"dict",
",",
"k8s_container_config_template",
":",
"dict",
",",
"component_type",
":",
"str",
",",
"component_index",
":",
"int",
")",
"->",
"dict",
":",
"# Copy config.",
"k8s_container_co... | [
176,
4
] | [
253,
35
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.stop_job | (job_name: str) | Activate stop job operation.
Args:
job_name (str): name of the MARO Job.
Returns:
None.
| Activate stop job operation. | def stop_job(job_name: str) -> None:
"""Activate stop job operation.
Args:
job_name (str): name of the MARO Job.
Returns:
None.
"""
K8sExecutor._stop_job(job_name=job_name) | [
"def",
"stop_job",
"(",
"job_name",
":",
"str",
")",
"->",
"None",
":",
"K8sExecutor",
".",
"_stop_job",
"(",
"job_name",
"=",
"job_name",
")"
] | [
256,
4
] | [
265,
48
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._stop_job | (job_name: str) | Stop MARO Job by stop k8s job object.
Args:
job_name (str): name of the MARO Job.
Returns:
None.
| Stop MARO Job by stop k8s job object. | def _stop_job(job_name: str):
"""Stop MARO Job by stop k8s job object.
Args:
job_name (str): name of the MARO Job.
Returns:
None.
"""
job_details = K8sDetailsReader.load_job_details(job_name=job_name)
client.BatchV1Api().delete_namespaced_job(nam... | [
"def",
"_stop_job",
"(",
"job_name",
":",
"str",
")",
":",
"job_details",
"=",
"K8sDetailsReader",
".",
"load_job_details",
"(",
"job_name",
"=",
"job_name",
")",
"client",
".",
"BatchV1Api",
"(",
")",
".",
"delete_namespaced_job",
"(",
"name",
"=",
"job_detai... | [
268,
4
] | [
278,
94
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._export_log | (pod_id: str, container_name: str, export_dir: str) | Export k8s job logs to the specific folder.
Args:
pod_id (str): id of the k8s pod.
container_name (str): name of the container.
export_dir (str): path of the exported folder.
Returns:
None.
| Export k8s job logs to the specific folder. | def _export_log(pod_id: str, container_name: str, export_dir: str):
"""Export k8s job logs to the specific folder.
Args:
pod_id (str): id of the k8s pod.
container_name (str): name of the container.
export_dir (str): path of the exported folder.
Returns:
... | [
"def",
"_export_log",
"(",
"pod_id",
":",
"str",
",",
"container_name",
":",
"str",
",",
"export_dir",
":",
"str",
")",
":",
"os",
".",
"makedirs",
"(",
"name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"export_dir",
"+",
"f\"/{pod_id}\"",
")",
"... | [
281,
4
] | [
295,
32
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.list_job | () | Print job_details of the cluster.
Returns:
None.
| Print job_details of the cluster. | def list_job() -> None:
"""Print job_details of the cluster.
Returns:
None.
"""
# Get jobs details
job_list = client.BatchV1Api().list_namespaced_job(namespace="default").to_dict()["items"]
# Print details
logger.info(
json.dumps(
... | [
"def",
"list_job",
"(",
")",
"->",
"None",
":",
"# Get jobs details",
"job_list",
"=",
"client",
".",
"BatchV1Api",
"(",
")",
".",
"list_namespaced_job",
"(",
"namespace",
"=",
"\"default\"",
")",
".",
"to_dict",
"(",
")",
"[",
"\"items\"",
"]",
"# Print det... | [
298,
4
] | [
315,
9
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.get_job_logs | (self, job_name: str, export_dir: str = "./") | Export MARO Job logs to the specific folder.
Args:
job_name (str): name of the MARO Job.
export_dir (str): path of the exported folder.
Returns:
None.
| Export MARO Job logs to the specific folder. | def get_job_logs(self, job_name: str, export_dir: str = "./") -> None:
"""Export MARO Job logs to the specific folder.
Args:
job_name (str): name of the MARO Job.
export_dir (str): path of the exported folder.
Returns:
None.
"""
# Load detail... | [
"def",
"get_job_logs",
"(",
"self",
",",
"job_name",
":",
"str",
",",
"export_dir",
":",
"str",
"=",
"\"./\"",
")",
"->",
"None",
":",
"# Load details",
"job_details",
"=",
"K8sDetailsReader",
".",
"load_job_details",
"(",
"job_name",
"=",
"job_name",
")",
"... | [
317,
4
] | [
344,
21
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.start_schedule | (self, deployment_path: str) | Start a MARO Schedule with start_schedule_deployment.
Args:
deployment_path (str): path of the start_schedule_deployment.
Returns:
None.
| Start a MARO Schedule with start_schedule_deployment. | def start_schedule(self, deployment_path: str) -> None:
"""Start a MARO Schedule with start_schedule_deployment.
Args:
deployment_path (str): path of the start_schedule_deployment.
Returns:
None.
"""
# Load start_schedule_deployment
with open(dep... | [
"def",
"start_schedule",
"(",
"self",
",",
"deployment_path",
":",
"str",
")",
"->",
"None",
":",
"# Load start_schedule_deployment",
"with",
"open",
"(",
"deployment_path",
",",
"\"r\"",
")",
"as",
"fr",
":",
"start_schedule_deployment",
"=",
"yaml",
".",
"safe... | [
348,
4
] | [
375,
61
] | python | en | ['en', 'de', 'en'] | True |
K8sExecutor.stop_schedule | (self, schedule_name: str) | Stop a MARO Schedule.
Args:
schedule_name (str): name of the MARO Schedule.
Returns:
None.
| Stop a MARO Schedule. | def stop_schedule(self, schedule_name: str) -> None:
"""Stop a MARO Schedule.
Args:
schedule_name (str): name of the MARO Schedule.
Returns:
None.
"""
schedule_details = K8sDetailsReader.load_schedule_details(schedule_name=schedule_name)
job_name... | [
"def",
"stop_schedule",
"(",
"self",
",",
"schedule_name",
":",
"str",
")",
"->",
"None",
":",
"schedule_details",
"=",
"K8sDetailsReader",
".",
"load_schedule_details",
"(",
"schedule_name",
"=",
"schedule_name",
")",
"job_names",
"=",
"schedule_details",
"[",
"\... | [
377,
4
] | [
396,
49
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._standardize_schedule_details | (start_schedule_deployment: dict) | Standardize schedule_details with start_schedule_deployment.
Args:
start_schedule_deployment (dict): start_schedule_deployment of k8s/aks.
See lib/deployments/internal for reference.
Returns:
dict: standardized job_details.
| Standardize schedule_details with start_schedule_deployment. | def _standardize_schedule_details(start_schedule_deployment: dict) -> dict:
"""Standardize schedule_details with start_schedule_deployment.
Args:
start_schedule_deployment (dict): start_schedule_deployment of k8s/aks.
See lib/deployments/internal for reference.
Retu... | [
"def",
"_standardize_schedule_details",
"(",
"start_schedule_deployment",
":",
"dict",
")",
"->",
"dict",
":",
"# Validate k8s_aks_start_schedule",
"with",
"open",
"(",
"f\"{K8sPaths.ABS_MARO_K8S_LIB}/deployments/internal/k8s_aks_start_schedule.yml\"",
")",
"as",
"fr",
":",
"st... | [
399,
4
] | [
432,
40
] | python | en | ['en', 'de', 'en'] | True |
K8sExecutor._build_job_details_for_schedule | (schedule_details: dict, job_name: str) | Build job_details from MARO Schedule.
Args:
schedule_details (dict): details of the MARO Schedule.
job_name (str): name of the MARO Job.
Returns:
None.
| Build job_details from MARO Schedule. | def _build_job_details_for_schedule(schedule_details: dict, job_name: str) -> dict:
"""Build job_details from MARO Schedule.
Args:
schedule_details (dict): details of the MARO Schedule.
job_name (str): name of the MARO Job.
Returns:
None.
"""
... | [
"def",
"_build_job_details_for_schedule",
"(",
"schedule_details",
":",
"dict",
",",
"job_name",
":",
"str",
")",
"->",
"dict",
":",
"# Convert schedule_details to job_details",
"job_details",
"=",
"copy",
".",
"deepcopy",
"(",
"schedule_details",
")",
"job_details",
... | [
435,
4
] | [
454,
26
] | python | en | ['en', 'nl', 'en'] | True |
K8sExecutor.status | () | Print details of specific MARO Resources (redis only at this time).
Returns:
None.
| Print details of specific MARO Resources (redis only at this time). | def status():
"""Print details of specific MARO Resources (redis only at this time).
Returns:
None.
"""
# Get resources
pod_list = client.CoreV1Api().list_pod_for_all_namespaces(watch=False).to_dict()["items"]
# Build return status
return_status = {
... | [
"def",
"status",
"(",
")",
":",
"# Get resources",
"pod_list",
"=",
"client",
".",
"CoreV1Api",
"(",
")",
".",
"list_pod_for_all_namespaces",
"(",
"watch",
"=",
"False",
")",
".",
"to_dict",
"(",
")",
"[",
"\"items\"",
"]",
"# Build return status",
"return_sta... | [
459,
4
] | [
483,
9
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor._get_redis_private_ip_address | (pod_list: list) | Get private_ip_address of the redis.
Args:
pod_list (list):
Returns:
str: private_ip_address.
| Get private_ip_address of the redis. | def _get_redis_private_ip_address(pod_list: list) -> str:
"""Get private_ip_address of the redis.
Args:
pod_list (list):
Returns:
str: private_ip_address.
"""
for pod in pod_list:
if "app" in pod["metadata"]["labels"] and pod["metadata"]["lab... | [
"def",
"_get_redis_private_ip_address",
"(",
"pod_list",
":",
"list",
")",
"->",
"str",
":",
"for",
"pod",
"in",
"pod_list",
":",
"if",
"\"app\"",
"in",
"pod",
"[",
"\"metadata\"",
"]",
"[",
"\"labels\"",
"]",
"and",
"pod",
"[",
"\"metadata\"",
"]",
"[",
... | [
486,
4
] | [
498,
17
] | python | en | ['en', 'en', 'en'] | True |
K8sExecutor.template | (export_path: str) | Export deployment template of k8s mode.
Args:
export_path (str): location to export the templates.
Returns:
None.
| Export deployment template of k8s mode. | def template(export_path: str) -> None:
"""Export deployment template of k8s mode.
Args:
export_path (str): location to export the templates.
Returns:
None.
"""
command = f"cp {K8sPaths.ABS_MARO_K8S_LIB}/deployments/external/* {export_path}"
_ = ... | [
"def",
"template",
"(",
"export_path",
":",
"str",
")",
"->",
"None",
":",
"command",
"=",
"f\"cp {K8sPaths.ABS_MARO_K8S_LIB}/deployments/external/* {export_path}\"",
"_",
"=",
"Subprocess",
".",
"run",
"(",
"command",
"=",
"command",
")"
] | [
503,
4
] | [
513,
43
] | python | en | ['en', 'nl', 'en'] | True |
K8sExecutor.load_k8s_context | (self) | Load k8s context of the MARO cluster.
Different providers have different loading mechanisms,
but every override methods must invoke "config.load_kube_config()" at the very end.
Returns:
None.
| Load k8s context of the MARO cluster. | def load_k8s_context(self):
""" Load k8s context of the MARO cluster.
Different providers have different loading mechanisms,
but every override methods must invoke "config.load_kube_config()" at the very end.
Returns:
None.
"""
pass | [
"def",
"load_k8s_context",
"(",
"self",
")",
":",
"pass"
] | [
518,
4
] | [
527,
12
] | python | en | ['en', 'en', 'en'] | True |
ToonFlowHandler.logger | (self) | Return logger. | Return logger. | def logger(self) -> logging.Logger:
"""Return logger."""
return logging.getLogger(__name__) | [
"def",
"logger",
"(",
"self",
")",
"->",
"logging",
".",
"Logger",
":",
"return",
"logging",
".",
"getLogger",
"(",
"__name__",
")"
] | [
25,
4
] | [
27,
42
] | python | en | ['es', 'no', 'en'] | False |
ToonFlowHandler.async_oauth_create_entry | (self, data: Dict[str, Any]) | Test connection and load up agreements. | Test connection and load up agreements. | async def async_oauth_create_entry(self, data: Dict[str, Any]) -> Dict[str, Any]:
"""Test connection and load up agreements."""
self.data = data
toon = Toon(
token=self.data["token"]["access_token"],
session=async_get_clientsession(self.hass),
)
try:
... | [
"async",
"def",
"async_oauth_create_entry",
"(",
"self",
",",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"self",
".",
"data",
"=",
"data",
"toon",
"=",
"Toon",
"(",
"token",
"=",
"self",
... | [
29,
4
] | [
45,
48
] | python | en | ['en', 'en', 'en'] | True |
ToonFlowHandler.async_step_import | (
self, config: Optional[Dict[str, Any]] = None
) | Start a configuration flow based on imported data.
This step is merely here to trigger "discovery" when the `toon`
integration is listed in the user configuration, or when migrating from
the version 1 schema.
| Start a configuration flow based on imported data. | async def async_step_import(
self, config: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Start a configuration flow based on imported data.
This step is merely here to trigger "discovery" when the `toon`
integration is listed in the user configuration, or when migrating fr... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"config",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"config",
"is",
"not",
"None",
"and",
"CONF_MIG... | [
47,
4
] | [
63,
43
] | python | en | ['en', 'en', 'en'] | True |
ToonFlowHandler.async_step_agreement | (
self, user_input: Dict[str, Any] = None
) | Select Toon agreement to add. | Select Toon agreement to add. | async def async_step_agreement(
self, user_input: Dict[str, Any] = None
) -> Dict[str, Any]:
"""Select Toon agreement to add."""
if len(self.agreements) == 1:
return await self._create_entry(self.agreements[0])
agreements_list = [
f"{agreement.street} {agreem... | [
"async",
"def",
"async_step_agreement",
"(",
"self",
",",
"user_input",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"len",
"(",
"self",
".",
"agreements",
")",
"==",
"1",
":",
... | [
65,
4
] | [
86,
73
] | python | en | ['en', 'en', 'en'] | True |
SearchMobileNet.__init__ | (self,
width_stages=[24,40,80,96,192,320],
n_cell_stages=[4,4,4,4,4,1],
stride_stages=[2,2,2,1,2,1],
width_mult=1, n_classes=1000,
dropout_rate=0, bn_param=(0.1, 1e-3)) |
Parameters
----------
width_stages: str
width (output channels) of each cell stage in the block
n_cell_stages: str
number of cells in each cell stage
stride_strages: str
stride of each cell stage in the block
width_mult : int
... |
Parameters
----------
width_stages: str
width (output channels) of each cell stage in the block
n_cell_stages: str
number of cells in each cell stage
stride_strages: str
stride of each cell stage in the block
width_mult : int
... | def __init__(self,
width_stages=[24,40,80,96,192,320],
n_cell_stages=[4,4,4,4,4,1],
stride_stages=[2,2,2,1,2,1],
width_mult=1, n_classes=1000,
dropout_rate=0, bn_param=(0.1, 1e-3)):
"""
Parameters
----------
... | [
"def",
"__init__",
"(",
"self",
",",
"width_stages",
"=",
"[",
"24",
",",
"40",
",",
"80",
",",
"96",
",",
"192",
",",
"320",
"]",
",",
"n_cell_stages",
"=",
"[",
"4",
",",
"4",
",",
"4",
",",
"4",
",",
"4",
",",
"1",
"]",
",",
"stride_stages... | [
9,
4
] | [
87,
64
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass, config) | Set up the versasense component. | Set up the versasense component. | async def async_setup(hass, config):
"""Set up the versasense component."""
session = aiohttp_client.async_get_clientsession(hass)
consumer = pyv.Consumer(config[DOMAIN]["host"], session)
hass.data[DOMAIN] = {KEY_CONSUMER: consumer}
await _configure_entities(hass, config, consumer)
# Return b... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"session",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"consumer",
"=",
"pyv",
".",
"Consumer",
"(",
"config",
"[",
"DOMAIN",
"]",
"[",
"\"host\"",
"]",
",",
... | [
32,
0
] | [
42,
15
] | python | en | ['en', 'ky', 'en'] | True |
_configure_entities | (hass, config, consumer) | Fetch all devices with their peripherals for representation. | Fetch all devices with their peripherals for representation. | async def _configure_entities(hass, config, consumer):
"""Fetch all devices with their peripherals for representation."""
devices = await consumer.fetchDevices()
_LOGGER.debug(devices)
sensor_info_list = []
switch_info_list = []
for mac, device in devices.items():
_LOGGER.info("Device ... | [
"async",
"def",
"_configure_entities",
"(",
"hass",
",",
"config",
",",
"consumer",
")",
":",
"devices",
"=",
"await",
"consumer",
".",
"fetchDevices",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"devices",
")",
"sensor_info_list",
"=",
"[",
"]",
"switch_info_li... | [
45,
0
] | [
73,
64
] | python | en | ['en', 'en', 'en'] | True |
_add_entity_info_to_list | (peripheral, device, entity_info_list) | Add info from a peripheral to specified list. | Add info from a peripheral to specified list. | def _add_entity_info_to_list(peripheral, device, entity_info_list):
"""Add info from a peripheral to specified list."""
for measurement in peripheral.measurements:
entity_info = {
KEY_IDENTIFIER: peripheral.identifier,
KEY_UNIT: measurement.unit,
KEY_MEASUREMENT: meas... | [
"def",
"_add_entity_info_to_list",
"(",
"peripheral",
",",
"device",
",",
"entity_info_list",
")",
":",
"for",
"measurement",
"in",
"peripheral",
".",
"measurements",
":",
"entity_info",
"=",
"{",
"KEY_IDENTIFIER",
":",
"peripheral",
".",
"identifier",
",",
"KEY_U... | [
76,
0
] | [
89,
27
] | python | en | ['en', 'en', 'en'] | True |
_load_platform | (hass, config, entity_type, entity_info_list) | Load platform with list of entity info. | Load platform with list of entity info. | def _load_platform(hass, config, entity_type, entity_info_list):
"""Load platform with list of entity info."""
hass.async_create_task(
async_load_platform(hass, entity_type, DOMAIN, entity_info_list, config)
) | [
"def",
"_load_platform",
"(",
"hass",
",",
"config",
",",
"entity_type",
",",
"entity_info_list",
")",
":",
"hass",
".",
"async_create_task",
"(",
"async_load_platform",
"(",
"hass",
",",
"entity_type",
",",
"DOMAIN",
",",
"entity_info_list",
",",
"config",
")",... | [
92,
0
] | [
96,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Xiaomi sensor from a config entry. | Set up the Xiaomi sensor from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Xiaomi sensor from a config entry."""
entities = []
if config_entry.data[CONF_FLOW_TYPE] == CONF_GATEWAY:
gateway = hass.data[DOMAIN][config_entry.entry_id]
# Gateway illuminance sensor
if gateway.mod... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"if",
"config_entry",
".",
"data",
"[",
"CONF_FLOW_TYPE",
"]",
"==",
"CONF_GATEWAY",
":",
"gateway",
"=",
"hass",
".",
"dat... | [
85,
0
] | [
119,
56
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the sensor from config. | Set up the sensor from config. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the sensor from config."""
if DATA_KEY not in hass.data:
hass.data[DATA_KEY] = {}
host = config[CONF_HOST]
token = config[CONF_TOKEN]
name = config[CONF_NAME]
_LOGGER.info("Initializing wit... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"DATA_KEY",
"not",
"in",
"hass",
".",
"data",
":",
"hass",
".",
"data",
"[",
"DATA_KEY",
"]",
"=",
"{",
"}"... | [
122,
0
] | [
149,
56
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.__init__ | (self, name, device, model, unique_id) | Initialize the entity. | Initialize the entity. | def __init__(self, name, device, model, unique_id):
"""Initialize the entity."""
self._name = name
self._device = device
self._model = model
self._unique_id = unique_id
self._icon = "mdi:cloud"
self._unit_of_measurement = "AQI"
self._available = None
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device",
",",
"model",
",",
"unique_id",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_model",
"=",
"model",
"self",
".",
"_unique_id",
"=",
"uniq... | [
155,
4
] | [
176,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.unique_id | (self) | Return an unique ID. | Return an unique ID. | def unique_id(self):
"""Return an unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
179,
4
] | [
181,
30
] | python | fr | ['fr', 'fr', 'en'] | True |
XiaomiAirQualityMonitor.name | (self) | Return the name of this entity, if any. | Return the name of this entity, if any. | def name(self):
"""Return the name of this entity, if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
184,
4
] | [
186,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
189,
4
] | [
191,
40
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.icon | (self) | Return the icon to use for device if any. | Return the icon to use for device if any. | def icon(self):
"""Return the icon to use for device if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
194,
4
] | [
196,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.available | (self) | Return true when state is known. | Return true when state is known. | def available(self):
"""Return true when state is known."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
199,
4
] | [
201,
30
] | python | en | ['en', 'de', 'en'] | True |
XiaomiAirQualityMonitor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
204,
4
] | [
206,
26
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return self._state_attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state_attrs"
] | [
209,
4
] | [
211,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirQualityMonitor.async_update | (self) | Fetch state from the miio device. | Fetch state from the miio device. | async def async_update(self):
"""Fetch state from the miio device."""
try:
state = await self.hass.async_add_executor_job(self._device.status)
_LOGGER.debug("Got new state: %s", state)
self._available = True
self._state = state.aqi
self._state... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"state",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_device",
".",
"status",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Got new state: %s\"",
",",
"stat... | [
213,
4
] | [
237,
79
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewaySensor.__init__ | (self, sub_device, entry, data_key) | Initialize the XiaomiSensor. | Initialize the XiaomiSensor. | def __init__(self, sub_device, entry, data_key):
"""Initialize the XiaomiSensor."""
super().__init__(sub_device, entry)
self._data_key = data_key
self._unique_id = f"{sub_device.sid}-{data_key}"
self._name = f"{data_key} ({sub_device.sid})".capitalize() | [
"def",
"__init__",
"(",
"self",
",",
"sub_device",
",",
"entry",
",",
"data_key",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"sub_device",
",",
"entry",
")",
"self",
".",
"_data_key",
"=",
"data_key",
"self",
".",
"_unique_id",
"=",
"f\"{sub_devi... | [
243,
4
] | [
248,
66
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewaySensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return GATEWAY_SENSOR_TYPES[self._data_key].icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"GATEWAY_SENSOR_TYPES",
"[",
"self",
".",
"_data_key",
"]",
".",
"icon"
] | [
251,
4
] | [
253,
56
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewaySensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return GATEWAY_SENSOR_TYPES[self._data_key].unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"GATEWAY_SENSOR_TYPES",
"[",
"self",
".",
"_data_key",
"]",
".",
"unit"
] | [
256,
4
] | [
258,
56
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewaySensor.device_class | (self) | Return the device class of this entity. | Return the device class of this entity. | def device_class(self):
"""Return the device class of this entity."""
return GATEWAY_SENSOR_TYPES[self._data_key].device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"GATEWAY_SENSOR_TYPES",
"[",
"self",
".",
"_data_key",
"]",
".",
"device_class"
] | [
261,
4
] | [
263,
64
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewaySensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._sub_device.status[self._data_key] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sub_device",
".",
"status",
"[",
"self",
".",
"_data_key",
"]"
] | [
266,
4
] | [
268,
54
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.__init__ | (self, gateway_device, gateway_name, gateway_device_id) | Initialize the entity. | Initialize the entity. | def __init__(self, gateway_device, gateway_name, gateway_device_id):
"""Initialize the entity."""
self._gateway = gateway_device
self._name = f"{gateway_name} Illuminance"
self._gateway_device_id = gateway_device_id
self._unique_id = f"{gateway_device_id}-illuminance"
sel... | [
"def",
"__init__",
"(",
"self",
",",
"gateway_device",
",",
"gateway_name",
",",
"gateway_device_id",
")",
":",
"self",
".",
"_gateway",
"=",
"gateway_device",
"self",
".",
"_name",
"=",
"f\"{gateway_name} Illuminance\"",
"self",
".",
"_gateway_device_id",
"=",
"g... | [
274,
4
] | [
281,
26
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.unique_id | (self) | Return an unique ID. | Return an unique ID. | def unique_id(self):
"""Return an unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
284,
4
] | [
286,
30
] | python | fr | ['fr', 'fr', 'en'] | True |
XiaomiGatewayIlluminanceSensor.device_info | (self) | Return the device info of the gateway. | Return the device info of the gateway. | def device_info(self):
"""Return the device info of the gateway."""
return {
"identifiers": {(DOMAIN, self._gateway_device_id)},
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_gateway_device_id",
")",
"}",
",",
"}"
] | [
289,
4
] | [
293,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.name | (self) | Return the name of this entity, if any. | Return the name of this entity, if any. | def name(self):
"""Return the name of this entity, if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
296,
4
] | [
298,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.available | (self) | Return true when state is known. | Return true when state is known. | def available(self):
"""Return true when state is known."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
301,
4
] | [
303,
30
] | python | en | ['en', 'de', 'en'] | True |
XiaomiGatewayIlluminanceSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity. | Return the unit of measurement of this entity. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity."""
return LIGHT_LUX | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"LIGHT_LUX"
] | [
306,
4
] | [
308,
24
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.device_class | (self) | Return the device class of this entity. | Return the device class of this entity. | def device_class(self):
"""Return the device class of this entity."""
return DEVICE_CLASS_ILLUMINANCE | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_ILLUMINANCE"
] | [
311,
4
] | [
313,
39
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
316,
4
] | [
318,
26
] | python | en | ['en', 'en', 'en'] | True |
XiaomiGatewayIlluminanceSensor.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
try:
self._state = await self.hass.async_add_executor_job(
self._gateway.get_illumination
)
self._available = True
except GatewayException as ex:
if self._available:
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_gateway",
".",
"get_illumination",
")",
"self",
".",
"_available",
"=",
"True",
... | [
320,
4
] | [
332,
17
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the aREST sensor. | Set up the aREST sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the aREST sensor."""
resource = config[CONF_RESOURCE]
var_conf = config[CONF_MONITORED_VARIABLES]
pins = config[CONF_PINS]
try:
response = requests.get(resource, timeout=10).json()
except requests.exceptions.... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"resource",
"=",
"config",
"[",
"CONF_RESOURCE",
"]",
"var_conf",
"=",
"config",
"[",
"CONF_MONITORED_VARIABLES",
"]",
"pins",
"=",
"config"... | [
52,
0
] | [
123,
27
] | python | en | ['en', 'da', 'en'] | True |
ArestSensor.__init__ | (
self,
arest,
resource,
location,
name,
variable=None,
pin=None,
unit_of_measurement=None,
renderer=None,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
arest,
resource,
location,
name,
variable=None,
pin=None,
unit_of_measurement=None,
renderer=None,
):
"""Initialize the sensor."""
self.arest = arest
self._resource = resource
self._name = f"{... | [
"def",
"__init__",
"(",
"self",
",",
"arest",
",",
"resource",
",",
"location",
",",
"name",
",",
"variable",
"=",
"None",
",",
"pin",
"=",
"None",
",",
"unit_of_measurement",
"=",
"None",
",",
"renderer",
"=",
"None",
",",
")",
":",
"self",
".",
"ar... | [
129,
4
] | [
153,
69
] | python | en | ['en', 'en', 'en'] | True |
ArestSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
156,
4
] | [
158,
25
] | python | en | ['en', 'mi', 'en'] | True |
ArestSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
161,
4
] | [
163,
40
] | python | en | ['en', 'en', 'en'] | True |
ArestSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
values = self.arest.data
if "error" in values:
return values["error"]
value = self._renderer(values.get("value", values.get(self._variable, None)))
return value | [
"def",
"state",
"(",
"self",
")",
":",
"values",
"=",
"self",
".",
"arest",
".",
"data",
"if",
"\"error\"",
"in",
"values",
":",
"return",
"values",
"[",
"\"error\"",
"]",
"value",
"=",
"self",
".",
"_renderer",
"(",
"values",
".",
"get",
"(",
"\"val... | [
166,
4
] | [
174,
20
] | python | en | ['en', 'en', 'en'] | True |
ArestSensor.update | (self) | Get the latest data from aREST API. | Get the latest data from aREST API. | def update(self):
"""Get the latest data from aREST API."""
self.arest.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"arest",
".",
"update",
"(",
")"
] | [
176,
4
] | [
178,
27
] | python | en | ['en', 'en', 'en'] | True |
ArestSensor.available | (self) | Could the device be accessed during the last update call. | Could the device be accessed during the last update call. | def available(self):
"""Could the device be accessed during the last update call."""
return self.arest.available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"arest",
".",
"available"
] | [
181,
4
] | [
183,
35
] | python | en | ['en', 'en', 'en'] | True |
ArestData.__init__ | (self, resource, pin=None) | Initialize the data object. | Initialize the data object. | def __init__(self, resource, pin=None):
"""Initialize the data object."""
self._resource = resource
self._pin = pin
self.data = {}
self.available = True | [
"def",
"__init__",
"(",
"self",
",",
"resource",
",",
"pin",
"=",
"None",
")",
":",
"self",
".",
"_resource",
"=",
"resource",
"self",
".",
"_pin",
"=",
"pin",
"self",
".",
"data",
"=",
"{",
"}",
"self",
".",
"available",
"=",
"True"
] | [
189,
4
] | [
194,
29
] | python | en | ['en', 'en', 'en'] | True |
ArestData.update | (self) | Get the latest data from aREST device. | Get the latest data from aREST device. | def update(self):
"""Get the latest data from aREST device."""
try:
if self._pin is None:
response = requests.get(self._resource, timeout=10)
self.data = response.json()["variables"]
else:
try:
if str(self._pin[0... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_pin",
"is",
"None",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"_resource",
",",
"timeout",
"=",
"10",
")",
"self",
".",
"data",
"=",
"response",
".",
"... | [
197,
4
] | [
218,
34
] | python | en | ['en', 'en', 'en'] | True |
get_next_departure | (
schedule: Any,
start_station_id: Any,
end_station_id: Any,
offset: cv.time_period,
include_tomorrow: bool = False,
) | Get the next departure for the given schedule. | Get the next departure for the given schedule. | def get_next_departure(
schedule: Any,
start_station_id: Any,
end_station_id: Any,
offset: cv.time_period,
include_tomorrow: bool = False,
) -> dict:
"""Get the next departure for the given schedule."""
now = dt_util.now().replace(tzinfo=None) + offset
now_date = now.strftime(dt_util.DAT... | [
"def",
"get_next_departure",
"(",
"schedule",
":",
"Any",
",",
"start_station_id",
":",
"Any",
",",
"end_station_id",
":",
"Any",
",",
"offset",
":",
"cv",
".",
"time_period",
",",
"include_tomorrow",
":",
"bool",
"=",
"False",
",",
")",
"->",
"dict",
":",... | [
270,
0
] | [
479,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (
hass: HomeAssistantType,
config: ConfigType,
add_entities: Callable[[list], None],
discovery_info: Optional[DiscoveryInfoType] = None,
) | Set up the GTFS sensor. | Set up the GTFS sensor. | def setup_platform(
hass: HomeAssistantType,
config: ConfigType,
add_entities: Callable[[list], None],
discovery_info: Optional[DiscoveryInfoType] = None,
) -> None:
"""Set up the GTFS sensor."""
gtfs_dir = hass.config.path(DEFAULT_PATH)
data = config[CONF_DATA]
origin = config.get(CONF_... | [
"def",
"setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"add_entities",
":",
"Callable",
"[",
"[",
"list",
"]",
",",
"None",
"]",
",",
"discovery_info",
":",
"Optional",
"[",
"DiscoveryInfoType",
"]",
"=",
"None... | [
482,
0
] | [
516,
5
] | python | en | ['en', 'bg', 'en'] | True |
GTFSDepartureSensor.__init__ | (
self,
gtfs: Any,
name: Optional[Any],
origin: Any,
destination: Any,
offset: cv.time_period,
include_tomorrow: bool,
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self,
gtfs: Any,
name: Optional[Any],
origin: Any,
destination: Any,
offset: cv.time_period,
include_tomorrow: bool,
) -> None:
"""Initialize the sensor."""
self._pygtfs = gtfs
self.origin = origin
self.destination... | [
"def",
"__init__",
"(",
"self",
",",
"gtfs",
":",
"Any",
",",
"name",
":",
"Optional",
"[",
"Any",
"]",
",",
"origin",
":",
"Any",
",",
"destination",
":",
"Any",
",",
"offset",
":",
"cv",
".",
"time_period",
",",
"include_tomorrow",
":",
"bool",
","... | [
522,
4
] | [
553,
21
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
556,
4
] | [
558,
25
] | python | en | ['en', 'mi', 'en'] | True |
GTFSDepartureSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> Optional[str]: # type: ignore
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# type: ignore",
"return",
"self",
".",
"_state"
] | [
561,
4
] | [
563,
26
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
566,
4
] | [
568,
30
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self) -> dict:
"""Return the state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_attributes"
] | [
571,
4
] | [
573,
31
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self) -> str:
"""Icon to use in the frontend, if any."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_icon"
] | [
576,
4
] | [
578,
25
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.device_class | (self) | Return the class of this device. | Return the class of this device. | def device_class(self) -> str:
"""Return the class of this device."""
return DEVICE_CLASS_TIMESTAMP | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_TIMESTAMP"
] | [
581,
4
] | [
583,
37
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.update | (self) | Get the latest data from GTFS and update the states. | Get the latest data from GTFS and update the states. | def update(self) -> None:
"""Get the latest data from GTFS and update the states."""
with self.lock:
# Fetch valid stop information once
if not self._origin:
stops = self._pygtfs.stops_by_id(self.origin)
if not stops:
self._avai... | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"with",
"self",
".",
"lock",
":",
"# Fetch valid stop information once",
"if",
"not",
"self",
".",
"_origin",
":",
"stops",
"=",
"self",
".",
"_pygtfs",
".",
"stops_by_id",
"(",
"self",
".",
"origin",
... | [
585,
4
] | [
668,
50
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.update_attributes | (self) | Update state attributes. | Update state attributes. | def update_attributes(self) -> None:
"""Update state attributes."""
# Add departure information
if self._departure:
self._attributes[ATTR_ARRIVAL] = dt_util.as_utc(
self._departure["arrival_time"]
).isoformat()
self._attributes[ATTR_DAY] = sel... | [
"def",
"update_attributes",
"(",
"self",
")",
"->",
"None",
":",
"# Add departure information",
"if",
"self",
".",
"_departure",
":",
"self",
".",
"_attributes",
"[",
"ATTR_ARRIVAL",
"]",
"=",
"dt_util",
".",
"as_utc",
"(",
"self",
".",
"_departure",
"[",
"\... | [
670,
4
] | [
804,
36
] | python | en | ['en', 'co', 'en'] | True |
GTFSDepartureSensor.dict_for_table | (resource: Any) | Return a dictionary for the SQLAlchemy resource given. | Return a dictionary for the SQLAlchemy resource given. | def dict_for_table(resource: Any) -> dict:
"""Return a dictionary for the SQLAlchemy resource given."""
return {
col: getattr(resource, col) for col in resource.__table__.columns.keys()
} | [
"def",
"dict_for_table",
"(",
"resource",
":",
"Any",
")",
"->",
"dict",
":",
"return",
"{",
"col",
":",
"getattr",
"(",
"resource",
",",
"col",
")",
"for",
"col",
"in",
"resource",
".",
"__table__",
".",
"columns",
".",
"keys",
"(",
")",
"}"
] | [
807,
4
] | [
811,
9
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.append_keys | (self, resource: dict, prefix: Optional[str] = None) | Properly format key val pairs to append to attributes. | Properly format key val pairs to append to attributes. | def append_keys(self, resource: dict, prefix: Optional[str] = None) -> None:
"""Properly format key val pairs to append to attributes."""
for attr, val in resource.items():
if val == "" or val is None or attr == "feed_id":
continue
key = attr
if prefix... | [
"def",
"append_keys",
"(",
"self",
",",
"resource",
":",
"dict",
",",
"prefix",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"for",
"attr",
",",
"val",
"in",
"resource",
".",
"items",
"(",
")",
":",
"if",
"val",
"==",
"\... | [
813,
4
] | [
822,
39
] | python | en | ['en', 'en', 'en'] | True |
GTFSDepartureSensor.remove_keys | (self, prefix: str) | Remove attributes whose key starts with prefix. | Remove attributes whose key starts with prefix. | def remove_keys(self, prefix: str) -> None:
"""Remove attributes whose key starts with prefix."""
self._attributes = {
k: v for k, v in self._attributes.items() if not k.startswith(prefix)
} | [
"def",
"remove_keys",
"(",
"self",
",",
"prefix",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_attributes",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_attributes",
".",
"items",
"(",
")",
"if",
"not",
"k",
".",
"s... | [
824,
4
] | [
828,
9
] | python | en | ['en', 'it', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the MCP23017 devices. | Set up the MCP23017 devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the MCP23017 devices."""
invert_logic = config.get(CONF_INVERT_LOGIC)
i2c_address = config.get(CONF_I2C_ADDRESS)
i2c = busio.I2C(board.SCL, board.SDA)
mcp = MCP23017(i2c, address=i2c_address)
switches = []
pins ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"invert_logic",
"=",
"config",
".",
"get",
"(",
"CONF_INVERT_LOGIC",
")",
"i2c_address",
"=",
"config",
".",
"get",
"(",
"CONF_I2C_ADDRESS",... | [
31,
0
] | [
44,
26
] | python | en | ['en', 'en', 'en'] | True |
MCP23017Switch.__init__ | (self, name, pin, invert_logic) | Initialize the pin. | Initialize the pin. | def __init__(self, name, pin, invert_logic):
"""Initialize the pin."""
self._name = name or DEVICE_DEFAULT_NAME
self._pin = pin
self._invert_logic = invert_logic
self._state = False
self._pin.direction = digitalio.Direction.OUTPUT
self._pin.value = self._invert_l... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"pin",
",",
"invert_logic",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"DEVICE_DEFAULT_NAME",
"self",
".",
"_pin",
"=",
"pin",
"self",
".",
"_invert_logic",
"=",
"invert_logic",
"self",
".",
"_sta... | [
50,
4
] | [
58,
44
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.