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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
EufySwitch.update | (self) | Synchronise state from the switch. | Synchronise state from the switch. | def update(self):
"""Synchronise state from the switch."""
self._switch.update()
self._state = self._switch.power | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_switch",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_switch",
".",
"power"
] | [
27,
4
] | [
30,
40
] | python | en | ['en', 'en', 'en'] | True |
EufySwitch.unique_id | (self) | Return the ID of this light. | Return the ID of this light. | def unique_id(self):
"""Return the ID of this light."""
return self._address | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_address"
] | [
33,
4
] | [
35,
28
] | python | en | ['en', 'en', 'en'] | True |
EufySwitch.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self):
"""Return the name of the device if any."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
38,
4
] | [
40,
25
] | python | en | ['en', 'en', 'en'] | True |
EufySwitch.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
43,
4
] | [
45,
26
] | python | en | ['en', 'fy', 'en'] | True |
EufySwitch.turn_on | (self, **kwargs) | Turn the specified switch on. | Turn the specified switch on. | def turn_on(self, **kwargs):
"""Turn the specified switch on."""
try:
self._switch.set_state(True)
except BrokenPipeError:
self._switch.connect()
self._switch.set_state(power=True) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_switch",
".",
"set_state",
"(",
"True",
")",
"except",
"BrokenPipeError",
":",
"self",
".",
"_switch",
".",
"connect",
"(",
")",
"self",
".",
"_switch",
".",... | [
47,
4
] | [
53,
46
] | python | en | ['en', 'en', 'en'] | True |
EufySwitch.turn_off | (self, **kwargs) | Turn the specified switch off. | Turn the specified switch off. | def turn_off(self, **kwargs):
"""Turn the specified switch off."""
try:
self._switch.set_state(False)
except BrokenPipeError:
self._switch.connect()
self._switch.set_state(False) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"_switch",
".",
"set_state",
"(",
"False",
")",
"except",
"BrokenPipeError",
":",
"self",
".",
"_switch",
".",
"connect",
"(",
")",
"self",
".",
"_switch",
".... | [
55,
4
] | [
61,
41
] | python | en | ['en', 'en', 'en'] | True |
BlenderbotSmallTokenizerFast.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. BlenderbotSmall
does not make use of token type ids, therefore a list of zeros is returned.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:ob... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. BlenderbotSmall
does not make use of token type ids, therefore a list of zeros is returned. | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Create a mask from the two sequences passed to be used in a sequence-pair classification task. BlenderbotSmall
does not make use of token type ids, ther... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
95,
4
] | [
116,
75
] | python | en | ['en', 'error', 'th'] | False |
validate_projector | (hass: HomeAssistant, host, port) | Validate the given host and port allows us to connect. | Validate the given host and port allows us to connect. | async def validate_projector(hass: HomeAssistant, host, port):
"""Validate the given host and port allows us to connect."""
epson_proj = Projector(
host=host,
websession=async_get_clientsession(hass, verify_ssl=False),
port=port,
)
_power = await epson_proj.get_property(POWER)
... | [
"async",
"def",
"validate_projector",
"(",
"hass",
":",
"HomeAssistant",
",",
"host",
",",
"port",
")",
":",
"epson_proj",
"=",
"Projector",
"(",
"host",
"=",
"host",
",",
"websession",
"=",
"async_get_clientsession",
"(",
"hass",
",",
"verify_ssl",
"=",
"Fa... | [
21,
0
] | [
31,
21
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the epson component. | Set up the epson component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the epson component."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
34,
0
] | [
37,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up epson from a config entry. | Set up epson from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up epson from a config entry."""
try:
projector = await validate_projector(
hass, entry.data[CONF_HOST], entry.data[CONF_PORT]
)
except CannotConnect:
_LOGGER.warning("Cannot connect to projector... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"try",
":",
"projector",
"=",
"await",
"validate_projector",
"(",
"hass",
",",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"entry",
".... | [
40,
0
] | [
54,
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... | [
57,
0
] | [
69,
20
] | python | en | ['en', 'es', 'en'] | True |
setup | (hass, config: dict) | Set up the BMW connected drive components. | Set up the BMW connected drive components. | def setup(hass, config: dict):
"""Set up the BMW connected drive components."""
accounts = []
for name, account_config in config[DOMAIN].items():
accounts.append(setup_account(account_config, hass, name))
hass.data[DOMAIN] = accounts
def _update_all(call) -> None:
"""Update all BMW... | [
"def",
"setup",
"(",
"hass",
",",
"config",
":",
"dict",
")",
":",
"accounts",
"=",
"[",
"]",
"for",
"name",
",",
"account_config",
"in",
"config",
"[",
"DOMAIN",
"]",
".",
"items",
"(",
")",
":",
"accounts",
".",
"append",
"(",
"setup_account",
"(",... | [
47,
0
] | [
68,
15
] | python | en | ['en', 'en', 'en'] | True |
setup_account | (account_config: dict, hass, name: str) | Set up a new BMWConnectedDriveAccount based on the config. | Set up a new BMWConnectedDriveAccount based on the config. | def setup_account(account_config: dict, hass, name: str) -> "BMWConnectedDriveAccount":
"""Set up a new BMWConnectedDriveAccount based on the config."""
username = account_config[CONF_USERNAME]
password = account_config[CONF_PASSWORD]
region = account_config[CONF_REGION]
read_only = account_config[C... | [
"def",
"setup_account",
"(",
"account_config",
":",
"dict",
",",
"hass",
",",
"name",
":",
"str",
")",
"->",
"\"BMWConnectedDriveAccount\"",
":",
"username",
"=",
"account_config",
"[",
"CONF_USERNAME",
"]",
"password",
"=",
"account_config",
"[",
"CONF_PASSWORD",... | [
71,
0
] | [
113,
21
] | python | en | ['en', 'en', 'en'] | True |
BMWConnectedDriveAccount.__init__ | (
self, username: str, password: str, region_str: str, name: str, read_only
) | Initialize account. | Initialize account. | def __init__(
self, username: str, password: str, region_str: str, name: str, read_only
) -> None:
"""Initialize account."""
region = get_region_from_name(region_str)
self.read_only = read_only
self.account = ConnectedDriveAccount(username, password, region)
self.nam... | [
"def",
"__init__",
"(",
"self",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"region_str",
":",
"str",
",",
"name",
":",
"str",
",",
"read_only",
")",
"->",
"None",
":",
"region",
"=",
"get_region_from_name",
"(",
"region_str",
")",
"... | [
119,
4
] | [
128,
35
] | python | en | ['en', 'en', 'en'] | False |
BMWConnectedDriveAccount.update | (self, *_) | Update the state of all vehicles.
Notify all listeners about the update.
| Update the state of all vehicles. | def update(self, *_):
"""Update the state of all vehicles.
Notify all listeners about the update.
"""
_LOGGER.debug(
"Updating vehicle state for account %s, notifying %d listeners",
self.name,
len(self._update_listeners),
)
try:
... | [
"def",
"update",
"(",
"self",
",",
"*",
"_",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating vehicle state for account %s, notifying %d listeners\"",
",",
"self",
".",
"name",
",",
"len",
"(",
"self",
".",
"_update_listeners",
")",
",",
")",
"try",
":",
... | [
130,
4
] | [
149,
40
] | python | en | ['en', 'en', 'en'] | True |
BMWConnectedDriveAccount.add_update_listener | (self, listener) | Add a listener for update notifications. | Add a listener for update notifications. | def add_update_listener(self, listener):
"""Add a listener for update notifications."""
self._update_listeners.append(listener) | [
"def",
"add_update_listener",
"(",
"self",
",",
"listener",
")",
":",
"self",
".",
"_update_listeners",
".",
"append",
"(",
"listener",
")"
] | [
151,
4
] | [
153,
47
] | python | en | ['en', 'en', 'en'] | True |
init_config_flow | (hass) | Init a configuration flow. | Init a configuration flow. | def init_config_flow(hass):
"""Init a configuration flow."""
config_flow.register_flow_implementation(
hass,
DOMAIN,
client_id="id",
client_secret="secret",
api_key="123",
redirect_uri="http://example.com",
sensors=None,
)
flow = config_flow.LogiCi... | [
"def",
"init_config_flow",
"(",
"hass",
")",
":",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"DOMAIN",
",",
"client_id",
"=",
"\"id\"",
",",
"client_secret",
"=",
"\"secret\"",
",",
"api_key",
"=",
"\"123\"",
",",
"redirect_uri",
"=",
... | [
28,
0
] | [
44,
15
] | python | en | ['es', 'fr', 'en'] | False |
mock_logi_circle | () | Mock logi_circle. | Mock logi_circle. | def mock_logi_circle():
"""Mock logi_circle."""
with patch(
"homeassistant.components.logi_circle.config_flow.LogiCircle"
) as logi_circle:
LogiCircle = logi_circle()
LogiCircle.authorize = AsyncMock(return_value=True)
LogiCircle.close = AsyncMock(return_value=True)
L... | [
"def",
"mock_logi_circle",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.logi_circle.config_flow.LogiCircle\"",
")",
"as",
"logi_circle",
":",
"LogiCircle",
"=",
"logi_circle",
"(",
")",
"LogiCircle",
".",
"authorize",
"=",
"AsyncMock",
"(",
"return... | [
48,
0
] | [
58,
24
] | python | en | ['en', 'yo', 'en'] | False |
test_step_import | (
hass, mock_logi_circle # pylint: disable=redefined-outer-name
) | Test that we trigger import when configuring with client. | Test that we trigger import when configuring with client. | async def test_step_import(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
result = await flow.async_step_import()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert re... | [
"async",
"def",
"test_step_import",
"(",
"hass",
",",
"mock_logi_circle",
"# pylint: disable=redefined-outer-name",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_import",
"(",
")",
"assert",
"result",
... | [
61,
0
] | [
69,
38
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow_implementation | (
hass, mock_logi_circle # pylint: disable=redefined-outer-name
) | Test registering an implementation and finishing flow works. | Test registering an implementation and finishing flow works. | async def test_full_flow_implementation(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(
hass,
"test-other",
client_id=None,
client_secret=None,
... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
",",
"mock_logi_circle",
"# pylint: disable=redefined-outer-name",
")",
":",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"\"test-other\"",
",",
"client_id",
"=",
"None",
",",
"client_s... | [
72,
0
] | [
100,
65
] | python | en | ['en', 'en', 'en'] | True |
test_we_reprompt_user_to_follow_link | (hass) | Test we prompt user to follow link if previously prompted. | Test we prompt user to follow link if previously prompted. | async def test_we_reprompt_user_to_follow_link(hass):
"""Test we prompt user to follow link if previously prompted."""
flow = init_config_flow(hass)
result = await flow.async_step_auth("dummy")
assert result["errors"]["base"] == "follow_link" | [
"async",
"def",
"test_we_reprompt_user_to_follow_link",
"(",
"hass",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_auth",
"(",
"\"dummy\"",
")",
"assert",
"result",
"[",
"\"errors\"",
"]",
"[",
"\... | [
103,
0
] | [
108,
52
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_no_implementation_registered | (hass) | Test we abort if no implementation is registered. | Test we abort if no implementation is registered. | async def test_abort_if_no_implementation_registered(hass):
"""Test we abort if no implementation is registered."""
flow = config_flow.LogiCircleFlowHandler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"... | [
"async",
"def",
"test_abort_if_no_implementation_registered",
"(",
"hass",
")",
":",
"flow",
"=",
"config_flow",
".",
"LogiCircleFlowHandler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",... | [
111,
0
] | [
118,
54
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_already_setup | (hass) | Test we abort if Logi Circle is already setup. | Test we abort if Logi Circle is already setup. | async def test_abort_if_already_setup(hass):
"""Test we abort if Logi Circle is already setup."""
flow = init_config_flow(hass)
with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_... | [
"async",
"def",
"test_abort_if_already_setup",
"(",
"hass",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config_entries",
",",
"\"async_entries\"",
",",
"return_value",
"=",
"[",
"{",
"}",
"]... | [
121,
0
] | [
143,
47
] | python | en | ['en', 'zu', 'en'] | True |
test_abort_if_authorize_fails | (
hass, mock_logi_circle, side_effect, error
) | Test we abort if authorizing fails. | Test we abort if authorizing fails. | async def test_abort_if_authorize_fails(
hass, mock_logi_circle, side_effect, error
): # pylint: disable=redefined-outer-name
"""Test we abort if authorizing fails."""
flow = init_config_flow(hass)
mock_logi_circle.authorize.side_effect = side_effect
result = await flow.async_step_code("123ABC")
... | [
"async",
"def",
"test_abort_if_authorize_fails",
"(",
"hass",
",",
"mock_logi_circle",
",",
"side_effect",
",",
"error",
")",
":",
"# pylint: disable=redefined-outer-name",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"mock_logi_circle",
".",
"authorize",
".",
"... | [
153,
0
] | [
165,
44
] | python | en | ['en', 'zu', 'en'] | True |
test_not_pick_implementation_if_only_one | (hass) | Test we bypass picking implementation if we have one flow_imp. | Test we bypass picking implementation if we have one flow_imp. | async def test_not_pick_implementation_if_only_one(hass):
"""Test we bypass picking implementation if we have one flow_imp."""
flow = init_config_flow(hass)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "auth" | [
"async",
"def",
"test_not_pick_implementation_if_only_one",
"(",
"hass",
")",
":",
"flow",
"=",
"init_config_flow",
"(",
"hass",
")",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",
"\"type\"",
"]",
"==",
"data_entry_fl... | [
168,
0
] | [
174,
38
] | python | en | ['en', 'en', 'en'] | True |
test_gen_auth_url | (
hass, mock_logi_circle
) | Test generating authorize URL from Logi Circle API. | Test generating authorize URL from Logi Circle API. | async def test_gen_auth_url(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
"""Test generating authorize URL from Logi Circle API."""
config_flow.register_flow_implementation(
hass,
"test-auth-url",
client_id="id",
client_secret="secret",
api_key="1... | [
"async",
"def",
"test_gen_auth_url",
"(",
"hass",
",",
"mock_logi_circle",
")",
":",
"# pylint: disable=redefined-outer-name",
"config_flow",
".",
"register_flow_implementation",
"(",
"hass",
",",
"\"test-auth-url\"",
",",
"client_id",
"=",
"\"id\"",
",",
"client_secret",... | [
177,
0
] | [
196,
43
] | python | en | ['en', 'zu', 'en'] | True |
test_callback_view_rejects_missing_code | (hass) | Test the auth callback view rejects requests with no code. | Test the auth callback view rejects requests with no code. | async def test_callback_view_rejects_missing_code(hass):
"""Test the auth callback view rejects requests with no code."""
view = LogiCircleAuthCallbackView()
resp = await view.get(MockRequest(hass, {}))
assert resp.status == 400 | [
"async",
"def",
"test_callback_view_rejects_missing_code",
"(",
"hass",
")",
":",
"view",
"=",
"LogiCircleAuthCallbackView",
"(",
")",
"resp",
"=",
"await",
"view",
".",
"get",
"(",
"MockRequest",
"(",
"hass",
",",
"{",
"}",
")",
")",
"assert",
"resp",
".",
... | [
199,
0
] | [
204,
29
] | python | en | ['en', 'en', 'en'] | True |
test_callback_view_accepts_code | (
hass, mock_logi_circle
) | Test the auth callback view handles requests with auth code. | Test the auth callback view handles requests with auth code. | async def test_callback_view_accepts_code(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
"""Test the auth callback view handles requests with auth code."""
init_config_flow(hass)
view = LogiCircleAuthCallbackView()
resp = await view.get(MockRequest(hass, {"code": "456"}))
as... | [
"async",
"def",
"test_callback_view_accepts_code",
"(",
"hass",
",",
"mock_logi_circle",
")",
":",
"# pylint: disable=redefined-outer-name",
"init_config_flow",
"(",
"hass",
")",
"view",
"=",
"LogiCircleAuthCallbackView",
"(",
")",
"resp",
"=",
"await",
"view",
".",
"... | [
207,
0
] | [
218,
56
] | python | en | ['en', 'en', 'en'] | True |
MockRequest.__init__ | (self, hass, query) | Init request object. | Init request object. | def __init__(self, hass, query):
"""Init request object."""
self.app = {"hass": hass}
self.query = query | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"query",
")",
":",
"self",
".",
"app",
"=",
"{",
"\"hass\"",
":",
"hass",
"}",
"self",
".",
"query",
"=",
"query"
] | [
22,
4
] | [
25,
26
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Bitcoin sensors. | Set up the Bitcoin sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Bitcoin sensors."""
currency = config[CONF_CURRENCY]
if currency not in exchangerates.get_ticker():
_LOGGER.warning("Currency %s is not available. Using USD", currency)
currency = DEFAULT_CURRENCY
data ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"currency",
"=",
"config",
"[",
"CONF_CURRENCY",
"]",
"if",
"currency",
"not",
"in",
"exchangerates",
".",
"get_ticker",
"(",
")",
":",
... | [
62,
0
] | [
76,
27
] | python | en | ['en', 'su', 'en'] | True |
BitcoinSensor.__init__ | (self, data, option_type, currency) | Initialize the sensor. | Initialize the sensor. | def __init__(self, data, option_type, currency):
"""Initialize the sensor."""
self.data = data
self._name = OPTION_TYPES[option_type][0]
self._unit_of_measurement = OPTION_TYPES[option_type][1]
self._currency = currency
self.type = option_type
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"option_type",
",",
"currency",
")",
":",
"self",
".",
"data",
"=",
"data",
"self",
".",
"_name",
"=",
"OPTION_TYPES",
"[",
"option_type",
"]",
"[",
"0",
"]",
"self",
".",
"_unit_of_measurement",
"=",
"... | [
82,
4
] | [
89,
26
] | python | en | ['en', 'en', 'en'] | True |
BitcoinSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
92,
4
] | [
94,
25
] | python | en | ['en', 'mi', 'en'] | True |
BitcoinSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
97,
4
] | [
99,
26
] | python | en | ['en', 'en', 'en'] | True |
BitcoinSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
102,
4
] | [
104,
40
] | python | en | ['en', 'en', 'en'] | True |
BitcoinSensor.icon | (self) | Return the icon to use in the frontend, if any. | Return the icon to use in the frontend, if any. | def icon(self):
"""Return the icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
107,
4
] | [
109,
19
] | python | en | ['en', 'en', 'en'] | True |
BitcoinSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
112,
4
] | [
114,
46
] | python | en | ['en', 'en', 'en'] | True |
BitcoinSensor.update | (self) | Get the latest data and updates the states. | Get the latest data and updates the states. | def update(self):
"""Get the latest data and updates the states."""
self.data.update()
stats = self.data.stats
ticker = self.data.ticker
if self.type == "exchangerate":
self._state = ticker[self._currency].p15min
self._unit_of_measurement = self._currency... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"data",
".",
"update",
"(",
")",
"stats",
"=",
"self",
".",
"data",
".",
"stats",
"ticker",
"=",
"self",
".",
"data",
".",
"ticker",
"if",
"self",
".",
"type",
"==",
"\"exchangerate\"",
":",
"sel... | [
116,
4
] | [
164,
57
] | python | en | ['en', 'en', 'en'] | True |
BitcoinData.__init__ | (self) | Initialize the data object. | Initialize the data object. | def __init__(self):
"""Initialize the data object."""
self.stats = None
self.ticker = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"stats",
"=",
"None",
"self",
".",
"ticker",
"=",
"None"
] | [
170,
4
] | [
173,
26
] | python | en | ['en', 'en', 'en'] | True |
BitcoinData.update | (self) | Get the latest data from blockchain.com. | Get the latest data from blockchain.com. | def update(self):
"""Get the latest data from blockchain.com."""
self.stats = statistics.get()
self.ticker = exchangerates.get_ticker() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"stats",
"=",
"statistics",
".",
"get",
"(",
")",
"self",
".",
"ticker",
"=",
"exchangerates",
".",
"get_ticker",
"(",
")"
] | [
175,
4
] | [
179,
48
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the GeoRSS component. | Set up the GeoRSS component. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the GeoRSS component."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
url = config.get(CONF_URL)
radius_in_km = config.get(CONF_RADIUS)
name ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"latitude",
"=",
"config",
".",
"get",
"(",
"CONF_LATITUDE",
",",
"hass",
".",
"config",
".",
"latitude",
")",
"longitude",
"=",
"config... | [
59,
0
] | [
95,
31
] | python | en | ['en', 'en', 'en'] | True |
GeoRssServiceSensor.__init__ | (
self, coordinates, url, radius, category, service_name, unit_of_measurement
) | Initialize the sensor. | Initialize the sensor. | def __init__(
self, coordinates, url, radius, category, service_name, unit_of_measurement
):
"""Initialize the sensor."""
self._category = category
self._service_name = service_name
self._state = None
self._state_attributes = None
self._unit_of_measurement = u... | [
"def",
"__init__",
"(",
"self",
",",
"coordinates",
",",
"url",
",",
"radius",
",",
"category",
",",
"service_name",
",",
"unit_of_measurement",
")",
":",
"self",
".",
"_category",
"=",
"category",
"self",
".",
"_service_name",
"=",
"service_name",
"self",
"... | [
101,
4
] | [
116,
9
] | python | en | ['en', 'en', 'en'] | True |
GeoRssServiceSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return f"{self._service_name} {'Any' if self._category is None else self._category}" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._service_name} {'Any' if self._category is None else self._category}\""
] | [
119,
4
] | [
121,
92
] | python | en | ['en', 'mi', 'en'] | True |
GeoRssServiceSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
124,
4
] | [
126,
26
] | python | en | ['en', 'en', 'en'] | True |
GeoRssServiceSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
129,
4
] | [
131,
40
] | python | en | ['en', 'la', 'en'] | True |
GeoRssServiceSensor.icon | (self) | Return the default icon to use in the frontend. | Return the default icon to use in the frontend. | def icon(self):
"""Return the default icon to use in the frontend."""
return DEFAULT_ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"DEFAULT_ICON"
] | [
134,
4
] | [
136,
27
] | python | en | ['en', 'en', 'en'] | True |
GeoRssServiceSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._state_attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state_attributes"
] | [
139,
4
] | [
141,
37
] | python | en | ['en', 'en', 'en'] | True |
GeoRssServiceSensor.update | (self) | Update this sensor from the GeoRSS service. | Update this sensor from the GeoRSS service. | def update(self):
"""Update this sensor from the GeoRSS service."""
status, feed_entries = self._feed.update()
if status == UPDATE_OK:
_LOGGER.debug(
"Adding events to sensor %s: %s", self.entity_id, feed_entries
)
self._state = len(feed_entri... | [
"def",
"update",
"(",
"self",
")",
":",
"status",
",",
"feed_entries",
"=",
"self",
".",
"_feed",
".",
"update",
"(",
")",
"if",
"status",
"==",
"UPDATE_OK",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Adding events to sensor %s: %s\"",
",",
"self",
".",
"entity... | [
143,
4
] | [
167,
39
] | python | en | ['en', 'en', 'en'] | True |
list_nodes | () | List the nodes in the cluster.
Returns:
None.
| List the nodes in the cluster. | def list_nodes():
"""List the nodes in the cluster.
Returns:
None.
"""
name_to_node_details = redis_controller.get_name_to_node_details()
return list(name_to_node_details.values()) | [
"def",
"list_nodes",
"(",
")",
":",
"name_to_node_details",
"=",
"redis_controller",
".",
"get_name_to_node_details",
"(",
")",
"return",
"list",
"(",
"name_to_node_details",
".",
"values",
"(",
")",
")"
] | [
24,
0
] | [
32,
46
] | python | en | ['en', 'en', 'en'] | True |
get_node | (node_name: str) | Get the node with node_name.
Returns:
None.
| Get the node with node_name. | def get_node(node_name: str):
"""Get the node with node_name.
Returns:
None.
"""
node_details = redis_controller.get_node_details(node_name=node_name)
return node_details | [
"def",
"get_node",
"(",
"node_name",
":",
"str",
")",
":",
"node_details",
"=",
"redis_controller",
".",
"get_node_details",
"(",
"node_name",
"=",
"node_name",
")",
"return",
"node_details"
] | [
37,
0
] | [
45,
23
] | python | en | ['en', 'en', 'en'] | True |
create_node | (**kwargs) | Create a node.
Returns:
None.
| Create a node. | def create_node(**kwargs):
"""Create a node.
Returns:
None.
"""
node_details = kwargs["json_dict"]
# Init runtime params.
if "name" not in node_details and "id" not in node_details:
node_name = NameCreator.create_node_name()
node_details["name"] = node_name
nod... | [
"def",
"create_node",
"(",
"*",
"*",
"kwargs",
")",
":",
"node_details",
"=",
"kwargs",
"[",
"\"json_dict\"",
"]",
"# Init runtime params.",
"if",
"\"name\"",
"not",
"in",
"node_details",
"and",
"\"id\"",
"not",
"in",
"node_details",
":",
"node_name",
"=",
"Na... | [
50,
0
] | [
76,
23
] | python | en | ['en', 'lb', 'en'] | True |
delete_node | (node_name: str) | Delete a node.
Returns:
None.
| Delete a node. | def delete_node(node_name: str):
"""Delete a node.
Returns:
None.
"""
# Get node_details.
node_details = redis_controller.get_node_details(node_name=node_name)
# leave the cluster
command = (
f"ssh -o StrictHostKeyChecking=no "
f"-i {Paths.MARO_LOCAL}/cluster/{loca... | [
"def",
"delete_node",
"(",
"node_name",
":",
"str",
")",
":",
"# Get node_details.",
"node_details",
"=",
"redis_controller",
".",
"get_node_details",
"(",
"node_name",
"=",
"node_name",
")",
"# leave the cluster",
"command",
"=",
"(",
"f\"ssh -o StrictHostKeyChecking=n... | [
81,
0
] | [
104,
23
] | python | ca | ['en', 'ca', 'pt'] | False |
start_node | (node_name: str) | Start a node.
Returns:
None.
| Start a node. | def start_node(node_name: str):
"""Start a node.
Returns:
None.
"""
node_details = redis_controller.get_node_details(node_name=node_name)
# Make sure the node is able to connect
try:
ConnectionTester.retry_connection(
node_username=node_details["username"],
... | [
"def",
"start_node",
"(",
"node_name",
":",
"str",
")",
":",
"node_details",
"=",
"redis_controller",
".",
"get_node_details",
"(",
"node_name",
"=",
"node_name",
")",
"# Make sure the node is able to connect",
"try",
":",
"ConnectionTester",
".",
"retry_connection",
... | [
109,
0
] | [
145,
13
] | python | en | ['en', 'lb', 'en'] | True |
stop_node | (node_name: str) | Stop a node.
Returns:
None.
| Stop a node. | def stop_node(node_name: str):
"""Stop a node.
Returns:
None.
"""
node_details = redis_controller.get_node_details(node_name=node_name)
# Make sure the node is able to connect
try:
ConnectionTester.retry_connection(
node_username=node_details["username"],
... | [
"def",
"stop_node",
"(",
"node_name",
":",
"str",
")",
":",
"node_details",
"=",
"redis_controller",
".",
"get_node_details",
"(",
"node_name",
"=",
"node_name",
")",
"# Make sure the node is able to connect",
"try",
":",
"ConnectionTester",
".",
"retry_connection",
"... | [
150,
0
] | [
186,
13
] | python | ca | ['en', 'ca', 'pt'] | False |
Experiment.__init__ | (self, config: ExperimentConfig) |
Prepare an experiment.
Use `Experiment.run()` to launch it.
Parameters
----------
config
Experiment configuration.
|
Prepare an experiment. | def __init__(self, config: ExperimentConfig) -> None:
"""
Prepare an experiment.
Use `Experiment.run()` to launch it.
Parameters
----------
config
Experiment configuration.
"""
... | [
"def",
"__init__",
"(",
"self",
",",
"config",
":",
"ExperimentConfig",
")",
"->",
"None",
":",
"..."
] | [
37,
4
] | [
48,
11
] | python | en | ['en', 'error', 'th'] | False |
Experiment.__init__ | (self, training_service: Union[str, List[str]]) |
Prepare an experiment, leaving configuration fields to be set later.
Example usage::
experiment = Experiment('remote')
experiment.config.trial_command = 'python3 trial.py'
experiment.config.machines.append(RemoteMachineConfig(ip=..., user_name=...))
...... |
Prepare an experiment, leaving configuration fields to be set later. | def __init__(self, training_service: Union[str, List[str]]) -> None:
"""
Prepare an experiment, leaving configuration fields to be set later.
Example usage::
experiment = Experiment('remote')
experiment.config.trial_command = 'python3 trial.py'
experiment.co... | [
"def",
"__init__",
"(",
"self",
",",
"training_service",
":",
"Union",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
")",
"->",
"None",
":",
"..."
] | [
51,
4
] | [
69,
11
] | python | en | ['en', 'error', 'th'] | False |
Experiment.start | (self, port: int = 8080, debug: bool = False) |
Start the experiment in background.
This method will raise exception on failure.
If it returns, the experiment should have been successfully started.
Parameters
----------
port
The port of web UI.
debug
Whether to start in debug mode.
... |
Start the experiment in background. | def start(self, port: int = 8080, debug: bool = False) -> None:
"""
Start the experiment in background.
This method will raise exception on failure.
If it returns, the experiment should have been successfully started.
Parameters
----------
port
The p... | [
"def",
"start",
"(",
"self",
",",
"port",
":",
"int",
"=",
"8080",
",",
"debug",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"atexit",
".",
"register",
"(",
"self",
".",
"stop",
")",
"if",
"self",
".",
"mode",
"==",
"'new'",
":",
"self",
... | [
89,
4
] | [
128,
25
] | python | en | ['en', 'error', 'th'] | False |
Experiment.stop | (self) |
Stop background experiment.
|
Stop background experiment.
| def stop(self) -> None:
"""
Stop background experiment.
"""
_logger.info('Stopping experiment, please wait...')
atexit.unregister(self.stop)
if self.id is not None:
nni.runtime.log.stop_experiment_log(self.id)
if self._proc is not None:
tr... | [
"def",
"stop",
"(",
"self",
")",
"->",
"None",
":",
"_logger",
".",
"info",
"(",
"'Stopping experiment, please wait...'",
")",
"atexit",
".",
"unregister",
"(",
"self",
".",
"stop",
")",
"if",
"self",
".",
"id",
"is",
"not",
"None",
":",
"nni",
".",
"r... | [
130,
4
] | [
150,
42
] | python | en | ['en', 'error', 'th'] | False |
Experiment.run | (self, port: int = 8080, wait_completion: bool = True, debug: bool = False) |
Run the experiment.
If wait_completion is True, this function will block until experiment finish or error.
Return `True` when experiment done; or return `False` when experiment failed.
Else if wait_completion is False, this function will non-block and return None immediately.
... |
Run the experiment. | def run(self, port: int = 8080, wait_completion: bool = True, debug: bool = False) -> bool:
"""
Run the experiment.
If wait_completion is True, this function will block until experiment finish or error.
Return `True` when experiment done; or return `False` when experiment failed.
... | [
"def",
"run",
"(",
"self",
",",
"port",
":",
"int",
"=",
"8080",
",",
"wait_completion",
":",
"bool",
"=",
"True",
",",
"debug",
":",
"bool",
"=",
"False",
")",
"->",
"bool",
":",
"self",
".",
"start",
"(",
"port",
",",
"debug",
")",
"if",
"wait_... | [
152,
4
] | [
175,
27
] | python | en | ['en', 'error', 'th'] | False |
Experiment.connect | (cls, port: int) |
Connect to an existing experiment.
Parameters
----------
port
The port of web UI.
|
Connect to an existing experiment. | def connect(cls, port: int):
"""
Connect to an existing experiment.
Parameters
----------
port
The port of web UI.
"""
experiment = Experiment()
experiment.port = port
experiment.id = experiment.get_experiment_profile().get('id')
... | [
"def",
"connect",
"(",
"cls",
",",
"port",
":",
"int",
")",
":",
"experiment",
"=",
"Experiment",
"(",
")",
"experiment",
".",
"port",
"=",
"port",
"experiment",
".",
"id",
"=",
"experiment",
".",
"get_experiment_profile",
"(",
")",
".",
"get",
"(",
"'... | [
178,
4
] | [
197,
25
] | python | en | ['en', 'error', 'th'] | False |
Experiment.resume | (cls, experiment_id: str, port: int = 8080, wait_completion: bool = True, debug: bool = False) |
Resume a stopped experiment.
Parameters
----------
experiment_id
The stopped experiment id.
port
The port of web UI.
wait_completion
If true, run in the foreground. If false, run in the background.
debug
Whether to... |
Resume a stopped experiment. | def resume(cls, experiment_id: str, port: int = 8080, wait_completion: bool = True, debug: bool = False):
"""
Resume a stopped experiment.
Parameters
----------
experiment_id
The stopped experiment id.
port
The port of web UI.
wait_complet... | [
"def",
"resume",
"(",
"cls",
",",
"experiment_id",
":",
"str",
",",
"port",
":",
"int",
"=",
"8080",
",",
"wait_completion",
":",
"bool",
"=",
"True",
",",
"debug",
":",
"bool",
"=",
"False",
")",
":",
"experiment",
"=",
"Experiment",
"(",
")",
"expe... | [
200,
4
] | [
220,
29
] | python | en | ['en', 'error', 'th'] | False |
Experiment.view | (cls, experiment_id: str, port: int = 8080, non_blocking: bool = False) |
View a stopped experiment.
Parameters
----------
experiment_id
The stopped experiment id.
port
The port of web UI.
non_blocking
If false, run in the foreground. If true, run in the background.
|
View a stopped experiment. | def view(cls, experiment_id: str, port: int = 8080, non_blocking: bool = False):
"""
View a stopped experiment.
Parameters
----------
experiment_id
The stopped experiment id.
port
The port of web UI.
non_blocking
If false, run ... | [
"def",
"view",
"(",
"cls",
",",
"experiment_id",
":",
"str",
",",
"port",
":",
"int",
"=",
"8080",
",",
"non_blocking",
":",
"bool",
"=",
"False",
")",
":",
"debug",
"=",
"False",
"experiment",
"=",
"Experiment",
"(",
")",
"experiment",
".",
"id",
"=... | [
223,
4
] | [
250,
33
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_status | (self) |
Return experiment status as a str.
Returns
-------
str
Experiment status.
|
Return experiment status as a str. | def get_status(self) -> str:
"""
Return experiment status as a str.
Returns
-------
str
Experiment status.
"""
resp = rest.get(self.port, '/check-status')
return resp['status'] | [
"def",
"get_status",
"(",
"self",
")",
"->",
"str",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/check-status'",
")",
"return",
"resp",
"[",
"'status'",
"]"
] | [
252,
4
] | [
262,
29
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_trial_job | (self, trial_job_id: str) |
Return a trial job.
Parameters
----------
trial_job_id: str
Trial job id.
Returns
-------
TrialJob
A `TrialJob` instance corresponding to `trial_job_id`.
|
Return a trial job. | def get_trial_job(self, trial_job_id: str):
"""
Return a trial job.
Parameters
----------
trial_job_id: str
Trial job id.
Returns
-------
TrialJob
A `TrialJob` instance corresponding to `trial_job_id`.
"""
resp = r... | [
"def",
"get_trial_job",
"(",
"self",
",",
"trial_job_id",
":",
"str",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/trial-jobs/{}'",
".",
"format",
"(",
"trial_job_id",
")",
")",
"return",
"TrialJob",
"(",
"*",
"*",
"resp... | [
264,
4
] | [
279,
31
] | python | en | ['en', 'error', 'th'] | False |
Experiment.list_trial_jobs | (self) |
Return information for all trial jobs as a list.
Returns
-------
list
List of `TrialJob`.
|
Return information for all trial jobs as a list. | def list_trial_jobs(self):
"""
Return information for all trial jobs as a list.
Returns
-------
list
List of `TrialJob`.
"""
resp = rest.get(self.port, '/trial-jobs')
return [TrialJob(**trial_job) for trial_job in resp] | [
"def",
"list_trial_jobs",
"(",
"self",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/trial-jobs'",
")",
"return",
"[",
"TrialJob",
"(",
"*",
"*",
"trial_job",
")",
"for",
"trial_job",
"in",
"resp",
"]"
] | [
281,
4
] | [
291,
60
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_job_statistics | (self) |
Return trial job statistics information as a dict.
Returns
-------
dict
Job statistics information.
|
Return trial job statistics information as a dict. | def get_job_statistics(self):
"""
Return trial job statistics information as a dict.
Returns
-------
dict
Job statistics information.
"""
resp = rest.get(self.port, '/job-statistics')
return resp | [
"def",
"get_job_statistics",
"(",
"self",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/job-statistics'",
")",
"return",
"resp"
] | [
293,
4
] | [
303,
19
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_job_metrics | (self, trial_job_id=None) |
Return trial job metrics.
Parameters
----------
trial_job_id: str
trial job id. if this parameter is None, all trail jobs' metrics will be returned.
Returns
-------
dict
Each key is a trialJobId, the corresponding value is a list of `Tri... |
Return trial job metrics. | def get_job_metrics(self, trial_job_id=None):
"""
Return trial job metrics.
Parameters
----------
trial_job_id: str
trial job id. if this parameter is None, all trail jobs' metrics will be returned.
Returns
-------
dict
Each key i... | [
"def",
"get_job_metrics",
"(",
"self",
",",
"trial_job_id",
"=",
"None",
")",
":",
"api",
"=",
"'/metric-data/{}'",
".",
"format",
"(",
"trial_job_id",
")",
"if",
"trial_job_id",
"else",
"'/metric-data'",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
... | [
305,
4
] | [
328,
26
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_experiment_profile | (self) |
Return experiment profile as a dict.
Returns
-------
dict
The profile of the experiment.
|
Return experiment profile as a dict. | def get_experiment_profile(self):
"""
Return experiment profile as a dict.
Returns
-------
dict
The profile of the experiment.
"""
resp = rest.get(self.port, '/experiment')
return resp | [
"def",
"get_experiment_profile",
"(",
"self",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/experiment'",
")",
"return",
"resp"
] | [
330,
4
] | [
340,
19
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_experiment_metadata | (self, exp_id: str) |
Return experiment metadata with specified exp_id as a dict.
Returns
-------
dict
The specified experiment metadata.
|
Return experiment metadata with specified exp_id as a dict. | def get_experiment_metadata(self, exp_id: str):
"""
Return experiment metadata with specified exp_id as a dict.
Returns
-------
dict
The specified experiment metadata.
"""
experiments_metadata = self.get_all_experiments_metadata()
for metadata... | [
"def",
"get_experiment_metadata",
"(",
"self",
",",
"exp_id",
":",
"str",
")",
":",
"experiments_metadata",
"=",
"self",
".",
"get_all_experiments_metadata",
"(",
")",
"for",
"metadata",
"in",
"experiments_metadata",
":",
"if",
"metadata",
"[",
"'id'",
"]",
"=="... | [
342,
4
] | [
355,
17
] | python | en | ['en', 'error', 'th'] | False |
Experiment.get_all_experiments_metadata | (self) |
Return all experiments metadata as a list.
Returns
-------
list
The experiments metadata.
|
Return all experiments metadata as a list. | def get_all_experiments_metadata(self):
"""
Return all experiments metadata as a list.
Returns
-------
list
The experiments metadata.
"""
resp = rest.get(self.port, '/experiments-info')
return resp | [
"def",
"get_all_experiments_metadata",
"(",
"self",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/experiments-info'",
")",
"return",
"resp"
] | [
357,
4
] | [
367,
19
] | python | en | ['en', 'error', 'th'] | False |
Experiment.export_data | (self) |
Return exported information for all trial jobs.
Returns
-------
list
List of `TrialResult`.
|
Return exported information for all trial jobs. | def export_data(self):
"""
Return exported information for all trial jobs.
Returns
-------
list
List of `TrialResult`.
"""
resp = rest.get(self.port, '/export-data')
return [TrialResult(**trial_result) for trial_result in resp] | [
"def",
"export_data",
"(",
"self",
")",
":",
"resp",
"=",
"rest",
".",
"get",
"(",
"self",
".",
"port",
",",
"'/export-data'",
")",
"return",
"[",
"TrialResult",
"(",
"*",
"*",
"trial_result",
")",
"for",
"trial_result",
"in",
"resp",
"]"
] | [
369,
4
] | [
379,
69
] | python | en | ['en', 'error', 'th'] | False |
Experiment._update_experiment_profile | (self, key: str, value: Any) |
Update an experiment's profile
Parameters
----------
key: str
One of `['trial_concurrency', 'max_experiment_duration', 'search_space', 'max_trial_number']`.
value: Any
New value of the key.
|
Update an experiment's profile | def _update_experiment_profile(self, key: str, value: Any):
"""
Update an experiment's profile
Parameters
----------
key: str
One of `['trial_concurrency', 'max_experiment_duration', 'search_space', 'max_trial_number']`.
value: Any
New value of th... | [
"def",
"_update_experiment_profile",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
":",
"api",
"=",
"'/experiment{}'",
".",
"format",
"(",
"self",
".",
"_get_query_type",
"(",
"key",
")",
")",
"experiment_profile",
"=",
"self",
".",
... | [
391,
4
] | [
406,
52
] | python | en | ['en', 'error', 'th'] | False |
Experiment.update_trial_concurrency | (self, value: int) |
Update an experiment's trial_concurrency
Parameters
----------
value: int
New trial_concurrency value.
|
Update an experiment's trial_concurrency | def update_trial_concurrency(self, value: int):
"""
Update an experiment's trial_concurrency
Parameters
----------
value: int
New trial_concurrency value.
"""
self._update_experiment_profile('trialConcurrency', value) | [
"def",
"update_trial_concurrency",
"(",
"self",
",",
"value",
":",
"int",
")",
":",
"self",
".",
"_update_experiment_profile",
"(",
"'trialConcurrency'",
",",
"value",
")"
] | [
408,
4
] | [
417,
66
] | python | en | ['en', 'error', 'th'] | False |
Experiment.update_max_experiment_duration | (self, value: str) |
Update an experiment's max_experiment_duration
Parameters
----------
value: str
Strings like '1m' for one minute or '2h' for two hours.
SUFFIX may be 's' for seconds, 'm' for minutes, 'h' for hours or 'd' for days.
|
Update an experiment's max_experiment_duration | def update_max_experiment_duration(self, value: str):
"""
Update an experiment's max_experiment_duration
Parameters
----------
value: str
Strings like '1m' for one minute or '2h' for two hours.
SUFFIX may be 's' for seconds, 'm' for minutes, 'h' for hours... | [
"def",
"update_max_experiment_duration",
"(",
"self",
",",
"value",
":",
"str",
")",
":",
"self",
".",
"_update_experiment_profile",
"(",
"'maxExecDuration'",
",",
"value",
")"
] | [
419,
4
] | [
429,
65
] | python | en | ['en', 'error', 'th'] | False |
Experiment.update_search_space | (self, value: dict) |
Update the experiment's search_space.
TODO: support searchspace file.
Parameters
----------
value: dict
New search_space.
|
Update the experiment's search_space.
TODO: support searchspace file. | def update_search_space(self, value: dict):
"""
Update the experiment's search_space.
TODO: support searchspace file.
Parameters
----------
value: dict
New search_space.
"""
value = json_tricks.dumps(value)
self._update_experiment_prof... | [
"def",
"update_search_space",
"(",
"self",
",",
"value",
":",
"dict",
")",
":",
"value",
"=",
"json_tricks",
".",
"dumps",
"(",
"value",
")",
"self",
".",
"_update_experiment_profile",
"(",
"'searchSpace'",
",",
"value",
")"
] | [
431,
4
] | [
442,
61
] | python | en | ['en', 'error', 'th'] | False |
Experiment.update_max_trial_number | (self, value: int) |
Update an experiment's max_trial_number
Parameters
----------
value: int
New max_trial_number value.
|
Update an experiment's max_trial_number | def update_max_trial_number(self, value: int):
"""
Update an experiment's max_trial_number
Parameters
----------
value: int
New max_trial_number value.
"""
self._update_experiment_profile('maxTrialNum', value) | [
"def",
"update_max_trial_number",
"(",
"self",
",",
"value",
":",
"int",
")",
":",
"self",
".",
"_update_experiment_profile",
"(",
"'maxTrialNum'",
",",
"value",
")"
] | [
444,
4
] | [
453,
61
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Beaglebone Black GPIO devices. | Set up the Beaglebone Black GPIO devices. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Beaglebone Black GPIO devices."""
pins = config[CONF_PINS]
binary_sensors = []
for pin, params in pins.items():
binary_sensors.append(BBBGPIOBinarySensor(pin, params))
add_entities(binary_sensors) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"pins",
"=",
"config",
"[",
"CONF_PINS",
"]",
"binary_sensors",
"=",
"[",
"]",
"for",
"pin",
",",
"params",
"in",
"pins",
".",
"items"... | [
31,
0
] | [
39,
32
] | python | en | ['en', 'pt', 'en'] | True |
BBBGPIOBinarySensor.__init__ | (self, pin, params) | Initialize the Beaglebone Black binary sensor. | Initialize the Beaglebone Black binary sensor. | def __init__(self, pin, params):
"""Initialize the Beaglebone Black binary sensor."""
self._pin = pin
self._name = params[CONF_NAME] or DEVICE_DEFAULT_NAME
self._bouncetime = params[CONF_BOUNCETIME]
self._pull_mode = params[CONF_PULL_MODE]
self._invert_logic = params[CONF... | [
"def",
"__init__",
"(",
"self",
",",
"pin",
",",
"params",
")",
":",
"self",
".",
"_pin",
"=",
"pin",
"self",
".",
"_name",
"=",
"params",
"[",
"CONF_NAME",
"]",
"or",
"DEVICE_DEFAULT_NAME",
"self",
".",
"_bouncetime",
"=",
"params",
"[",
"CONF_BOUNCETIM... | [
45,
4
] | [
61,
68
] | python | en | ['en', 'ku', 'en'] | True |
BBBGPIOBinarySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
64,
4
] | [
66,
20
] | python | en | ['en', 'en', 'en'] | True |
BBBGPIOBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
69,
4
] | [
71,
25
] | python | en | ['en', 'mi', 'en'] | True |
BBBGPIOBinarySensor.is_on | (self) | Return the state of the entity. | Return the state of the entity. | def is_on(self):
"""Return the state of the entity."""
return self._state != self._invert_logic | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"!=",
"self",
".",
"_invert_logic"
] | [
74,
4
] | [
76,
48
] | python | en | ['en', 'en', 'en'] | True |
XnliProcessor.get_train_examples | (self, data_dir) | See base class. | See base class. | def get_train_examples(self, data_dir):
"""See base class."""
lg = self.language if self.train_language is None else self.train_language
lines = self._read_tsv(os.path.join(data_dir, "XNLI-MT-1.0/multinli/multinli.train.{}.tsv".format(lg)))
examples = []
for (i, line) in enumerat... | [
"def",
"get_train_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"lg",
"=",
"self",
".",
"language",
"if",
"self",
".",
"train_language",
"is",
"None",
"else",
"self",
".",
"train_language",
"lines",
"=",
"self",
".",
"_read_tsv",
"(",
"os",
".",
"pa... | [
37,
4
] | [
53,
23
] | python | en | ['en', 'en', 'en'] | True |
XnliProcessor.get_test_examples | (self, data_dir) | See base class. | See base class. | def get_test_examples(self, data_dir):
"""See base class."""
lines = self._read_tsv(os.path.join(data_dir, "XNLI-1.0/xnli.test.tsv"))
examples = []
for (i, line) in enumerate(lines):
if i == 0:
continue
language = line[0]
if language !=... | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"lines",
"=",
"self",
".",
"_read_tsv",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"XNLI-1.0/xnli.test.tsv\"",
")",
")",
"examples",
"=",
"[",
"]",
"for",
"(",
"i",
"... | [
55,
4
] | [
73,
23
] | python | en | ['en', 'en', 'en'] | True |
XnliProcessor.get_labels | (self) | See base class. | See base class. | def get_labels(self):
"""See base class."""
return ["contradiction", "entailment", "neutral"] | [
"def",
"get_labels",
"(",
"self",
")",
":",
"return",
"[",
"\"contradiction\"",
",",
"\"entailment\"",
",",
"\"neutral\"",
"]"
] | [
75,
4
] | [
77,
57
] | python | en | ['en', 'en', 'en'] | True |
store | (hass) | Mock store. | Mock store. | def store(hass):
"""Mock store."""
return auth_store.AuthStore(hass) | [
"def",
"store",
"(",
"hass",
")",
":",
"return",
"auth_store",
".",
"AuthStore",
"(",
"hass",
")"
] | [
9,
0
] | [
11,
37
] | python | en | ['en', 'fy', 'en'] | False |
provider | (hass, store) | Mock provider. | Mock provider. | def provider(hass, store):
"""Mock provider."""
return legacy_api_password.LegacyApiPasswordAuthProvider(
hass, store, {"type": "legacy_api_password", "api_password": "test-password"}
) | [
"def",
"provider",
"(",
"hass",
",",
"store",
")",
":",
"return",
"legacy_api_password",
".",
"LegacyApiPasswordAuthProvider",
"(",
"hass",
",",
"store",
",",
"{",
"\"type\"",
":",
"\"legacy_api_password\"",
",",
"\"api_password\"",
":",
"\"test-password\"",
"}",
... | [
15,
0
] | [
19,
5
] | python | en | ['en', 'sv', 'en'] | False |
manager | (hass, store, provider) | Mock manager. | Mock manager. | def manager(hass, store, provider):
"""Mock manager."""
return auth.AuthManager(hass, store, {(provider.type, provider.id): provider}, {}) | [
"def",
"manager",
"(",
"hass",
",",
"store",
",",
"provider",
")",
":",
"return",
"auth",
".",
"AuthManager",
"(",
"hass",
",",
"store",
",",
"{",
"(",
"provider",
".",
"type",
",",
"provider",
".",
"id",
")",
":",
"provider",
"}",
",",
"{",
"}",
... | [
23,
0
] | [
25,
86
] | python | da | ['id', 'da', 'en'] | False |
test_create_new_credential | (manager, provider) | Test that we create a new credential. | Test that we create a new credential. | async def test_create_new_credential(manager, provider):
"""Test that we create a new credential."""
credentials = await provider.async_get_or_create_credentials({})
assert credentials.is_new is True
user = await manager.async_get_or_create_user(credentials)
assert user.name == legacy_api_password.... | [
"async",
"def",
"test_create_new_credential",
"(",
"manager",
",",
"provider",
")",
":",
"credentials",
"=",
"await",
"provider",
".",
"async_get_or_create_credentials",
"(",
"{",
"}",
")",
"assert",
"credentials",
".",
"is_new",
"is",
"True",
"user",
"=",
"awai... | [
28,
0
] | [
35,
25
] | python | en | ['en', 'en', 'en'] | True |
test_only_one_credentials | (manager, provider) | Call create twice will return same credential. | Call create twice will return same credential. | async def test_only_one_credentials(manager, provider):
"""Call create twice will return same credential."""
credentials = await provider.async_get_or_create_credentials({})
await manager.async_get_or_create_user(credentials)
credentials2 = await provider.async_get_or_create_credentials({})
assert c... | [
"async",
"def",
"test_only_one_credentials",
"(",
"manager",
",",
"provider",
")",
":",
"credentials",
"=",
"await",
"provider",
".",
"async_get_or_create_credentials",
"(",
"{",
"}",
")",
"await",
"manager",
".",
"async_get_or_create_user",
"(",
"credentials",
")",... | [
38,
0
] | [
44,
39
] | python | en | ['en', 'en', 'en'] | True |
test_verify_login | (hass, provider) | Test login using legacy api password auth provider. | Test login using legacy api password auth provider. | async def test_verify_login(hass, provider):
"""Test login using legacy api password auth provider."""
provider.async_validate_login("test-password")
with pytest.raises(legacy_api_password.InvalidAuthError):
provider.async_validate_login("invalid-password") | [
"async",
"def",
"test_verify_login",
"(",
"hass",
",",
"provider",
")",
":",
"provider",
".",
"async_validate_login",
"(",
"\"test-password\"",
")",
"with",
"pytest",
".",
"raises",
"(",
"legacy_api_password",
".",
"InvalidAuthError",
")",
":",
"provider",
".",
... | [
47,
0
] | [
51,
57
] | python | en | ['en', 'en', 'en'] | True |
test_login_flow_works | (hass, manager) | Test wrong config. | Test wrong config. | async def test_login_flow_works(hass, manager):
"""Test wrong config."""
result = await manager.login_flow.async_init(handler=("legacy_api_password", None))
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
result = await manager.login_flow.async_configure(
flow_id=result["flow_id"], us... | [
"async",
"def",
"test_login_flow_works",
"(",
"hass",
",",
"manager",
")",
":",
"result",
"=",
"await",
"manager",
".",
"login_flow",
".",
"async_init",
"(",
"handler",
"=",
"(",
"\"legacy_api_password\"",
",",
"None",
")",
")",
"assert",
"result",
"[",
"\"t... | [
54,
0
] | [
68,
69
] | python | en | ['en', 'en', 'en'] | True |
valid_config | (config=None) |
This function validates the bit setting configuration
|
This function validates the bit setting configuration
| def valid_config(config=None):
"""
This function validates the bit setting configuration
"""
if config is None:
return
support_bit = [8, 16, 32]
for name in config.keys():
if 'weight_bit' in config[name]:
w_bit = config[name]['weight_bit']
assert w_bit in ... | [
"def",
"valid_config",
"(",
"config",
"=",
"None",
")",
":",
"if",
"config",
"is",
"None",
":",
"return",
"support_bit",
"=",
"[",
"8",
",",
"16",
",",
"32",
"]",
"for",
"name",
"in",
"config",
".",
"keys",
"(",
")",
":",
"if",
"'weight_bit'",
"in"... | [
30,
0
] | [
43,
77
] | python | en | ['en', 'error', 'th'] | False |
handle_gemm | (network, layer_idx, config) |
This function handles special gemm operation due to layer numbers of gemm changed during pytorch->onnx model convertion.
Parameters
----------
network : tensorrt.INetworkDefinition
Represents a TensorRT Network from which the Builder can build an Engine
layer_idx : int
layer index ... |
This function handles special gemm operation due to layer numbers of gemm changed during pytorch->onnx model convertion. | def handle_gemm(network, layer_idx, config):
"""
This function handles special gemm operation due to layer numbers of gemm changed during pytorch->onnx model convertion.
Parameters
----------
network : tensorrt.INetworkDefinition
Represents a TensorRT Network from which the Builder can buil... | [
"def",
"handle_gemm",
"(",
"network",
",",
"layer_idx",
",",
"config",
")",
":",
"layer",
"=",
"network",
".",
"get_layer",
"(",
"layer_idx",
")",
"pre_layer",
"=",
"network",
".",
"get_layer",
"(",
"layer_idx",
"-",
"1",
")",
"next_layer",
"=",
"network",... | [
45,
0
] | [
95,
88
] | python | en | ['en', 'error', 'th'] | False |
build_engine | (model_file, config=None, extra_layer_bit=32, strict_datatype=False, calib=None) |
This function builds an engine from an onnx model with calibration process.
Parameters
----------
model_file : str
The path of onnx model
config : dict
Config recording bit number and name of layers
extra_layer_bit : int
Other layers which are not in config will be quan... |
This function builds an engine from an onnx model with calibration process. | def build_engine(model_file, config=None, extra_layer_bit=32, strict_datatype=False, calib=None):
"""
This function builds an engine from an onnx model with calibration process.
Parameters
----------
model_file : str
The path of onnx model
config : dict
Config recording bit numb... | [
"def",
"build_engine",
"(",
"model_file",
",",
"config",
"=",
"None",
",",
"extra_layer_bit",
"=",
"32",
",",
"strict_datatype",
"=",
"False",
",",
"calib",
"=",
"None",
")",
":",
"with",
"trt",
".",
"Builder",
"(",
"TRT_LOGGER",
")",
"as",
"builder",
",... | [
97,
0
] | [
199,
21
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT.__init__ | (self, model, input_shape, config=None, onnx_path="default_model.onnx", extra_layer_bit=32, strict_datatype=True,
calibrate_type=CalibrateType.ENTROPY2, calib_data_loader=None, calibration_cache = "calibration.cache", batchsize=1,
input_names=["actual_input_1"], output_names=["output1"]) |
Parameters
----------
model : pytorch model
The model to speed up by quantization.
input_shape : tuple
The input shape of model, shall pass it to torch.onnx.export.
config : dict
Config recording bit number and name of layers.
onnx_pat... |
Parameters
----------
model : pytorch model
The model to speed up by quantization.
input_shape : tuple
The input shape of model, shall pass it to torch.onnx.export.
config : dict
Config recording bit number and name of layers.
onnx_pat... | def __init__(self, model, input_shape, config=None, onnx_path="default_model.onnx", extra_layer_bit=32, strict_datatype=True,
calibrate_type=CalibrateType.ENTROPY2, calib_data_loader=None, calibration_cache = "calibration.cache", batchsize=1,
input_names=["actual_input_1"], output_names=["output1"]):
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"input_shape",
",",
"config",
"=",
"None",
",",
"onnx_path",
"=",
"\"default_model.onnx\"",
",",
"extra_layer_bit",
"=",
"32",
",",
"strict_datatype",
"=",
"True",
",",
"calibrate_type",
"=",
"CalibrateType",
... | [
202,
4
] | [
250,
29
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT.compress | (self) |
Get onnx config and build tensorrt engine.
|
Get onnx config and build tensorrt engine.
| def compress(self):
"""
Get onnx config and build tensorrt engine.
"""
assert self.model is not None
assert self.onnx_path is not None
assert self.input_shape is not None
# Convert pytorch model to onnx model and save onnx model in onnx_path
_, self.onnx_... | [
"def",
"compress",
"(",
"self",
")",
":",
"assert",
"self",
".",
"model",
"is",
"not",
"None",
"assert",
"self",
".",
"onnx_path",
"is",
"not",
"None",
"assert",
"self",
".",
"input_shape",
"is",
"not",
"None",
"# Convert pytorch model to onnx model and save onn... | [
252,
4
] | [
269,
30
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT._tensorrt_build_withcalib | (self, onnx_path) |
Convert pytorch tensor to numpy darray
Parameters
----------
onnx_path : str
The path of onnx model
Returns
-------
tensorrt.IExecutionContext
Context for executing inference using an ICudaEngine
|
Convert pytorch tensor to numpy darray | def _tensorrt_build_withcalib(self, onnx_path):
"""
Convert pytorch tensor to numpy darray
Parameters
----------
onnx_path : str
The path of onnx model
Returns
-------
tensorrt.IExecutionContext
Context for executing inference usi... | [
"def",
"_tensorrt_build_withcalib",
"(",
"self",
",",
"onnx_path",
")",
":",
"calib_data",
"=",
"None",
"if",
"type",
"(",
"self",
".",
"calib_data_loader",
")",
"==",
"torch",
".",
"utils",
".",
"data",
".",
"dataloader",
".",
"DataLoader",
":",
"calib_data... | [
271,
4
] | [
299,
48
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT._tensorrt_build_withoutcalib | (self, onnx_path) |
Build inference engine without calibration
Parameters
----------
onnx_path : str
The path of onnx model
Returns
-------
tensorrt.IExecutionContext
Context for executing inference using an ICudaEngine
|
Build inference engine without calibration | def _tensorrt_build_withoutcalib(self, onnx_path):
"""
Build inference engine without calibration
Parameters
----------
onnx_path : str
The path of onnx model
Returns
-------
tensorrt.IExecutionContext
Context for executing infere... | [
"def",
"_tensorrt_build_withoutcalib",
"(",
"self",
",",
"onnx_path",
")",
":",
"engine",
"=",
"build_engine",
"(",
"onnx_path",
",",
"self",
".",
"onnx_config",
",",
"self",
".",
"extra_layer_bit",
",",
"self",
".",
"strict_datatype",
")",
"return",
"engine",
... | [
301,
4
] | [
316,
48
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT.inference | (self, test_data) |
Do inference by tensorrt builded engine.
Parameters
----------
test_data : pytorch tensor
Model input tensor
|
Do inference by tensorrt builded engine. | def inference(self, test_data):
"""
Do inference by tensorrt builded engine.
Parameters
----------
test_data : pytorch tensor
Model input tensor
"""
# convert pytorch tensor to numpy darray
test_data = test_data.numpy()
# Numpy dtype s... | [
"def",
"inference",
"(",
"self",
",",
"test_data",
")",
":",
"# convert pytorch tensor to numpy darray",
"test_data",
"=",
"test_data",
".",
"numpy",
"(",
")",
"# Numpy dtype should be float32",
"assert",
"test_data",
".",
"dtype",
"==",
"np",
".",
"float32",
"elaps... | [
318,
4
] | [
351,
35
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT.export_quantized_model | (self, path) |
Export TensorRT quantized model engine which only can be loaded by TensorRT deserialize API.
Parameters
----------
path : str
The path of export model
|
Export TensorRT quantized model engine which only can be loaded by TensorRT deserialize API. | def export_quantized_model(self, path):
"""
Export TensorRT quantized model engine which only can be loaded by TensorRT deserialize API.
Parameters
----------
path : str
The path of export model
"""
assert path is not None
with open(path, "wb"... | [
"def",
"export_quantized_model",
"(",
"self",
",",
"path",
")",
":",
"assert",
"path",
"is",
"not",
"None",
"with",
"open",
"(",
"path",
",",
"\"wb\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"self",
".",
"context",
".",
"engine",
".",
"serializ... | [
353,
4
] | [
365,
69
] | python | en | ['en', 'error', 'th'] | False |
ModelSpeedupTensorRT.load_quantized_model | (self, path) |
Load TensorRT quantized model engine from specific path.
Parameters
----------
path : str
The path of export model
|
Load TensorRT quantized model engine from specific path. | def load_quantized_model(self, path):
"""
Load TensorRT quantized model engine from specific path.
Parameters
----------
path : str
The path of export model
"""
assert path is not None
with open(path, "rb") as f, trt.Runtime(TRT_LOGGER) as run... | [
"def",
"load_quantized_model",
"(",
"self",
",",
"path",
")",
":",
"assert",
"path",
"is",
"not",
"None",
"with",
"open",
"(",
"path",
",",
"\"rb\"",
")",
"as",
"f",
",",
"trt",
".",
"Runtime",
"(",
"TRT_LOGGER",
")",
"as",
"runtime",
":",
"engine",
... | [
367,
4
] | [
380,
75
] | 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.