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
BloomSkySensor.__init__
(self, bs, device, sensor_name)
Initialize a BloomSky sensor.
Initialize a BloomSky sensor.
def __init__(self, bs, device, sensor_name): """Initialize a BloomSky sensor.""" self._bloomsky = bs self._device_id = device["DeviceID"] self._sensor_name = sensor_name self._name = f"{device['DeviceName']} {sensor_name}" self._state = None self._unique_id = f"{s...
[ "def", "__init__", "(", "self", ",", "bs", ",", "device", ",", "sensor_name", ")", ":", "self", ".", "_bloomsky", "=", "bs", "self", ".", "_device_id", "=", "device", "[", "\"DeviceID\"", "]", "self", ".", "_sensor_name", "=", "sensor_name", "self", ".",...
[ 75, 4 ]
[ 82, 66 ]
python
cs
['sk', 'cs', 'en']
False
BloomSkySensor.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 85, 4 ]
[ 87, 30 ]
python
ca
['fr', 'ca', 'en']
False
BloomSkySensor.name
(self)
Return the name of the BloomSky device and this sensor.
Return the name of the BloomSky device and this sensor.
def name(self): """Return the name of the BloomSky device and this sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 90, 4 ]
[ 92, 25 ]
python
en
['en', 'en', 'en']
True
BloomSkySensor.state
(self)
Return the current state, eg. value, of this sensor.
Return the current state, eg. value, of this sensor.
def state(self): """Return the current state, eg. value, of this sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 95, 4 ]
[ 97, 26 ]
python
en
['en', 'en', 'en']
True
BloomSkySensor.unit_of_measurement
(self)
Return the sensor units.
Return the sensor units.
def unit_of_measurement(self): """Return the sensor units.""" if self._bloomsky.is_metric: return SENSOR_UNITS_METRIC.get(self._sensor_name, None) return SENSOR_UNITS_IMPERIAL.get(self._sensor_name, None)
[ "def", "unit_of_measurement", "(", "self", ")", ":", "if", "self", ".", "_bloomsky", ".", "is_metric", ":", "return", "SENSOR_UNITS_METRIC", ".", "get", "(", "self", ".", "_sensor_name", ",", "None", ")", "return", "SENSOR_UNITS_IMPERIAL", ".", "get", "(", "...
[ 100, 4 ]
[ 104, 65 ]
python
en
['en', 'bg', 'en']
True
BloomSkySensor.update
(self)
Request an update from the BloomSky API.
Request an update from the BloomSky API.
def update(self): """Request an update from the BloomSky API.""" self._bloomsky.refresh_devices() state = self._bloomsky.devices[self._device_id]["Data"][self._sensor_name] if self._sensor_name in FORMAT_NUMBERS: self._state = f"{state:.2f}" else: self._...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_bloomsky", ".", "refresh_devices", "(", ")", "state", "=", "self", ".", "_bloomsky", ".", "devices", "[", "self", ".", "_device_id", "]", "[", "\"Data\"", "]", "[", "self", ".", "_sensor_name", "]"...
[ 106, 4 ]
[ 115, 31 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the CPU speed sensor.
Set up the CPU speed sensor.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the CPU speed sensor.""" name = config[CONF_NAME] add_entities([CpuSpeedSensor(name)], True)
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", "[", "CONF_NAME", "]", "add_entities", "(", "[", "CpuSpeedSensor", "(", "name", ")", "]", ",", "True", ")" ]
[ 25, 0 ]
[ 28, 46 ]
python
en
['en', 'su', 'en']
True
CpuSpeedSensor.__init__
(self, name)
Initialize the CPU sensor.
Initialize the CPU sensor.
def __init__(self, name): """Initialize the CPU sensor.""" self._name = name self._state = None self.info = None
[ "def", "__init__", "(", "self", ",", "name", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "info", "=", "None" ]
[ 34, 4 ]
[ 38, 24 ]
python
en
['en', 'co', 'en']
True
CpuSpeedSensor.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" ]
[ 41, 4 ]
[ 43, 25 ]
python
en
['en', 'mi', 'en']
True
CpuSpeedSensor.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._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 46, 4 ]
[ 48, 26 ]
python
en
['en', 'en', 'en']
True
CpuSpeedSensor.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 FREQUENCY_GIGAHERTZ
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "FREQUENCY_GIGAHERTZ" ]
[ 51, 4 ]
[ 53, 34 ]
python
en
['en', 'en', 'en']
True
CpuSpeedSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" if self.info is not None: attrs = { ATTR_ARCH: self.info["arch_string_raw"], ATTR_BRAND: self.info["brand_raw"], } if HZ_ADVERTISED in self.info: attr...
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "self", ".", "info", "is", "not", "None", ":", "attrs", "=", "{", "ATTR_ARCH", ":", "self", ".", "info", "[", "\"arch_string_raw\"", "]", ",", "ATTR_BRAND", ":", "self", ".", "info", "[", "...
[ 56, 4 ]
[ 65, 24 ]
python
en
['en', 'en', 'en']
True
CpuSpeedSensor.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" ]
[ 68, 4 ]
[ 70, 19 ]
python
en
['en', 'en', 'en']
True
CpuSpeedSensor.update
(self)
Get the latest data and updates the state.
Get the latest data and updates the state.
def update(self): """Get the latest data and updates the state.""" self.info = cpuinfo.get_cpu_info() if HZ_ACTUAL in self.info: self._state = round(float(self.info[HZ_ACTUAL][0]) / 10 ** 9, 2) else: self._state = None
[ "def", "update", "(", "self", ")", ":", "self", ".", "info", "=", "cpuinfo", ".", "get_cpu_info", "(", ")", "if", "HZ_ACTUAL", "in", "self", ".", "info", ":", "self", ".", "_state", "=", "round", "(", "float", "(", "self", ".", "info", "[", "HZ_ACT...
[ 72, 4 ]
[ 78, 30 ]
python
en
['en', 'en', 'en']
True
BaseMutator.mutables
(self)
A generator of all modules inheriting :class:`~nni.nas.pytorch.mutables.Mutable`. Modules are yielded in the order that they are defined in ``__init__``. For mutables with their keys appearing multiple times, only the first one will appear.
A generator of all modules inheriting :class:`~nni.nas.pytorch.mutables.Mutable`. Modules are yielded in the order that they are defined in ``__init__``. For mutables with their keys appearing multiple times, only the first one will appear.
def mutables(self): """ A generator of all modules inheriting :class:`~nni.nas.pytorch.mutables.Mutable`. Modules are yielded in the order that they are defined in ``__init__``. For mutables with their keys appearing multiple times, only the first one will appear. """ ret...
[ "def", "mutables", "(", "self", ")", ":", "return", "self", ".", "_structured_mutables" ]
[ 58, 4 ]
[ 64, 40 ]
python
en
['en', 'error', 'th']
False
BaseMutator.forward
(self, *inputs)
Warnings -------- Don't call forward of a mutator.
Warnings -------- Don't call forward of a mutator.
def forward(self, *inputs): """ Warnings -------- Don't call forward of a mutator. """ raise RuntimeError("Forward is undefined for mutators.")
[ "def", "forward", "(", "self", ",", "*", "inputs", ")", ":", "raise", "RuntimeError", "(", "\"Forward is undefined for mutators.\"", ")" ]
[ 70, 4 ]
[ 76, 64 ]
python
en
['en', 'error', 'th']
False
BaseMutator.enter_mutable_scope
(self, mutable_scope)
Callback when forward of a MutableScope is entered. Parameters ---------- mutable_scope : MutableScope The mutable scope that is entered.
Callback when forward of a MutableScope is entered.
def enter_mutable_scope(self, mutable_scope): """ Callback when forward of a MutableScope is entered. Parameters ---------- mutable_scope : MutableScope The mutable scope that is entered. """ pass
[ "def", "enter_mutable_scope", "(", "self", ",", "mutable_scope", ")", ":", "pass" ]
[ 84, 4 ]
[ 93, 12 ]
python
en
['en', 'error', 'th']
False
BaseMutator.exit_mutable_scope
(self, mutable_scope)
Callback when forward of a MutableScope is exited. Parameters ---------- mutable_scope : MutableScope The mutable scope that is exited.
Callback when forward of a MutableScope is exited.
def exit_mutable_scope(self, mutable_scope): """ Callback when forward of a MutableScope is exited. Parameters ---------- mutable_scope : MutableScope The mutable scope that is exited. """ pass
[ "def", "exit_mutable_scope", "(", "self", ",", "mutable_scope", ")", ":", "pass" ]
[ 95, 4 ]
[ 104, 12 ]
python
en
['en', 'error', 'th']
False
BaseMutator.on_forward_layer_choice
(self, mutable, *args, **kwargs)
Callbacks of forward in LayerChoice. Parameters ---------- mutable : nni.nas.pytorch.mutables.LayerChoice Module whose forward is called. args : list of torch.Tensor The arguments of its forward function. kwargs : dict The keyword arg...
Callbacks of forward in LayerChoice.
def on_forward_layer_choice(self, mutable, *args, **kwargs): """ Callbacks of forward in LayerChoice. Parameters ---------- mutable : nni.nas.pytorch.mutables.LayerChoice Module whose forward is called. args : list of torch.Tensor The arguments of...
[ "def", "on_forward_layer_choice", "(", "self", ",", "mutable", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "raise", "NotImplementedError" ]
[ 106, 4 ]
[ 124, 33 ]
python
en
['en', 'error', 'th']
False
BaseMutator.on_forward_input_choice
(self, mutable, tensor_list)
Callbacks of forward in InputChoice. Parameters ---------- mutable : nni.nas.pytorch.mutables.InputChoice Mutable that is called. tensor_list : list of torch.Tensor The arguments mutable is called with. Returns ------- tuple of t...
Callbacks of forward in InputChoice.
def on_forward_input_choice(self, mutable, tensor_list): """ Callbacks of forward in InputChoice. Parameters ---------- mutable : nni.nas.pytorch.mutables.InputChoice Mutable that is called. tensor_list : list of torch.Tensor The arguments mutable...
[ "def", "on_forward_input_choice", "(", "self", ",", "mutable", ",", "tensor_list", ")", ":", "raise", "NotImplementedError" ]
[ 126, 4 ]
[ 142, 33 ]
python
en
['en', 'error', 'th']
False
BaseMutator.export
(self)
Export the data of all decisions. This should output the decisions of all the mutables, so that the whole network can be fully determined with these decisions for further training from scratch. Returns ------- dict Mappings from mutable keys to decisions.
Export the data of all decisions. This should output the decisions of all the mutables, so that the whole network can be fully determined with these decisions for further training from scratch.
def export(self): """ Export the data of all decisions. This should output the decisions of all the mutables, so that the whole network can be fully determined with these decisions for further training from scratch. Returns ------- dict Mappings from mutable ...
[ "def", "export", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 144, 4 ]
[ 154, 33 ]
python
en
['en', 'error', 'th']
False
PFLDInference.__init__
(self, lookup_table, num_points=106)
Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf num_points : int the number of landmarks for prediction
Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf num_points : int the number of landmarks for prediction
def __init__(self, lookup_table, num_points=106): """ Parameters ---------- lookup_table : class to manage the candidate ops, layer information and layer perf num_points : int the number of landmarks for prediction """ super(PFLDInference, ...
[ "def", "__init__", "(", "self", ",", "lookup_table", ",", "num_points", "=", "106", ")", ":", "super", "(", "PFLDInference", ",", "self", ")", ".", "__init__", "(", ")", "stage_names", "=", "[", "stage", "for", "stage", "in", "lookup_table", ".", "layer_...
[ 24, 4 ]
[ 75, 26 ]
python
en
['en', 'error', 'th']
False
PFLDInference.forward
(self, x)
Parameters ---------- x : tensor input image Returns ------- output: tensor the predicted landmarks output: tensor the intermediate features
Parameters ---------- x : tensor input image
def forward(self, x): """ Parameters ---------- x : tensor input image Returns ------- output: tensor the predicted landmarks output: tensor the intermediate features """ x, y1 = self.stem(x) out...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", ",", "y1", "=", "self", ".", "stem", "(", "x", ")", "out1", "=", "x", "x", "=", "self", ".", "block4_1", "(", "x", ")", "for", "i", ",", "block", "in", "enumerate", "(", "self", ".", "...
[ 91, 4 ]
[ 126, 30 ]
python
en
['en', 'error', 'th']
False
AuxiliaryNet.forward
(self, x)
Parameters ---------- x : tensor input intermediate features Returns ------- output: tensor the predicted pose angles
Parameters ---------- x : tensor input intermediate features
def forward(self, x): """ Parameters ---------- x : tensor input intermediate features Returns ------- output: tensor the predicted pose angles """ x = self.conv1(x) x = self.conv2(x) x = self.conv3(x) ...
[ "def", "forward", "(", "self", ",", "x", ")", ":", "x", "=", "self", ".", "conv1", "(", "x", ")", "x", "=", "self", ".", "conv2", "(", "x", ")", "x", "=", "self", ".", "conv3", "(", "x", ")", "x", "=", "self", ".", "conv4", "(", "x", ")",...
[ 142, 4 ]
[ 163, 16 ]
python
en
['en', 'error', 'th']
False
get_service
(hass, config, discovery_info=None)
Get the Synology Chat notification service.
Get the Synology Chat notification service.
def get_service(hass, config, discovery_info=None): """Get the Synology Chat notification service.""" resource = config.get(CONF_RESOURCE) verify_ssl = config.get(CONF_VERIFY_SSL) return SynologyChatNotificationService(resource, verify_ssl)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "resource", "=", "config", ".", "get", "(", "CONF_RESOURCE", ")", "verify_ssl", "=", "config", ".", "get", "(", "CONF_VERIFY_SSL", ")", "return", "SynologyChatNot...
[ 27, 0 ]
[ 32, 64 ]
python
en
['en', 'en', 'en']
True
SynologyChatNotificationService.__init__
(self, resource, verify_ssl)
Initialize the service.
Initialize the service.
def __init__(self, resource, verify_ssl): """Initialize the service.""" self._resource = resource self._verify_ssl = verify_ssl
[ "def", "__init__", "(", "self", ",", "resource", ",", "verify_ssl", ")", ":", "self", ".", "_resource", "=", "resource", "self", ".", "_verify_ssl", "=", "verify_ssl" ]
[ 38, 4 ]
[ 41, 37 ]
python
en
['en', 'en', 'en']
True
SynologyChatNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" data = {"text": message} extended_data = kwargs.get(ATTR_DATA) file_url = extended_data.get(ATTR_FILE_URL) if extended_data else None if file_url: data["file_url"] = file_url to_s...
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"text\"", ":", "message", "}", "extended_data", "=", "kwargs", ".", "get", "(", "ATTR_DATA", ")", "file_url", "=", "extended_data", ...
[ 43, 4 ]
[ 64, 13 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a Axis light.
Set up a Axis light.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a Axis light.""" device = hass.data[AXIS_DOMAIN][config_entry.unique_id] if not device.api.vapix.light_control: return @callback def async_add_sensor(event_id): """Add light from Axis device.""" ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", "if", "not", "device", ".", "api", ".", "va...
[ 16, 0 ]
[ 33, 5 ]
python
en
['en', 'lb', 'en']
True
AxisLight.__init__
(self, event, device)
Initialize the Axis light.
Initialize the Axis light.
def __init__(self, event, device): """Initialize the Axis light.""" super().__init__(event, device) self.light_id = f"led{self.event.id}" self.current_intensity = 0 self.max_intensity = 0 self._features = SUPPORT_BRIGHTNESS
[ "def", "__init__", "(", "self", ",", "event", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "event", ",", "device", ")", "self", ".", "light_id", "=", "f\"led{self.event.id}\"", "self", ".", "current_intensity", "=", "0", "self", ".",...
[ 39, 4 ]
[ 48, 43 ]
python
en
['en', 'en', 'en']
True
AxisLight.async_added_to_hass
(self)
Subscribe lights events.
Subscribe lights events.
async def async_added_to_hass(self) -> None: """Subscribe lights events.""" await super().async_added_to_hass() current_intensity = ( await self.device.api.vapix.light_control.get_current_intensity( self.light_id ) ) self.current_intensity...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "current_intensity", "=", "(", "await", "self", ".", "device", ".", "api", ".", "vapix", ".", "light_control", "."...
[ 50, 4 ]
[ 64, 71 ]
python
en
['en', 'en', 'en']
True
AxisLight.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" ]
[ 67, 4 ]
[ 69, 29 ]
python
en
['da', 'en', 'en']
True
AxisLight.name
(self)
Return the name of the light.
Return the name of the light.
def name(self): """Return the name of the light.""" light_type = self.device.api.vapix.light_control[self.light_id].light_type return f"{self.device.name} {light_type} {self.event.TYPE} {self.event.id}"
[ "def", "name", "(", "self", ")", ":", "light_type", "=", "self", ".", "device", ".", "api", ".", "vapix", ".", "light_control", "[", "self", ".", "light_id", "]", ".", "light_type", "return", "f\"{self.device.name} {light_type} {self.event.TYPE} {self.event.id}\"" ]
[ 72, 4 ]
[ 75, 83 ]
python
en
['en', 'en', 'en']
True
AxisLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self): """Return true if light is on.""" return self.event.is_tripped
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "event", ".", "is_tripped" ]
[ 78, 4 ]
[ 80, 36 ]
python
en
['en', 'et', 'en']
True
AxisLight.brightness
(self)
Return the brightness of this light between 0..255.
Return the brightness of this light between 0..255.
def brightness(self): """Return the brightness of this light between 0..255.""" return int((self.current_intensity / self.max_intensity) * 255)
[ "def", "brightness", "(", "self", ")", ":", "return", "int", "(", "(", "self", ".", "current_intensity", "/", "self", ".", "max_intensity", ")", "*", "255", ")" ]
[ 83, 4 ]
[ 85, 71 ]
python
en
['en', 'en', 'en']
True
AxisLight.async_turn_on
(self, **kwargs)
Turn on light.
Turn on light.
async def async_turn_on(self, **kwargs): """Turn on light.""" if not self.is_on: await self.device.api.vapix.light_control.activate_light(self.light_id) if ATTR_BRIGHTNESS in kwargs: intensity = int((kwargs[ATTR_BRIGHTNESS] / 255) * self.max_intensity) await ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_on", ":", "await", "self", ".", "device", ".", "api", ".", "vapix", ".", "light_control", ".", "activate_light", "(", "self", ".", "light_id"...
[ 87, 4 ]
[ 96, 13 ]
python
en
['en', 'et', 'en']
True
AxisLight.async_turn_off
(self, **kwargs)
Turn off light.
Turn off light.
async def async_turn_off(self, **kwargs): """Turn off light.""" if self.is_on: await self.device.api.vapix.light_control.deactivate_light(self.light_id)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_on", ":", "await", "self", ".", "device", ".", "api", ".", "vapix", ".", "light_control", ".", "deactivate_light", "(", "self", ".", "light_id", ")...
[ 98, 4 ]
[ 101, 85 ]
python
en
['en', 'zh', 'en']
True
AxisLight.async_update
(self)
Update brightness.
Update brightness.
async def async_update(self): """Update brightness.""" current_intensity = ( await self.device.api.vapix.light_control.get_current_intensity( self.light_id ) ) self.current_intensity = current_intensity["data"]["intensity"]
[ "async", "def", "async_update", "(", "self", ")", ":", "current_intensity", "=", "(", "await", "self", ".", "device", ".", "api", ".", "vapix", ".", "light_control", ".", "get_current_intensity", "(", "self", ".", "light_id", ")", ")", "self", ".", "curren...
[ 103, 4 ]
[ 110, 71 ]
python
en
['en', 'sn', 'en']
False
AxisLight.should_poll
(self)
Brightness needs polling.
Brightness needs polling.
def should_poll(self): """Brightness needs polling.""" return True
[ "def", "should_poll", "(", "self", ")", ":", "return", "True" ]
[ 113, 4 ]
[ 115, 19 ]
python
en
['en', 'ky', 'en']
True
async_register
(hass: HomeAssistantType, handler: "IntentHandler")
Register an intent with Home Assistant.
Register an intent with Home Assistant.
def async_register(hass: HomeAssistantType, handler: "IntentHandler") -> None: """Register an intent with Home Assistant.""" intents = hass.data.get(DATA_KEY) if intents is None: intents = hass.data[DATA_KEY] = {} assert handler.intent_type is not None, "intent_type cannot be None" if hand...
[ "def", "async_register", "(", "hass", ":", "HomeAssistantType", ",", "handler", ":", "\"IntentHandler\"", ")", "->", "None", ":", "intents", "=", "hass", ".", "data", ".", "get", "(", "DATA_KEY", ")", "if", "intents", "is", "None", ":", "intents", "=", "...
[ 31, 0 ]
[ 44, 42 ]
python
en
['en', 'en', 'en']
True
async_handle
( hass: HomeAssistantType, platform: str, intent_type: str, slots: Optional[_SlotsType] = None, text_input: Optional[str] = None, context: Optional[Context] = None, )
Handle an intent.
Handle an intent.
async def async_handle( hass: HomeAssistantType, platform: str, intent_type: str, slots: Optional[_SlotsType] = None, text_input: Optional[str] = None, context: Optional[Context] = None, ) -> "IntentResponse": """Handle an intent.""" handler: IntentHandler = hass.data.get(DATA_KEY, {}).g...
[ "async", "def", "async_handle", "(", "hass", ":", "HomeAssistantType", ",", "platform", ":", "str", ",", "intent_type", ":", "str", ",", "slots", ":", "Optional", "[", "_SlotsType", "]", "=", "None", ",", "text_input", ":", "Optional", "[", "str", "]", "...
[ 48, 0 ]
[ 77, 77 ]
python
en
['en', 'en', 'en']
True
async_match_state
( hass: HomeAssistantType, name: str, states: Optional[Iterable[State]] = None )
Find a state that matches the name.
Find a state that matches the name.
def async_match_state( hass: HomeAssistantType, name: str, states: Optional[Iterable[State]] = None ) -> State: """Find a state that matches the name.""" if states is None: states = hass.states.async_all() state = _fuzzymatch(name, states, lambda state: state.name) if state is None: ...
[ "def", "async_match_state", "(", "hass", ":", "HomeAssistantType", ",", "name", ":", "str", ",", "states", ":", "Optional", "[", "Iterable", "[", "State", "]", "]", "=", "None", ")", "->", "State", ":", "if", "states", "is", "None", ":", "states", "=",...
[ 102, 0 ]
[ 114, 16 ]
python
en
['en', 'en', 'en']
True
async_test_feature
(state: State, feature: int, feature_name: str)
Test is state supports a feature.
Test is state supports a feature.
def async_test_feature(state: State, feature: int, feature_name: str) -> None: """Test is state supports a feature.""" if state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) & feature == 0: raise IntentHandleError(f"Entity {state.name} does not support {feature_name}")
[ "def", "async_test_feature", "(", "state", ":", "State", ",", "feature", ":", "int", ",", "feature_name", ":", "str", ")", "->", "None", ":", "if", "state", ".", "attributes", ".", "get", "(", "ATTR_SUPPORTED_FEATURES", ",", "0", ")", "&", "feature", "==...
[ 118, 0 ]
[ 121, 87 ]
python
en
['en', 'en', 'en']
True
_fuzzymatch
(name: str, items: Iterable[T], key: Callable[[T], str])
Fuzzy matching function.
Fuzzy matching function.
def _fuzzymatch(name: str, items: Iterable[T], key: Callable[[T], str]) -> Optional[T]: """Fuzzy matching function.""" matches = [] pattern = ".*?".join(name) regex = re.compile(pattern, re.IGNORECASE) for idx, item in enumerate(items): match = regex.search(key(item)) if match: ...
[ "def", "_fuzzymatch", "(", "name", ":", "str", ",", "items", ":", "Iterable", "[", "T", "]", ",", "key", ":", "Callable", "[", "[", "T", "]", ",", "str", "]", ")", "->", "Optional", "[", "T", "]", ":", "matches", "=", "[", "]", "pattern", "=", ...
[ 163, 0 ]
[ 174, 53 ]
python
en
['en', 'en', 'en']
True
IntentHandler.async_can_handle
(self, intent_obj: "Intent")
Test if an intent can be handled.
Test if an intent can be handled.
def async_can_handle(self, intent_obj: "Intent") -> bool: """Test if an intent can be handled.""" return self.platforms is None or intent_obj.platform in self.platforms
[ "def", "async_can_handle", "(", "self", ",", "intent_obj", ":", "\"Intent\"", ")", "->", "bool", ":", "return", "self", ".", "platforms", "is", "None", "or", "intent_obj", ".", "platform", "in", "self", ".", "platforms" ]
[ 133, 4 ]
[ 135, 78 ]
python
en
['en', 'en', 'en']
True
IntentHandler.async_validate_slots
(self, slots: _SlotsType)
Validate slot information.
Validate slot information.
def async_validate_slots(self, slots: _SlotsType) -> _SlotsType: """Validate slot information.""" if self.slot_schema is None: return slots if self._slot_schema is None: self._slot_schema = vol.Schema( { key: SLOT_SCHEMA.extend({"value...
[ "def", "async_validate_slots", "(", "self", ",", "slots", ":", "_SlotsType", ")", "->", "_SlotsType", ":", "if", "self", ".", "slot_schema", "is", "None", ":", "return", "slots", "if", "self", ".", "_slot_schema", "is", "None", ":", "self", ".", "_slot_sch...
[ 138, 4 ]
[ 152, 39 ]
python
en
['en', 'da', 'en']
True
IntentHandler.async_handle
(self, intent_obj: "Intent")
Handle the intent.
Handle the intent.
async def async_handle(self, intent_obj: "Intent") -> "IntentResponse": """Handle the intent.""" raise NotImplementedError()
[ "async", "def", "async_handle", "(", "self", ",", "intent_obj", ":", "\"Intent\"", ")", "->", "\"IntentResponse\"", ":", "raise", "NotImplementedError", "(", ")" ]
[ 154, 4 ]
[ 156, 35 ]
python
en
['en', 'en', 'en']
True
IntentHandler.__repr__
(self)
Represent a string of an intent handler.
Represent a string of an intent handler.
def __repr__(self) -> str: """Represent a string of an intent handler.""" return f"<{self.__class__.__name__} - {self.intent_type}>"
[ "def", "__repr__", "(", "self", ")", "->", "str", ":", "return", "f\"<{self.__class__.__name__} - {self.intent_type}>\"" ]
[ 158, 4 ]
[ 160, 66 ]
python
en
['en', 'lb', 'en']
True
ServiceIntentHandler.__init__
( self, intent_type: str, domain: str, service: str, speech: str )
Create Service Intent Handler.
Create Service Intent Handler.
def __init__( self, intent_type: str, domain: str, service: str, speech: str ) -> None: """Create Service Intent Handler.""" self.intent_type = intent_type self.domain = domain self.service = service self.speech = speech
[ "def", "__init__", "(", "self", ",", "intent_type", ":", "str", ",", "domain", ":", "str", ",", "service", ":", "str", ",", "speech", ":", "str", ")", "->", "None", ":", "self", ".", "intent_type", "=", "intent_type", "self", ".", "domain", "=", "dom...
[ 185, 4 ]
[ 192, 28 ]
python
en
['en', 'nl', 'en']
True
ServiceIntentHandler.async_handle
(self, intent_obj: "Intent")
Handle the hass intent.
Handle the hass intent.
async def async_handle(self, intent_obj: "Intent") -> "IntentResponse": """Handle the hass intent.""" hass = intent_obj.hass slots = self.async_validate_slots(intent_obj.slots) state = async_match_state(hass, slots["name"]["value"]) await hass.services.async_call( se...
[ "async", "def", "async_handle", "(", "self", ",", "intent_obj", ":", "\"Intent\"", ")", "->", "\"IntentResponse\"", ":", "hass", "=", "intent_obj", ".", "hass", "slots", "=", "self", ".", "async_validate_slots", "(", "intent_obj", ".", "slots", ")", "state", ...
[ 194, 4 ]
[ 209, 23 ]
python
en
['en', 'en', 'en']
True
Intent.__init__
( self, hass: HomeAssistantType, platform: str, intent_type: str, slots: _SlotsType, text_input: Optional[str], context: Context, )
Initialize an intent.
Initialize an intent.
def __init__( self, hass: HomeAssistantType, platform: str, intent_type: str, slots: _SlotsType, text_input: Optional[str], context: Context, ) -> None: """Initialize an intent.""" self.hass = hass self.platform = platform self....
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "platform", ":", "str", ",", "intent_type", ":", "str", ",", "slots", ":", "_SlotsType", ",", "text_input", ":", "Optional", "[", "str", "]", ",", "context", ":", "Context", ",",...
[ 217, 4 ]
[ 232, 30 ]
python
en
['en', 'en', 'en']
True
Intent.create_response
(self)
Create a response.
Create a response.
def create_response(self) -> "IntentResponse": """Create a response.""" return IntentResponse(self)
[ "def", "create_response", "(", "self", ")", "->", "\"IntentResponse\"", ":", "return", "IntentResponse", "(", "self", ")" ]
[ 235, 4 ]
[ 237, 35 ]
python
en
['en', 'gl', 'en']
True
IntentResponse.__init__
(self, intent: Optional[Intent] = None)
Initialize an IntentResponse.
Initialize an IntentResponse.
def __init__(self, intent: Optional[Intent] = None) -> None: """Initialize an IntentResponse.""" self.intent = intent self.speech: Dict[str, Dict[str, Any]] = {} self.card: Dict[str, Dict[str, str]] = {}
[ "def", "__init__", "(", "self", ",", "intent", ":", "Optional", "[", "Intent", "]", "=", "None", ")", "->", "None", ":", "self", ".", "intent", "=", "intent", "self", ".", "speech", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]...
[ 243, 4 ]
[ 247, 49 ]
python
en
['en', 'en', 'it']
True
IntentResponse.async_set_speech
( self, speech: str, speech_type: str = "plain", extra_data: Optional[Any] = None )
Set speech response.
Set speech response.
def async_set_speech( self, speech: str, speech_type: str = "plain", extra_data: Optional[Any] = None ) -> None: """Set speech response.""" self.speech[speech_type] = {"speech": speech, "extra_data": extra_data}
[ "def", "async_set_speech", "(", "self", ",", "speech", ":", "str", ",", "speech_type", ":", "str", "=", "\"plain\"", ",", "extra_data", ":", "Optional", "[", "Any", "]", "=", "None", ")", "->", "None", ":", "self", ".", "speech", "[", "speech_type", "]...
[ 250, 4 ]
[ 254, 79 ]
python
cs
['cs', 'lb', 'en']
False
IntentResponse.async_set_card
( self, title: str, content: str, card_type: str = "simple" )
Set speech response.
Set speech response.
def async_set_card( self, title: str, content: str, card_type: str = "simple" ) -> None: """Set speech response.""" self.card[card_type] = {"title": title, "content": content}
[ "def", "async_set_card", "(", "self", ",", "title", ":", "str", ",", "content", ":", "str", ",", "card_type", ":", "str", "=", "\"simple\"", ")", "->", "None", ":", "self", ".", "card", "[", "card_type", "]", "=", "{", "\"title\"", ":", "title", ",",...
[ 257, 4 ]
[ 261, 67 ]
python
cs
['cs', 'lb', 'en']
False
IntentResponse.as_dict
(self)
Return a dictionary representation of an intent response.
Return a dictionary representation of an intent response.
def as_dict(self) -> Dict[str, Dict[str, Dict[str, Any]]]: """Return a dictionary representation of an intent response.""" return {"speech": self.speech, "card": self.card}
[ "def", "as_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", "]", ":", "return", "{", "\"speech\"", ":", "self", ".", "speech", ",", "\"card\"", ":", "self", ".", "card", ...
[ 264, 4 ]
[ 266, 57 ]
python
en
['en', 'en', 'en']
True
mock_disco
()
Mock discovery service.
Mock discovery service.
def mock_disco(): """Mock discovery service.""" disco = Mock() disco.pi_disco = Mock() disco.pi_disco.controllers = {} yield disco
[ "def", "mock_disco", "(", ")", ":", "disco", "=", "Mock", "(", ")", "disco", ".", "pi_disco", "=", "Mock", "(", ")", "disco", ".", "pi_disco", ".", "controllers", "=", "{", "}", "yield", "disco" ]
[ 11, 0 ]
[ 16, 15 ]
python
en
['en', 'en', 'en']
True
test_not_found
(hass, mock_disco)
Test not finding iZone controller.
Test not finding iZone controller.
async def test_not_found(hass, mock_disco): """Test not finding iZone controller.""" with patch( "homeassistant.components.izone.config_flow.async_start_discovery_service" ) as start_disco, patch( "homeassistant.components.izone.config_flow.async_stop_discovery_service", return_valu...
[ "async", "def", "test_not_found", "(", "hass", ",", "mock_disco", ")", ":", "with", "patch", "(", "\"homeassistant.components.izone.config_flow.async_start_discovery_service\"", ")", "as", "start_disco", ",", "patch", "(", "\"homeassistant.components.izone.config_flow.async_sto...
[ 29, 0 ]
[ 51, 35 ]
python
en
['en', 'en', 'en']
True
test_found
(hass, mock_disco)
Test not finding iZone controller.
Test not finding iZone controller.
async def test_found(hass, mock_disco): """Test not finding iZone controller.""" mock_disco.pi_disco.controllers["blah"] = object() with patch( "homeassistant.components.izone.climate.async_setup_entry", return_value=True, ) as mock_setup, patch( "homeassistant.components.izone....
[ "async", "def", "test_found", "(", "hass", ",", "mock_disco", ")", ":", "mock_disco", ".", "pi_disco", ".", "controllers", "[", "\"blah\"", "]", "=", "object", "(", ")", "with", "patch", "(", "\"homeassistant.components.izone.climate.async_setup_entry\"", ",", "re...
[ 54, 0 ]
[ 80, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up ESPHome fans based on a config entry.
Set up ESPHome fans based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up ESPHome fans based on a config entry.""" await platform_async_setup_entry( hass, entry, async_add_entities, component_key="fan", info_type=FanInfo, ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "await", "platform_async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ",", "comp...
[ 25, 0 ]
[ 37, 5 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.async_set_speed
(self, speed: str)
Set the speed of the fan.
Set the speed of the fan.
async def async_set_speed(self, speed: str) -> None: """Set the speed of the fan.""" if speed == SPEED_OFF: await self.async_turn_off() return await self._client.fan_command( self._static_info.key, speed=_fan_speeds.from_hass(speed) )
[ "async", "def", "async_set_speed", "(", "self", ",", "speed", ":", "str", ")", "->", "None", ":", "if", "speed", "==", "SPEED_OFF", ":", "await", "self", ".", "async_turn_off", "(", ")", "return", "await", "self", ".", "_client", ".", "fan_command", "(",...
[ 60, 4 ]
[ 68, 9 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.async_turn_on
(self, speed: Optional[str] = None, **kwargs)
Turn on the fan.
Turn on the fan.
async def async_turn_on(self, speed: Optional[str] = None, **kwargs) -> None: """Turn on the fan.""" if speed == SPEED_OFF: await self.async_turn_off() return data = {"key": self._static_info.key, "state": True} if speed is not None: data["speed"] = _f...
[ "async", "def", "async_turn_on", "(", "self", ",", "speed", ":", "Optional", "[", "str", "]", "=", "None", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "speed", "==", "SPEED_OFF", ":", "await", "self", ".", "async_turn_off", "(", ")", "retu...
[ 70, 4 ]
[ 78, 46 ]
python
en
['en', 'fy', 'en']
True
EsphomeFan.async_turn_off
(self, **kwargs)
Turn off the fan.
Turn off the fan.
async def async_turn_off(self, **kwargs) -> None: """Turn off the fan.""" await self._client.fan_command(key=self._static_info.key, state=False)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "fan_command", "(", "key", "=", "self", ".", "_static_info", ".", "key", ",", "state", "=", "False", ")" ]
[ 80, 4 ]
[ 82, 78 ]
python
en
['en', 'fy', 'en']
True
EsphomeFan.async_oscillate
(self, oscillating: bool)
Oscillate the fan.
Oscillate the fan.
async def async_oscillate(self, oscillating: bool) -> None: """Oscillate the fan.""" await self._client.fan_command( key=self._static_info.key, oscillating=oscillating )
[ "async", "def", "async_oscillate", "(", "self", ",", "oscillating", ":", "bool", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "fan_command", "(", "key", "=", "self", ".", "_static_info", ".", "key", ",", "oscillating", "=", "oscillating", ...
[ 84, 4 ]
[ 88, 9 ]
python
en
['en', 'fy', 'en']
True
EsphomeFan.is_on
(self)
Return true if the entity is on.
Return true if the entity is on.
def is_on(self) -> Optional[bool]: """Return true if the entity is on.""" return self._state.state
[ "def", "is_on", "(", "self", ")", "->", "Optional", "[", "bool", "]", ":", "return", "self", ".", "_state", ".", "state" ]
[ 94, 4 ]
[ 96, 32 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.speed
(self)
Return the current speed.
Return the current speed.
def speed(self) -> Optional[str]: """Return the current speed.""" if not self._static_info.supports_speed: return None return _fan_speeds.from_esphome(self._state.speed)
[ "def", "speed", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "self", ".", "_static_info", ".", "supports_speed", ":", "return", "None", "return", "_fan_speeds", ".", "from_esphome", "(", "self", ".", "_state", ".", "speed", ")" ...
[ 99, 4 ]
[ 103, 58 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.oscillating
(self)
Return the oscillation state.
Return the oscillation state.
def oscillating(self) -> None: """Return the oscillation state.""" if not self._static_info.supports_oscillation: return None return self._state.oscillating
[ "def", "oscillating", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "_static_info", ".", "supports_oscillation", ":", "return", "None", "return", "self", ".", "_state", ".", "oscillating" ]
[ 106, 4 ]
[ 110, 38 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.speed_list
(self)
Get the list of available speeds.
Get the list of available speeds.
def speed_list(self) -> Optional[List[str]]: """Get the list of available speeds.""" if not self._static_info.supports_speed: return None return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
[ "def", "speed_list", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "if", "not", "self", ".", "_static_info", ".", "supports_speed", ":", "return", "None", "return", "[", "SPEED_OFF", ",", "SPEED_LOW", ",", "SPEED_MEDIUM", ",...
[ 113, 4 ]
[ 117, 63 ]
python
en
['en', 'en', 'en']
True
EsphomeFan.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" flags = 0 if self._static_info.supports_oscillation: flags |= SUPPORT_OSCILLATE if self._static_info.supports_speed: flags |= SUPPORT_SET_SPEED return flags
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "flags", "=", "0", "if", "self", ".", "_static_info", ".", "supports_oscillation", ":", "flags", "|=", "SUPPORT_OSCILLATE", "if", "self", ".", "_static_info", ".", "supports_speed", ":", "flags",...
[ 120, 4 ]
[ 127, 20 ]
python
en
['da', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Z-Wave Fan from Config Entry.
Set up Z-Wave Fan from Config Entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Z-Wave Fan from Config Entry.""" @callback def async_add_fan(fan): """Add Z-Wave Fan.""" async_add_entities([fan]) async_dispatcher_connect(hass, "zwave_new_fan", async_add_fan)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "@", "callback", "def", "async_add_fan", "(", "fan", ")", ":", "\"\"\"Add Z-Wave Fan.\"\"\"", "async_add_entities", "(", "[", "fan", "]", ")", "async_dispat...
[ 27, 0 ]
[ 35, 66 ]
python
en
['en', 'en', 'en']
True
get_device
(values, **kwargs)
Create Z-Wave entity device.
Create Z-Wave entity device.
def get_device(values, **kwargs): """Create Z-Wave entity device.""" return ZwaveFan(values)
[ "def", "get_device", "(", "values", ",", "*", "*", "kwargs", ")", ":", "return", "ZwaveFan", "(", "values", ")" ]
[ 38, 0 ]
[ 40, 27 ]
python
en
['en', 'pl', 'en']
True
ZwaveFan.__init__
(self, values)
Initialize the Z-Wave fan device.
Initialize the Z-Wave fan device.
def __init__(self, values): """Initialize the Z-Wave fan device.""" ZWaveDeviceEntity.__init__(self, values, DOMAIN) self.update_properties()
[ "def", "__init__", "(", "self", ",", "values", ")", ":", "ZWaveDeviceEntity", ".", "__init__", "(", "self", ",", "values", ",", "DOMAIN", ")", "self", ".", "update_properties", "(", ")" ]
[ 46, 4 ]
[ 49, 32 ]
python
en
['en', 'fy', 'en']
True
ZwaveFan.update_properties
(self)
Handle data changes for node values.
Handle data changes for node values.
def update_properties(self): """Handle data changes for node values.""" value = math.ceil(self.values.primary.data * 3 / 100) self._state = VALUE_TO_SPEED[value]
[ "def", "update_properties", "(", "self", ")", ":", "value", "=", "math", ".", "ceil", "(", "self", ".", "values", ".", "primary", ".", "data", "*", "3", "/", "100", ")", "self", ".", "_state", "=", "VALUE_TO_SPEED", "[", "value", "]" ]
[ 51, 4 ]
[ 54, 43 ]
python
en
['fr', 'en', 'en']
True
ZwaveFan.set_speed
(self, speed)
Set the speed of the fan.
Set the speed of the fan.
def set_speed(self, speed): """Set the speed of the fan.""" self.node.set_dimmer(self.values.primary.value_id, SPEED_TO_VALUE[speed])
[ "def", "set_speed", "(", "self", ",", "speed", ")", ":", "self", ".", "node", ".", "set_dimmer", "(", "self", ".", "values", ".", "primary", ".", "value_id", ",", "SPEED_TO_VALUE", "[", "speed", "]", ")" ]
[ 56, 4 ]
[ 58, 81 ]
python
en
['en', 'en', 'en']
True
ZwaveFan.turn_on
(self, speed=None, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, speed=None, **kwargs): """Turn the device on.""" if speed is None: # Value 255 tells device to return to previous value self.node.set_dimmer(self.values.primary.value_id, 255) else: self.set_speed(speed)
[ "def", "turn_on", "(", "self", ",", "speed", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "speed", "is", "None", ":", "# Value 255 tells device to return to previous value", "self", ".", "node", ".", "set_dimmer", "(", "self", ".", "values", ".", ...
[ 60, 4 ]
[ 66, 33 ]
python
en
['en', 'en', 'en']
True
ZwaveFan.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" self.node.set_dimmer(self.values.primary.value_id, 0)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "node", ".", "set_dimmer", "(", "self", ".", "values", ".", "primary", ".", "value_id", ",", "0", ")" ]
[ 68, 4 ]
[ 70, 61 ]
python
en
['en', 'en', 'en']
True
ZwaveFan.speed
(self)
Return the current speed.
Return the current speed.
def speed(self): """Return the current speed.""" return self._state
[ "def", "speed", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 73, 4 ]
[ 75, 26 ]
python
en
['en', 'en', 'en']
True
ZwaveFan.speed_list
(self)
Get the list of available speeds.
Get the list of available speeds.
def speed_list(self): """Get the list of available speeds.""" return SPEED_LIST
[ "def", "speed_list", "(", "self", ")", ":", "return", "SPEED_LIST" ]
[ 78, 4 ]
[ 80, 25 ]
python
en
['en', 'en', 'en']
True
ZwaveFan.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORTED_FEATURES
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORTED_FEATURES" ]
[ 83, 4 ]
[ 85, 33 ]
python
en
['da', 'en', 'en']
True
adjust_learning_rate
(optimizer, decay=0.1)
Sets the learning rate to the initial LR decayed by 0.5 every 20 epochs
Sets the learning rate to the initial LR decayed by 0.5 every 20 epochs
def adjust_learning_rate(optimizer, decay=0.1): """Sets the learning rate to the initial LR decayed by 0.5 every 20 epochs""" for param_group in optimizer.param_groups: param_group['lr'] = decay * param_group['lr']
[ "def", "adjust_learning_rate", "(", "optimizer", ",", "decay", "=", "0.1", ")", ":", "for", "param_group", "in", "optimizer", ".", "param_groups", ":", "param_group", "[", "'lr'", "]", "=", "decay", "*", "param_group", "[", "'lr'", "]" ]
[ 10, 0 ]
[ 13, 53 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor.create
(create_deployment: dict)
Create MARO Cluster with create_deployment. Args: create_deployment (dict): create_deployment of grass/azure. See lib/deployments/internal for reference. Returns: None.
Create MARO Cluster with create_deployment.
def create(create_deployment: dict) -> None: """Create MARO Cluster with create_deployment. Args: create_deployment (dict): create_deployment of grass/azure. See lib/deployments/internal for reference. Returns: None. """ logger.info("Creating cluster") ...
[ "def", "create", "(", "create_deployment", ":", "dict", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Creating cluster\"", ")", "# Get standardized cluster_details", "cluster_details", "=", "GrassAzureExecutor", ".", "_standardize_cluster_details", "(", "create...
[ 54, 4 ]
[ 98, 65 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._standardize_cluster_details
(create_deployment: dict)
Standardize cluster_details from create_deployment. We use create_deployment to build cluster_details (they share the same keys structure). Args: create_deployment (dict): create_deployment of grass/azure. See lib/deployments/internal for reference. Returns: dict: stan...
Standardize cluster_details from create_deployment.
def _standardize_cluster_details(create_deployment: dict) -> dict: """Standardize cluster_details from create_deployment. We use create_deployment to build cluster_details (they share the same keys structure). Args: create_deployment (dict): create_deployment of grass/azure. See li...
[ "def", "_standardize_cluster_details", "(", "create_deployment", ":", "dict", ")", "->", "dict", ":", "samba_password", "=", "\"\"", ".", "join", "(", "secrets", ".", "choice", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ")", "for", "_...
[ 101, 4 ]
[ 140, 32 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._create_resource_group
(cluster_details: dict)
Create the resource group if it does not exist. Args: cluster_details (dict): details of the cluster. Returns: None.
Create the resource group if it does not exist.
def _create_resource_group(cluster_details: dict) -> None: """Create the resource group if it does not exist. Args: cluster_details (dict): details of the cluster. Returns: None. """ # Load params subscription = cluster_details["cloud"]["subscrip...
[ "def", "_create_resource_group", "(", "cluster_details", ":", "dict", ")", "->", "None", ":", "# Load params", "subscription", "=", "cluster_details", "[", "\"cloud\"", "]", "[", "\"subscription\"", "]", "resource_group", "=", "cluster_details", "[", "\"cloud\"", "]...
[ 143, 4 ]
[ 173, 78 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._create_vnet
(cluster_details: dict)
Create vnet for the MARO Cluster. Args: cluster_details (dict): details of the MARO Cluster. Returns: None.
Create vnet for the MARO Cluster.
def _create_vnet(cluster_details: dict) -> None: """Create vnet for the MARO Cluster. Args: cluster_details (dict): details of the MARO Cluster. Returns: None. """ logger.info("Creating vnet") # Create ARM parameters and start deployment ...
[ "def", "_create_vnet", "(", "cluster_details", ":", "dict", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Creating vnet\"", ")", "# Create ARM parameters and start deployment", "template_file_path", "=", "f\"{GrassPaths.ABS_MARO_GRASS_LIB}/modes/azure/create_vnet/templ...
[ 176, 4 ]
[ 203, 44 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._build_node_image
(cluster_details: dict)
Build Azure Image for MARO Node. The built image will contain required Node runtime environment including GPU support. See https://docs.microsoft.com/en-us/azure/virtual-machines/linux/capture-image for reference. Args: cluster_details (dict): details of the MARO Cluster. ...
Build Azure Image for MARO Node.
def _build_node_image(cluster_details: dict) -> None: """Build Azure Image for MARO Node. The built image will contain required Node runtime environment including GPU support. See https://docs.microsoft.com/en-us/azure/virtual-machines/linux/capture-image for reference. Args: ...
[ "def", "_build_node_image", "(", "cluster_details", ":", "dict", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Building MARO Node image\"", ")", "# Build params", "resource_name", "=", "\"build-node-image\"", "image_name", "=", "f\"{cluster_details['id']}-node-im...
[ 206, 4 ]
[ 290, 53 ]
python
en
['en', 'da', 'en']
True
GrassAzureExecutor._create_and_init_master
(cluster_details: dict)
Create and init MARO Master. Args: cluster_details (dict): details of the MARO Cluster. Returns: None.
Create and init MARO Master.
def _create_and_init_master(cluster_details: dict) -> None: """Create and init MARO Master. Args: cluster_details (dict): details of the MARO Cluster. Returns: None. """ logger.info("Creating MARO Master") GrassAzureExecutor._create_master_vm(cl...
[ "def", "_create_and_init_master", "(", "cluster_details", ":", "dict", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Creating MARO Master\"", ")", "GrassAzureExecutor", ".", "_create_master_vm", "(", "cluster_details", "=", "cluster_details", ")", "GrassAzure...
[ 293, 4 ]
[ 320, 51 ]
python
en
['en', 'sn', 'en']
True
GrassAzureExecutor._create_master_vm
(cluster_details: dict)
Create MARO Master VM. Args: cluster_details (dict): details of the MARO Cluster. Returns: None.
Create MARO Master VM.
def _create_master_vm(cluster_details: dict) -> None: """Create MARO Master VM. Args: cluster_details (dict): details of the MARO Cluster. Returns: None. """ logger.info("Creating Master VM") # Build params vm_name = f"{cluster_details['...
[ "def", "_create_master_vm", "(", "cluster_details", ":", "dict", ")", "->", "None", ":", "logger", ".", "info", "(", "\"Creating Master VM\"", ")", "# Build params", "vm_name", "=", "f\"{cluster_details['id']}-master-vm\"", "# Create ARM parameters and start deployment", "t...
[ 323, 4 ]
[ 375, 49 ]
python
en
['en', 'sv', 'en']
True
GrassAzureExecutor.delete
(self)
Delete the MARO Cluster. Returns: None.
Delete the MARO Cluster.
def delete(self) -> None: """Delete the MARO Cluster. Returns: None. """ logger.info(f"Deleting cluster '{self.cluster_name}'") # Get resource list resource_list = AzureController.list_resources(resource_group=self.resource_group) # Filter resources...
[ "def", "delete", "(", "self", ")", "->", "None", ":", "logger", ".", "info", "(", "f\"Deleting cluster '{self.cluster_name}'\"", ")", "# Get resource list", "resource_list", "=", "AzureController", ".", "list_resources", "(", "resource_group", "=", "self", ".", "res...
[ 379, 4 ]
[ 403, 70 ]
python
en
['en', 'it', 'en']
True
GrassAzureExecutor.scale_node
(self, replicas: int, node_size: str)
Scale up/down MARO Node using predefined Node Image. Args: replicas (int): desired number of MARO Node in specific node_size. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes for reference. Returns: ...
Scale up/down MARO Node using predefined Node Image.
def scale_node(self, replicas: int, node_size: str): """Scale up/down MARO Node using predefined Node Image. Args: replicas (int): desired number of MARO Node in specific node_size. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-mac...
[ "def", "scale_node", "(", "self", ",", "replicas", ":", "int", ",", "node_size", ":", "str", ")", ":", "# Load details", "nodes_details", "=", "self", ".", "master_api_client", ".", "list_nodes", "(", ")", "# Init node_size_to_count", "node_size_to_count", "=", ...
[ 407, 4 ]
[ 443, 74 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._create_nodes
(self, num: int, node_size: str)
Create MARO Nodes in parallel. Args: num (int): number of MARO Nodes (with specific node_size) to create. node_size (str): size of the MARO Node VM. Returns: None.
Create MARO Nodes in parallel.
def _create_nodes(self, num: int, node_size: str) -> None: """Create MARO Nodes in parallel. Args: num (int): number of MARO Nodes (with specific node_size) to create. node_size (str): size of the MARO Node VM. Returns: None. """ logger.info(...
[ "def", "_create_nodes", "(", "self", ",", "num", ":", "int", ",", "node_size", ":", "str", ")", "->", "None", ":", "logger", ".", "info", "(", "f\"Scaling up {num}\"", ")", "# Parallel create", "with", "ThreadPool", "(", "GlobalParams", ".", "PARALLELS", ")"...
[ 445, 4 ]
[ 462, 13 ]
python
en
['en', 'es', 'it']
False
GrassAzureExecutor._create_node
(self, node_size: str)
Create a MARO Node. Args: node_size (str): size of the MARO Node VM. Returns: None.
Create a MARO Node.
def _create_node(self, node_size: str) -> None: """Create a MARO Node. Args: node_size (str): size of the MARO Node VM. Returns: None. """ # Generate node name node_name = NameCreator.create_node_name() logger.info(message=f"Creating node...
[ "def", "_create_node", "(", "self", ",", "node_size", ":", "str", ")", "->", "None", ":", "# Generate node name", "node_name", "=", "NameCreator", ".", "create_node_name", "(", ")", "logger", ".", "info", "(", "message", "=", "f\"Creating node '{node_name}'\"", ...
[ 464, 4 ]
[ 486, 67 ]
python
en
['en', 'gl', 'en']
True
GrassAzureExecutor._delete_nodes
(self, num: int, node_size: str)
Delete MARO Nodes in parallel. Args: num (int): number of MARO Nodes (with specific node_size) to delete. node_size (str): size of the MARO Node VM. Returns: None.
Delete MARO Nodes in parallel.
def _delete_nodes(self, num: int, node_size: str) -> None: """Delete MARO Nodes in parallel. Args: num (int): number of MARO Nodes (with specific node_size) to delete. node_size (str): size of the MARO Node VM. Returns: None. """ # Load detai...
[ "def", "_delete_nodes", "(", "self", ",", "num", ":", "int", ",", "node_size", ":", "str", ")", "->", "None", ":", "# Load details", "nodes_details", "=", "self", ".", "master_api_client", ".", "list_nodes", "(", ")", "# Get deletable_nodes and check, TODO: consid...
[ 488, 4 ]
[ 520, 13 ]
python
en
['en', 'es', 'it']
False
GrassAzureExecutor._create_vm
(self, node_name: str, node_size: str)
Create MARO Node VM. Args: node_name (str): name of the MARO Node. Also the id of the MARO Node. node_size (str): size of the MARO Node VM. Returns: dict: join_cluster_deployment that needed in "join cluster" operation. See /lib/scripts/join_cluster....
Create MARO Node VM.
def _create_vm(self, node_name: str, node_size: str) -> dict: """Create MARO Node VM. Args: node_name (str): name of the MARO Node. Also the id of the MARO Node. node_size (str): size of the MARO Node VM. Returns: dict: join_cluster_deployment that needed in...
[ "def", "_create_vm", "(", "self", ",", "node_name", ":", "str", ",", "node_size", ":", "str", ")", "->", "dict", ":", "logger", ".", "info", "(", "message", "=", "f\"Creating VM '{node_name}'\"", ")", "# Create ARM parameters and start deployment", "os", ".", "m...
[ 522, 4 ]
[ 606, 38 ]
python
en
['en', 'sv', 'en']
True
GrassAzureExecutor._delete_node
(self, node_name: str)
Delete the MARO Node. Args: node_name (str): name of the MARO Node. Returns: None.
Delete the MARO Node.
def _delete_node(self, node_name: str) -> None: """Delete the MARO Node. Args: node_name (str): name of the MARO Node. Returns: None. """ logger.info(f"Deleting node '{node_name}'") # Delete node self.master_api_client.delete_node(node_n...
[ "def", "_delete_node", "(", "self", ",", "node_name", ":", "str", ")", "->", "None", ":", "logger", ".", "info", "(", "f\"Deleting node '{node_name}'\"", ")", "# Delete node", "self", ".", "master_api_client", ".", "delete_node", "(", "node_name", "=", "node_nam...
[ 608, 4 ]
[ 638, 59 ]
python
en
['en', 'it', 'en']
True
GrassAzureExecutor._join_cluster
(self, node_details: dict)
Join the cluster using node_details. Args: node_details (str): details of the MARO Node. Returns: None.
Join the cluster using node_details.
def _join_cluster(self, node_details: dict) -> None: """Join the cluster using node_details. Args: node_details (str): details of the MARO Node. Returns: None. """ node_name = node_details["name"] logger.info(f"Node '{node_name}' is joining the ...
[ "def", "_join_cluster", "(", "self", ",", "node_details", ":", "dict", ")", "->", "None", ":", "node_name", "=", "node_details", "[", "\"name\"", "]", "logger", ".", "info", "(", "f\"Node '{node_name}' is joining the cluster '{self.cluster_name}'\"", ")", "# Make sure...
[ 640, 4 ]
[ 687, 58 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor.start_node
(self, replicas: int, node_size: str)
Start MARO Node VMs in parallel. Args: replicas (int): number of MARO Node in specific node_size to start. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes for reference. Returns: None. ...
Start MARO Node VMs in parallel.
def start_node(self, replicas: int, node_size: str): """Start MARO Node VMs in parallel. Args: replicas (int): number of MARO Node in specific node_size to start. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes ...
[ "def", "start_node", "(", "self", ",", "replicas", ":", "int", ",", "node_size", ":", "str", ")", ":", "# Get nodes details", "nodes_details", "=", "self", ".", "master_api_client", ".", "list_nodes", "(", ")", "# Get startable nodes", "startable_nodes", "=", "[...
[ 689, 4 ]
[ 721, 13 ]
python
de
['en', 'de', 'nl']
False
GrassAzureExecutor._start_node
(self, node_name: str)
Start the MARO Node VM. Args: node_name (str): name of the MARO Node. Returns: None.
Start the MARO Node VM.
def _start_node(self, node_name: str): """Start the MARO Node VM. Args: node_name (str): name of the MARO Node. Returns: None. """ logger.info(f"Starting node '{node_name}'") # Start node vm AzureController.start_vm( resource...
[ "def", "_start_node", "(", "self", ",", "node_name", ":", "str", ")", ":", "logger", ".", "info", "(", "f\"Starting node '{node_name}'\"", ")", "# Start node vm", "AzureController", ".", "start_vm", "(", "resource_group", "=", "self", ".", "resource_group", ",", ...
[ 723, 4 ]
[ 743, 59 ]
python
en
['en', 'sv', 'en']
True
GrassAzureExecutor.stop_node
(self, replicas: int, node_size: str)
Stop MARO Node VMs in parallel. Args: replicas (int): number of MARO Node in specific node_size to stop. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/sizes for reference. Returns: None. ...
Stop MARO Node VMs in parallel.
def stop_node(self, replicas: int, node_size: str): """Stop MARO Node VMs in parallel. Args: replicas (int): number of MARO Node in specific node_size to stop. node_size (str): size of the MARO Node VM, see https://docs.microsoft.com/en-us/azure/virtual-machines/...
[ "def", "stop_node", "(", "self", ",", "replicas", ":", "int", ",", "node_size", ":", "str", ")", ":", "# Get nodes details", "nodes_details", "=", "self", ".", "master_api_client", ".", "list_nodes", "(", ")", "# Get stoppable nodes", "stoppable_nodes_details", "=...
[ 745, 4 ]
[ 781, 13 ]
python
en
['en', 'nl', 'it']
False
GrassAzureExecutor._stop_node
(self, node_details: dict)
Stop MARO Node VM. Args: node_details (dict): details of the MARO Node. Returns: None.
Stop MARO Node VM.
def _stop_node(self, node_details: dict): """Stop MARO Node VM. Args: node_details (dict): details of the MARO Node. Returns: None. """ node_name = node_details["name"] logger.info(f"Stopping node '{node_name}'") # Stop node sel...
[ "def", "_stop_node", "(", "self", ",", "node_details", ":", "dict", ")", ":", "node_name", "=", "node_details", "[", "\"name\"", "]", "logger", ".", "info", "(", "f\"Stopping node '{node_name}'\"", ")", "# Stop node", "self", ".", "master_api_client", ".", "stop...
[ 783, 4 ]
[ 805, 59 ]
python
en
['en', 'sv', 'pt']
False
GrassAzureExecutor._get_node_size_to_spec
(self)
Get node_size to spec mapping of Azure VM. Returns: dict: node_size to spec mapping.
Get node_size to spec mapping of Azure VM.
def _get_node_size_to_spec(self) -> dict: """Get node_size to spec mapping of Azure VM. Returns: dict: node_size to spec mapping. """ # List available sizes for VMs specs = AzureController.list_vm_sizes(location=self.location) # Get node_size_to_spec ...
[ "def", "_get_node_size_to_spec", "(", "self", ")", "->", "dict", ":", "# List available sizes for VMs", "specs", "=", "AzureController", ".", "list_vm_sizes", "(", "location", "=", "self", ".", "location", ")", "# Get node_size_to_spec", "node_size_to_spec", "=", "{",...
[ 807, 4 ]
[ 821, 32 ]
python
en
['en', 'en', 'en']
True
GrassAzureExecutor._count_running_containers
(node_details: dict)
Count running containers based on field "Status". Args: node_details (dict): details of the MARO Node. Returns: int: num of running containers.
Count running containers based on field "Status".
def _count_running_containers(node_details: dict) -> int: """Count running containers based on field "Status". Args: node_details (dict): details of the MARO Node. Returns: int: num of running containers. """ # Extract details containers_details ...
[ "def", "_count_running_containers", "(", "node_details", ":", "dict", ")", "->", "int", ":", "# Extract details", "containers_details", "=", "node_details", "[", "\"containers\"", "]", "# Do counting", "count", "=", "0", "for", "container_details", "in", "containers_d...
[ 824, 4 ]
[ 842, 20 ]
python
en
['en', 'en', 'en']
True