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
DysonFilterLifeSensor.state
(self)
Return filter life in hours.
Return filter life in hours.
def state(self): """Return filter life in hours.""" if self._device.state: return int(self._device.state.filter_life) return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ":", "return", "int", "(", "self", ".", "_device", ".", "state", ".", "filter_life", ")", "return", "None" ]
[ 136, 4 ]
[ 140, 19 ]
python
en
['en', 'en', 'en']
True
DysonCarbonFilterLifeSensor.__init__
(self, device)
Create a new Dyson Carbon Filter Life sensor.
Create a new Dyson Carbon Filter Life sensor.
def __init__(self, device): """Create a new Dyson Carbon Filter Life sensor.""" super().__init__(device, "carbon_filter_state") self._name = f"{self._device.name} Carbon Filter Remaining Life"
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"carbon_filter_state\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} Carbon Filter Remaining Life\"" ]
[ 146, 4 ]
[ 149, 72 ]
python
en
['en', 'gl', 'en']
True
DysonCarbonFilterLifeSensor.state
(self)
Return filter life remaining in percent.
Return filter life remaining in percent.
def state(self): """Return filter life remaining in percent.""" if self._device.state: return int(self._device.state.carbon_filter_state) return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ":", "return", "int", "(", "self", ".", "_device", ".", "state", ".", "carbon_filter_state", ")", "return", "None" ]
[ 152, 4 ]
[ 156, 19 ]
python
en
['it', 'en', 'en']
True
DysonHepaFilterLifeSensor.__init__
(self, device, filter_type="HEPA")
Create a new Dyson Filter Life sensor.
Create a new Dyson Filter Life sensor.
def __init__(self, device, filter_type="HEPA"): """Create a new Dyson Filter Life sensor.""" super().__init__(device, "hepa_filter_state") self._name = f"{self._device.name} {filter_type} Filter Remaining Life"
[ "def", "__init__", "(", "self", ",", "device", ",", "filter_type", "=", "\"HEPA\"", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"hepa_filter_state\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} {filter_type} Filter Remaining Li...
[ 162, 4 ]
[ 165, 79 ]
python
en
['en', 'gl', 'en']
True
DysonHepaFilterLifeSensor.state
(self)
Return filter life remaining in percent.
Return filter life remaining in percent.
def state(self): """Return filter life remaining in percent.""" if self._device.state: return int(self._device.state.hepa_filter_state) return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "state", ":", "return", "int", "(", "self", ".", "_device", ".", "state", ".", "hepa_filter_state", ")", "return", "None" ]
[ 168, 4 ]
[ 172, 19 ]
python
en
['it', 'en', 'en']
True
DysonDustSensor.__init__
(self, device)
Create a new Dyson Dust sensor.
Create a new Dyson Dust sensor.
def __init__(self, device): """Create a new Dyson Dust sensor.""" super().__init__(device, "dust") self._name = f"{self._device.name} Dust"
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"dust\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} Dust\"" ]
[ 178, 4 ]
[ 181, 48 ]
python
en
['en', 'ga', 'en']
True
DysonDustSensor.state
(self)
Return Dust value.
Return Dust value.
def state(self): """Return Dust value.""" if self._device.environmental_state: return self._device.environmental_state.dust return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "return", "self", ".", "_device", ".", "environmental_state", ".", "dust", "return", "None" ]
[ 184, 4 ]
[ 188, 19 ]
python
en
['en', 'no', 'en']
True
DysonHumiditySensor.__init__
(self, device)
Create a new Dyson Humidity sensor.
Create a new Dyson Humidity sensor.
def __init__(self, device): """Create a new Dyson Humidity sensor.""" super().__init__(device, "humidity") self._name = f"{self._device.name} Humidity"
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"humidity\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} Humidity\"" ]
[ 194, 4 ]
[ 197, 52 ]
python
en
['en', 'mg', 'en']
True
DysonHumiditySensor.state
(self)
Return Humidity value.
Return Humidity value.
def state(self): """Return Humidity value.""" if self._device.environmental_state: if self._device.environmental_state.humidity == 0: return STATE_OFF return self._device.environmental_state.humidity return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "if", "self", ".", "_device", ".", "environmental_state", ".", "humidity", "==", "0", ":", "return", "STATE_OFF", "return", "self", ".", "_device", ".", ...
[ 200, 4 ]
[ 206, 19 ]
python
en
['en', 'et', 'en']
True
DysonTemperatureSensor.__init__
(self, device, unit)
Create a new Dyson Temperature sensor.
Create a new Dyson Temperature sensor.
def __init__(self, device, unit): """Create a new Dyson Temperature sensor.""" super().__init__(device, "temperature") self._name = f"{self._device.name} Temperature" self._unit = unit
[ "def", "__init__", "(", "self", ",", "device", ",", "unit", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"temperature\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} Temperature\"", "self", ".", "_unit", "=", "unit" ]
[ 212, 4 ]
[ 216, 25 ]
python
en
['en', 'it', 'en']
True
DysonTemperatureSensor.state
(self)
Return Temperature value.
Return Temperature value.
def state(self): """Return Temperature value.""" if self._device.environmental_state: temperature_kelvin = self._device.environmental_state.temperature if temperature_kelvin == 0: return STATE_OFF if self._unit == TEMP_CELSIUS: return f...
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "temperature_kelvin", "=", "self", ".", "_device", ".", "environmental_state", ".", "temperature", "if", "temperature_kelvin", "==", "0", ":", "return", "STAT...
[ 219, 4 ]
[ 228, 19 ]
python
en
['en', 'la', 'en']
True
DysonTemperatureSensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self): """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 231, 4 ]
[ 233, 25 ]
python
en
['en', 'en', 'en']
True
DysonAirQualitySensor.__init__
(self, device)
Create a new Dyson Air Quality sensor.
Create a new Dyson Air Quality sensor.
def __init__(self, device): """Create a new Dyson Air Quality sensor.""" super().__init__(device, "air_quality") self._name = f"{self._device.name} AQI"
[ "def", "__init__", "(", "self", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "\"air_quality\"", ")", "self", ".", "_name", "=", "f\"{self._device.name} AQI\"" ]
[ 239, 4 ]
[ 242, 47 ]
python
en
['en', 'ga', 'en']
True
DysonAirQualitySensor.state
(self)
Return Air Quality value.
Return Air Quality value.
def state(self): """Return Air Quality value.""" if self._device.environmental_state: return int(self._device.environmental_state.volatil_organic_compounds) return None
[ "def", "state", "(", "self", ")", ":", "if", "self", ".", "_device", ".", "environmental_state", ":", "return", "int", "(", "self", ".", "_device", ".", "environmental_state", ".", "volatil_organic_compounds", ")", "return", "None" ]
[ 245, 4 ]
[ 249, 19 ]
python
en
['en', 'gd', 'en']
True
async_describe_on_off_states
( hass: HomeAssistantType, registry: GroupIntegrationRegistry )
Describe group on off states.
Describe group on off states.
def async_describe_on_off_states( hass: HomeAssistantType, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_ON}, STATE_OFF)
[ "def", "async_describe_on_off_states", "(", "hass", ":", "HomeAssistantType", ",", "registry", ":", "GroupIntegrationRegistry", ")", "->", "None", ":", "registry", ".", "on_off_states", "(", "{", "STATE_ON", "}", ",", "STATE_OFF", ")" ]
[ 10, 0 ]
[ 14, 49 ]
python
en
['en', 'en', 'en']
True
conv2d
(x, W)
conv2d returns a 2d convolution layer with full stride.
conv2d returns a 2d convolution layer with full stride.
def conv2d(x, W): """conv2d returns a 2d convolution layer with full stride.""" return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME')
[ "def", "conv2d", "(", "x", ",", "W", ")", ":", "return", "tf", ".", "nn", ".", "conv2d", "(", "x", ",", "W", ",", "strides", "=", "[", "1", ",", "1", ",", "1", ",", "1", "]", ",", "padding", "=", "'SAME'", ")" ]
[ 97, 0 ]
[ 99, 67 ]
python
en
['en', 'en', 'en']
True
max_pool
(x, pool_size)
max_pool downsamples a feature map by 2X.
max_pool downsamples a feature map by 2X.
def max_pool(x, pool_size): """max_pool downsamples a feature map by 2X.""" return tf.nn.max_pool(x, ksize=[1, pool_size, pool_size, 1], strides=[1, pool_size, pool_size, 1], padding='SAME')
[ "def", "max_pool", "(", "x", ",", "pool_size", ")", ":", "return", "tf", ".", "nn", ".", "max_pool", "(", "x", ",", "ksize", "=", "[", "1", ",", "pool_size", ",", "pool_size", ",", "1", "]", ",", "strides", "=", "[", "1", ",", "pool_size", ",", ...
[ 102, 0 ]
[ 105, 49 ]
python
en
['en', 'en', 'en']
True
weight_variable
(shape)
weight_variable generates a weight variable of a given shape.
weight_variable generates a weight variable of a given shape.
def weight_variable(shape): """weight_variable generates a weight variable of a given shape.""" initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial)
[ "def", "weight_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "truncated_normal", "(", "shape", ",", "stddev", "=", "0.1", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
[ 113, 0 ]
[ 116, 31 ]
python
en
['en', 'en', 'en']
True
bias_variable
(shape)
bias_variable generates a bias variable of a given shape.
bias_variable generates a bias variable of a given shape.
def bias_variable(shape): """bias_variable generates a bias variable of a given shape.""" initial = tf.constant(0.1, shape=shape) return tf.Variable(initial)
[ "def", "bias_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "constant", "(", "0.1", ",", "shape", "=", "shape", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
[ 119, 0 ]
[ 122, 31 ]
python
en
['en', 'en', 'en']
True
mock_weather
()
Mock weather data.
Mock weather data.
def mock_weather(): """Mock weather data.""" with patch("metno.MetWeatherData") as mock_data: mock_data = mock_data.return_value mock_data.fetching_data = AsyncMock(return_value=True) mock_data.get_current_weather.return_value = { "condition": "cloudy", "temperatu...
[ "def", "mock_weather", "(", ")", ":", "with", "patch", "(", "\"metno.MetWeatherData\"", ")", "as", "mock_data", ":", "mock_data", "=", "mock_data", ".", "return_value", "mock_data", ".", "fetching_data", "=", "AsyncMock", "(", "return_value", "=", "True", ")", ...
[ 7, 0 ]
[ 21, 23 ]
python
en
['en', 'xh', 'en']
True
test_sending_location
(hass, create_registrations, webhook_client)
Test sending a location via a webhook.
Test sending a location via a webhook.
async def test_sending_location(hass, create_registrations, webhook_client): """Test sending a location via a webhook.""" resp = await webhook_client.post( "/api/webhook/{}".format(create_registrations[1]["webhook_id"]), json={ "type": "update_location", "data": { ...
[ "async", "def", "test_sending_location", "(", "hass", ",", "create_registrations", ",", "webhook_client", ")", ":", "resp", "=", "await", "webhook_client", ".", "post", "(", "\"/api/webhook/{}\"", ".", "format", "(", "create_registrations", "[", "1", "]", "[", "...
[ 3, 0 ]
[ 67, 53 ]
python
en
['en', 'lb', 'en']
True
test_restoring_location
(hass, create_registrations, webhook_client)
Test sending a location via a webhook.
Test sending a location via a webhook.
async def test_restoring_location(hass, create_registrations, webhook_client): """Test sending a location via a webhook.""" resp = await webhook_client.post( "/api/webhook/{}".format(create_registrations[1]["webhook_id"]), json={ "type": "update_location", "data": { ...
[ "async", "def", "test_restoring_location", "(", "hass", ",", "create_registrations", ",", "webhook_client", ")", ":", "resp", "=", "await", "webhook_client", ".", "post", "(", "\"/api/webhook/{}\"", ".", "format", "(", "create_registrations", "[", "1", "]", "[", ...
[ 70, 0 ]
[ 114, 56 ]
python
en
['en', 'lb', 'en']
True
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up the Minecraft Server component.
Set up the Minecraft Server component.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up the Minecraft Server component.""" return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "return", "True" ]
[ 28, 0 ]
[ 30, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, config_entry: ConfigEntry)
Set up Minecraft Server from a config entry.
Set up Minecraft Server from a config entry.
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool: """Set up Minecraft Server from a config entry.""" domain_data = hass.data.setdefault(DOMAIN, {}) # Create and store server instance. unique_id = config_entry.unique_id _LOGGER.debug( "Creating server i...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "domain_data", "=", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "# Create and store serv...
[ 33, 0 ]
[ 55, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
( hass: HomeAssistantType, config_entry: ConfigEntry )
Unload Minecraft Server config entry.
Unload Minecraft Server config entry.
async def async_unload_entry( hass: HomeAssistantType, config_entry: ConfigEntry ) -> bool: """Unload Minecraft Server config entry.""" unique_id = config_entry.unique_id server = hass.data[DOMAIN][unique_id] # Unload platforms. await asyncio.gather( *[ hass.config_entries.a...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ")", "->", "bool", ":", "unique_id", "=", "config_entry", ".", "unique_id", "server", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "un...
[ 58, 0 ]
[ 77, 15 ]
python
da
['da', 'es', 'en']
False
MinecraftServer.__init__
( self, hass: HomeAssistantType, unique_id: str, config_data: ConfigType )
Initialize server instance.
Initialize server instance.
def __init__( self, hass: HomeAssistantType, unique_id: str, config_data: ConfigType ) -> None: """Initialize server instance.""" self._hass = hass # Server data self.unique_id = unique_id self.name = config_data[CONF_NAME] self.host = config_data[CONF_HOST] ...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistantType", ",", "unique_id", ":", "str", ",", "config_data", ":", "ConfigType", ")", "->", "None", ":", "self", ".", "_hass", "=", "hass", "# Server data", "self", ".", "unique_id", "=", "unique_i...
[ 86, 4 ]
[ 116, 41 ]
python
en
['en', 'en', 'en']
True
MinecraftServer.start_periodic_update
(self)
Start periodic execution of update method.
Start periodic execution of update method.
def start_periodic_update(self) -> None: """Start periodic execution of update method.""" self._stop_periodic_update = async_track_time_interval( self._hass, self.async_update, timedelta(seconds=SCAN_INTERVAL) )
[ "def", "start_periodic_update", "(", "self", ")", "->", "None", ":", "self", ".", "_stop_periodic_update", "=", "async_track_time_interval", "(", "self", ".", "_hass", ",", "self", ".", "async_update", ",", "timedelta", "(", "seconds", "=", "SCAN_INTERVAL", ")",...
[ 118, 4 ]
[ 122, 9 ]
python
en
['en', 'en', 'en']
True
MinecraftServer.stop_periodic_update
(self)
Stop periodic execution of update method.
Stop periodic execution of update method.
def stop_periodic_update(self) -> None: """Stop periodic execution of update method.""" self._stop_periodic_update()
[ "def", "stop_periodic_update", "(", "self", ")", "->", "None", ":", "self", ".", "_stop_periodic_update", "(", ")" ]
[ 124, 4 ]
[ 126, 36 ]
python
en
['en', 'en', 'en']
True
MinecraftServer.async_check_connection
(self)
Check server connection using a 'status' request and store connection status.
Check server connection using a 'status' request and store connection status.
async def async_check_connection(self) -> None: """Check server connection using a 'status' request and store connection status.""" # Check if host is a valid SRV record, if not already done. if not self.srv_record_checked: self.srv_record_checked = True srv_record = awai...
[ "async", "def", "async_check_connection", "(", "self", ")", "->", "None", ":", "# Check if host is a valid SRV record, if not already done.", "if", "not", "self", ".", "srv_record_checked", ":", "self", ".", "srv_record_checked", "=", "True", "srv_record", "=", "await",...
[ 128, 4 ]
[ 160, 31 ]
python
en
['en', 'en', 'en']
True
MinecraftServer.async_update
(self, now: datetime = None)
Get server data from 3rd party library and update properties.
Get server data from 3rd party library and update properties.
async def async_update(self, now: datetime = None) -> None: """Get server data from 3rd party library and update properties.""" # Check connection status. server_online_old = self.online await self.async_check_connection() server_online = self.online # Inform user once a...
[ "async", "def", "async_update", "(", "self", ",", "now", ":", "datetime", "=", "None", ")", "->", "None", ":", "# Check connection status.", "server_online_old", "=", "self", ".", "online", "await", "self", ".", "async_check_connection", "(", ")", "server_online...
[ 162, 4 ]
[ 180, 59 ]
python
en
['en', 'en', 'en']
True
MinecraftServer._async_status_request
(self)
Request server status and update properties.
Request server status and update properties.
async def _async_status_request(self) -> None: """Request server status and update properties.""" try: status_response = await self._hass.async_add_executor_job( self._mc_status.status, self._MAX_RETRIES_STATUS ) # Got answer to request, update proper...
[ "async", "def", "_async_status_request", "(", "self", ")", "->", "None", ":", "try", ":", "status_response", "=", "await", "self", ".", "_hass", ".", "async_add_executor_job", "(", "self", ".", "_mc_status", ".", "status", ",", "self", ".", "_MAX_RETRIES_STATU...
[ 182, 4 ]
[ 226, 51 ]
python
en
['en', 'en', 'en']
True
MinecraftServerEntity.__init__
( self, server: MinecraftServer, type_name: str, icon: str, device_class: str )
Initialize base entity.
Initialize base entity.
def __init__( self, server: MinecraftServer, type_name: str, icon: str, device_class: str ) -> None: """Initialize base entity.""" self._server = server self._name = f"{server.name} {type_name}" self._icon = icon self._unique_id = f"{self._server.unique_id}-{type_name...
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ",", "type_name", ":", "str", ",", "icon", ":", "str", ",", "device_class", ":", "str", ")", "->", "None", ":", "self", ".", "_server", "=", "server", "self", ".", "_name", "=", "...
[ 232, 4 ]
[ 249, 42 ]
python
es
['es', 'zu', 'it']
False
MinecraftServerEntity.name
(self)
Return name.
Return name.
def name(self) -> str: """Return name.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 252, 4 ]
[ 254, 25 ]
python
en
['en', 'ig', 'en']
False
MinecraftServerEntity.unique_id
(self)
Return unique ID.
Return unique ID.
def unique_id(self) -> str: """Return unique ID.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 257, 4 ]
[ 259, 30 ]
python
en
['fr', 'la', 'en']
False
MinecraftServerEntity.device_info
(self)
Return device information.
Return device information.
def device_info(self) -> Dict[str, Any]: """Return device information.""" return self._device_info
[ "def", "device_info", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_device_info" ]
[ 262, 4 ]
[ 264, 32 ]
python
da
['es', 'da', 'en']
False
MinecraftServerEntity.device_class
(self)
Return device class.
Return device class.
def device_class(self) -> str: """Return device class.""" return self._device_class
[ "def", "device_class", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_device_class" ]
[ 267, 4 ]
[ 269, 33 ]
python
en
['es', 'zh', 'en']
False
MinecraftServerEntity.icon
(self)
Return icon.
Return icon.
def icon(self) -> str: """Return icon.""" return self._icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_icon" ]
[ 272, 4 ]
[ 274, 25 ]
python
en
['en', 'la', 'en']
False
MinecraftServerEntity.should_poll
(self)
Disable polling.
Disable polling.
def should_poll(self) -> bool: """Disable polling.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 277, 4 ]
[ 279, 20 ]
python
en
['fr', 'en', 'en']
False
MinecraftServerEntity.async_update
(self)
Fetch data from the server.
Fetch data from the server.
async def async_update(self) -> None: """Fetch data from the server.""" raise NotImplementedError()
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "raise", "NotImplementedError", "(", ")" ]
[ 281, 4 ]
[ 283, 35 ]
python
en
['en', 'en', 'en']
True
MinecraftServerEntity.async_added_to_hass
(self)
Connect dispatcher to signal from server.
Connect dispatcher to signal from server.
async def async_added_to_hass(self) -> None: """Connect dispatcher to signal from server.""" self._disconnect_dispatcher = async_dispatcher_connect( self.hass, self._server.signal_name, self._update_callback )
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "self", ".", "_disconnect_dispatcher", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "self", ".", "_server", ".", "signal_name", ",", "self", ".", "_update_callback", ...
[ 285, 4 ]
[ 289, 9 ]
python
en
['en', 'en', 'en']
True
MinecraftServerEntity.async_will_remove_from_hass
(self)
Disconnect dispatcher before removal.
Disconnect dispatcher before removal.
async def async_will_remove_from_hass(self) -> None: """Disconnect dispatcher before removal.""" self._disconnect_dispatcher()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "self", ".", "_disconnect_dispatcher", "(", ")" ]
[ 291, 4 ]
[ 293, 37 ]
python
en
['en', 'en', 'en']
True
MinecraftServerEntity._update_callback
(self)
Triggers update of properties after receiving signal from server.
Triggers update of properties after receiving signal from server.
def _update_callback(self) -> None: """Triggers update of properties after receiving signal from server.""" self.async_schedule_update_ha_state(force_refresh=True)
[ "def", "_update_callback", "(", "self", ")", "->", "None", ":", "self", ".", "async_schedule_update_ha_state", "(", "force_refresh", "=", "True", ")" ]
[ 296, 4 ]
[ 298, 63 ]
python
en
['en', 'en', 'en']
True
pyorbit_polychord
(config_in, input_datasets=None, return_output=None)
A dummy file is created to let the cpulimit script to proceed with the next step
A dummy file is created to let the cpulimit script to proceed with the next step
def pyorbit_polychord(config_in, input_datasets=None, return_output=None): output_directory = './' + config_in['output'] + '/polychord/' mc = ModelContainerPolyChord() pars_input(config_in, mc, input_datasets) if mc.nested_sampling_parameters['shutdown_jitter']: for dataset_name, dataset in mc...
[ "def", "pyorbit_polychord", "(", "config_in", ",", "input_datasets", "=", "None", ",", "return_output", "=", "None", ")", ":", "output_directory", "=", "'./'", "+", "config_in", "[", "'output'", "]", "+", "'/polychord/'", "mc", "=", "ModelContainerPolyChord", "(...
[ 27, 0 ]
[ 94, 14 ]
python
en
['en', 'en', 'en']
True
async_get_engine
(hass, config, discovery_info=None)
Set up Google Cloud TTS component.
Set up Google Cloud TTS component.
async def async_get_engine(hass, config, discovery_info=None): """Set up Google Cloud TTS component.""" key_file = config.get(CONF_KEY_FILE) if key_file: key_file = hass.config.path(key_file) if not os.path.isfile(key_file): _LOGGER.error("File %s doesn't exist", key_file) ...
[ "async", "def", "async_get_engine", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "key_file", "=", "config", ".", "get", "(", "CONF_KEY_FILE", ")", "if", "key_file", ":", "key_file", "=", "hass", ".", "config", ".", "path", "(...
[ 134, 0 ]
[ 154, 5 ]
python
en
['en', 'ca', 'en']
True
GoogleCloudTTSProvider.__init__
( self, hass, key_file=None, language=DEFAULT_LANG, gender=DEFAULT_GENDER, voice=DEFAULT_VOICE, encoding=DEFAULT_ENCODING, speed=1.0, pitch=0, gain=0, profiles=None, )
Init Google Cloud TTS service.
Init Google Cloud TTS service.
def __init__( self, hass, key_file=None, language=DEFAULT_LANG, gender=DEFAULT_GENDER, voice=DEFAULT_VOICE, encoding=DEFAULT_ENCODING, speed=1.0, pitch=0, gain=0, profiles=None, ): """Init Google Cloud TTS service.""" ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "key_file", "=", "None", ",", "language", "=", "DEFAULT_LANG", ",", "gender", "=", "DEFAULT_GENDER", ",", "voice", "=", "DEFAULT_VOICE", ",", "encoding", "=", "DEFAULT_ENCODING", ",", "speed", "=", "1.0", "...
[ 160, 4 ]
[ 190, 60 ]
python
ca
['nl', 'ca', 'en']
False
GoogleCloudTTSProvider.supported_languages
(self)
Return list of supported languages.
Return list of supported languages.
def supported_languages(self): """Return list of supported languages.""" return SUPPORTED_LANGUAGES
[ "def", "supported_languages", "(", "self", ")", ":", "return", "SUPPORTED_LANGUAGES" ]
[ 193, 4 ]
[ 195, 34 ]
python
en
['en', 'en', 'en']
True
GoogleCloudTTSProvider.default_language
(self)
Return the default language.
Return the default language.
def default_language(self): """Return the default language.""" return self._language
[ "def", "default_language", "(", "self", ")", ":", "return", "self", ".", "_language" ]
[ 198, 4 ]
[ 200, 29 ]
python
en
['en', 'et', 'en']
True
GoogleCloudTTSProvider.supported_options
(self)
Return a list of supported options.
Return a list of supported options.
def supported_options(self): """Return a list of supported options.""" return SUPPORTED_OPTIONS
[ "def", "supported_options", "(", "self", ")", ":", "return", "SUPPORTED_OPTIONS" ]
[ 203, 4 ]
[ 205, 32 ]
python
en
['en', 'en', 'en']
True
GoogleCloudTTSProvider.default_options
(self)
Return a dict including default options.
Return a dict including default options.
def default_options(self): """Return a dict including default options.""" return { CONF_GENDER: self._gender, CONF_VOICE: self._voice, CONF_ENCODING: self._encoding, CONF_SPEED: self._speed, CONF_PITCH: self._pitch, CONF_GAIN: self....
[ "def", "default_options", "(", "self", ")", ":", "return", "{", "CONF_GENDER", ":", "self", ".", "_gender", ",", "CONF_VOICE", ":", "self", ".", "_voice", ",", "CONF_ENCODING", ":", "self", ".", "_encoding", ",", "CONF_SPEED", ":", "self", ".", "_speed", ...
[ 208, 4 ]
[ 218, 9 ]
python
ca
['id', 'ca', 'en']
False
GoogleCloudTTSProvider.async_get_tts_audio
(self, message, language, options=None)
Load TTS from google.
Load TTS from google.
async def async_get_tts_audio(self, message, language, options=None): """Load TTS from google.""" options_schema = vol.Schema( { vol.Optional(CONF_GENDER, default=self._gender): GENDER_SCHEMA, vol.Optional(CONF_VOICE, default=self._voice): VOICE_SCHEMA, ...
[ "async", "def", "async_get_tts_audio", "(", "self", ",", "message", ",", "language", ",", "options", "=", "None", ")", ":", "options_schema", "=", "vol", ".", "Schema", "(", "{", "vol", ".", "Optional", "(", "CONF_GENDER", ",", "default", "=", "self", "....
[ 220, 4 ]
[ 270, 25 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 24, 0 ]
[ 26, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 30, 0 ]
[ 32, 30 ]
python
en
['en', 'fy', 'en']
True
calls
(hass)
Track calls to a mock service.
Track calls to a mock service.
def calls(hass): """Track calls to a mock service.""" return async_mock_service(hass, "test", "automation")
[ "def", "calls", "(", "hass", ")", ":", "return", "async_mock_service", "(", "hass", ",", "\"test\"", ",", "\"automation\"", ")" ]
[ 36, 0 ]
[ 38, 57 ]
python
en
['en', 'en', 'en']
True
test_get_conditions
(hass, device_reg, entity_reg)
Test we get the expected conditions from a vacuum.
Test we get the expected conditions from a vacuum.
async def test_get_conditions(hass, device_reg, entity_reg): """Test we get the expected conditions from a vacuum.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id, ...
[ "async", "def", "test_get_conditions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")",...
[ 41, 0 ]
[ 67, 54 ]
python
en
['en', 'en', 'en']
True
test_if_state
(hass, calls)
Test for turn_on and turn_off conditions.
Test for turn_on and turn_off conditions.
async def test_if_state(hass, calls): """Test for turn_on and turn_off conditions.""" hass.states.async_set("vacuum.entity", STATE_DOCKED) assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "trigger":...
[ "async", "def", "test_if_state", "(", "hass", ",", "calls", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"vacuum.entity\"", ",", "STATE_DOCKED", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", ".", "DOMAIN", ",", ...
[ 70, 0 ]
[ 137, 71 ]
python
en
['en', 'en', 'en']
True
RefCOCO.__init__
(self, image_set, root_path, data_path, boxes='gt', proposal_source='official', transform=None, test_mode=False, zip_mode=False, cache_mode=False, cache_db=False, ignore_db_cache=True, tokenizer=None, pretrained_model_name=None, add_image_as_a_box=Fals...
RefCOCO+ Dataset :param image_set: image folder name :param root_path: root path to cache database loaded from annotation file :param data_path: path to dataset :param boxes: boxes to use, 'gt' or 'proposal' :param transform: transform :param test_mode: test mod...
RefCOCO+ Dataset
def __init__(self, image_set, root_path, data_path, boxes='gt', proposal_source='official', transform=None, test_mode=False, zip_mode=False, cache_mode=False, cache_db=False, ignore_db_cache=True, tokenizer=None, pretrained_model_name=None, add_image_a...
[ "def", "__init__", "(", "self", ",", "image_set", ",", "root_path", ",", "data_path", ",", "boxes", "=", "'gt'", ",", "proposal_source", "=", "'official'", ",", "transform", "=", "None", ",", "test_mode", "=", "False", ",", "zip_mode", "=", "False", ",", ...
[ 22, 4 ]
[ 113, 61 ]
python
en
['en', 'error', 'th']
False
create_influx_url
(conf: Dict)
Build URL used from config inputs and default when necessary.
Build URL used from config inputs and default when necessary.
def create_influx_url(conf: Dict) -> Dict: """Build URL used from config inputs and default when necessary.""" if conf[CONF_API_VERSION] == API_VERSION_2: if CONF_SSL not in conf: conf[CONF_SSL] = DEFAULT_SSL_V2 if CONF_HOST not in conf: conf[CONF_HOST] = DEFAULT_HOST_V2 ...
[ "def", "create_influx_url", "(", "conf", ":", "Dict", ")", "->", "Dict", ":", "if", "conf", "[", "CONF_API_VERSION", "]", "==", "API_VERSION_2", ":", "if", "CONF_SSL", "not", "in", "conf", ":", "conf", "[", "CONF_SSL", "]", "=", "DEFAULT_SSL_V2", "if", "...
[ 101, 0 ]
[ 123, 15 ]
python
en
['en', 'en', 'en']
True
validate_version_specific_config
(conf: Dict)
Ensure correct config fields are provided based on API version used.
Ensure correct config fields are provided based on API version used.
def validate_version_specific_config(conf: Dict) -> Dict: """Ensure correct config fields are provided based on API version used.""" if conf[CONF_API_VERSION] == API_VERSION_2: if CONF_TOKEN not in conf: raise vol.Invalid( f"{CONF_TOKEN} and {CONF_BUCKET} are required when {C...
[ "def", "validate_version_specific_config", "(", "conf", ":", "Dict", ")", "->", "Dict", ":", "if", "conf", "[", "CONF_API_VERSION", "]", "==", "API_VERSION_2", ":", "if", "CONF_TOKEN", "not", "in", "conf", ":", "raise", "vol", ".", "Invalid", "(", "f\"{CONF_...
[ 126, 0 ]
[ 145, 15 ]
python
en
['en', 'en', 'en']
True
_generate_event_to_json
(conf: Dict)
Build event to json converter and add to config.
Build event to json converter and add to config.
def _generate_event_to_json(conf: Dict) -> Callable[[Dict], str]: """Build event to json converter and add to config.""" entity_filter = convert_include_exclude_filter(conf) tags = conf.get(CONF_TAGS) tags_attributes = conf.get(CONF_TAGS_ATTRIBUTES) default_measurement = conf.get(CONF_DEFAULT_MEASUR...
[ "def", "_generate_event_to_json", "(", "conf", ":", "Dict", ")", "->", "Callable", "[", "[", "Dict", "]", ",", "str", "]", ":", "entity_filter", "=", "convert_include_exclude_filter", "(", "conf", ")", "tags", "=", "conf", ".", "get", "(", "CONF_TAGS", ")"...
[ 194, 0 ]
[ 313, 24 ]
python
en
['en', 'en', 'en']
True
get_influx_connection
(conf, test_write=False, test_read=False)
Create the correct influx connection for the API version.
Create the correct influx connection for the API version.
def get_influx_connection(conf, test_write=False, test_read=False): """Create the correct influx connection for the API version.""" kwargs = { CONF_TIMEOUT: TIMEOUT, } precision = conf.get(CONF_PRECISION) if conf[CONF_API_VERSION] == API_VERSION_2: kwargs[CONF_URL] = conf[CONF_URL] ...
[ "def", "get_influx_connection", "(", "conf", ",", "test_write", "=", "False", ",", "test_read", "=", "False", ")", ":", "kwargs", "=", "{", "CONF_TIMEOUT", ":", "TIMEOUT", ",", "}", "precision", "=", "conf", ".", "get", "(", "CONF_PRECISION", ")", "if", ...
[ 326, 0 ]
[ 460, 64 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the InfluxDB component.
Set up the InfluxDB component.
def setup(hass, config): """Set up the InfluxDB component.""" conf = config[DOMAIN] try: influx = get_influx_connection(conf, test_write=True) except ConnectionError as exc: _LOGGER.error(RETRY_MESSAGE, exc) event_helper.call_later(hass, RETRY_INTERVAL, lambda _: setup(hass, conf...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "try", ":", "influx", "=", "get_influx_connection", "(", "conf", ",", "test_write", "=", "True", ")", "except", "ConnectionError", "as", "exc", ":", "_LOGGER...
[ 463, 0 ]
[ 486, 15 ]
python
en
['en', 'en', 'en']
True
InfluxThread.__init__
(self, hass, influx, event_to_json, max_tries)
Initialize the listener.
Initialize the listener.
def __init__(self, hass, influx, event_to_json, max_tries): """Initialize the listener.""" threading.Thread.__init__(self, name=DOMAIN) self.queue = queue.Queue() self.influx = influx self.event_to_json = event_to_json self.max_tries = max_tries self.write_errors ...
[ "def", "__init__", "(", "self", ",", "hass", ",", "influx", ",", "event_to_json", ",", "max_tries", ")", ":", "threading", ".", "Thread", ".", "__init__", "(", "self", ",", "name", "=", "DOMAIN", ")", "self", ".", "queue", "=", "queue", ".", "Queue", ...
[ 492, 4 ]
[ 501, 66 ]
python
en
['en', 'en', 'en']
True
InfluxThread._event_listener
(self, event)
Listen for new messages on the bus and queue them for Influx.
Listen for new messages on the bus and queue them for Influx.
def _event_listener(self, event): """Listen for new messages on the bus and queue them for Influx.""" item = (time.monotonic(), event) self.queue.put(item)
[ "def", "_event_listener", "(", "self", ",", "event", ")", ":", "item", "=", "(", "time", ".", "monotonic", "(", ")", ",", "event", ")", "self", ".", "queue", ".", "put", "(", "item", ")" ]
[ 504, 4 ]
[ 507, 28 ]
python
en
['en', 'en', 'en']
True
InfluxThread.batch_timeout
()
Return number of seconds to wait for more events.
Return number of seconds to wait for more events.
def batch_timeout(): """Return number of seconds to wait for more events.""" return BATCH_TIMEOUT
[ "def", "batch_timeout", "(", ")", ":", "return", "BATCH_TIMEOUT" ]
[ 510, 4 ]
[ 512, 28 ]
python
en
['en', 'en', 'en']
True
InfluxThread.get_events_json
(self)
Return a batch of events formatted for writing.
Return a batch of events formatted for writing.
def get_events_json(self): """Return a batch of events formatted for writing.""" queue_seconds = QUEUE_BACKLOG_SECONDS + self.max_tries * RETRY_DELAY count = 0 json = [] dropped = 0 try: while len(json) < BATCH_BUFFER_SIZE and not self.shutdown: ...
[ "def", "get_events_json", "(", "self", ")", ":", "queue_seconds", "=", "QUEUE_BACKLOG_SECONDS", "+", "self", ".", "max_tries", "*", "RETRY_DELAY", "count", "=", "0", "json", "=", "[", "]", "dropped", "=", "0", "try", ":", "while", "len", "(", "json", ")"...
[ 514, 4 ]
[ 548, 26 ]
python
en
['en', 'en', 'en']
True
InfluxThread.write_to_influxdb
(self, json)
Write preprocessed events to influxdb, with retry.
Write preprocessed events to influxdb, with retry.
def write_to_influxdb(self, json): """Write preprocessed events to influxdb, with retry.""" for retry in range(self.max_tries + 1): try: self.influx.write(json) if self.write_errors: _LOGGER.error(RESUMED_MESSAGE, self.write_errors) ...
[ "def", "write_to_influxdb", "(", "self", ",", "json", ")", ":", "for", "retry", "in", "range", "(", "self", ".", "max_tries", "+", "1", ")", ":", "try", ":", "self", ".", "influx", ".", "write", "(", "json", ")", "if", "self", ".", "write_errors", ...
[ 550, 4 ]
[ 571, 50 ]
python
en
['en', 'en', 'en']
True
InfluxThread.run
(self)
Process incoming events.
Process incoming events.
def run(self): """Process incoming events.""" while not self.shutdown: count, json = self.get_events_json() if json: self.write_to_influxdb(json) for _ in range(count): self.queue.task_done()
[ "def", "run", "(", "self", ")", ":", "while", "not", "self", ".", "shutdown", ":", "count", ",", "json", "=", "self", ".", "get_events_json", "(", ")", "if", "json", ":", "self", ".", "write_to_influxdb", "(", "json", ")", "for", "_", "in", "range", ...
[ 573, 4 ]
[ 580, 38 ]
python
en
['en', 'en', 'en']
True
InfluxThread.block_till_done
(self)
Block till all events processed.
Block till all events processed.
def block_till_done(self): """Block till all events processed.""" self.queue.join()
[ "def", "block_till_done", "(", "self", ")", ":", "self", ".", "queue", ".", "join", "(", ")" ]
[ 582, 4 ]
[ 584, 25 ]
python
en
['sv', 'en', 'en']
True
async_assert_state_equals
( entity_id: str, state_obj: State, expected: Any, attribute: WithingsAttribute )
Assert at given state matches what is expected.
Assert at given state matches what is expected.
def async_assert_state_equals( entity_id: str, state_obj: State, expected: Any, attribute: WithingsAttribute ) -> None: """Assert at given state matches what is expected.""" assert state_obj, f"Expected entity {entity_id} to exist but it did not" assert state_obj.state == str(expected), ( f"Exp...
[ "def", "async_assert_state_equals", "(", "entity_id", ":", "str", ",", "state_obj", ":", "State", ",", "expected", ":", "Any", ",", "attribute", ":", "WithingsAttribute", ")", "->", "None", ":", "assert", "state_obj", ",", "f\"Expected entity {entity_id} to exist bu...
[ 290, 0 ]
[ 299, 5 ]
python
en
['en', 'en', 'en']
True
test_sensor_default_enabled_entities
( hass: HomeAssistant, component_factory: ComponentFactory )
Test entities enabled by default.
Test entities enabled by default.
async def test_sensor_default_enabled_entities( hass: HomeAssistant, component_factory: ComponentFactory ) -> None: """Test entities enabled by default.""" entity_registry: EntityRegistry = ( await hass.helpers.entity_registry.async_get_registry() ) await component_factory.configure_compone...
[ "async", "def", "test_sensor_default_enabled_entities", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "entity_registry", ":", "EntityRegistry", "=", "(", "await", "hass", ".", "helpers", ".", "entity_re...
[ 302, 0 ]
[ 342, 43 ]
python
en
['en', 'en', 'en']
True
test_all_entities
( hass: HomeAssistant, component_factory: ComponentFactory )
Test all entities.
Test all entities.
async def test_all_entities( hass: HomeAssistant, component_factory: ComponentFactory ) -> None: """Test all entities.""" entity_registry: EntityRegistry = ( await hass.helpers.entity_registry.async_get_registry() ) with patch( "homeassistant.components.withings.sensor.BaseWithingsS...
[ "async", "def", "test_all_entities", "(", "hass", ":", "HomeAssistant", ",", "component_factory", ":", "ComponentFactory", ")", "->", "None", ":", "entity_registry", ":", "EntityRegistry", "=", "(", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "...
[ 345, 0 ]
[ 387, 43 ]
python
en
['sv', 'en', 'en']
True
test_hls_stream
(hass, hass_client)
Test hls stream. Purposefully not mocking anything here to test full integration with the stream component.
Test hls stream.
async def test_hls_stream(hass, hass_client): """ Test hls stream. Purposefully not mocking anything here to test full integration with the stream component. """ await async_setup_component(hass, "stream", {"stream": {}}) # Setup demo HLS track source = generate_h264_video() stream...
[ "async", "def", "test_hls_stream", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "# Setup demo HLS track", "source", "=", "generate_h264_video", "(", ...
[ 18, 0 ]
[ 61, 49 ]
python
en
['en', 'error', 'th']
False
test_stream_timeout
(hass, hass_client)
Test hls stream timeout.
Test hls stream timeout.
async def test_stream_timeout(hass, hass_client): """Test hls stream timeout.""" await async_setup_component(hass, "stream", {"stream": {}}) # Setup demo HLS track source = generate_h264_video() stream = preload_stream(hass, source) stream.add_provider("hls") # Request stream url = req...
[ "async", "def", "test_stream_timeout", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "# Setup demo HLS track", "source", "=", "generate_h264_video", "...
[ 65, 0 ]
[ 98, 49 ]
python
en
['en', 'en', 'en']
True
test_stream_ended
(hass)
Test hls stream packets ended.
Test hls stream packets ended.
async def test_stream_ended(hass): """Test hls stream packets ended.""" await async_setup_component(hass, "stream", {"stream": {}}) # Setup demo HLS track source = generate_h264_video() stream = preload_stream(hass, source) track = stream.add_provider("hls") # Request stream request_st...
[ "async", "def", "test_stream_ended", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "# Setup demo HLS track", "source", "=", "generate_h264_video", "(", ")", "stream", "...
[ 102, 0 ]
[ 125, 17 ]
python
en
['en', 'en', 'en']
True
test_stream_keepalive
(hass)
Test hls stream retries the stream when keepalive=True.
Test hls stream retries the stream when keepalive=True.
async def test_stream_keepalive(hass): """Test hls stream retries the stream when keepalive=True.""" await async_setup_component(hass, "stream", {"stream": {}}) # Setup demo HLS track source = "test_stream_keepalive_source" stream = preload_stream(hass, source) track = stream.add_provider("hls"...
[ "async", "def", "test_stream_keepalive", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "# Setup demo HLS track", "source", "=", "\"test_stream_keepalive_source\"", "stream", ...
[ 128, 0 ]
[ 161, 17 ]
python
en
['en', 'de', 'en']
True
get_log_path
(experiment_id)
generate stdout and stderr log path
generate stdout and stderr log path
def get_log_path(experiment_id): '''generate stdout and stderr log path''' os.makedirs(os.path.join(NNI_HOME_DIR, experiment_id, 'log'), exist_ok=True) stdout_full_path = os.path.join(NNI_HOME_DIR, experiment_id, 'log', 'nnictl_stdout.log') stderr_full_path = os.path.join(NNI_HOME_DIR, experiment_id, 'l...
[ "def", "get_log_path", "(", "experiment_id", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "join", "(", "NNI_HOME_DIR", ",", "experiment_id", ",", "'log'", ")", ",", "exist_ok", "=", "True", ")", "stdout_full_path", "=", "os", ".", "path"...
[ 29, 0 ]
[ 34, 45 ]
python
en
['en', 'en', 'en']
True
print_log_content
(config_file_name)
print log information
print log information
def print_log_content(config_file_name): '''print log information''' stdout_full_path, stderr_full_path = get_log_path(config_file_name) print_normal(' Stdout:') print(check_output_command(stdout_full_path)) print('\n\n') print_normal(' Stderr:') print(check_output_command(stderr_full_path))
[ "def", "print_log_content", "(", "config_file_name", ")", ":", "stdout_full_path", ",", "stderr_full_path", "=", "get_log_path", "(", "config_file_name", ")", "print_normal", "(", "' Stdout:'", ")", "print", "(", "check_output_command", "(", "stdout_full_path", ")", "...
[ 36, 0 ]
[ 43, 49 ]
python
en
['fr', 'jv', 'en']
False
start_rest_server
(port, platform, mode, experiment_id, foreground=False, log_dir=None, log_level=None, url_prefix=None)
Run nni manager process
Run nni manager process
def start_rest_server(port, platform, mode, experiment_id, foreground=False, log_dir=None, log_level=None, url_prefix=None): '''Run nni manager process''' if detect_port(port): print_error('Port %s is used by another process, please reset the port!\n' \ 'You could use \'nnictl create --help\' to...
[ "def", "start_rest_server", "(", "port", ",", "platform", ",", "mode", ",", "experiment_id", ",", "foreground", "=", "False", ",", "log_dir", "=", "None", ",", "log_level", "=", "None", ",", "url_prefix", "=", "None", ")", ":", "if", "detect_port", "(", ...
[ 45, 0 ]
[ 107, 42 ]
python
da
['da', 'ha', 'en']
False
set_trial_config
(experiment_config, port, config_file_name)
set trial configuration
set trial configuration
def set_trial_config(experiment_config, port, config_file_name): '''set trial configuration''' request_data = dict() request_data['trial_config'] = experiment_config['trial'] response = rest_put(cluster_metadata_url(port), json.dumps(request_data), REST_TIME_OUT) if check_response(response): ...
[ "def", "set_trial_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "request_data", "=", "dict", "(", ")", "request_data", "[", "'trial_config'", "]", "=", "experiment_config", "[", "'trial'", "]", "response", "=", "rest_put", "(...
[ 109, 0 ]
[ 122, 20 ]
python
en
['en', 'fr', 'en']
True
set_adl_config
(experiment_config, port, config_file_name)
set adl configuration
set adl configuration
def set_adl_config(experiment_config, port, config_file_name): '''set adl configuration''' adl_config_data = dict() # hack for supporting v2 config, need refactor adl_config_data['adl_config'] = {} response = rest_put(cluster_metadata_url(port), json.dumps(adl_config_data), REST_TIME_OUT) err_me...
[ "def", "set_adl_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "adl_config_data", "=", "dict", "(", ")", "# hack for supporting v2 config, need refactor", "adl_config_data", "[", "'adl_config'", "]", "=", "{", "}", "response", "=", ...
[ 124, 0 ]
[ 143, 76 ]
python
en
['en', 'fr', 'en']
True
setNNIManagerIp
(experiment_config, port, config_file_name)
set nniManagerIp
set nniManagerIp
def setNNIManagerIp(experiment_config, port, config_file_name): '''set nniManagerIp''' if experiment_config.get('nniManagerIp') is None: return True, None ip_config_dict = dict() ip_config_dict['nni_manager_ip'] = {'nniManagerIp': experiment_config['nniManagerIp']} response = rest_put(cluste...
[ "def", "setNNIManagerIp", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "if", "experiment_config", ".", "get", "(", "'nniManagerIp'", ")", "is", "None", ":", "return", "True", ",", "None", "ip_config_dict", "=", "dict", "(", ")", ...
[ 172, 0 ]
[ 187, 21 ]
python
da
['en', 'da', 'sw']
False
set_kubeflow_config
(experiment_config, port, config_file_name)
set kubeflow configuration
set kubeflow configuration
def set_kubeflow_config(experiment_config, port, config_file_name): '''set kubeflow configuration''' kubeflow_config_data = dict() kubeflow_config_data['kubeflow_config'] = experiment_config['kubeflowConfig'] response = rest_put(cluster_metadata_url(port), json.dumps(kubeflow_config_data), REST_TIME_OUT...
[ "def", "set_kubeflow_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "kubeflow_config_data", "=", "dict", "(", ")", "kubeflow_config_data", "[", "'kubeflow_config'", "]", "=", "experiment_config", "[", "'kubeflowConfig'", "]", "respo...
[ 189, 0 ]
[ 207, 83 ]
python
en
['en', 'xh', 'ur']
False
set_frameworkcontroller_config
(experiment_config, port, config_file_name)
set kubeflow configuration
set kubeflow configuration
def set_frameworkcontroller_config(experiment_config, port, config_file_name): '''set kubeflow configuration''' frameworkcontroller_config_data = dict() frameworkcontroller_config_data['frameworkcontroller_config'] = experiment_config['frameworkcontrollerConfig'] response = rest_put(cluster_metadata_url...
[ "def", "set_frameworkcontroller_config", "(", "experiment_config", ",", "port", ",", "config_file_name", ")", ":", "frameworkcontroller_config_data", "=", "dict", "(", ")", "frameworkcontroller_config_data", "[", "'frameworkcontroller_config'", "]", "=", "experiment_config", ...
[ 209, 0 ]
[ 227, 83 ]
python
en
['en', 'xh', 'ur']
False
set_experiment_v1
(experiment_config, mode, port, config_file_name)
Call startExperiment (rest POST /experiment) with yaml file content
Call startExperiment (rest POST /experiment) with yaml file content
def set_experiment_v1(experiment_config, mode, port, config_file_name): '''Call startExperiment (rest POST /experiment) with yaml file content''' request_data = dict() request_data['authorName'] = experiment_config['authorName'] request_data['experimentName'] = experiment_config['experimentName'] re...
[ "def", "set_experiment_v1", "(", "experiment_config", ",", "mode", ",", "port", ",", "config_file_name", ")", ":", "request_data", "=", "dict", "(", ")", "request_data", "[", "'authorName'", "]", "=", "experiment_config", "[", "'authorName'", "]", "request_data", ...
[ 243, 0 ]
[ 312, 19 ]
python
en
['en', 'en', 'en']
True
set_experiment_v2
(experiment_config, mode, port, config_file_name)
Call startExperiment (rest POST /experiment) with yaml file content
Call startExperiment (rest POST /experiment) with yaml file content
def set_experiment_v2(experiment_config, mode, port, config_file_name): '''Call startExperiment (rest POST /experiment) with yaml file content''' response = rest_post(experiment_url(port), json.dumps(experiment_config), REST_TIME_OUT, show_error=True) if check_response(response): return response ...
[ "def", "set_experiment_v2", "(", "experiment_config", ",", "mode", ",", "port", ",", "config_file_name", ")", ":", "response", "=", "rest_post", "(", "experiment_url", "(", "port", ")", ",", "json", ".", "dumps", "(", "experiment_config", ")", ",", "REST_TIME_...
[ 314, 0 ]
[ 325, 19 ]
python
en
['en', 'en', 'en']
True
set_platform_config
(platform, experiment_config, port, config_file_name, rest_process)
call set_cluster_metadata for specific platform
call set_cluster_metadata for specific platform
def set_platform_config(platform, experiment_config, port, config_file_name, rest_process): '''call set_cluster_metadata for specific platform''' print_normal('Setting {0} config...'.format(platform)) config_result, err_msg = None, None if platform == 'adl': config_result, err_msg = set_adl_conf...
[ "def", "set_platform_config", "(", "platform", ",", "experiment_config", ",", "port", ",", "config_file_name", ",", "rest_process", ")", ":", "print_normal", "(", "'Setting {0} config...'", ".", "format", "(", "platform", ")", ")", "config_result", ",", "err_msg", ...
[ 327, 0 ]
[ 350, 15 ]
python
en
['en', 'en', 'en']
True
launch_experiment
(args, experiment_config, mode, experiment_id, config_version)
follow steps to start rest server and start experiment
follow steps to start rest server and start experiment
def launch_experiment(args, experiment_config, mode, experiment_id, config_version): '''follow steps to start rest server and start experiment''' # check packages for tuner package_name, module_name = None, None if experiment_config.get('tuner') and experiment_config['tuner'].get('builtinTunerName'): ...
[ "def", "launch_experiment", "(", "args", ",", "experiment_config", ",", "mode", ",", "experiment_id", ",", "config_version", ")", ":", "# check packages for tuner", "package_name", ",", "module_name", "=", "None", ",", "None", "if", "experiment_config", ".", "get", ...
[ 352, 0 ]
[ 470, 50 ]
python
en
['en', 'en', 'en']
True
create_experiment
(args)
start a new experiment
start a new experiment
def create_experiment(args): '''start a new experiment''' experiment_id = ''.join(random.sample(string.ascii_letters + string.digits, 8)) config_path = os.path.abspath(args.config) if not os.path.exists(config_path): print_error('Please set correct config path!') exit(1) config_yml =...
[ "def", "create_experiment", "(", "args", ")", ":", "experiment_id", "=", "''", ".", "join", "(", "random", ".", "sample", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ",", "8", ")", ")", "config_path", "=", "os", ".", "path", ".",...
[ 493, 0 ]
[ 525, 15 ]
python
en
['it', 'lb', 'en']
False
manage_stopped_experiment
(args, mode)
view a stopped experiment
view a stopped experiment
def manage_stopped_experiment(args, mode): '''view a stopped experiment''' update_experiment() experiments_config = Experiments() experiments_dict = experiments_config.get_all_experiments() experiment_id = None #find the latest stopped experiment if not args.id: print_error('Please s...
[ "def", "manage_stopped_experiment", "(", "args", ",", "mode", ")", ":", "update_experiment", "(", ")", "experiments_config", "=", "Experiments", "(", ")", "experiments_dict", "=", "experiments_config", ".", "get_all_experiments", "(", ")", "experiment_id", "=", "Non...
[ 527, 0 ]
[ 563, 15 ]
python
en
['it', 'en', 'en']
True
view_experiment
(args)
view a stopped experiment
view a stopped experiment
def view_experiment(args): '''view a stopped experiment''' manage_stopped_experiment(args, 'view')
[ "def", "view_experiment", "(", "args", ")", ":", "manage_stopped_experiment", "(", "args", ",", "'view'", ")" ]
[ 565, 0 ]
[ 567, 43 ]
python
en
['it', 'en', 'en']
True
resume_experiment
(args)
resume an experiment
resume an experiment
def resume_experiment(args): '''resume an experiment''' manage_stopped_experiment(args, 'resume')
[ "def", "resume_experiment", "(", "args", ")", ":", "manage_stopped_experiment", "(", "args", ",", "'resume'", ")" ]
[ 569, 0 ]
[ 571, 45 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities )
Set up the Minecraft Server sensor platform.
Set up the Minecraft Server sensor platform.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the Minecraft Server sensor platform.""" server = hass.data[DOMAIN][config_entry.unique_id] # Create entities list. entities = [ MinecraftServerVersionSensor(server), ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "server", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config_entry", ".", "unique_id...
[ 28, 0 ]
[ 44, 38 ]
python
en
['en', 'lv', 'en']
True
MinecraftServerSensorEntity.__init__
( self, server: MinecraftServer, type_name: str, icon: str = None, unit: str = None, device_class: str = None, )
Initialize sensor base entity.
Initialize sensor base entity.
def __init__( self, server: MinecraftServer, type_name: str, icon: str = None, unit: str = None, device_class: str = None, ) -> None: """Initialize sensor base entity.""" super().__init__(server, type_name, icon, device_class) self._state = Non...
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ",", "type_name", ":", "str", ",", "icon", ":", "str", "=", "None", ",", "unit", ":", "str", "=", "None", ",", "device_class", ":", "str", "=", "None", ",", ")", "->", "None", "...
[ 50, 4 ]
[ 61, 25 ]
python
es
['es', 'zu', 'it']
False
MinecraftServerSensorEntity.available
(self)
Return sensor availability.
Return sensor availability.
def available(self) -> bool: """Return sensor availability.""" return self._server.online
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_server", ".", "online" ]
[ 64, 4 ]
[ 66, 34 ]
python
en
['fr', 'ga', 'en']
False
MinecraftServerSensorEntity.state
(self)
Return sensor state.
Return sensor state.
def state(self) -> Any: """Return sensor state.""" return self._state
[ "def", "state", "(", "self", ")", "->", "Any", ":", "return", "self", ".", "_state" ]
[ 69, 4 ]
[ 71, 26 ]
python
en
['en', 'bs', 'en']
True
MinecraftServerSensorEntity.unit_of_measurement
(self)
Return sensor measurement unit.
Return sensor measurement unit.
def unit_of_measurement(self) -> str: """Return sensor measurement unit.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit" ]
[ 74, 4 ]
[ 76, 25 ]
python
en
['en', 'ca', 'en']
True
MinecraftServerVersionSensor.__init__
(self, server: MinecraftServer)
Initialize version sensor.
Initialize version sensor.
def __init__(self, server: MinecraftServer) -> None: """Initialize version sensor.""" super().__init__( server=server, type_name=NAME_VERSION, icon=ICON_VERSION, unit=UNIT_VERSION )
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "server", "=", "server", ",", "type_name", "=", "NAME_VERSION", ",", "icon", "=", "ICON_VERSION", ",", "unit", "=", ...
[ 82, 4 ]
[ 86, 9 ]
python
en
['nl', 'ro', 'en']
False
MinecraftServerVersionSensor.async_update
(self)
Update version.
Update version.
async def async_update(self) -> None: """Update version.""" self._state = self._server.version
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_server", ".", "version" ]
[ 88, 4 ]
[ 90, 42 ]
python
de
['nl', 'de', 'en']
False
MinecraftServerProtocolVersionSensor.__init__
(self, server: MinecraftServer)
Initialize protocol version sensor.
Initialize protocol version sensor.
def __init__(self, server: MinecraftServer) -> None: """Initialize protocol version sensor.""" super().__init__( server=server, type_name=NAME_PROTOCOL_VERSION, icon=ICON_PROTOCOL_VERSION, unit=UNIT_PROTOCOL_VERSION, )
[ "def", "__init__", "(", "self", ",", "server", ":", "MinecraftServer", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "server", "=", "server", ",", "type_name", "=", "NAME_PROTOCOL_VERSION", ",", "icon", "=", "ICON_PROTOCOL_VERSION", ",", ...
[ 96, 4 ]
[ 103, 9 ]
python
en
['en', 'ro', 'en']
True
MinecraftServerProtocolVersionSensor.async_update
(self)
Update protocol version.
Update protocol version.
async def async_update(self) -> None: """Update protocol version.""" self._state = self._server.protocol_version
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "self", ".", "_state", "=", "self", ".", "_server", ".", "protocol_version" ]
[ 105, 4 ]
[ 107, 51 ]
python
en
['en', 'en', 'en']
True