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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ResourceController.get_allocation_plan | (allocation_details: dict, required_resources: list, free_resources: list) | Get container allocation mapping.
Args:
allocation_details (dict): Details of allocation config.
required_resources (list): List of ContainerResource.
free_resources (list): List of NodeResource.
Returns:
dict: container_name to node_name mapping.
... | Get container allocation mapping. | def get_allocation_plan(allocation_details: dict, required_resources: list, free_resources: list) -> dict:
"""Get container allocation mapping.
Args:
allocation_details (dict): Details of allocation config.
required_resources (list): List of ContainerResource.
free_r... | [
"def",
"get_allocation_plan",
"(",
"allocation_details",
":",
"dict",
",",
"required_resources",
":",
"list",
",",
"free_resources",
":",
"list",
")",
"->",
"dict",
":",
"if",
"allocation_details",
"[",
"\"mode\"",
"]",
"==",
"\"single-metric-balanced\"",
":",
"re... | [
802,
4
] | [
826,
70
] | python | en | ['en', 'en', 'en'] | True |
ResourceController._get_single_metric_compacted_allocation_plan | (
allocation_details: dict,
required_resources: list, free_resources: list
) | Get single_metric_compacted allocation plan.
The strategy uses a specific metric as the priority,
then use a greedy approach to match the container to the available node
with the smallest remaining free resource.
Args:
allocation_details (dict): Details of allocation config... | Get single_metric_compacted allocation plan. | def _get_single_metric_compacted_allocation_plan(
allocation_details: dict,
required_resources: list, free_resources: list
) -> dict:
"""Get single_metric_compacted allocation plan.
The strategy uses a specific metric as the priority,
then use a greedy approach to match the ... | [
"def",
"_get_single_metric_compacted_allocation_plan",
"(",
"allocation_details",
":",
"dict",
",",
"required_resources",
":",
"list",
",",
"free_resources",
":",
"list",
")",
"->",
"dict",
":",
"# Init params.",
"allocation_plan",
"=",
"{",
"}",
"if",
"\"metric\"",
... | [
829,
4
] | [
918,
30
] | python | en | ['en', 'en', 'en'] | True |
ResourceController._get_single_metric_balanced_allocation_plan | (
allocation_details: dict,
required_resources: list, free_resources: list
) | Get single_metric_balanced allocation plan.
The strategy uses a specific metric as the priority,
then use a greedy approach to match the container to the available node
with the largest remaining free resource.
Args:
allocation_details (dict): Details of allocation config.
... | Get single_metric_balanced allocation plan. | def _get_single_metric_balanced_allocation_plan(
allocation_details: dict,
required_resources: list, free_resources: list
) -> dict:
"""Get single_metric_balanced allocation plan.
The strategy uses a specific metric as the priority,
then use a greedy approach to match the co... | [
"def",
"_get_single_metric_balanced_allocation_plan",
"(",
"allocation_details",
":",
"dict",
",",
"required_resources",
":",
"list",
",",
"free_resources",
":",
"list",
")",
"->",
"dict",
":",
"# Init params.",
"allocation_plan",
"=",
"{",
"}",
"if",
"\"metric\"",
... | [
921,
4
] | [
1010,
30
] | python | en | ['en', 'zh', 'en'] | True |
ResourceController.get_free_resources | (redis_controller: RedisController, cluster_name: str) | Get free resources of nodes in cluster.
Args:
redis_controller (RedisController): RedisController of the agent.
cluster_name (str): Name of the cluster.
Returns:
list: List of NodeResource.
| Get free resources of nodes in cluster. | def get_free_resources(redis_controller: RedisController, cluster_name: str) -> list:
"""Get free resources of nodes in cluster.
Args:
redis_controller (RedisController): RedisController of the agent.
cluster_name (str): Name of the cluster.
Returns:
list: L... | [
"def",
"get_free_resources",
"(",
"redis_controller",
":",
"RedisController",
",",
"cluster_name",
":",
"str",
")",
"->",
"list",
":",
"# Load details.",
"name_to_node_details",
"=",
"redis_controller",
".",
"get_name_to_node_details",
"(",
")",
"# Get free resources.",
... | [
1013,
4
] | [
1046,
34
] | python | en | ['en', 'en', 'en'] | True |
ResourceController.get_required_resources | (job_details: dict) | Get required resources from job_details.
Args:
job_details: Details of jobs.
Returns:
list: List of ContainerResource.
| Get required resources from job_details. | def get_required_resources(job_details: dict) -> list:
"""Get required resources from job_details.
Args:
job_details: Details of jobs.
Returns:
list: List of ContainerResource.
"""
# Load configs.
type_to_component_details = job_details["componen... | [
"def",
"get_required_resources",
"(",
"job_details",
":",
"dict",
")",
"->",
"list",
":",
"# Load configs.",
"type_to_component_details",
"=",
"job_details",
"[",
"\"components\"",
"]",
"job_id",
"=",
"job_details",
"[",
"\"id\"",
"]",
"# Get required resources.",
"re... | [
1049,
4
] | [
1080,
29
] | python | en | ['en', 'en', 'en'] | True |
ContainerController.build_container_name | (job_id: str, component_id: str, component_index: int) | Build the container name with job-related params.
Ref: The container name must be from 1 to 255 characters long.
Args:
job_id: The Id of the job.
component_id: The Id of the component.
component_index: The index of the current component.
Returns:
... | Build the container name with job-related params. | def build_container_name(job_id: str, component_id: str, component_index: int) -> str:
"""Build the container name with job-related params.
Ref: The container name must be from 1 to 255 characters long.
Args:
job_id: The Id of the job.
component_id: The Id of the compon... | [
"def",
"build_container_name",
"(",
"job_id",
":",
"str",
",",
"component_id",
":",
"str",
",",
"component_index",
":",
"int",
")",
"->",
"str",
":",
"return",
"f\"{job_id}-{component_id}-{component_index}-{uuid.uuid4().hex[:6]}\""
] | [
1088,
4
] | [
1101,
82
] | python | en | ['en', 'en', 'en'] | True |
JobController.get_component_id_to_component_type | (job_details: dict) | Get component_id_to_component_type mapping from job_details
Args:
job_details: Details of jobs.
Returns:
dict[str, str]: component_id_to_component_type mapping.
| Get component_id_to_component_type mapping from job_details | def get_component_id_to_component_type(job_details: dict) -> dict:
"""Get component_id_to_component_type mapping from job_details
Args:
job_details: Details of jobs.
Returns:
dict[str, str]: component_id_to_component_type mapping.
"""
# Load details.
... | [
"def",
"get_component_id_to_component_type",
"(",
"job_details",
":",
"dict",
")",
"->",
"dict",
":",
"# Load details.",
"type_to_component_details",
"=",
"job_details",
"[",
"\"components\"",
"]",
"# Get component_id_to_type.",
"component_id_to_component_type",
"=",
"{",
"... | [
1109,
4
] | [
1125,
45
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Random number sensor. | Set up the Random number sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Random number sensor."""
name = config.get(CONF_NAME)
minimum = config.get(CONF_MINIMUM)
maximum = config.get(CONF_MAXIMUM)
unit = config.get(CONF_UNIT_OF_MEASUREMENT)
async_add_entities([Random... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"minimum",
"=",
"config",
".",
"get",
"(",
"CONF_MINIMUM",
... | [
34,
0
] | [
41,
74
] | python | en | ['en', 'da', 'en'] | True |
RandomSensor.__init__ | (self, name, minimum, maximum, unit_of_measurement) | Initialize the Random sensor. | Initialize the Random sensor. | def __init__(self, name, minimum, maximum, unit_of_measurement):
"""Initialize the Random sensor."""
self._name = name
self._minimum = minimum
self._maximum = maximum
self._unit_of_measurement = unit_of_measurement
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"minimum",
",",
"maximum",
",",
"unit_of_measurement",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_minimum",
"=",
"minimum",
"self",
".",
"_maximum",
"=",
"maximum",
"self",
".",
"_unit_of... | [
47,
4
] | [
53,
26
] | python | en | ['en', 'pt', 'en'] | True |
RandomSensor.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
56,
4
] | [
58,
25
] | python | en | ['en', 'en', 'en'] | True |
RandomSensor.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"
] | [
61,
4
] | [
63,
26
] | python | en | ['en', 'en', 'en'] | True |
RandomSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
66,
4
] | [
68,
19
] | python | en | ['en', 'en', 'en'] | True |
RandomSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
71,
4
] | [
73,
40
] | python | en | ['en', 'en', 'en'] | True |
RandomSensor.device_state_attributes | (self) | Return the attributes of the sensor. | Return the attributes of the sensor. | def device_state_attributes(self):
"""Return the attributes of the sensor."""
return {ATTR_MAXIMUM: self._maximum, ATTR_MINIMUM: self._minimum} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_MAXIMUM",
":",
"self",
".",
"_maximum",
",",
"ATTR_MINIMUM",
":",
"self",
".",
"_minimum",
"}"
] | [
76,
4
] | [
78,
73
] | python | en | ['en', 'en', 'en'] | True |
RandomSensor.async_update | (self) | Get a new number and updates the states. | Get a new number and updates the states. | async def async_update(self):
"""Get a new number and updates the states."""
self._state = randrange(self._minimum, self._maximum + 1) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"randrange",
"(",
"self",
".",
"_minimum",
",",
"self",
".",
"_maximum",
"+",
"1",
")"
] | [
80,
4
] | [
83,
65
] | python | en | ['en', 'en', 'en'] | True |
async_attach_trigger | (hass, config, action, automation_info) | Listen for state changes based on configuration. | Listen for state changes based on configuration. | async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
topic = config[CONF_TOPIC]
payload = config.get(CONF_PAYLOAD)
encoding = config[CONF_ENCODING] or None
qos = config[CONF_QOS]
job = HassJob(action)
@callback
def... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
")",
":",
"topic",
"=",
"config",
"[",
"CONF_TOPIC",
"]",
"payload",
"=",
"config",
".",
"get",
"(",
"CONF_PAYLOAD",
")",
"encoding",
"=",
"config",
... | [
31,
0
] | [
61,
17
] | python | en | ['en', 'en', 'en'] | True |
create_upnp_datagram_endpoint | (
host_ip_addr,
upnp_bind_multicast,
advertise_ip,
advertise_port,
) | Create the UPNP socket and protocol. | Create the UPNP socket and protocol. | def create_upnp_datagram_endpoint(
host_ip_addr,
upnp_bind_multicast,
advertise_ip,
advertise_port,
):
"""Create the UPNP socket and protocol."""
# Listen for UDP port 1900 packets sent to SSDP multicast address
ssdp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ssdp_socket.... | [
"def",
"create_upnp_datagram_endpoint",
"(",
"host_ip_addr",
",",
"upnp_bind_multicast",
",",
"advertise_ip",
",",
"advertise_port",
",",
")",
":",
"# Listen for UDP port 1900 packets sent to SSDP multicast address",
"ssdp_socket",
"=",
"socket",
".",
"socket",
"(",
"socket",... | [
58,
0
] | [
90,
5
] | python | en | ['en', 'en', 'en'] | True |
DescriptionXmlView.__init__ | (self, config) | Initialize the instance of the view. | Initialize the instance of the view. | def __init__(self, config):
"""Initialize the instance of the view."""
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config"
] | [
25,
4
] | [
27,
28
] | python | en | ['en', 'en', 'en'] | True |
DescriptionXmlView.get | (self, request) | Handle a GET request. | Handle a GET request. | def get(self, request):
"""Handle a GET request."""
resp_text = f"""<?xml version="1.0" encoding="UTF-8" ?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>http://{self.config.advertise_ip}:{self.config.advertise_port}/</URLBase>
<de... | [
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"resp_text",
"=",
"f\"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n<specVersion>\n<major>1</major>\n<minor>0</minor>\n</specVersion>\n<URLBase>http://{self.config.advertise_ip}:{self.config... | [
30,
4
] | [
54,
68
] | python | en | ['en', 'en', 'en'] | True |
UPNPResponderProtocol.__init__ | (self, loop, ssdp_socket, advertise_ip, advertise_port) | Initialize the class. | Initialize the class. | def __init__(self, loop, ssdp_socket, advertise_ip, advertise_port):
"""Initialize the class."""
self.transport = None
self._loop = loop
self._sock = ssdp_socket
self.advertise_ip = advertise_ip
self.advertise_port = advertise_port
self._upnp_root_response = self.... | [
"def",
"__init__",
"(",
"self",
",",
"loop",
",",
"ssdp_socket",
",",
"advertise_ip",
",",
"advertise_port",
")",
":",
"self",
".",
"transport",
"=",
"None",
"self",
".",
"_loop",
"=",
"loop",
"self",
".",
"_sock",
"=",
"ssdp_socket",
"self",
".",
"adver... | [
96,
4
] | [
108,
9
] | python | en | ['en', 'en', 'en'] | True |
UPNPResponderProtocol.connection_made | (self, transport) | Set the transport. | Set the transport. | def connection_made(self, transport):
"""Set the transport."""
self.transport = transport | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"transport",
"=",
"transport"
] | [
110,
4
] | [
112,
34
] | python | en | ['en', 'da', 'en'] | True |
UPNPResponderProtocol.connection_lost | (self, exc) | Handle connection lost. | Handle connection lost. | def connection_lost(self, exc):
"""Handle connection lost.""" | [
"def",
"connection_lost",
"(",
"self",
",",
"exc",
")",
":"
] | [
114,
4
] | [
115,
37
] | python | en | ['es', 'en', 'en'] | True |
UPNPResponderProtocol.datagram_received | (self, data, addr) | Respond to msearch packets. | Respond to msearch packets. | def datagram_received(self, data, addr):
"""Respond to msearch packets."""
decoded_data = data.decode("utf-8", errors="ignore")
if "M-SEARCH" not in decoded_data:
return
_LOGGER.debug("UPNP Responder M-SEARCH method received: %s", data)
# SSDP M-SEARCH method receiv... | [
"def",
"datagram_received",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"decoded_data",
"=",
"data",
".",
"decode",
"(",
"\"utf-8\"",
",",
"errors",
"=",
"\"ignore\"",
")",
"if",
"\"M-SEARCH\"",
"not",
"in",
"decoded_data",
":",
"return",
"_LOGGER",
"... | [
117,
4
] | [
128,
45
] | python | en | ['en', 'en', 'en'] | True |
UPNPResponderProtocol.error_received | (self, exc) | Log UPNP errors. | Log UPNP errors. | def error_received(self, exc): # pylint: disable=no-self-use
"""Log UPNP errors."""
_LOGGER.error("UPNP Error received: %s", exc) | [
"def",
"error_received",
"(",
"self",
",",
"exc",
")",
":",
"# pylint: disable=no-self-use",
"_LOGGER",
".",
"error",
"(",
"\"UPNP Error received: %s\"",
",",
"exc",
")"
] | [
130,
4
] | [
132,
53
] | python | da | ['da', 'no', 'en'] | False |
UPNPResponderProtocol.close | (self) | Stop the server. | Stop the server. | def close(self):
"""Stop the server."""
_LOGGER.info("UPNP responder shutting down")
if self.transport:
self.transport.close()
self._loop.remove_writer(self._sock.fileno())
self._loop.remove_reader(self._sock.fileno())
self._sock.close() | [
"def",
"close",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"UPNP responder shutting down\"",
")",
"if",
"self",
".",
"transport",
":",
"self",
".",
"transport",
".",
"close",
"(",
")",
"self",
".",
"_loop",
".",
"remove_writer",
"(",
"self",
"... | [
134,
4
] | [
141,
26
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Perform the setup for Fibaro controller devices. | Perform the setup for Fibaro controller devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Perform the setup for Fibaro controller devices."""
if discovery_info is None:
return
add_entities(
[FibaroThermostat(device) for device in hass.data[FIBARO_DEVICES]["climate"]],
True,
) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"add_entities",
"(",
"[",
"FibaroThermostat",
"(",
"device",
")",
"for",
"device",
"i... | [
95,
0
] | [
103,
5
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.__init__ | (self, fibaro_device) | Initialize the Fibaro device. | Initialize the Fibaro device. | def __init__(self, fibaro_device):
"""Initialize the Fibaro device."""
super().__init__(fibaro_device)
self._temp_sensor_device = None
self._target_temp_device = None
self._op_mode_device = None
self._fan_mode_device = None
self._support_flags = 0
self.ent... | [
"def",
"__init__",
"(",
"self",
",",
"fibaro_device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"fibaro_device",
")",
"self",
".",
"_temp_sensor_device",
"=",
"None",
"self",
".",
"_target_temp_device",
"=",
"None",
"self",
".",
"_op_mode_device",
"... | [
109,
4
] | [
189,
69
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
_LOGGER.debug(
"Climate %s\n"
"- _temp_sensor_device %s\n"
"- _target_temp_device %s\n"
"- _op_mode_device %s\n"
"- _fan_mode_device %s",
self.ha_id,
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Climate %s\\n\"",
"\"- _temp_sensor_device %s\\n\"",
"\"- _target_temp_device %s\\n\"",
"\"- _op_mode_device %s\\n\"",
"\"- _fan_mode_device %s\"",
",",
"self",
".",
"ha_id",
",",
... | [
191,
4
] | [
211,
74
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self):
"""Return the list of supported features."""
return self._support_flags | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_support_flags"
] | [
214,
4
] | [
216,
34
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.fan_modes | (self) | Return the list of available fan modes. | Return the list of available fan modes. | def fan_modes(self):
"""Return the list of available fan modes."""
if not self._fan_mode_device:
return None
return self._fan_support | [
"def",
"fan_modes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_fan_mode_device",
":",
"return",
"None",
"return",
"self",
".",
"_fan_support"
] | [
219,
4
] | [
223,
32
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.fan_mode | (self) | Return the fan setting. | Return the fan setting. | def fan_mode(self):
"""Return the fan setting."""
if not self._fan_mode_device:
return None
mode = int(self._fan_mode_device.fibaro_device.properties.mode)
return FANMODES[mode] | [
"def",
"fan_mode",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_fan_mode_device",
":",
"return",
"None",
"mode",
"=",
"int",
"(",
"self",
".",
"_fan_mode_device",
".",
"fibaro_device",
".",
"properties",
".",
"mode",
")",
"return",
"FANMODES",
"[",
... | [
226,
4
] | [
231,
29
] | python | en | ['en', 'fy', 'en'] | True |
FibaroThermostat.set_fan_mode | (self, fan_mode) | Set new target fan mode. | Set new target fan mode. | def set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
if not self._fan_mode_device:
return
self._fan_mode_device.action("setFanMode", HA_FANMODES[fan_mode]) | [
"def",
"set_fan_mode",
"(",
"self",
",",
"fan_mode",
")",
":",
"if",
"not",
"self",
".",
"_fan_mode_device",
":",
"return",
"self",
".",
"_fan_mode_device",
".",
"action",
"(",
"\"setFanMode\"",
",",
"HA_FANMODES",
"[",
"fan_mode",
"]",
")"
] | [
233,
4
] | [
237,
73
] | python | en | ['sv', 'fy', 'en'] | False |
FibaroThermostat.fibaro_op_mode | (self) | Return the operating mode of the device. | Return the operating mode of the device. | def fibaro_op_mode(self):
"""Return the operating mode of the device."""
if not self._op_mode_device:
return 3 # Default to AUTO
if "operatingMode" in self._op_mode_device.fibaro_device.properties:
return int(self._op_mode_device.fibaro_device.properties.operatingMode)
... | [
"def",
"fibaro_op_mode",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_op_mode_device",
":",
"return",
"3",
"# Default to AUTO",
"if",
"\"operatingMode\"",
"in",
"self",
".",
"_op_mode_device",
".",
"fibaro_device",
".",
"properties",
":",
"return",
"int",
... | [
240,
4
] | [
248,
70
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.hvac_mode | (self) | Return current operation ie. heat, cool, idle. | Return current operation ie. heat, cool, idle. | def hvac_mode(self):
"""Return current operation ie. heat, cool, idle."""
return OPMODES_HVAC[self.fibaro_op_mode] | [
"def",
"hvac_mode",
"(",
"self",
")",
":",
"return",
"OPMODES_HVAC",
"[",
"self",
".",
"fibaro_op_mode",
"]"
] | [
251,
4
] | [
253,
48
] | python | en | ['nl', 'en', 'en'] | True |
FibaroThermostat.hvac_modes | (self) | Return the list of available operation modes. | Return the list of available operation modes. | def hvac_modes(self):
"""Return the list of available operation modes."""
if not self._op_mode_device:
return [HVAC_MODE_AUTO] # Default to this
return self._hvac_support | [
"def",
"hvac_modes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_op_mode_device",
":",
"return",
"[",
"HVAC_MODE_AUTO",
"]",
"# Default to this",
"return",
"self",
".",
"_hvac_support"
] | [
256,
4
] | [
260,
33
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.set_hvac_mode | (self, hvac_mode) | Set new target operation mode. | Set new target operation mode. | def set_hvac_mode(self, hvac_mode):
"""Set new target operation mode."""
if not self._op_mode_device:
return
if self.preset_mode:
return
if "setOperatingMode" in self._op_mode_device.fibaro_device.actions:
self._op_mode_device.action("setOperatingMode... | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
")",
":",
"if",
"not",
"self",
".",
"_op_mode_device",
":",
"return",
"if",
"self",
".",
"preset_mode",
":",
"return",
"if",
"\"setOperatingMode\"",
"in",
"self",
".",
"_op_mode_device",
".",
"fibaro_devic... | [
262,
4
] | [
272,
78
] | python | en | ['nl', 'en', 'en'] | True |
FibaroThermostat.preset_mode | (self) | Return the current preset mode, e.g., home, away, temp.
Requires SUPPORT_PRESET_MODE.
| Return the current preset mode, e.g., home, away, temp. | def preset_mode(self):
"""Return the current preset mode, e.g., home, away, temp.
Requires SUPPORT_PRESET_MODE.
"""
if not self._op_mode_device:
return None
if "operatingMode" in self._op_mode_device.fibaro_device.properties:
mode = int(self._op_mode_dev... | [
"def",
"preset_mode",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_op_mode_device",
":",
"return",
"None",
"if",
"\"operatingMode\"",
"in",
"self",
".",
"_op_mode_device",
".",
"fibaro_device",
".",
"properties",
":",
"mode",
"=",
"int",
"(",
"self",
... | [
275,
4
] | [
290,
35
] | python | en | ['en', 'pt', 'en'] | True |
FibaroThermostat.preset_modes | (self) | Return a list of available preset modes.
Requires SUPPORT_PRESET_MODE.
| Return a list of available preset modes. | def preset_modes(self):
"""Return a list of available preset modes.
Requires SUPPORT_PRESET_MODE.
"""
if not self._op_mode_device:
return None
return self._preset_support | [
"def",
"preset_modes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_op_mode_device",
":",
"return",
"None",
"return",
"self",
".",
"_preset_support"
] | [
293,
4
] | [
300,
35
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.set_preset_mode | (self, preset_mode: str) | Set new preset mode. | Set new preset mode. | def set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
if self._op_mode_device is None:
return
if "setOperatingMode" in self._op_mode_device.fibaro_device.actions:
self._op_mode_device.action(
"setOperatingMode", HA_OPMODES_PRESET[... | [
"def",
"set_preset_mode",
"(",
"self",
",",
"preset_mode",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"_op_mode_device",
"is",
"None",
":",
"return",
"if",
"\"setOperatingMode\"",
"in",
"self",
".",
"_op_mode_device",
".",
"fibaro_device",
".",
"... | [
302,
4
] | [
311,
82
] | python | en | ['en', 'sr', 'en'] | True |
FibaroThermostat.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self):
"""Return the unit of measurement."""
return self._unit_of_temp | [
"def",
"temperature_unit",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_temp"
] | [
314,
4
] | [
316,
33
] | python | en | ['en', 'la', 'en'] | True |
FibaroThermostat.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self):
"""Return the current temperature."""
if self._temp_sensor_device:
device = self._temp_sensor_device.fibaro_device
if "heatingThermostatSetpoint" in device.properties:
return float(device.properties.heatingThermostatSetpoint)
... | [
"def",
"current_temperature",
"(",
"self",
")",
":",
"if",
"self",
".",
"_temp_sensor_device",
":",
"device",
"=",
"self",
".",
"_temp_sensor_device",
".",
"fibaro_device",
"if",
"\"heatingThermostatSetpoint\"",
"in",
"device",
".",
"properties",
":",
"return",
"f... | [
319,
4
] | [
326,
19
] | python | en | ['en', 'la', 'en'] | True |
FibaroThermostat.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self):
"""Return the temperature we try to reach."""
if self._target_temp_device:
device = self._target_temp_device.fibaro_device
if "heatingThermostatSetpointFuture" in device.properties:
return float(device.properties.heatingThermostatSetp... | [
"def",
"target_temperature",
"(",
"self",
")",
":",
"if",
"self",
".",
"_target_temp_device",
":",
"device",
"=",
"self",
".",
"_target_temp_device",
".",
"fibaro_device",
"if",
"\"heatingThermostatSetpointFuture\"",
"in",
"device",
".",
"properties",
":",
"return",... | [
329,
4
] | [
336,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroThermostat.set_temperature | (self, **kwargs) | Set new target temperatures. | Set new target temperatures. | def set_temperature(self, **kwargs):
"""Set new target temperatures."""
temperature = kwargs.get(ATTR_TEMPERATURE)
target = self._target_temp_device
if temperature is not None:
if "setThermostatSetpoint" in target.fibaro_device.actions:
target.action("setTherm... | [
"def",
"set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"target",
"=",
"self",
".",
"_target_temp_device",
"if",
"temperature",
"is",
"not",
"None",
":",
"if",
"\"set... | [
338,
4
] | [
348,
60
] | python | en | ['en', 'ca', 'en'] | True |
async_attach_trigger | (
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: dict,
) | Listen for state changes based on configuration. | Listen for state changes based on configuration. | async def async_attach_trigger(
hass: HomeAssistant,
config: ConfigType,
action: AutomationActionType,
automation_info: dict,
) -> CALLBACK_TYPE:
"""Listen for state changes based on configuration."""
return await toggle_entity.async_attach_trigger(
hass, config, action, automation_info
... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"action",
":",
"AutomationActionType",
",",
"automation_info",
":",
"dict",
",",
")",
"->",
"CALLBACK_TYPE",
":",
"return",
"await",
"toggle_entity",
... | [
18,
0
] | [
27,
5
] | python | en | ['en', 'en', 'en'] | True |
async_get_triggers | (hass: HomeAssistant, device_id: str) | List device triggers. | List device triggers. | async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device triggers."""
return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN) | [
"async",
"def",
"async_get_triggers",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"await",
"toggle_entity",
".",
"async_get_triggers",
"(",
"hass",
",",
"device_id",
",",
"DOMAIN",
")"
... | [
30,
0
] | [
32,
74
] | python | en | ['fr', 'en', 'en'] | True |
async_get_trigger_capabilities | (hass: HomeAssistant, config: dict) | List trigger capabilities. | List trigger capabilities. | async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict:
"""List trigger capabilities."""
return await toggle_entity.async_get_trigger_capabilities(hass, config) | [
"async",
"def",
"async_get_trigger_capabilities",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
"->",
"dict",
":",
"return",
"await",
"toggle_entity",
".",
"async_get_trigger_capabilities",
"(",
"hass",
",",
"config",
")"
] | [
35,
0
] | [
37,
75
] | python | en | ['en', 'la', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) |
Set up the electricity price sensor from configuration.yaml.
```yaml
pvpc_hourly_pricing:
- name: PVPC manual ve
tariff: electric_car
- name: PVPC manual nocturna
tariff: discrimination
timeout: 3
```
|
Set up the electricity price sensor from configuration.yaml. | async def async_setup(hass: HomeAssistant, config: dict):
"""
Set up the electricity price sensor from configuration.yaml.
```yaml
pvpc_hourly_pricing:
- name: PVPC manual ve
tariff: electric_car
- name: PVPC manual nocturna
tariff: discrimination
timeout: 3
```
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"for",
"conf",
"in",
"config",
".",
"get",
"(",
"DOMAIN",
",",
"[",
"]",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entri... | [
21,
0
] | [
41,
15
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass: HomeAssistant, entry: config_entries.ConfigEntry) | Set up pvpc hourly pricing from a config entry. | Set up pvpc hourly pricing from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: config_entries.ConfigEntry):
"""Set up pvpc hourly pricing from a config entry."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, PLATFORM)
)
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_setup",
"(",
"entry",
",",
... | [
44,
0
] | [
50,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: config_entries.ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: config_entries.ConfigEntry):
"""Unload a config entry."""
return await hass.config_entries.async_forward_entry_unload(entry, PLATFORM) | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"return",
"await",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"PLATFORM",
")"
] | [
53,
0
] | [
55,
80
] | python | en | ['en', 'es', 'en'] | True |
generate_slurm_config_files | (
output_directory, template_directory, input_file, instance_types_data_path, dryrun, no_gpu
) |
Generate Slurm configuration files.
For each queue, generate slurm_parallelcluster_{QueueName}_partitions.conf
and slurm_parallelcluster_{QueueName}_gres.conf, which contain node info.
Generate slurm_parallelcluster.conf and slurm_parallelcluster_gres.conf,
which includes queue specifc configurat... |
Generate Slurm configuration files. | def generate_slurm_config_files(
output_directory, template_directory, input_file, instance_types_data_path, dryrun, no_gpu
):
"""
Generate Slurm configuration files.
For each queue, generate slurm_parallelcluster_{QueueName}_partitions.conf
and slurm_parallelcluster_{QueueName}_gres.conf, which co... | [
"def",
"generate_slurm_config_files",
"(",
"output_directory",
",",
"template_directory",
",",
"input_file",
",",
"instance_types_data_path",
",",
"dryrun",
",",
"no_gpu",
")",
":",
"# Make output directories",
"output_directory",
"=",
"path",
".",
"abspath",
"(",
"outp... | [
32,
0
] | [
84,
25
] | python | en | ['en', 'error', 'th'] | False |
_load_cluster_config | (input_file_path) |
Load queues_info and add information used to render templates.
:return: queues_info containing id for first queue, head_node_hostname and queue_name
|
Load queues_info and add information used to render templates. | def _load_cluster_config(input_file_path):
"""
Load queues_info and add information used to render templates.
:return: queues_info containing id for first queue, head_node_hostname and queue_name
"""
with open(input_file_path) as input_file:
return yaml.load(input_file, Loader=yaml.SafeLoad... | [
"def",
"_load_cluster_config",
"(",
"input_file_path",
")",
":",
"with",
"open",
"(",
"input_file_path",
")",
"as",
"input_file",
":",
"return",
"yaml",
".",
"load",
"(",
"input_file",
",",
"Loader",
"=",
"yaml",
".",
"SafeLoader",
")"
] | [
87,
0
] | [
94,
60
] | python | en | ['en', 'error', 'th'] | False |
_get_head_node_private_ip | () | Get head node private ip from EC2 metadata. | Get head node private ip from EC2 metadata. | def _get_head_node_private_ip():
"""Get head node private ip from EC2 metadata."""
return _get_metadata("local-ipv4") | [
"def",
"_get_head_node_private_ip",
"(",
")",
":",
"return",
"_get_metadata",
"(",
"\"local-ipv4\"",
")"
] | [
104,
0
] | [
106,
38
] | python | en | ['en', 'la', 'en'] | True |
_get_jinja_env | (template_directory) | Return jinja environment with trim_blocks/lstrip_blocks set to True. | Return jinja environment with trim_blocks/lstrip_blocks set to True. | def _get_jinja_env(template_directory):
"""Return jinja environment with trim_blocks/lstrip_blocks set to True."""
file_loader = FileSystemLoader(template_directory)
# A nosec comment is appended to the following line in order to disable the B701 check.
# The contents of the default templates are known ... | [
"def",
"_get_jinja_env",
"(",
"template_directory",
")",
":",
"file_loader",
"=",
"FileSystemLoader",
"(",
"template_directory",
")",
"# A nosec comment is appended to the following line in order to disable the B701 check.",
"# The contents of the default templates are known and the input ... | [
143,
0
] | [
155,
14
] | python | en | ['en', 'mt', 'en'] | True |
_gpu_count | (instance_type) | Return the number of GPUs for the instance. | Return the number of GPUs for the instance. | def _gpu_count(instance_type):
"""Return the number of GPUs for the instance."""
gpu_info = instance_types_data[instance_type].get("GpuInfo", None)
gpu_count = 0
if gpu_info:
for gpus in gpu_info.get("Gpus", []):
gpu_manufacturer = gpus.get("Manufacturer", "")
if gpu_man... | [
"def",
"_gpu_count",
"(",
"instance_type",
")",
":",
"gpu_info",
"=",
"instance_types_data",
"[",
"instance_type",
"]",
".",
"get",
"(",
"\"GpuInfo\"",
",",
"None",
")",
"gpu_count",
"=",
"0",
"if",
"gpu_info",
":",
"for",
"gpus",
"in",
"gpu_info",
".",
"g... | [
158,
0
] | [
175,
20
] | python | en | ['en', 'en', 'en'] | True |
_gpu_type | (instance_type) | Return name or type of the GPU for the instance. | Return name or type of the GPU for the instance. | def _gpu_type(instance_type):
"""Return name or type of the GPU for the instance."""
gpu_info = instance_types_data[instance_type].get("GpuInfo", None)
# Remove space and change to all lowercase for name
return "no_gpu_type" if not gpu_info else gpu_info.get("Gpus")[0].get("Name").replace(" ", "").lower... | [
"def",
"_gpu_type",
"(",
"instance_type",
")",
":",
"gpu_info",
"=",
"instance_types_data",
"[",
"instance_type",
"]",
".",
"get",
"(",
"\"GpuInfo\"",
",",
"None",
")",
"# Remove space and change to all lowercase for name",
"return",
"\"no_gpu_type\"",
"if",
"not",
"g... | [
178,
0
] | [
182,
106
] | python | en | ['en', 'en', 'en'] | True |
_vcpus | (compute_resource) | Get the number of vcpus for the instance according to disable_hyperthreading and instance features. | Get the number of vcpus for the instance according to disable_hyperthreading and instance features. | def _vcpus(compute_resource) -> int:
"""Get the number of vcpus for the instance according to disable_hyperthreading and instance features."""
instance_type = compute_resource["InstanceType"]
disable_simultaneous_multithreading = compute_resource["DisableSimultaneousMultithreading"]
instance_type_info =... | [
"def",
"_vcpus",
"(",
"compute_resource",
")",
"->",
"int",
":",
"instance_type",
"=",
"compute_resource",
"[",
"\"InstanceType\"",
"]",
"disable_simultaneous_multithreading",
"=",
"compute_resource",
"[",
"\"DisableSimultaneousMultithreading\"",
"]",
"instance_type_info",
... | [
185,
0
] | [
196,
104
] | python | en | ['en', 'en', 'en'] | True |
generate_instance_type_mapping_file | (output_dir, queues) | Generate a mapping file to retrieve the Instance Type related to the instance key used in the slurm nodename. | Generate a mapping file to retrieve the Instance Type related to the instance key used in the slurm nodename. | def generate_instance_type_mapping_file(output_dir, queues):
"""Generate a mapping file to retrieve the Instance Type related to the instance key used in the slurm nodename."""
instance_name_type_mapping = {}
for queue in queues:
instance_name_type_mapping[queue["Name"]] = {}
compute_resourc... | [
"def",
"generate_instance_type_mapping_file",
"(",
"output_dir",
",",
"queues",
")",
":",
"instance_name_type_mapping",
"=",
"{",
"}",
"for",
"queue",
"in",
"queues",
":",
"instance_name_type_mapping",
"[",
"queue",
"[",
"\"Name\"",
"]",
"]",
"=",
"{",
"}",
"com... | [
211,
0
] | [
225,
75
] | python | en | ['en', 'en', 'en'] | True |
_get_metadata | (metadata_path) |
Get EC2 instance metadata.
:param metadata_path: the metadata relative path
:return the metadata value.
|
Get EC2 instance metadata. | def _get_metadata(metadata_path):
"""
Get EC2 instance metadata.
:param metadata_path: the metadata relative path
:return the metadata value.
"""
try:
token = requests.put(
"http://169.254.169.254/latest/api/token", headers={"X-aws-ec2-metadata-token-ttl-seconds": "300"}
... | [
"def",
"_get_metadata",
"(",
"metadata_path",
")",
":",
"try",
":",
"token",
"=",
"requests",
".",
"put",
"(",
"\"http://169.254.169.254/latest/api/token\"",
",",
"headers",
"=",
"{",
"\"X-aws-ec2-metadata-token-ttl-seconds\"",
":",
"\"300\"",
"}",
")",
"headers",
"... | [
228,
0
] | [
250,
25
] | python | en | ['en', 'error', 'th'] | False |
async_setup_scanner | (
hass: HomeAssistantType, config, see, discovery_info=None
) | Old way of setting up the iCloud tracker. | Old way of setting up the iCloud tracker. | async def async_setup_scanner(
hass: HomeAssistantType, config, see, discovery_info=None
):
"""Old way of setting up the iCloud tracker.""" | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
",",
"see",
",",
"discovery_info",
"=",
"None",
")",
":"
] | [
19,
0
] | [
22,
51
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up device tracker for iCloud component. | Set up device tracker for iCloud component. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up device tracker for iCloud component."""
account = hass.data[DOMAIN][entry.unique_id]
tracked = set()
@callback
def update_account():
"""Update the values of the account."""
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"account",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"unique_id",
"]",
"... | [
25,
0
] | [
41,
20
] | python | en | ['en', 'en', 'en'] | True |
add_entities | (account, async_add_entities, tracked) | Add new tracker entities from the account. | Add new tracker entities from the account. | def add_entities(account, async_add_entities, tracked):
"""Add new tracker entities from the account."""
new_tracked = []
for dev_id, device in account.devices.items():
if dev_id in tracked or device.location is None:
continue
new_tracked.append(IcloudTrackerEntity(account, dev... | [
"def",
"add_entities",
"(",
"account",
",",
"async_add_entities",
",",
"tracked",
")",
":",
"new_tracked",
"=",
"[",
"]",
"for",
"dev_id",
",",
"device",
"in",
"account",
".",
"devices",
".",
"items",
"(",
")",
":",
"if",
"dev_id",
"in",
"tracked",
"or",... | [
45,
0
] | [
57,
45
] | python | en | ['en', 'en', 'en'] | True |
icon_for_icloud_device | (icloud_device: IcloudDevice) | Return a battery icon valid identifier. | Return a battery icon valid identifier. | def icon_for_icloud_device(icloud_device: IcloudDevice) -> str:
"""Return a battery icon valid identifier."""
switcher = {
"iPad": "mdi:tablet-ipad",
"iPhone": "mdi:cellphone-iphone",
"iPod": "mdi:ipod",
"iMac": "mdi:desktop-mac",
"MacBookPro": "mdi:laptop-mac",
}
... | [
"def",
"icon_for_icloud_device",
"(",
"icloud_device",
":",
"IcloudDevice",
")",
"->",
"str",
":",
"switcher",
"=",
"{",
"\"iPad\"",
":",
"\"mdi:tablet-ipad\"",
",",
"\"iPhone\"",
":",
"\"mdi:cellphone-iphone\"",
",",
"\"iPod\"",
":",
"\"mdi:ipod\"",
",",
"\"iMac\""... | [
135,
0
] | [
145,
73
] | python | en | ['en', 'fy', 'en'] | True |
IcloudTrackerEntity.__init__ | (self, account: IcloudAccount, device: IcloudDevice) | Set up the iCloud tracker entity. | Set up the iCloud tracker entity. | def __init__(self, account: IcloudAccount, device: IcloudDevice):
"""Set up the iCloud tracker entity."""
self._account = account
self._device = device
self._unsub_dispatcher = None | [
"def",
"__init__",
"(",
"self",
",",
"account",
":",
"IcloudAccount",
",",
"device",
":",
"IcloudDevice",
")",
":",
"self",
".",
"_account",
"=",
"account",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_unsub_dispatcher",
"=",
"None"
] | [
63,
4
] | [
67,
37
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._device.unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"unique_id"
] | [
70,
4
] | [
72,
37
] | python | ca | ['fr', 'ca', 'en'] | False |
IcloudTrackerEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self) -> str:
"""Return the name of the device."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
75,
4
] | [
77,
32
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.location_accuracy | (self) | Return the location accuracy of the device. | Return the location accuracy of the device. | def location_accuracy(self):
"""Return the location accuracy of the device."""
return self._device.location[DEVICE_LOCATION_HORIZONTAL_ACCURACY] | [
"def",
"location_accuracy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"location",
"[",
"DEVICE_LOCATION_HORIZONTAL_ACCURACY",
"]"
] | [
80,
4
] | [
82,
73
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
return self._device.location[DEVICE_LOCATION_LATITUDE] | [
"def",
"latitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"location",
"[",
"DEVICE_LOCATION_LATITUDE",
"]"
] | [
85,
4
] | [
87,
62
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
return self._device.location[DEVICE_LOCATION_LONGITUDE] | [
"def",
"longitude",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"location",
"[",
"DEVICE_LOCATION_LONGITUDE",
"]"
] | [
90,
4
] | [
92,
63
] | python | en | ['en', 'zu', 'en'] | True |
IcloudTrackerEntity.battery_level | (self) | Return the battery level of the device. | Return the battery level of the device. | def battery_level(self) -> int:
"""Return the battery level of the device."""
return self._device.battery_level | [
"def",
"battery_level",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device",
".",
"battery_level"
] | [
95,
4
] | [
97,
41
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self) -> str:
"""Return the source type, eg gps or router, of the device."""
return SOURCE_TYPE_GPS | [
"def",
"source_type",
"(",
"self",
")",
"->",
"str",
":",
"return",
"SOURCE_TYPE_GPS"
] | [
100,
4
] | [
102,
30
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.icon | (self) | Return the icon. | Return the icon. | def icon(self) -> str:
"""Return the icon."""
return icon_for_icloud_device(self._device) | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"icon_for_icloud_device",
"(",
"self",
".",
"_device",
")"
] | [
105,
4
] | [
107,
51
] | python | en | ['en', 'sr', 'en'] | True |
IcloudTrackerEntity.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self) -> Dict[str, any]:
"""Return the device state attributes."""
return self._device.state_attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"self",
".",
"_device",
".",
"state_attributes"
] | [
110,
4
] | [
112,
44
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> Dict[str, any]:
"""Return the device information."""
return {
"identifiers": {(DOMAIN, self._device.unique_id)},
"name": self._device.name,
"manufacturer": "Apple",
"model": self._device.device_model,
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device",
... | [
115,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
IcloudTrackerEntity.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, self._account.signal_device_update, self.async_write_ha_state
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_account",
".",
"signal_device_update",
",",
"self",
".",
"async_write_ha_state",
")"
] | [
124,
4
] | [
128,
9
] | python | en | ['en', 'co', 'en'] | True |
IcloudTrackerEntity.async_will_remove_from_hass | (self) | Clean up after entity before removal. | Clean up after entity before removal. | async def async_will_remove_from_hass(self):
"""Clean up after entity before removal."""
self._unsub_dispatcher() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"(",
")"
] | [
130,
4
] | [
132,
32
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Melnor RainCloud component. | Set up the Melnor RainCloud component. | def setup(hass, config):
"""Set up the Melnor RainCloud component."""
conf = config[DOMAIN]
username = conf.get(CONF_USERNAME)
password = conf.get(CONF_PASSWORD)
scan_interval = conf.get(CONF_SCAN_INTERVAL)
try:
raincloud = RainCloudy(username=username, password=password)
if not... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"username",
"=",
"conf",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"conf",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"scan_interval",
"=",
"conf... | [
94,
0
] | [
124,
15
] | python | en | ['en', 'fr', 'en'] | True |
RainCloudHub.__init__ | (self, data) | Initialize the entity. | Initialize the entity. | def __init__(self, data):
"""Initialize the entity."""
self.data = data | [
"def",
"__init__",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"data",
"=",
"data"
] | [
130,
4
] | [
132,
24
] | python | en | ['en', 'en', 'en'] | True |
RainCloudEntity.__init__ | (self, data, sensor_type) | Initialize the RainCloud entity. | Initialize the RainCloud entity. | def __init__(self, data, sensor_type):
"""Initialize the RainCloud entity."""
self.data = data
self._sensor_type = sensor_type
self._name = f"{self.data.name} {KEY_MAP.get(self._sensor_type)}"
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"sensor_type",
")",
":",
"self",
".",
"data",
"=",
"data",
"self",
".",
"_sensor_type",
"=",
"sensor_type",
"self",
".",
"_name",
"=",
"f\"{self.data.name} {KEY_MAP.get(self._sensor_type)}\"",
"self",
".",
"_stat... | [
138,
4
] | [
143,
26
] | python | en | ['en', 'fr', 'en'] | True |
RainCloudEntity.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"
] | [
146,
4
] | [
148,
25
] | python | en | ['en', 'mi', 'en'] | True |
RainCloudEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_RAINCLOUD, self._update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_RAINCLOUD",
",",
"self",
".",
"_update_callback",
")",
")"
] | [
150,
4
] | [
156,
9
] | python | en | ['en', 'no', 'en'] | False |
RainCloudEntity._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"schedule_update_ha_state",
"(",
"True",
")"
] | [
158,
4
] | [
160,
43
] | python | en | ['en', 'sn', 'en'] | True |
RainCloudEntity.unit_of_measurement | (self) | Return the units of measurement. | Return the units of measurement. | def unit_of_measurement(self):
"""Return the units of measurement."""
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type) | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"UNIT_OF_MEASUREMENT_MAP",
".",
"get",
"(",
"self",
".",
"_sensor_type",
")"
] | [
163,
4
] | [
165,
61
] | python | en | ['en', 'bg', 'en'] | True |
RainCloudEntity.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION, "identifier": self.data.serial} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
",",
"\"identifier\"",
":",
"self",
".",
"data",
".",
"serial",
"}"
] | [
168,
4
] | [
170,
78
] | python | en | ['en', 'en', 'en'] | True |
RainCloudEntity.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON_MAP.get(self._sensor_type) | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON_MAP",
".",
"get",
"(",
"self",
".",
"_sensor_type",
")"
] | [
173,
4
] | [
175,
46
] | python | en | ['en', 'en', 'en'] | True |
load_tf_weights_in_electra | (model, config, tf_checkpoint_path, discriminator_or_generator="discriminator") | Load tf checkpoints in a pytorch model. | Load tf checkpoints in a pytorch model. | def load_tf_weights_in_electra(model, config, tf_checkpoint_path, discriminator_or_generator="discriminator"):
"""Load tf checkpoints in a pytorch model."""
try:
import re
import numpy as np
import tensorflow as tf
except ImportError:
logger.error(
"Loading a Ten... | [
"def",
"load_tf_weights_in_electra",
"(",
"model",
",",
"config",
",",
"tf_checkpoint_path",
",",
"discriminator_or_generator",
"=",
"\"discriminator\"",
")",
":",
"try",
":",
"import",
"re",
"import",
"numpy",
"as",
"np",
"import",
"tensorflow",
"as",
"tf",
"exce... | [
71,
0
] | [
151,
16
] | python | en | ['en', 'en', 'en'] | True |
ElectraPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
654,
4
] | [
668,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: Dict) | Set up the DirecTV component. | Set up the DirecTV component. | async def async_setup(hass: HomeAssistant, config: Dict) -> bool:
"""Set up the DirecTV component."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"Dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
30,
0
] | [
33,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up DirecTV from a config entry. | Set up DirecTV from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up DirecTV from a config entry."""
dtv = DIRECTV(entry.data[CONF_HOST], session=async_get_clientsession(hass))
try:
await dtv.update()
except DIRECTVError as err:
raise ConfigEntryNotReady from err
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"dtv",
"=",
"DIRECTV",
"(",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"session",
"=",
"async_get_clientsession",
"(",
... | [
36,
0
] | [
52,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_fo... | [
55,
0
] | [
69,
20
] | python | en | ['en', 'es', 'en'] | True |
DIRECTVEntity.__init__ | (self, *, dtv: DIRECTV, name: str, address: str = "0") | Initialize the DirecTV entity. | Initialize the DirecTV entity. | def __init__(self, *, dtv: DIRECTV, name: str, address: str = "0") -> None:
"""Initialize the DirecTV entity."""
self._address = address
self._device_id = address if address != "0" else dtv.device.info.receiver_id
self._is_client = address != "0"
self._name = name
self.dt... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"dtv",
":",
"DIRECTV",
",",
"name",
":",
"str",
",",
"address",
":",
"str",
"=",
"\"0\"",
")",
"->",
"None",
":",
"self",
".",
"_address",
"=",
"address",
"self",
".",
"_device_id",
"=",
"address",
"if... | [
75,
4
] | [
81,
22
] | python | en | ['en', 'en', 'en'] | True |
DIRECTVEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
84,
4
] | [
86,
25
] | python | en | ['en', 'en', 'en'] | True |
DIRECTVEntity.device_info | (self) | Return device information about this DirecTV receiver. | Return device information about this DirecTV receiver. | def device_info(self) -> Dict[str, Any]:
"""Return device information about this DirecTV receiver."""
return {
ATTR_IDENTIFIERS: {(DOMAIN, self._device_id)},
ATTR_NAME: self.name,
ATTR_MANUFACTURER: self.dtv.device.info.brand,
ATTR_MODEL: None,
... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"ATTR_IDENTIFIERS",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
")",
"}",
",",
"ATTR_NAME",
":",
"self",
".",
"name",
",",
"ATTR_MANUF... | [
89,
4
] | [
98,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up covers for deCONZ component.
Covers are based on the same device class as lights in deCONZ.
| Set up covers for deCONZ component. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up covers for deCONZ component.
Covers are based on the same device class as lights in deCONZ.
"""
gateway = get_gateway_from_config_entry(hass, config_entry)
gateway.entities[DOMAIN] = set()
@callback
def async_ad... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"gateway",
".",
"entities",
"[",
"DOMAIN",
"]",
"=",
"set",
"(",
... | [
19,
0
] | [
48,
48
] | python | en | ['da', 'en', 'en'] | True |
DeconzCover.__init__ | (self, device, gateway) | Set up cover device. | Set up cover device. | def __init__(self, device, gateway):
"""Set up cover device."""
super().__init__(device, gateway)
self._features = SUPPORT_OPEN
self._features |= SUPPORT_CLOSE
self._features |= SUPPORT_STOP
self._features |= SUPPORT_SET_POSITION | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"gateway",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
",",
"gateway",
")",
"self",
".",
"_features",
"=",
"SUPPORT_OPEN",
"self",
".",
"_features",
"|=",
"SUPPORT_CLOSE",
"self",
".",
... | [
56,
4
] | [
63,
46
] | python | en | ['fr', 'en', 'en'] | True |
DeconzCover.current_cover_position | (self) | Return the current position of the cover. | Return the current position of the cover. | def current_cover_position(self):
"""Return the current position of the cover."""
return 100 - int(self._device.brightness / 254 * 100) | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"return",
"100",
"-",
"int",
"(",
"self",
".",
"_device",
".",
"brightness",
"/",
"254",
"*",
"100",
")"
] | [
66,
4
] | [
68,
61
] | python | en | ['en', 'en', 'en'] | True |
DeconzCover.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
return self._device.state | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
71,
4
] | [
73,
33
] | python | en | ['en', 'en', 'en'] | True |
DeconzCover.device_class | (self) | Return the class of the cover. | Return the class of the cover. | def device_class(self):
"""Return the class of the cover."""
if self._device.type in DAMPERS:
return "damper"
if self._device.type in WINDOW_COVERS:
return DEVICE_CLASS_WINDOW | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"type",
"in",
"DAMPERS",
":",
"return",
"\"damper\"",
"if",
"self",
".",
"_device",
".",
"type",
"in",
"WINDOW_COVERS",
":",
"return",
"DEVICE_CLASS_WINDOW"
] | [
76,
4
] | [
81,
38
] | python | en | ['en', 'en', 'en'] | True |
DeconzCover.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_features"
] | [
84,
4
] | [
86,
29
] | python | en | ['da', 'en', 'en'] | True |
DeconzCover.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
position = kwargs[ATTR_POSITION]
data = {"on": False}
if position < 100:
data["on"] = True
data["bri"] = 254 - int(position / 100 * 254)
await self._device.a... | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"position",
"=",
"kwargs",
"[",
"ATTR_POSITION",
"]",
"data",
"=",
"{",
"\"on\"",
":",
"False",
"}",
"if",
"position",
"<",
"100",
":",
"data",
"[",
"\"on\"",
"... | [
88,
4
] | [
97,
48
] | python | en | ['en', 'en', 'en'] | True |
DeconzCover.async_open_cover | (self, **kwargs) | Open cover. | Open cover. | async def async_open_cover(self, **kwargs):
"""Open cover."""
data = {ATTR_POSITION: 100}
await self.async_set_cover_position(**data) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"ATTR_POSITION",
":",
"100",
"}",
"await",
"self",
".",
"async_set_cover_position",
"(",
"*",
"*",
"data",
")"
] | [
99,
4
] | [
102,
51
] | python | en | ['es', 'en', 'en'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.