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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_reload_with_platform_not_setup | (hass) | Test the ability to reload lights. | Test the ability to reload lights. | async def test_reload_with_platform_not_setup(hass):
"""Test the ability to reload lights."""
hass.states.async_set("light.bowl", STATE_ON)
await async_setup_component(
hass,
LIGHT_DOMAIN,
{
LIGHT_DOMAIN: [
{"platform": "demo"},
]
},
... | [
"async",
"def",
"test_reload_with_platform_not_setup",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.bowl\"",
",",
"STATE_ON",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"LIGHT_DOMAIN",
",",
"{",
"LIGHT_DOMAIN",
":",
... | [
685,
0
] | [
724,
70
] | python | en | ['en', 'en', 'en'] | True |
test_reload_with_base_integration_platform_not_setup | (hass) | Test the ability to reload lights. | Test the ability to reload lights. | async def test_reload_with_base_integration_platform_not_setup(hass):
"""Test the ability to reload lights."""
assert await async_setup_component(
hass,
"group",
{
"group": {
"group_zero": {"entities": "light.Bowl", "icon": "mdi:work"},
}
}... | [
"async",
"def",
"test_reload_with_base_integration_platform_not_setup",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"group\"",
",",
"{",
"\"group\"",
":",
"{",
"\"group_zero\"",
":",
"{",
"\"entities\"",
":",
"\"light.Bowl\""... | [
727,
0
] | [
763,
77
] | python | en | ['en', 'en', 'en'] | True |
test_nested_group | (hass) | Test nested light group. | Test nested light group. | async def test_nested_group(hass):
"""Test nested light group."""
hass.states.async_set("light.kitchen", "on")
await async_setup_component(
hass,
LIGHT_DOMAIN,
{
LIGHT_DOMAIN: [
{
"platform": DOMAIN,
"entities": ["li... | [
"async",
"def",
"test_nested_group",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.kitchen\"",
",",
"\"on\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"LIGHT_DOMAIN",
",",
"{",
"LIGHT_DOMAIN",
":",
"[",
"{",
"\... | [
766,
0
] | [
799,
74
] | python | da | ['da', 'no', 'en'] | False |
test_abort_if_existing_entry | (hass) | Check flow abort when an entry already exist. | Check flow abort when an entry already exist. | async def test_abort_if_existing_entry(hass):
"""Check flow abort when an entry already exist."""
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
flow = config_flow.NetatmoFlowHandler()
flow.hass = hass
result = await hass.config_entries.flow.async_init(
"netatmo", context={"source": conf... | [
"async",
"def",
"test_abort_if_existing_entry",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"flow",
"=",
"config_flow",
".",
"NetatmoFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"has... | [
22,
0
] | [
41,
51
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow | (hass, aiohttp_client, aioclient_mock, current_request) | Check full flow. | Check full flow. | async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request):
"""Check full flow."""
assert await setup.async_setup_component(
hass,
"netatmo",
{
"netatmo": {CONF_CLIENT_ID: CLIENT_ID, CONF_CLIENT_SECRET: CLIENT_SECRET},
"http": {"base_url": "ht... | [
"async",
"def",
"test_full_flow",
"(",
"hass",
",",
"aiohttp_client",
",",
"aioclient_mock",
",",
"current_request",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"netatmo\"",
",",
"{",
"\"netatmo\"",
":",
"{",
"CONF_CLI... | [
44,
0
] | [
103,
42
] | python | en | ['sv', 'no', 'en'] | False |
test_option_flow | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow(hass):
"""Test config flow options."""
valid_option = {
"lat_ne": 32.91336,
"lon_ne": -117.187429,
"lat_sw": 32.83336,
"lon_sw": -117.26743,
"show_on_map": False,
"area_name": "Home",
"mode": "avg",
}
expected_result = {... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
")",
":",
"valid_option",
"=",
"{",
"\"lat_ne\"",
":",
"32.91336",
",",
"\"lon_ne\"",
":",
"-",
"117.187429",
",",
"\"lat_sw\"",
":",
"32.83336",
",",
"\"lon_sw\"",
":",
"-",
"117.26743",
",",
"\"show_on_map\"",... | [
106,
0
] | [
161,
71
] | python | en | ['en', 'fr', 'en'] | True |
test_option_flow_wrong_coordinates | (hass) | Test config flow options with mixed up coordinates. | Test config flow options with mixed up coordinates. | async def test_option_flow_wrong_coordinates(hass):
"""Test config flow options with mixed up coordinates."""
valid_option = {
"lat_ne": 32.1234567,
"lon_ne": -117.2345678,
"lat_sw": 32.2345678,
"lon_sw": -117.1234567,
"show_on_map": False,
"area_name": "Home",
... | [
"async",
"def",
"test_option_flow_wrong_coordinates",
"(",
"hass",
")",
":",
"valid_option",
"=",
"{",
"\"lat_ne\"",
":",
"32.1234567",
",",
"\"lon_ne\"",
":",
"-",
"117.2345678",
",",
"\"lat_sw\"",
":",
"32.2345678",
",",
"\"lon_sw\"",
":",
"-",
"117.1234567",
... | [
164,
0
] | [
219,
71
] | python | en | ['en', 'en', 'en'] | True |
test_request_least_info | (hass) | Test request config with least amount of data. | Test request config with least amount of data. | async def test_request_least_info(hass):
"""Test request config with least amount of data."""
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
assert 1 == len(
hass.services.async_services().get(configurator.DOMAIN, [])
), "No new service registered"
sta... | [
"async",
"def",
"test_request_least_info",
"(",
"hass",
")",
":",
"request_id",
"=",
"configurator",
".",
"async_request_config",
"(",
"hass",
",",
"\"Test Request\"",
",",
"lambda",
"_",
":",
"None",
")",
"assert",
"1",
"==",
"len",
"(",
"hass",
".",
"servi... | [
6,
0
] | [
21,
77
] | python | en | ['en', 'en', 'en'] | True |
test_request_all_info | (hass) | Test request config with all possible info. | Test request config with all possible info. | async def test_request_all_info(hass):
"""Test request config with all possible info."""
exp_attr = {
ATTR_FRIENDLY_NAME: "Test Request",
configurator.ATTR_DESCRIPTION: """config description
[link name](link url)
""",
configurator.ATTR_SUBMIT_CAPTI... | [
"async",
"def",
"test_request_all_info",
"(",
"hass",
")",
":",
"exp_attr",
"=",
"{",
"ATTR_FRIENDLY_NAME",
":",
"\"Test Request\"",
",",
"configurator",
".",
"ATTR_DESCRIPTION",
":",
"\"\"\"config description\n\n[link name](link url)\n\n\"\"... | [
24,
0
] | [
55,
39
] | python | en | ['en', 'en', 'en'] | True |
test_callback_called_on_configure | (hass) | Test if our callback gets called when configure service called. | Test if our callback gets called when configure service called. | async def test_callback_called_on_configure(hass):
"""Test if our callback gets called when configure service called."""
calls = []
request_id = configurator.async_request_config(
hass, "Test Request", lambda _: calls.append(1)
)
await hass.services.async_call(
configurator.DOMAIN,
... | [
"async",
"def",
"test_callback_called_on_configure",
"(",
"hass",
")",
":",
"calls",
"=",
"[",
"]",
"request_id",
"=",
"configurator",
".",
"async_request_config",
"(",
"hass",
",",
"\"Test Request\"",
",",
"lambda",
"_",
":",
"calls",
".",
"append",
"(",
"1",... | [
58,
0
] | [
72,
49
] | python | en | ['en', 'en', 'en'] | True |
test_state_change_on_notify_errors | (hass) | Test state change on notify errors. | Test state change on notify errors. | async def test_state_change_on_notify_errors(hass):
"""Test state change on notify errors."""
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
error = "Oh no bad bad bad"
configurator.async_notify_errors(hass, request_id, error)
states = hass.states.async_all()
... | [
"async",
"def",
"test_state_change_on_notify_errors",
"(",
"hass",
")",
":",
"request_id",
"=",
"configurator",
".",
"async_request_config",
"(",
"hass",
",",
"\"Test Request\"",
",",
"lambda",
"_",
":",
"None",
")",
"error",
"=",
"\"Oh no bad bad bad\"",
"configura... | [
75,
0
] | [
84,
66
] | python | en | ['en', 'en', 'en'] | True |
test_notify_errors_fail_silently_on_bad_request_id | (hass) | Test if notify errors fails silently with a bad request id. | Test if notify errors fails silently with a bad request id. | async def test_notify_errors_fail_silently_on_bad_request_id(hass):
"""Test if notify errors fails silently with a bad request id."""
configurator.async_notify_errors(hass, 2015, "Try this error") | [
"async",
"def",
"test_notify_errors_fail_silently_on_bad_request_id",
"(",
"hass",
")",
":",
"configurator",
".",
"async_notify_errors",
"(",
"hass",
",",
"2015",
",",
"\"Try this error\"",
")"
] | [
87,
0
] | [
89,
66
] | python | en | ['en', 'en', 'en'] | True |
test_request_done_works | (hass) | Test if calling request done works. | Test if calling request done works. | async def test_request_done_works(hass):
"""Test if calling request done works."""
request_id = configurator.async_request_config(hass, "Test Request", lambda _: None)
configurator.async_request_done(hass, request_id)
assert 1 == len(hass.states.async_all())
hass.bus.async_fire(EVENT_TIME_CHANGED)
... | [
"async",
"def",
"test_request_done_works",
"(",
"hass",
")",
":",
"request_id",
"=",
"configurator",
".",
"async_request_config",
"(",
"hass",
",",
"\"Test Request\"",
",",
"lambda",
"_",
":",
"None",
")",
"configurator",
".",
"async_request_done",
"(",
"hass",
... | [
92,
0
] | [
100,
44
] | python | en | ['en', 'en', 'en'] | True |
test_request_done_fail_silently_on_bad_request_id | (hass) | Test that request_done fails silently with a bad request id. | Test that request_done fails silently with a bad request id. | async def test_request_done_fail_silently_on_bad_request_id(hass):
"""Test that request_done fails silently with a bad request id."""
configurator.async_request_done(hass, 2016) | [
"async",
"def",
"test_request_done_fail_silently_on_bad_request_id",
"(",
"hass",
")",
":",
"configurator",
".",
"async_request_done",
"(",
"hass",
",",
"2016",
")"
] | [
103,
0
] | [
105,
47
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Volumio component. | Set up the Volumio component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Volumio component."""
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"return",
"True"
] | [
16,
0
] | [
18,
15
] | python | en | ['en', 'sr', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Volumio from a config entry. | Set up Volumio from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Volumio from a config entry."""
volumio = Volumio(
entry.data[CONF_HOST], entry.data[CONF_PORT], async_get_clientsession(hass)
)
try:
info = await volumio.get_system_version()
except CannotConnectError a... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"volumio",
"=",
"Volumio",
"(",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"entry",
".",
"data",
"[",
"CONF_PORT",
"]",
",",
"async... | [
21,
0
] | [
42,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
45,
0
] | [
58,
20
] | python | en | ['en', 'es', 'en'] | True |
options_updated | (hass, entry) | Handle options update. | Handle options update. | async def options_updated(hass, entry):
"""Handle options update."""
gateway = hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][entry.data[CONF_ID]]
async_dispatcher_send(hass, gateway.options_update_signal, entry) | [
"async",
"def",
"options_updated",
"(",
"hass",
",",
"entry",
")",
":",
"gateway",
"=",
"hass",
".",
"data",
"[",
"DATA_OPENTHERM_GW",
"]",
"[",
"DATA_GATEWAYS",
"]",
"[",
"entry",
".",
"data",
"[",
"CONF_ID",
"]",
"]",
"async_dispatcher_send",
"(",
"hass"... | [
79,
0
] | [
82,
69
] | python | en | ['en', 'nl', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up the OpenTherm Gateway component. | Set up the OpenTherm Gateway component. | async def async_setup_entry(hass, config_entry):
"""Set up the OpenTherm Gateway component."""
if DATA_OPENTHERM_GW not in hass.data:
hass.data[DATA_OPENTHERM_GW] = {DATA_GATEWAYS: {}}
gateway = OpenThermGatewayDevice(hass, config_entry)
hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS][config_entry.... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"if",
"DATA_OPENTHERM_GW",
"not",
"in",
"hass",
".",
"data",
":",
"hass",
".",
"data",
"[",
"DATA_OPENTHERM_GW",
"]",
"=",
"{",
"DATA_GATEWAYS",
":",
"{",
"}",
"}",
"gateway",... | [
85,
0
] | [
104,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the OpenTherm Gateway component. | Set up the OpenTherm Gateway component. | async def async_setup(hass, config):
"""Set up the OpenTherm Gateway component."""
if not hass.config_entries.async_entries(DOMAIN) and DOMAIN in config:
conf = config[DOMAIN]
for device_id, device_config in conf.items():
device_config[CONF_ID] = device_id
hass.async_cre... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"if",
"not",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
"and",
"DOMAIN",
"in",
"config",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"for",
"device_id"... | [
107,
0
] | [
119,
15
] | python | en | ['en', 'en', 'en'] | True |
register_services | (hass) | Register services for the component. | Register services for the component. | def register_services(hass):
"""Register services for the component."""
service_reset_schema = vol.Schema(
{
vol.Required(ATTR_GW_ID): vol.All(
cv.string, vol.In(hass.data[DATA_OPENTHERM_GW][DATA_GATEWAYS])
)
}
)
service_set_central_heating_ovrd_sc... | [
"def",
"register_services",
"(",
"hass",
")",
":",
"service_reset_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"ATTR_GW_ID",
")",
":",
"vol",
".",
"All",
"(",
"cv",
".",
"string",
",",
"vol",
".",
"In",
"(",
"hass",
".",... | [
122,
0
] | [
381,
5
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Cleanup and disconnect from gateway. | Cleanup and disconnect from gateway. | async def async_unload_entry(hass, entry):
"""Cleanup and disconnect from gateway."""
await asyncio.gather(
hass.config_entries.async_forward_entry_unload(entry, COMP_BINARY_SENSOR),
hass.config_entries.async_forward_entry_unload(entry, COMP_CLIMATE),
hass.config_entries.async_forward_en... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"await",
"asyncio",
".",
"gather",
"(",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"COMP_BINARY_SENSOR",
")",
",",
"hass",
".",
"config_entries",... | [
384,
0
] | [
393,
15
] | python | en | ['en', 'en', 'en'] | True |
OpenThermGatewayDevice.__init__ | (self, hass, config_entry) | Initialize the OpenTherm Gateway. | Initialize the OpenTherm Gateway. | def __init__(self, hass, config_entry):
"""Initialize the OpenTherm Gateway."""
self.hass = hass
self.device_path = config_entry.data[CONF_DEVICE]
self.gw_id = config_entry.data[CONF_ID]
self.name = config_entry.data[CONF_NAME]
self.climate_config = config_entry.options
... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"device_path",
"=",
"config_entry",
".",
"data",
"[",
"CONF_DEVICE",
"]",
"self",
".",
"gw_id",
"=",
"config_entry",
".",
"data",
... | [
399,
4
] | [
410,
30
] | python | en | ['en', 'en', 'en'] | True |
OpenThermGatewayDevice.cleanup | (self, event=None) | Reset overrides on the gateway. | Reset overrides on the gateway. | async def cleanup(self, event=None):
"""Reset overrides on the gateway."""
await self.gateway.set_control_setpoint(0)
await self.gateway.set_max_relative_mod("-")
await self.gateway.disconnect() | [
"async",
"def",
"cleanup",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"await",
"self",
".",
"gateway",
".",
"set_control_setpoint",
"(",
"0",
")",
"await",
"self",
".",
"gateway",
".",
"set_max_relative_mod",
"(",
"\"-\"",
")",
"await",
"self",
".... | [
412,
4
] | [
416,
39
] | python | en | ['en', 'en', 'en'] | True |
OpenThermGatewayDevice.connect_and_subscribe | (self) | Connect to serial device and subscribe report handler. | Connect to serial device and subscribe report handler. | async def connect_and_subscribe(self):
"""Connect to serial device and subscribe report handler."""
self.status = await self.gateway.connect(self.hass.loop, self.device_path)
_LOGGER.debug("Connected to OpenTherm Gateway at %s", self.device_path)
self.gw_version = self.status.get(gw_vars... | [
"async",
"def",
"connect_and_subscribe",
"(",
"self",
")",
":",
"self",
".",
"status",
"=",
"await",
"self",
".",
"gateway",
".",
"connect",
"(",
"self",
".",
"hass",
".",
"loop",
",",
"self",
".",
"device_path",
")",
"_LOGGER",
".",
"debug",
"(",
"\"C... | [
418,
4
] | [
432,
45
] | python | en | ['en', 'en', 'en'] | True |
get_service_handles | () | Get dictionary of {service_name: service_handle}. | Get dictionary of {service_name: service_handle}. | def get_service_handles():
"""Get dictionary of {service_name: service_handle}."""
SERVICE_ACCOUNT_FILE = current_app.config['SERVICE_ACCOUNT_FILE']
# GROUP_KEY = current_app.config['GROUP_KEY']
SCOPES = current_app.config['SCOPES']
credentials = service_account.Credentials.from_service_account_fil... | [
"def",
"get_service_handles",
"(",
")",
":",
"SERVICE_ACCOUNT_FILE",
"=",
"current_app",
".",
"config",
"[",
"'SERVICE_ACCOUNT_FILE'",
"]",
"# GROUP_KEY = current_app.config['GROUP_KEY']",
"SCOPES",
"=",
"current_app",
".",
"config",
"[",
"'SCOPES'",
"]",
"credentials",
... | [
18,
0
] | [
36,
5
] | python | en | ['en', 'en', 'en'] | True |
get_members_dict | () | Get dictionary of {google_id: email_address}.
Return:
members_dict (dict): google ID: email dictionary.
| Get dictionary of {google_id: email_address}. | def get_members_dict():
"""Get dictionary of {google_id: email_address}.
Return:
members_dict (dict): google ID: email dictionary.
"""
service = SERVICE_HANDLES['dir']
# GOOGLE GROUP MEMBERS
group_key = current_app.config['GROUP_KEY']
logging.info("Looking up group members list.")... | [
"def",
"get_members_dict",
"(",
")",
":",
"service",
"=",
"SERVICE_HANDLES",
"[",
"'dir'",
"]",
"# GOOGLE GROUP MEMBERS",
"group_key",
"=",
"current_app",
".",
"config",
"[",
"'GROUP_KEY'",
"]",
"logging",
".",
"info",
"(",
"\"Looking up group members list.\"",
")",... | [
42,
0
] | [
61,
23
] | python | en | ['en', 'en', 'en'] | True |
get_domain_users | () | Get list of domain users (who might not be in specified Google Group).
Warning: will only fetch up to 100 users.
| Get list of domain users (who might not be in specified Google Group). | def get_domain_users():
"""Get list of domain users (who might not be in specified Google Group).
Warning: will only fetch up to 100 users.
"""
users = []
service = SERVICE_HANDLES['dir']
logger.info("Looking up domain-specific users.")
res = service.users().list(customer='my_customer').exe... | [
"def",
"get_domain_users",
"(",
")",
":",
"users",
"=",
"[",
"]",
"service",
"=",
"SERVICE_HANDLES",
"[",
"'dir'",
"]",
"logger",
".",
"info",
"(",
"\"Looking up domain-specific users.\"",
")",
"res",
"=",
"service",
".",
"users",
"(",
")",
".",
"list",
"(... | [
64,
0
] | [
79,
16
] | python | en | ['en', 'en', 'en'] | True |
ApiTable.refresh_df | (self) | Subclasses will override this method. | Subclasses will override this method. | def refresh_df(self):
"""Subclasses will override this method."""
pass | [
"def",
"refresh_df",
"(",
"self",
")",
":",
"pass"
] | [
101,
4
] | [
103,
12
] | python | en | ['en', 'en', 'en'] | True |
ApiTable._get_utc_naive | (dt) | Convert timezone aware timestamp to UTC naive timestamp. | Convert timezone aware timestamp to UTC naive timestamp. | def _get_utc_naive(dt):
"""Convert timezone aware timestamp to UTC naive timestamp."""
return dt.astimezone(timezone.utc).replace(tzinfo=None) | [
"def",
"_get_utc_naive",
"(",
"dt",
")",
":",
"return",
"dt",
".",
"astimezone",
"(",
"timezone",
".",
"utc",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"None",
")"
] | [
117,
4
] | [
119,
63
] | python | en | ['en', 'bg-Latn', 'en'] | True |
StatusTable.refresh_df | (self) | Return status table. Example below.
status n_requests
0 Unassigned 2
1 Processing 0
2 Shipped 0
3 Received 1
4 Problem 0
5 Cancelled 0
| Return status table. Example below.
status n_requests
0 Unassigned 2
1 Processing 0
2 Shipped 0
3 Received 1
4 Problem 0
5 Cancelled 0
| def refresh_df(self):
"""Return status table. Example below.
status n_requests
0 Unassigned 2
1 Processing 0
2 Shipped 0
3 Received 1
4 Problem 0
5 Cancell... | [
"def",
"refresh_df",
"(",
"self",
")",
":",
"status_dict",
"=",
"OrderedDict",
"(",
"[",
"(",
"'unassigned'",
",",
"'Unassigned'",
")",
",",
"(",
"'processing'",
",",
"'Processing'",
")",
",",
"(",
"'shipped'",
",",
"'Shipped'",
")",
",",
"(",
"'received'"... | [
134,
4
] | [
158,
27
] | python | en | ['en', 'id', 'en'] | True |
Calendar.parse_datetime | (start_dict) | Get naive datetime in UTC or date for dates. | Get naive datetime in UTC or date for dates. | def parse_datetime(start_dict):
"""Get naive datetime in UTC or date for dates."""
if 'dateTime' in start_dict:
return parse_timestamp_str(start_dict['dateTime'])
if 'date' in start_dict:
return datetime.strptime(start_dict['date'], '%Y-%m-%d').date() | [
"def",
"parse_datetime",
"(",
"start_dict",
")",
":",
"if",
"'dateTime'",
"in",
"start_dict",
":",
"return",
"parse_timestamp_str",
"(",
"start_dict",
"[",
"'dateTime'",
"]",
")",
"if",
"'date'",
"in",
"start_dict",
":",
"return",
"datetime",
".",
"strptime",
... | [
190,
4
] | [
195,
75
] | python | en | ['en', 'en', 'en'] | True |
Calendar.parse_time | (time) | Return naive datetime in UTC. | Return naive datetime in UTC. | def parse_time(time):
"""Return naive datetime in UTC."""
if pd.isnull(time):
return np.nan
stripped = time[:-3] + time[-2:] # remove colon in UTC offset
dt = datetime.strptime(stripped, '%Y-%m-%dT%H:%M:%S%z')
return ApiTable._get_utc_naive(dt) | [
"def",
"parse_time",
"(",
"time",
")",
":",
"if",
"pd",
".",
"isnull",
"(",
"time",
")",
":",
"return",
"np",
".",
"nan",
"stripped",
"=",
"time",
"[",
":",
"-",
"3",
"]",
"+",
"time",
"[",
"-",
"2",
":",
"]",
"# remove colon in UTC offset",
"dt",
... | [
198,
4
] | [
204,
42
] | python | en | ['en', 'sl', 'en'] | True |
Calendar.in_past | (t) | Get 'in past' status (True or False) for date or time.
Args:
t: timezone aware or naive timestamps, or date
| Get 'in past' status (True or False) for date or time. | def in_past(t):
"""Get 'in past' status (True or False) for date or time.
Args:
t: timezone aware or naive timestamps, or date
"""
now_naive = datetime.now()
now = now_naive if t.tzinfo is None else now_naive.replace(tzinfo=timezone.utc)
if isinstance(t, date... | [
"def",
"in_past",
"(",
"t",
")",
":",
"now_naive",
"=",
"datetime",
".",
"now",
"(",
")",
"now",
"=",
"now_naive",
"if",
"t",
".",
"tzinfo",
"is",
"None",
"else",
"now_naive",
".",
"replace",
"(",
"tzinfo",
"=",
"timezone",
".",
"utc",
")",
"if",
"... | [
207,
4
] | [
220,
33
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass) | Set up demo cover component. | Set up demo cover component. | async def setup_comp(hass):
"""Set up demo cover component."""
with assert_setup_component(1, DOMAIN):
await async_setup_component(hass, DOMAIN, CONFIG)
await hass.async_block_till_done() | [
"async",
"def",
"setup_comp",
"(",
"hass",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"DOMAIN",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"CONFIG",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")... | [
40,
0
] | [
44,
42
] | python | en | ['en', 'en', 'en'] | True |
test_supported_features | (hass, setup_comp) | Test cover supported features. | Test cover supported features. | async def test_supported_features(hass, setup_comp):
"""Test cover supported features."""
state = hass.states.get("cover.garage_door")
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 3
state = hass.states.get("cover.kitchen_window")
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 11
stat... | [
"async",
"def",
"test_supported_features",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"cover.garage_door\"",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_SUPPORTED_FEATURES",
"]",
"==",
"3",
"stat... | [
47,
0
] | [
56,
59
] | python | en | ['en', 'en', 'en'] | True |
test_close_cover | (hass, setup_comp) | Test closing the cover. | Test closing the cover. | async def test_close_cover(hass, setup_comp):
"""Test closing the cover."""
state = hass.states.get(ENTITY_COVER)
assert state.state == STATE_OPEN
assert state.attributes[ATTR_CURRENT_POSITION] == 70
await hass.services.async_call(
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}... | [
"async",
"def",
"test_close_cover",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_OPEN",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_C... | [
59,
0
] | [
77,
55
] | python | en | ['en', 'en', 'en'] | True |
test_open_cover | (hass, setup_comp) | Test opening the cover. | Test opening the cover. | async def test_open_cover(hass, setup_comp):
"""Test opening the cover."""
state = hass.states.get(ENTITY_COVER)
assert state.state == STATE_OPEN
assert state.attributes[ATTR_CURRENT_POSITION] == 70
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, b... | [
"async",
"def",
"test_open_cover",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_OPEN",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CU... | [
80,
0
] | [
97,
57
] | python | en | ['en', 'en', 'en'] | True |
test_toggle_cover | (hass, setup_comp) | Test toggling the cover. | Test toggling the cover. | async def test_toggle_cover(hass, setup_comp):
"""Test toggling the cover."""
# Start open
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
)
for _ in range(7):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fir... | [
"async",
"def",
"test_toggle_cover",
"(",
"hass",
",",
"setup_comp",
")",
":",
"# Start open",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_COVER",
"}",
",",
"blocking",
... | [
100,
0
] | [
137,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_cover_position | (hass, setup_comp) | Test moving the cover to a specific position. | Test moving the cover to a specific position. | async def test_set_cover_position(hass, setup_comp):
"""Test moving the cover to a specific position."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_POSITION] == 70
await hass.services.async_call(
DOMAIN,
SERVICE_SET_COVER_POSITION,
{ATTR_ENTITY_ID:... | [
"async",
"def",
"test_set_cover_position",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_POSITION",
"]",
"==",
"70",
"await",
"has... | [
140,
0
] | [
156,
56
] | python | en | ['en', 'en', 'en'] | True |
test_stop_cover | (hass, setup_comp) | Test stopping the cover. | Test stopping the cover. | async def test_stop_cover(hass, setup_comp):
"""Test stopping the cover."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_POSITION] == 70
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
)
future = dt_u... | [
"async",
"def",
"test_stop_cover",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_POSITION",
"]",
"==",
"70",
"await",
"hass",
".... | [
159,
0
] | [
175,
56
] | python | en | ['en', 'en', 'en'] | True |
test_close_cover_tilt | (hass, setup_comp) | Test closing the cover tilt. | Test closing the cover tilt. | async def test_close_cover_tilt(hass, setup_comp):
"""Test closing the cover tilt."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
await hass.services.async_call(
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
... | [
"async",
"def",
"test_close_cover_tilt",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TILT_POSITION",
"]",
"==",
"50",
"await",
"... | [
178,
0
] | [
191,
60
] | python | en | ['en', 'no', 'en'] | True |
test_open_cover_tilt | (hass, setup_comp) | Test opening the cover tilt. | Test opening the cover tilt. | async def test_open_cover_tilt(hass, setup_comp):
"""Test opening the cover tilt."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
... | [
"async",
"def",
"test_open_cover_tilt",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TILT_POSITION",
"]",
"==",
"50",
"await",
"h... | [
194,
0
] | [
207,
62
] | python | en | ['en', 'no', 'en'] | True |
test_toggle_cover_tilt | (hass, setup_comp) | Test toggling the cover tilt. | Test toggling the cover tilt. | async def test_toggle_cover_tilt(hass, setup_comp):
"""Test toggling the cover tilt."""
# Start open
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
)
for _ in range(7):
future = dt_util.utcnow() + timedelta(seconds=1)
... | [
"async",
"def",
"test_toggle_cover_tilt",
"(",
"hass",
",",
"setup_comp",
")",
":",
"# Start open",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER_TILT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_COVER",
"}",
",",
"bl... | [
210,
0
] | [
244,
62
] | python | en | ['en', 'en', 'en'] | True |
test_set_cover_tilt_position | (hass, setup_comp) | Test moving the cover til to a specific position. | Test moving the cover til to a specific position. | async def test_set_cover_tilt_position(hass, setup_comp):
"""Test moving the cover til to a specific position."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
await hass.services.async_call(
DOMAIN,
SERVICE_SET_COVER_TILT_POSITION,
... | [
"async",
"def",
"test_set_cover_tilt_position",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TILT_POSITION",
"]",
"==",
"50",
"awai... | [
247,
0
] | [
263,
61
] | python | en | ['en', 'en', 'en'] | True |
test_stop_cover_tilt | (hass, setup_comp) | Test stopping the cover tilt. | Test stopping the cover tilt. | async def test_stop_cover_tilt(hass, setup_comp):
"""Test stopping the cover tilt."""
state = hass.states.get(ENTITY_COVER)
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 50
await hass.services.async_call(
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True
... | [
"async",
"def",
"test_stop_cover_tilt",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_COVER",
")",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_CURRENT_TILT_POSITION",
"]",
"==",
"50",
"await",
"h... | [
266,
0
] | [
282,
61
] | python | en | ['en', 'no', 'en'] | True |
nni_log | (log_type, log_message) | Log message into stdout | Log message into stdout | def nni_log(log_type, log_message):
'''Log message into stdout'''
dt = datetime.now()
print('[{0}] {1} {2}'.format(dt, log_type.value, log_message), flush=True) | [
"def",
"nni_log",
"(",
"log_type",
",",
"log_message",
")",
":",
"dt",
"=",
"datetime",
".",
"now",
"(",
")",
"print",
"(",
"'[{0}] {1} {2}'",
".",
"format",
"(",
"dt",
",",
"log_type",
".",
"value",
",",
"log_message",
")",
",",
"flush",
"=",
"True",
... | [
39,
0
] | [
42,
78
] | python | en | ['en', 'en', 'en'] | True |
RemoteLogger.__init__ | (self, syslog_host, syslog_port, tag, std_output_type, log_collection, trial_id=None, channel=None, log_level=logging.INFO) |
constructor
|
constructor
| def __init__(self, syslog_host, syslog_port, tag, std_output_type, log_collection, trial_id=None, channel=None, log_level=logging.INFO):
'''
constructor
'''
logger_name = 'nni_syslog_{}'.format(tag)
# to prevent multiple trial logged in same logger
if trial_id is not None... | [
"def",
"__init__",
"(",
"self",
",",
"syslog_host",
",",
"syslog_port",
",",
"tag",
",",
"std_output_type",
",",
"log_collection",
",",
"trial_id",
"=",
"None",
",",
"channel",
"=",
"None",
",",
"log_level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger_n... | [
80,
4
] | [
98,
44
] | python | en | ['en', 'error', 'th'] | False |
RemoteLogger.get_pipelog_reader | (self) |
Get pipe for remote logger
|
Get pipe for remote logger
| def get_pipelog_reader(self):
'''
Get pipe for remote logger
'''
self.pipeReader = PipeLogReader(self.logger, self.log_collection, logging.INFO)
return self.pipeReader | [
"def",
"get_pipelog_reader",
"(",
"self",
")",
":",
"self",
".",
"pipeReader",
"=",
"PipeLogReader",
"(",
"self",
".",
"logger",
",",
"self",
".",
"log_collection",
",",
"logging",
".",
"INFO",
")",
"return",
"self",
".",
"pipeReader"
] | [
100,
4
] | [
105,
30
] | python | en | ['en', 'error', 'th'] | False |
RemoteLogger.flush | (self) |
Add flush in handler
|
Add flush in handler
| def flush(self):
'''
Add flush in handler
'''
for handler in self.logger.handlers:
handler.flush() | [
"def",
"flush",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
":",
"handler",
".",
"flush",
"(",
")"
] | [
107,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
RemoteLogger.write | (self, buf) |
Write buffer data into logger/stdout
|
Write buffer data into logger/stdout
| def write(self, buf):
'''
Write buffer data into logger/stdout
'''
for line in buf.rstrip().splitlines():
self.orig_stdout.write(line.rstrip() + '\n')
self.orig_stdout.flush()
try:
self.logger.log(self.log_level, line.rstrip())
... | [
"def",
"write",
"(",
"self",
",",
"buf",
")",
":",
"for",
"line",
"in",
"buf",
".",
"rstrip",
"(",
")",
".",
"splitlines",
"(",
")",
":",
"self",
".",
"orig_stdout",
".",
"write",
"(",
"line",
".",
"rstrip",
"(",
")",
"+",
"'\\n'",
")",
"self",
... | [
114,
4
] | [
124,
20
] | python | en | ['en', 'error', 'th'] | False |
RemoteLogger.close | (self) |
Close handlers and resources
|
Close handlers and resources
| def close(self):
'''
Close handlers and resources
'''
if self.pipeReader is not None:
self.pipeReader.set_process_exit()
for handler in self.logger.handlers:
handler.close()
self.logger.removeHandler(handler) | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"pipeReader",
"is",
"not",
"None",
":",
"self",
".",
"pipeReader",
".",
"set_process_exit",
"(",
")",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
":",
"handler",
".",
"close"... | [
126,
4
] | [
134,
46
] | python | en | ['en', 'error', 'th'] | False |
PipeLogReader.__init__ | (self, logger, log_collection, log_level=logging.INFO) | Setup the object with a logger and a loglevel
and start the thread
| Setup the object with a logger and a loglevel
and start the thread
| def __init__(self, logger, log_collection, log_level=logging.INFO):
"""Setup the object with a logger and a loglevel
and start the thread
"""
threading.Thread.__init__(self)
self.queue = Queue()
self.logger = logger
self.daemon = False
self.log_level = log... | [
"def",
"__init__",
"(",
"self",
",",
"logger",
",",
"log_collection",
",",
"log_level",
"=",
"logging",
".",
"INFO",
")",
":",
"threading",
".",
"Thread",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"queue",
"=",
"Queue",
"(",
")",
"self",
".",
"... | [
142,
4
] | [
180,
42
] | python | en | ['en', 'en', 'en'] | True |
PipeLogReader.fileno | (self) | Return the write file descriptor of the pipe
| Return the write file descriptor of the pipe
| def fileno(self):
"""Return the write file descriptor of the pipe
"""
return self.fdWrite | [
"def",
"fileno",
"(",
"self",
")",
":",
"return",
"self",
".",
"fdWrite"
] | [
182,
4
] | [
185,
27
] | python | en | ['en', 'it', 'en'] | True |
PipeLogReader.run | (self) | Run the thread, logging everything.
If the log_collection is 'none', the log content will not be enqueued
| Run the thread, logging everything.
If the log_collection is 'none', the log content will not be enqueued
| def run(self):
"""Run the thread, logging everything.
If the log_collection is 'none', the log content will not be enqueued
"""
for line in iter(self.pipeReader.readline, ''):
self.orig_stdout.write(line.rstrip() + '\n')
self.orig_stdout.flush()
if... | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"line",
"in",
"iter",
"(",
"self",
".",
"pipeReader",
".",
"readline",
",",
"''",
")",
":",
"self",
".",
"orig_stdout",
".",
"write",
"(",
"line",
".",
"rstrip",
"(",
")",
"+",
"'\\n'",
")",
"self",
"."... | [
187,
4
] | [
203,
31
] | python | en | ['en', 'zh', 'en'] | True |
PipeLogReader.close | (self) | Close the write end of the pipe.
| Close the write end of the pipe.
| def close(self):
"""Close the write end of the pipe.
"""
os.close(self.fdWrite) | [
"def",
"close",
"(",
"self",
")",
":",
"os",
".",
"close",
"(",
"self",
".",
"fdWrite",
")"
] | [
205,
4
] | [
208,
30
] | python | en | ['en', 'en', 'en'] | True |
PipeLogReader.is_read_completed | (self) | Return if read is completed
| Return if read is completed
| def is_read_completed(self):
"""Return if read is completed
"""
return self._is_read_completed | [
"def",
"is_read_completed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_read_completed"
] | [
211,
4
] | [
214,
38
] | python | en | ['en', 'en', 'en'] | True |
top_k_filter | (logits, k, probs=False) |
Masks everything but the k top entries as -infinity (1e10).
Used to mask logits such that e^-infinity -> 0 won't contribute to the
sum of the denominator.
|
Masks everything but the k top entries as -infinity (1e10).
Used to mask logits such that e^-infinity -> 0 won't contribute to the
sum of the denominator.
| def top_k_filter(logits, k, probs=False):
"""
Masks everything but the k top entries as -infinity (1e10).
Used to mask logits such that e^-infinity -> 0 won't contribute to the
sum of the denominator.
"""
if k == 0:
return logits
else:
values = torch.topk(logits, k)[0]
... | [
"def",
"top_k_filter",
"(",
"logits",
",",
"k",
",",
"probs",
"=",
"False",
")",
":",
"if",
"k",
"==",
"0",
":",
"return",
"logits",
"else",
":",
"values",
"=",
"torch",
".",
"topk",
"(",
"logits",
",",
"k",
")",
"[",
"0",
"]",
"batch_mins",
"=",... | [
76,
0
] | [
89,
93
] | python | en | ['en', 'error', 'th'] | False |
LayoutLMPreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
612,
4
] | [
626,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Dune HD media player platform. | Set up the Dune HD media player platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Dune HD media player platform."""
host = config.get(CONF_HOST)
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_HOST: ho... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config... | [
45,
0
] | [
53,
5
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Add Dune HD entities from a config_entry. | Add Dune HD entities from a config_entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Add Dune HD entities from a config_entry."""
unique_id = config_entry.entry_id
player = hass.data[DOMAIN][config_entry.entry_id]
async_add_entities([DuneHDPlayerEntity(player, DEFAULT_NAME, unique_id)], True) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"unique_id",
"=",
"config_entry",
".",
"entry_id",
"player",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
... | [
56,
0
] | [
62,
83
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.__init__ | (self, player, name, unique_id) | Initialize entity to control Dune HD. | Initialize entity to control Dune HD. | def __init__(self, player, name, unique_id):
"""Initialize entity to control Dune HD."""
self._player = player
self._name = name
self._media_title = None
self._state = None
self._unique_id = unique_id | [
"def",
"__init__",
"(",
"self",
",",
"player",
",",
"name",
",",
"unique_id",
")",
":",
"self",
".",
"_player",
"=",
"player",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_media_title",
"=",
"None",
"self",
".",
"_state",
"=",
"None",
"self",
".... | [
68,
4
] | [
74,
35
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.update | (self) | Update internal status of the entity. | Update internal status of the entity. | def update(self):
"""Update internal status of the entity."""
self._state = self._player.update_state()
self.__update_title()
return True | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"update_state",
"(",
")",
"self",
".",
"__update_title",
"(",
")",
"return",
"True"
] | [
76,
4
] | [
80,
19
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.state | (self) | Return player state. | Return player state. | def state(self):
"""Return player state."""
state = STATE_OFF
if "playback_position" in self._state:
state = STATE_PLAYING
if self._state.get("player_state") in ("playing", "buffering", "photo_viewer"):
state = STATE_PLAYING
if int(self._state.get("playbac... | [
"def",
"state",
"(",
"self",
")",
":",
"state",
"=",
"STATE_OFF",
"if",
"\"playback_position\"",
"in",
"self",
".",
"_state",
":",
"state",
"=",
"STATE_PLAYING",
"if",
"self",
".",
"_state",
".",
"get",
"(",
"\"player_state\"",
")",
"in",
"(",
"\"playing\"... | [
83,
4
] | [
94,
20
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return bool(self._state) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"_state",
")"
] | [
102,
4
] | [
104,
32
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.unique_id | (self) | Return a unique_id for this entity. | Return a unique_id for this entity. | def unique_id(self):
"""Return a unique_id for this entity."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
107,
4
] | [
109,
30
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self._unique_id)},
"name": DEFAULT_NAME,
"manufacturer": ATTR_MANUFACTURER,
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_unique_id",
")",
"}",
",",
"\"name\"",
":",
"DEFAULT_NAME",
",",
"\"manufacturer\"",
":",
"ATTR_MANUFACTURER",
",",
"}"
] | [
112,
4
] | [
118,
9
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.volume_level | (self) | Return the volume level of the media player (0..1). | Return the volume level of the media player (0..1). | def volume_level(self):
"""Return the volume level of the media player (0..1)."""
return int(self._state.get("playback_volume", 0)) / 100 | [
"def",
"volume_level",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"_state",
".",
"get",
"(",
"\"playback_volume\"",
",",
"0",
")",
")",
"/",
"100"
] | [
121,
4
] | [
123,
63
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.is_volume_muted | (self) | Return a boolean if volume is currently muted. | Return a boolean if volume is currently muted. | def is_volume_muted(self):
"""Return a boolean if volume is currently muted."""
return int(self._state.get("playback_mute", 0)) == 1 | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"_state",
".",
"get",
"(",
"\"playback_mute\"",
",",
"0",
")",
")",
"==",
"1"
] | [
126,
4
] | [
128,
60
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return DUNEHD_PLAYER_SUPPORT | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"DUNEHD_PLAYER_SUPPORT"
] | [
131,
4
] | [
133,
36
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.volume_up | (self) | Volume up media player. | Volume up media player. | def volume_up(self):
"""Volume up media player."""
self._state = self._player.volume_up() | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"volume_up",
"(",
")"
] | [
135,
4
] | [
137,
46
] | python | en | ['en', 'no', 'en'] | True |
DuneHDPlayerEntity.volume_down | (self) | Volume down media player. | Volume down media player. | def volume_down(self):
"""Volume down media player."""
self._state = self._player.volume_down() | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"volume_down",
"(",
")"
] | [
139,
4
] | [
141,
48
] | python | en | ['en', 'sl', 'en'] | True |
DuneHDPlayerEntity.mute_volume | (self, mute) | Mute/unmute player volume. | Mute/unmute player volume. | def mute_volume(self, mute):
"""Mute/unmute player volume."""
self._state = self._player.mute(mute) | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"mute",
"(",
"mute",
")"
] | [
143,
4
] | [
145,
45
] | python | de | ['nl', 'de', 'it'] | False |
DuneHDPlayerEntity.turn_off | (self) | Turn off media player. | Turn off media player. | def turn_off(self):
"""Turn off media player."""
self._media_title = None
self._state = self._player.turn_off() | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_media_title",
"=",
"None",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"turn_off",
"(",
")"
] | [
147,
4
] | [
150,
45
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.turn_on | (self) | Turn off media player. | Turn off media player. | def turn_on(self):
"""Turn off media player."""
self._state = self._player.turn_on() | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"turn_on",
"(",
")"
] | [
152,
4
] | [
154,
44
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.media_play | (self) | Play media player. | Play media player. | def media_play(self):
"""Play media player."""
self._state = self._player.play() | [
"def",
"media_play",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"play",
"(",
")"
] | [
156,
4
] | [
158,
41
] | python | en | ['fr', 'en', 'en'] | True |
DuneHDPlayerEntity.media_pause | (self) | Pause media player. | Pause media player. | def media_pause(self):
"""Pause media player."""
self._state = self._player.pause() | [
"def",
"media_pause",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"pause",
"(",
")"
] | [
160,
4
] | [
162,
42
] | python | en | ['fr', 'en', 'en'] | True |
DuneHDPlayerEntity.media_title | (self) | Return the current media source. | Return the current media source. | def media_title(self):
"""Return the current media source."""
self.__update_title()
if self._media_title:
return self._media_title | [
"def",
"media_title",
"(",
"self",
")",
":",
"self",
".",
"__update_title",
"(",
")",
"if",
"self",
".",
"_media_title",
":",
"return",
"self",
".",
"_media_title"
] | [
165,
4
] | [
169,
36
] | python | en | ['en', 'en', 'en'] | True |
DuneHDPlayerEntity.media_previous_track | (self) | Send previous track command. | Send previous track command. | def media_previous_track(self):
"""Send previous track command."""
self._state = self._player.previous_track() | [
"def",
"media_previous_track",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"previous_track",
"(",
")"
] | [
181,
4
] | [
183,
51
] | python | en | ['en', 'it', 'en'] | True |
DuneHDPlayerEntity.media_next_track | (self) | Send next track command. | Send next track command. | def media_next_track(self):
"""Send next track command."""
self._state = self._player.next_track() | [
"def",
"media_next_track",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_player",
".",
"next_track",
"(",
")"
] | [
185,
4
] | [
187,
47
] | python | en | ['en', 'pt', 'en'] | True |
setup | (hass: HomeAssistant, yaml_config: Dict[str, Any]) | Activate Google Pub/Sub component. | Activate Google Pub/Sub component. | def setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
"""Activate Google Pub/Sub component."""
config = yaml_config[DOMAIN]
project_id = config[CONF_PROJECT_ID]
topic_name = config[CONF_TOPIC_NAME]
service_principal_path = os.path.join(
hass.config.config_dir, config[CONF_SERVICE_PRI... | [
"def",
"setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"yaml_config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"config",
"=",
"yaml_config",
"[",
"DOMAIN",
"]",
"project_id",
"=",
"config",
"[",
"CONF_PROJECT_ID",
"]",
"topic_name",
"=",
"con... | [
39,
0
] | [
82,
15
] | python | en | ['en', 'la', 'en'] | True |
DateTimeJSONEncoder.default | (self, o) | Implement encoding logic. | Implement encoding logic. | def default(self, o):
"""Implement encoding logic."""
if isinstance(o, datetime.datetime):
return o.isoformat()
return super().default(o) | [
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"o",
".",
"isoformat",
"(",
")",
"return",
"super",
"(",
")",
".",
"default",
"(",
"o",
")"
] | [
91,
4
] | [
95,
33
] | python | en | ['fr', 'zu', 'en'] | False |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up the Tradfri component. | Set up the Tradfri component. | async def async_setup(hass: HomeAssistantType, config: ConfigType):
"""Set up the Tradfri component."""
conf = config.get(DOMAIN)
if conf is None:
return True
configured_hosts = [
entry.data.get("host") for entry in hass.config_entries.async_entries(DOMAIN)
]
legacy_hosts = aw... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"if",
"conf",
"is",
"None",
":",
"return",
"True",
"configured_hosts",
"=",
"[",
"ent... | [
58,
0
] | [
100,
15
] | python | en | ['en', 'ca', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Create a gateway. | Create a gateway. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Create a gateway."""
# host, identity, key, allow_tradfri_groups
tradfri_data = hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {}
listeners = tradfri_data[LISTENERS] = []
factory = await APIFactory.init(
entry.... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"# host, identity, key, allow_tradfri_groups",
"tradfri_data",
"=",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
... | [
103,
0
] | [
169,
15
] | python | en | ['en', 'gd', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_un... | [
172,
0
] | [
190,
20
] | python | en | ['en', 'es', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the SendGrid notification service. | Get the SendGrid notification service. | def get_service(hass, config, discovery_info=None):
"""Get the SendGrid notification service."""
return SendgridNotificationService(config) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"SendgridNotificationService",
"(",
"config",
")"
] | [
38,
0
] | [
40,
46
] | python | en | ['en', 'zh', 'en'] | True |
SendgridNotificationService.__init__ | (self, config) | Initialize the service. | Initialize the service. | def __init__(self, config):
"""Initialize the service."""
self.api_key = config[CONF_API_KEY]
self.sender = config[CONF_SENDER]
self.sender_name = config[CONF_SENDER_NAME]
self.recipient = config[CONF_RECIPIENT]
self._sg = SendGridAPIClient(self.api_key) | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"api_key",
"=",
"config",
"[",
"CONF_API_KEY",
"]",
"self",
".",
"sender",
"=",
"config",
"[",
"CONF_SENDER",
"]",
"self",
".",
"sender_name",
"=",
"config",
"[",
"CONF_SENDER_NAME",
"... | [
46,
4
] | [
53,
50
] | python | en | ['en', 'en', 'en'] | True |
SendgridNotificationService.send_message | (self, message="", **kwargs) | Send an email to a user via SendGrid. | Send an email to a user via SendGrid. | def send_message(self, message="", **kwargs):
"""Send an email to a user via SendGrid."""
subject = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
data = {
"personalizations": [
{"to": [{"email": self.recipient}], "subject": subject}
],
"from": {"... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"subject",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
",",
"ATTR_TITLE_DEFAULT",
")",
"data",
"=",
"{",
"\"personalizations\"",
":",
"[",
"{",
"\"to\""... | [
55,
4
] | [
69,
56
] | python | en | ['en', 'gd', 'en'] | True |
async_attach_trigger | (hass, config, action, automation_info) | Listen for tag_scanned events based on configuration. | Listen for tag_scanned events based on configuration. | async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for tag_scanned events based on configuration."""
tag_id = config.get(TAG_ID)
device_id = config.get(DEVICE_ID)
event_data = {TAG_ID: tag_id}
if device_id:
event_data[DEVICE_ID] = device_id
event_config = ... | [
"async",
"def",
"async_attach_trigger",
"(",
"hass",
",",
"config",
",",
"action",
",",
"automation_info",
")",
":",
"tag_id",
"=",
"config",
".",
"get",
"(",
"TAG_ID",
")",
"device_id",
"=",
"config",
".",
"get",
"(",
"DEVICE_ID",
")",
"event_data",
"=",
... | [
18,
0
] | [
36,
5
] | python | en | ['en', 'en', 'en'] | True |
generate_identified_filename | (filename: Path, identifier: str) |
Append a string-identifier at the end (before the extension, if any) to the provided filepath
Args:
filename: pathlib.Path The actual path object we would like to add an identifier suffix
identifier: The suffix to add
Returns: String with concatenated identifier at the end of the filename... |
Append a string-identifier at the end (before the extension, if any) to the provided filepath | def generate_identified_filename(filename: Path, identifier: str) -> Path:
"""
Append a string-identifier at the end (before the extension, if any) to the provided filepath
Args:
filename: pathlib.Path The actual path object we would like to add an identifier suffix
identifier: The suffix t... | [
"def",
"generate_identified_filename",
"(",
"filename",
":",
"Path",
",",
"identifier",
":",
"str",
")",
"->",
"Path",
":",
"return",
"filename",
".",
"parent",
".",
"joinpath",
"(",
"filename",
".",
"stem",
"+",
"identifier",
")",
".",
"with_suffix",
"(",
... | [
90,
0
] | [
100,
92
] | python | en | ['en', 'error', 'th'] | False |
check_onnxruntime_requirements | (minimum_version: Version) |
Check onnxruntime is installed and if the installed version match is recent enough
Raises:
ImportError: If onnxruntime is not installed or too old version is found
|
Check onnxruntime is installed and if the installed version match is recent enough | def check_onnxruntime_requirements(minimum_version: Version):
"""
Check onnxruntime is installed and if the installed version match is recent enough
Raises:
ImportError: If onnxruntime is not installed or too old version is found
"""
try:
import onnxruntime
# Parse the vers... | [
"def",
"check_onnxruntime_requirements",
"(",
"minimum_version",
":",
"Version",
")",
":",
"try",
":",
"import",
"onnxruntime",
"# Parse the version of the installed onnxruntime",
"ort_version",
"=",
"parse",
"(",
"onnxruntime",
".",
"__version__",
")",
"# We require 1.4.0 ... | [
103,
0
] | [
129,
9
] | python | en | ['en', 'error', 'th'] | False |
ensure_valid_input | (model, tokens, input_names) |
Ensure input are presented in the correct order, without any Non
Args:
model: The model used to forward the input data
tokens: BatchEncoding holding the input data
input_names: The name of the inputs
Returns: Tuple
|
Ensure input are presented in the correct order, without any Non | def ensure_valid_input(model, tokens, input_names):
"""
Ensure input are presented in the correct order, without any Non
Args:
model: The model used to forward the input data
tokens: BatchEncoding holding the input data
input_names: The name of the inputs
Returns: Tuple
""... | [
"def",
"ensure_valid_input",
"(",
"model",
",",
"tokens",
",",
"input_names",
")",
":",
"print",
"(",
"\"Ensuring inputs are in correct order\"",
")",
"model_args_name",
"=",
"model",
".",
"forward",
".",
"__code__",
".",
"co_varnames",
"model_args",
",",
"ordered_i... | [
132,
0
] | [
157,
49
] | python | en | ['en', 'error', 'th'] | False |
infer_shapes | (nlp: Pipeline, framework: str) |
Attempt to infer the static vs dynamic axes for each input and output tensors for a specific model
Args:
nlp: The pipeline object holding the model to be exported
framework: The framework identifier to dispatch to the correct inference scheme (pt/tf)
Returns:
- List of the inferr... |
Attempt to infer the static vs dynamic axes for each input and output tensors for a specific model | def infer_shapes(nlp: Pipeline, framework: str) -> Tuple[List[str], List[str], Dict, BatchEncoding]:
"""
Attempt to infer the static vs dynamic axes for each input and output tensors for a specific model
Args:
nlp: The pipeline object holding the model to be exported
framework: The framewor... | [
"def",
"infer_shapes",
"(",
"nlp",
":",
"Pipeline",
",",
"framework",
":",
"str",
")",
"->",
"Tuple",
"[",
"List",
"[",
"str",
"]",
",",
"List",
"[",
"str",
"]",
",",
"Dict",
",",
"BatchEncoding",
"]",
":",
"def",
"build_shape_dict",
"(",
"name",
":"... | [
160,
0
] | [
221,
57
] | python | en | ['en', 'error', 'th'] | False |
load_graph_from_args | (
pipeline_name: str, framework: str, model: str, tokenizer: Optional[str] = None, **models_kwargs
) |
Convert the set of arguments provided through the CLI to an actual pipeline reference (tokenizer + model
Args:
pipeline_name: The kind of pipeline to use (ner, question-answering, etc.)
framework: The actual model to convert the pipeline from ("pt" or "tf")
model: The model name which ... |
Convert the set of arguments provided through the CLI to an actual pipeline reference (tokenizer + model | def load_graph_from_args(
pipeline_name: str, framework: str, model: str, tokenizer: Optional[str] = None, **models_kwargs
) -> Pipeline:
"""
Convert the set of arguments provided through the CLI to an actual pipeline reference (tokenizer + model
Args:
pipeline_name: The kind of pipeline to use... | [
"def",
"load_graph_from_args",
"(",
"pipeline_name",
":",
"str",
",",
"framework",
":",
"str",
",",
"model",
":",
"str",
",",
"tokenizer",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"models_kwargs",
")",
"->",
"Pipeline",
":",
"# If no... | [
224,
0
] | [
252,
117
] | python | en | ['en', 'error', 'th'] | False |
convert_pytorch | (nlp: Pipeline, opset: int, output: Path, use_external_format: bool) |
Export a PyTorch backed pipeline to ONNX Intermediate Representation (IR
Args:
nlp: The pipeline to be exported
opset: The actual version of the ONNX operator set to use
output: Path where will be stored the generated ONNX model
use_external_format: Split the model definition f... |
Export a PyTorch backed pipeline to ONNX Intermediate Representation (IR | def convert_pytorch(nlp: Pipeline, opset: int, output: Path, use_external_format: bool):
"""
Export a PyTorch backed pipeline to ONNX Intermediate Representation (IR
Args:
nlp: The pipeline to be exported
opset: The actual version of the ONNX operator set to use
output: Path where w... | [
"def",
"convert_pytorch",
"(",
"nlp",
":",
"Pipeline",
",",
"opset",
":",
"int",
",",
"output",
":",
"Path",
",",
"use_external_format",
":",
"bool",
")",
":",
"if",
"not",
"is_torch_available",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"Cannot convert bec... | [
255,
0
] | [
291,
9
] | python | en | ['en', 'error', 'th'] | False |
convert_tensorflow | (nlp: Pipeline, opset: int, output: Path) |
Export a TensorFlow backed pipeline to ONNX Intermediate Representation (IR
Args:
nlp: The pipeline to be exported
opset: The actual version of the ONNX operator set to use
output: Path where will be stored the generated ONNX model
Notes: TensorFlow cannot export model bigger than... |
Export a TensorFlow backed pipeline to ONNX Intermediate Representation (IR | def convert_tensorflow(nlp: Pipeline, opset: int, output: Path):
"""
Export a TensorFlow backed pipeline to ONNX Intermediate Representation (IR
Args:
nlp: The pipeline to be exported
opset: The actual version of the ONNX operator set to use
output: Path where will be stored the gen... | [
"def",
"convert_tensorflow",
"(",
"nlp",
":",
"Pipeline",
",",
"opset",
":",
"int",
",",
"output",
":",
"Path",
")",
":",
"if",
"not",
"is_tf_available",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"Cannot convert because TF is not installed. Please install tensorfl... | [
294,
0
] | [
328,
119
] | python | en | ['en', 'error', 'th'] | False |
convert | (
framework: str,
model: str,
output: Path,
opset: int,
tokenizer: Optional[str] = None,
use_external_format: bool = False,
pipeline_name: str = "feature-extraction",
**model_kwargs
) |
Convert the pipeline object to the ONNX Intermediate Representation (IR) format
Args:
framework: The framework the pipeline is backed by ("pt" or "tf")
model: The name of the model to load for the pipeline
output: The path where the ONNX graph will be stored
opset: The actual v... |
Convert the pipeline object to the ONNX Intermediate Representation (IR) format | def convert(
framework: str,
model: str,
output: Path,
opset: int,
tokenizer: Optional[str] = None,
use_external_format: bool = False,
pipeline_name: str = "feature-extraction",
**model_kwargs
):
"""
Convert the pipeline object to the ONNX Intermediate Representation (IR) format
... | [
"def",
"convert",
"(",
"framework",
":",
"str",
",",
"model",
":",
"str",
",",
"output",
":",
"Path",
",",
"opset",
":",
"int",
",",
"tokenizer",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"use_external_format",
":",
"bool",
"=",
"False",
",... | [
331,
0
] | [
372,
46
] | python | en | ['en', 'error', 'th'] | False |
optimize | (onnx_model_path: Path) |
Load the model at the specified path and let onnxruntime look at transformations on the graph to enable all the
optimizations possibl
Args:
onnx_model_path: filepath where the model binary description is stored
Returns: Path where the optimized model binary description has been saved
|
Load the model at the specified path and let onnxruntime look at transformations on the graph to enable all the
optimizations possibl | def optimize(onnx_model_path: Path) -> Path:
"""
Load the model at the specified path and let onnxruntime look at transformations on the graph to enable all the
optimizations possibl
Args:
onnx_model_path: filepath where the model binary description is stored
Returns: Path where the optimi... | [
"def",
"optimize",
"(",
"onnx_model_path",
":",
"Path",
")",
"->",
"Path",
":",
"from",
"onnxruntime",
"import",
"InferenceSession",
",",
"SessionOptions",
"# Generate model name with suffix \"optimized\"",
"opt_model_path",
"=",
"generate_identified_filename",
"(",
"onnx_m... | [
375,
0
] | [
397,
25
] | python | en | ['en', 'error', 'th'] | False |
quantize | (onnx_model_path: Path) |
Quantize the weights of the model from float32 to in8 to allow very efficient inference on modern CPU
Args:
onnx_model_path: Path to location the exported ONNX model is stored
Returns: The Path generated for the quantized
|
Quantize the weights of the model from float32 to in8 to allow very efficient inference on modern CPU | def quantize(onnx_model_path: Path) -> Path:
"""
Quantize the weights of the model from float32 to in8 to allow very efficient inference on modern CPU
Args:
onnx_model_path: Path to location the exported ONNX model is stored
Returns: The Path generated for the quantized
"""
import onnx... | [
"def",
"quantize",
"(",
"onnx_model_path",
":",
"Path",
")",
"->",
"Path",
":",
"import",
"onnx",
"from",
"onnxruntime",
".",
"quantization",
"import",
"QuantizationMode",
",",
"quantize",
"onnx_model",
"=",
"onnx",
".",
"load",
"(",
"onnx_model_path",
".",
"a... | [
400,
0
] | [
434,
31
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.