partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Resource.check_presets | Lists all resource presets in the current scaling group with additiona
information. | src/ai/backend/client/resource.py | async def check_presets(cls):
'''
Lists all resource presets in the current scaling group with additiona
information.
'''
rqst = Request(cls.session, 'POST', '/resource/check-presets')
async with rqst.fetch() as resp:
return await resp.json() | async def check_presets(cls):
'''
Lists all resource presets in the current scaling group with additiona
information.
'''
rqst = Request(cls.session, 'POST', '/resource/check-presets')
async with rqst.fetch() as resp:
return await resp.json() | [
"Lists",
"all",
"resource",
"presets",
"in",
"the",
"current",
"scaling",
"group",
"with",
"additiona",
"information",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/resource.py#L31-L38 | [
"async",
"def",
"check_presets",
"(",
"cls",
")",
":",
"rqst",
"=",
"Request",
"(",
"cls",
".",
"session",
",",
"'POST'",
",",
"'/resource/check-presets'",
")",
"async",
"with",
"rqst",
".",
"fetch",
"(",
")",
"as",
"resp",
":",
"return",
"await",
"resp"... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | add_perf_task | function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into
JSON and issues a RESTFUL call to create the performance task.
device.
:param task: dictionary containing all required fields for performance tasks
:param auth: requests ... | build/lib/pyhpeimc/plat/perf.py | def add_perf_task(task, auth, url):
"""
function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into
JSON and issues a RESTFUL call to create the performance task.
device.
:param task: dictionary containing all required fields f... | def add_perf_task(task, auth, url):
"""
function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into
JSON and issues a RESTFUL call to create the performance task.
device.
:param task: dictionary containing all required fields f... | [
"function",
"takes",
"the",
"a",
"python",
"dict",
"containing",
"all",
"necessary",
"fields",
"for",
"a",
"performance",
"tasks",
"transforms",
"the",
"dict",
"into",
"JSON",
"and",
"issues",
"a",
"RESTFUL",
"call",
"to",
"create",
"the",
"performance",
"task... | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/perf.py#L19-L54 | [
"def",
"add_perf_task",
"(",
"task",
",",
"auth",
",",
"url",
")",
":",
"add_perf_task_url",
"=",
"\"/imcrs/perf/task\"",
"f_url",
"=",
"url",
"+",
"add_perf_task_url",
"payload",
"=",
"json",
".",
"dumps",
"(",
"task",
")",
"# creates the URL using the payload va... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_perf_task | function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call
to the IMC REST service. It will return a list
:param task_name: str containing the name of the performance task
:param auth: requests auth object #usually auth.creds from auth pyhpei... | build/lib/pyhpeimc/plat/perf.py | def get_perf_task(task_name, auth, url):
"""
function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call
to the IMC REST service. It will return a list
:param task_name: str containing the name of the performance task
:param auth: ... | def get_perf_task(task_name, auth, url):
"""
function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call
to the IMC REST service. It will return a list
:param task_name: str containing the name of the performance task
:param auth: ... | [
"function",
"takes",
"the",
"a",
"str",
"object",
"containing",
"the",
"name",
"of",
"an",
"existing",
"performance",
"tasks",
"and",
"issues",
"a",
"RESTFUL",
"call",
"to",
"the",
"IMC",
"REST",
"service",
".",
"It",
"will",
"return",
"a",
"list"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/perf.py#L56-L92 | [
"def",
"get_perf_task",
"(",
"task_name",
",",
"auth",
",",
"url",
")",
":",
"get_perf_task_url",
"=",
"\"/imcrs/perf/task?name=\"",
"+",
"task_name",
"+",
"\"&orderBy=taskId&desc=false\"",
"f_url",
"=",
"url",
"+",
"get_perf_task_url",
"# creates the URL using the payloa... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_vm_host_info | function takes hostId as input to RESTFUL call to HP IMC
:param hostip: int or string of hostip of Hypervisor host
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:return: Dict... | build/lib/pyhpeimc/plat/vrm.py | def get_vm_host_info(hostip, auth, url):
"""
function takes hostId as input to RESTFUL call to HP IMC
:param hostip: int or string of hostip of Hypervisor host
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually aut... | def get_vm_host_info(hostip, auth, url):
"""
function takes hostId as input to RESTFUL call to HP IMC
:param hostip: int or string of hostip of Hypervisor host
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually aut... | [
"function",
"takes",
"hostId",
"as",
"input",
"to",
"RESTFUL",
"call",
"to",
"HP",
"IMC"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/vrm.py#L18-L80 | [
"def",
"get_vm_host_info",
"(",
"hostip",
",",
"auth",
",",
"url",
")",
":",
"hostId",
"=",
"get_dev_details",
"(",
"hostip",
",",
"auth",
",",
"url",
")",
"[",
"'id'",
"]",
"get_vm_host_info_url",
"=",
"\"/imcrs/vrm/host?hostId=\"",
"+",
"str",
"(",
"hostId... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_ac_info_all | function takes no input as input to RESTFUL call to HP IMC
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:return: list of dictionaries where each element of the list represents a ... | pyhpeimc/wsm/acinfo.py | def get_ac_info_all(auth, url):
"""
function takes no input as input to RESTFUL call to HP IMC
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:return: list of dictionaries ... | def get_ac_info_all(auth, url):
"""
function takes no input as input to RESTFUL call to HP IMC
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:return: list of dictionaries ... | [
"function",
"takes",
"no",
"input",
"as",
"input",
"to",
"RESTFUL",
"call",
"to",
"HP",
"IMC"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/wsm/acinfo.py#L18-L50 | [
"def",
"get_ac_info_all",
"(",
"auth",
",",
"url",
")",
":",
"f_url",
"=",
"url",
"+",
"\"/imcrs/wlan/acInfo/queryAcBasicInfo\"",
"response",
"=",
"requests",
".",
"get",
"(",
"f_url",
",",
"auth",
"=",
"auth",
",",
"headers",
"=",
"HEADERS",
")",
"try",
"... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | set_imc_creds | This function prompts user for IMC server information and credentuials and stores
values in url and auth global variables | build/lib/pyhpimc/auth.py | def set_imc_creds(h_url=None, imc_server=None, imc_port=None, imc_user=None,imc_pw=None):
""" This function prompts user for IMC server information and credentuials and stores
values in url and auth global variables"""
global auth, url
if h_url is None:
imc_protocol = input(
"What protoc... | def set_imc_creds(h_url=None, imc_server=None, imc_port=None, imc_user=None,imc_pw=None):
""" This function prompts user for IMC server information and credentuials and stores
values in url and auth global variables"""
global auth, url
if h_url is None:
imc_protocol = input(
"What protoc... | [
"This",
"function",
"prompts",
"user",
"for",
"IMC",
"server",
"information",
"and",
"credentuials",
"and",
"stores",
"values",
"in",
"url",
"and",
"auth",
"global",
"variables"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L78-L110 | [
"def",
"set_imc_creds",
"(",
"h_url",
"=",
"None",
",",
"imc_server",
"=",
"None",
",",
"imc_port",
"=",
"None",
",",
"imc_user",
"=",
"None",
",",
"imc_pw",
"=",
"None",
")",
":",
"global",
"auth",
",",
"url",
"if",
"h_url",
"is",
"None",
":",
"imc_... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | print_to_file | Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt
:param: Object: object of type str, list, or dict
:return: No return. Just prints out to file handler and save to current working directory as pyoutput.txt | build/lib/pyhpimc/auth.py | def print_to_file(object):
"""
Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt
:param: Object: object of type str, list, or dict
:return: No return. Just prints out to file handler and save to current working directory as pyoutput.txt
... | def print_to_file(object):
"""
Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt
:param: Object: object of type str, list, or dict
:return: No return. Just prints out to file handler and save to current working directory as pyoutput.txt
... | [
"Function",
"takes",
"in",
"object",
"of",
"type",
"str",
"list",
"or",
"dict",
"and",
"prints",
"out",
"to",
"current",
"working",
"directory",
"as",
"pyoutput",
".",
"txt",
":",
"param",
":",
"Object",
":",
"object",
"of",
"type",
"str",
"list",
"or",
... | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L119-L133 | [
"def",
"print_to_file",
"(",
"object",
")",
":",
"with",
"open",
"(",
"'pyoutput.txt'",
",",
"'w'",
")",
"as",
"fh",
":",
"x",
"=",
"None",
"if",
"type",
"(",
"object",
")",
"is",
"list",
":",
"x",
"=",
"json",
".",
"dumps",
"(",
"object",
",",
"... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | IMCAuth.get_auth | This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object
:return: | build/lib/pyhpimc/auth.py | def get_auth(self):
"""
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object
:return:
"""
url = self.h_url + self.server + ":" + self.port
auth = requests.auth.HTTPDigestAuth(self.username,self.password)
auth_url... | def get_auth(self):
"""
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object
:return:
"""
url = self.h_url + self.server + ":" + self.port
auth = requests.auth.HTTPDigestAuth(self.username,self.password)
auth_url... | [
"This",
"method",
"requests",
"an",
"authentication",
"object",
"from",
"the",
"HPE",
"IMC",
"NMS",
"and",
"returns",
"an",
"HTTPDigest",
"Auth",
"Object",
":",
"return",
":"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L55-L73 | [
"def",
"get_auth",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"h_url",
"+",
"self",
".",
"server",
"+",
"\":\"",
"+",
"self",
".",
"port",
"auth",
"=",
"requests",
".",
"auth",
".",
"HTTPDigestAuth",
"(",
"self",
".",
"username",
",",
"self",
... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_version | Load and return the contents of version.json.
:param root: The root path that the ``version.json`` file will be opened
:type root: str
:returns: Content of ``version.json`` or None
:rtype: dict or None | src/dockerflow/version.py | def get_version(root):
"""
Load and return the contents of version.json.
:param root: The root path that the ``version.json`` file will be opened
:type root: str
:returns: Content of ``version.json`` or None
:rtype: dict or None
"""
version_json = os.path.join(root, 'version.json')
... | def get_version(root):
"""
Load and return the contents of version.json.
:param root: The root path that the ``version.json`` file will be opened
:type root: str
:returns: Content of ``version.json`` or None
:rtype: dict or None
"""
version_json = os.path.join(root, 'version.json')
... | [
"Load",
"and",
"return",
"the",
"contents",
"of",
"version",
".",
"json",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/version.py#L10-L23 | [
"def",
"get_version",
"(",
"root",
")",
":",
"version_json",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"'version.json'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"version_json",
")",
":",
"with",
"open",
"(",
"version_json",
",",
... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | ApiClient.fetch | Calls this instance's request_client's post method with the
specified component endpoint
Args:
- endpoint_name (str) - The endpoint to call like "property/value".
- identifier_input - One or more identifiers to request data for. An identifier can
be in one of the... | housecanary/apiclient.py | def fetch(self, endpoint_name, identifier_input, query_params=None):
"""Calls this instance's request_client's post method with the
specified component endpoint
Args:
- endpoint_name (str) - The endpoint to call like "property/value".
- identifier_input - One or more ide... | def fetch(self, endpoint_name, identifier_input, query_params=None):
"""Calls this instance's request_client's post method with the
specified component endpoint
Args:
- endpoint_name (str) - The endpoint to call like "property/value".
- identifier_input - One or more ide... | [
"Calls",
"this",
"instance",
"s",
"request_client",
"s",
"post",
"method",
"with",
"the",
"specified",
"component",
"endpoint"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L61-L117 | [
"def",
"fetch",
"(",
"self",
",",
"endpoint_name",
",",
"identifier_input",
",",
"query_params",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"constants",
".",
"URL_PREFIX",
"+",
"\"/\"",
"+",
"self",
".",
"_version",
"+",
"\"/\"",
"+",
"endpoint_name",
"if",... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | ApiClient.fetch_synchronous | Calls this instance's request_client's get method with the
specified component endpoint | housecanary/apiclient.py | def fetch_synchronous(self, endpoint_name, query_params=None):
"""Calls this instance's request_client's get method with the
specified component endpoint"""
endpoint_url = constants.URL_PREFIX + "/" + self._version + "/" + endpoint_name
if query_params is None:
query_params... | def fetch_synchronous(self, endpoint_name, query_params=None):
"""Calls this instance's request_client's get method with the
specified component endpoint"""
endpoint_url = constants.URL_PREFIX + "/" + self._version + "/" + endpoint_name
if query_params is None:
query_params... | [
"Calls",
"this",
"instance",
"s",
"request_client",
"s",
"get",
"method",
"with",
"the",
"specified",
"component",
"endpoint"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L119-L128 | [
"def",
"fetch_synchronous",
"(",
"self",
",",
"endpoint_name",
",",
"query_params",
"=",
"None",
")",
":",
"endpoint_url",
"=",
"constants",
".",
"URL_PREFIX",
"+",
"\"/\"",
"+",
"self",
".",
"_version",
"+",
"\"/\"",
"+",
"endpoint_name",
"if",
"query_params"... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | ComponentWrapper.get_identifier_input | Convert the various formats of input identifier_data into
the proper json format expected by the ApiClient fetch method,
which is a list of dicts. | housecanary/apiclient.py | def get_identifier_input(self, identifier_data):
"""Convert the various formats of input identifier_data into
the proper json format expected by the ApiClient fetch method,
which is a list of dicts."""
identifier_input = []
if isinstance(identifier_data, list) and len(identifie... | def get_identifier_input(self, identifier_data):
"""Convert the various formats of input identifier_data into
the proper json format expected by the ApiClient fetch method,
which is a list of dicts."""
identifier_input = []
if isinstance(identifier_data, list) and len(identifie... | [
"Convert",
"the",
"various",
"formats",
"of",
"input",
"identifier_data",
"into",
"the",
"proper",
"json",
"format",
"expected",
"by",
"the",
"ApiClient",
"fetch",
"method",
"which",
"is",
"a",
"list",
"of",
"dicts",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L143-L157 | [
"def",
"get_identifier_input",
"(",
"self",
",",
"identifier_data",
")",
":",
"identifier_input",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"identifier_data",
",",
"list",
")",
"and",
"len",
"(",
"identifier_data",
")",
">",
"0",
":",
"# if list, convert each item... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | ComponentWrapper.fetch_identifier_component | Common method for handling parameters before passing to api_client | housecanary/apiclient.py | def fetch_identifier_component(self, endpoint_name, identifier_data, query_params=None):
"""Common method for handling parameters before passing to api_client"""
if query_params is None:
query_params = {}
identifier_input = self.get_identifier_input(identifier_data)
return... | def fetch_identifier_component(self, endpoint_name, identifier_data, query_params=None):
"""Common method for handling parameters before passing to api_client"""
if query_params is None:
query_params = {}
identifier_input = self.get_identifier_input(identifier_data)
return... | [
"Common",
"method",
"for",
"handling",
"parameters",
"before",
"passing",
"to",
"api_client"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L159-L167 | [
"def",
"fetch_identifier_component",
"(",
"self",
",",
"endpoint_name",
",",
"identifier_data",
",",
"query_params",
"=",
"None",
")",
":",
"if",
"query_params",
"is",
"None",
":",
"query_params",
"=",
"{",
"}",
"identifier_input",
"=",
"self",
".",
"get_identif... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | PropertyComponentWrapper._convert_to_identifier_json | Convert input address data into json format | housecanary/apiclient.py | def _convert_to_identifier_json(self, address_data):
"""Convert input address data into json format"""
if isinstance(address_data, str):
# allow just passing a slug string.
return {"slug": address_data}
if isinstance(address_data, tuple) and len(address_data) > 0:
... | def _convert_to_identifier_json(self, address_data):
"""Convert input address data into json format"""
if isinstance(address_data, str):
# allow just passing a slug string.
return {"slug": address_data}
if isinstance(address_data, tuple) and len(address_data) > 0:
... | [
"Convert",
"input",
"address",
"data",
"into",
"json",
"format"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L218-L250 | [
"def",
"_convert_to_identifier_json",
"(",
"self",
",",
"address_data",
")",
":",
"if",
"isinstance",
"(",
"address_data",
",",
"str",
")",
":",
"# allow just passing a slug string.",
"return",
"{",
"\"slug\"",
":",
"address_data",
"}",
"if",
"isinstance",
"(",
"a... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | PropertyComponentWrapper.value_report | Call the value_report component
Value Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- report_type - "full" or "summary". Default is "full".
- format_type - "json", "pdf", "xlsx" or "all". Default is "json". | housecanary/apiclient.py | def value_report(self, address, zipcode, report_type="full", format_type="json"):
"""Call the value_report component
Value Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- report_type - "full" or "summary". Default is "full... | def value_report(self, address, zipcode, report_type="full", format_type="json"):
"""Call the value_report component
Value Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- report_type - "full" or "summary". Default is "full... | [
"Call",
"the",
"value_report",
"component"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L413-L433 | [
"def",
"value_report",
"(",
"self",
",",
"address",
",",
"zipcode",
",",
"report_type",
"=",
"\"full\"",
",",
"format_type",
"=",
"\"json\"",
")",
":",
"query_params",
"=",
"{",
"\"report_type\"",
":",
"report_type",
",",
"\"format\"",
":",
"format_type",
",",... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | PropertyComponentWrapper.rental_report | Call the rental_report component
Rental Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- format_type - "json", "xlsx" or "all". Default is "json". | housecanary/apiclient.py | def rental_report(self, address, zipcode, format_type="json"):
"""Call the rental_report component
Rental Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- format_type - "json", "xlsx" or "all". Default is "json".
""... | def rental_report(self, address, zipcode, format_type="json"):
"""Call the rental_report component
Rental Report only supports a single address.
Args:
- address
- zipcode
Kwargs:
- format_type - "json", "xlsx" or "all". Default is "json".
""... | [
"Call",
"the",
"rental_report",
"component"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L435-L455 | [
"def",
"rental_report",
"(",
"self",
",",
"address",
",",
"zipcode",
",",
"format_type",
"=",
"\"json\"",
")",
":",
"# only json is supported by rental report.",
"query_params",
"=",
"{",
"\"format\"",
":",
"format_type",
",",
"\"address\"",
":",
"address",
",",
"... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | ZipComponentWrapper.component_mget | Call the zip component_mget endpoint
Args:
- zip_data - As described in the class docstring.
- components - A list of strings for each component to include in the request.
Example: ["zip/details", "zip/volatility"] | housecanary/apiclient.py | def component_mget(self, zip_data, components):
"""Call the zip component_mget endpoint
Args:
- zip_data - As described in the class docstring.
- components - A list of strings for each component to include in the request.
Example: ["zip/details", "zip/volatility... | def component_mget(self, zip_data, components):
"""Call the zip component_mget endpoint
Args:
- zip_data - As described in the class docstring.
- components - A list of strings for each component to include in the request.
Example: ["zip/details", "zip/volatility... | [
"Call",
"the",
"zip",
"component_mget",
"endpoint"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L645-L660 | [
"def",
"component_mget",
"(",
"self",
",",
"zip_data",
",",
"components",
")",
":",
"if",
"not",
"isinstance",
"(",
"components",
",",
"list",
")",
":",
"print",
"(",
"\"Components param must be a list\"",
")",
"return",
"query_params",
"=",
"{",
"\"components\"... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | version | Returns the contents of version.json or a 404. | src/dockerflow/django/views.py | def version(request):
"""
Returns the contents of version.json or a 404.
"""
version_json = import_string(version_callback)(settings.BASE_DIR)
if version_json is None:
return HttpResponseNotFound('version.json not found')
else:
return JsonResponse(version_json) | def version(request):
"""
Returns the contents of version.json or a 404.
"""
version_json = import_string(version_callback)(settings.BASE_DIR)
if version_json is None:
return HttpResponseNotFound('version.json not found')
else:
return JsonResponse(version_json) | [
"Returns",
"the",
"contents",
"of",
"version",
".",
"json",
"or",
"a",
"404",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/views.py#L20-L28 | [
"def",
"version",
"(",
"request",
")",
":",
"version_json",
"=",
"import_string",
"(",
"version_callback",
")",
"(",
"settings",
".",
"BASE_DIR",
")",
"if",
"version_json",
"is",
"None",
":",
"return",
"HttpResponseNotFound",
"(",
"'version.json not found'",
")",
... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | heartbeat | Runs all the Django checks and returns a JsonResponse with either
a status code of 200 or 500 depending on the results of the checks.
Any check that returns a warning or worse (error, critical) will
return a 500 response. | src/dockerflow/django/views.py | def heartbeat(request):
"""
Runs all the Django checks and returns a JsonResponse with either
a status code of 200 or 500 depending on the results of the checks.
Any check that returns a warning or worse (error, critical) will
return a 500 response.
"""
all_checks = checks.registry.registry... | def heartbeat(request):
"""
Runs all the Django checks and returns a JsonResponse with either
a status code of 200 or 500 depending on the results of the checks.
Any check that returns a warning or worse (error, critical) will
return a 500 response.
"""
all_checks = checks.registry.registry... | [
"Runs",
"all",
"the",
"Django",
"checks",
"and",
"returns",
"a",
"JsonResponse",
"with",
"either",
"a",
"status",
"code",
"of",
"200",
"or",
"500",
"depending",
"on",
"the",
"results",
"of",
"the",
"checks",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/views.py#L40-L75 | [
"def",
"heartbeat",
"(",
"request",
")",
":",
"all_checks",
"=",
"checks",
".",
"registry",
".",
"registry",
".",
"get_checks",
"(",
"include_deployment_checks",
"=",
"not",
"settings",
".",
"DEBUG",
",",
")",
"details",
"=",
"{",
"}",
"statuses",
"=",
"{"... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | _create_component_results | Returns a list of ComponentResult from the json_data | housecanary/object.py | def _create_component_results(json_data, result_key):
""" Returns a list of ComponentResult from the json_data"""
component_results = []
for key, value in list(json_data.items()):
if key not in [result_key, "meta"]:
component_result = ComponentResult(
key,
... | def _create_component_results(json_data, result_key):
""" Returns a list of ComponentResult from the json_data"""
component_results = []
for key, value in list(json_data.items()):
if key not in [result_key, "meta"]:
component_result = ComponentResult(
key,
... | [
"Returns",
"a",
"list",
"of",
"ComponentResult",
"from",
"the",
"json_data"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L13-L27 | [
"def",
"_create_component_results",
"(",
"json_data",
",",
"result_key",
")",
":",
"component_results",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"json_data",
".",
"items",
"(",
")",
")",
":",
"if",
"key",
"not",
"in",
"[",
"result_ke... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | HouseCanaryObject.has_error | Returns whether there was a business logic error when fetching data
for any components for this property.
Returns:
boolean | housecanary/object.py | def has_error(self):
"""Returns whether there was a business logic error when fetching data
for any components for this property.
Returns:
boolean
"""
return next(
(True for cr in self.component_results
if cr.has_error()),
False
... | def has_error(self):
"""Returns whether there was a business logic error when fetching data
for any components for this property.
Returns:
boolean
"""
return next(
(True for cr in self.component_results
if cr.has_error()),
False
... | [
"Returns",
"whether",
"there",
"was",
"a",
"business",
"logic",
"error",
"when",
"fetching",
"data",
"for",
"any",
"components",
"for",
"this",
"property",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L42-L53 | [
"def",
"has_error",
"(",
"self",
")",
":",
"return",
"next",
"(",
"(",
"True",
"for",
"cr",
"in",
"self",
".",
"component_results",
"if",
"cr",
".",
"has_error",
"(",
")",
")",
",",
"False",
")"
] | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | HouseCanaryObject.get_errors | If there were any business errors fetching data for this property,
returns the error messages.
Returns:
string - the error message, or None if there was no error. | housecanary/object.py | def get_errors(self):
"""If there were any business errors fetching data for this property,
returns the error messages.
Returns:
string - the error message, or None if there was no error.
"""
return [{cr.component_name: cr.get_error()}
for cr in self... | def get_errors(self):
"""If there were any business errors fetching data for this property,
returns the error messages.
Returns:
string - the error message, or None if there was no error.
"""
return [{cr.component_name: cr.get_error()}
for cr in self... | [
"If",
"there",
"were",
"any",
"business",
"errors",
"fetching",
"data",
"for",
"this",
"property",
"returns",
"the",
"error",
"messages",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L55-L64 | [
"def",
"get_errors",
"(",
"self",
")",
":",
"return",
"[",
"{",
"cr",
".",
"component_name",
":",
"cr",
".",
"get_error",
"(",
")",
"}",
"for",
"cr",
"in",
"self",
".",
"component_results",
"if",
"cr",
".",
"has_error",
"(",
")",
"]"
] | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | Property.create_from_json | Deserialize property json data into a Property object
Args:
json_data (dict): The json data for this property
Returns:
Property object | housecanary/object.py | def create_from_json(cls, json_data):
"""Deserialize property json data into a Property object
Args:
json_data (dict): The json data for this property
Returns:
Property object
"""
prop = Property()
address_info = json_data["address_info"]
... | def create_from_json(cls, json_data):
"""Deserialize property json data into a Property object
Args:
json_data (dict): The json data for this property
Returns:
Property object
"""
prop = Property()
address_info = json_data["address_info"]
... | [
"Deserialize",
"property",
"json",
"data",
"into",
"a",
"Property",
"object"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L102-L134 | [
"def",
"create_from_json",
"(",
"cls",
",",
"json_data",
")",
":",
"prop",
"=",
"Property",
"(",
")",
"address_info",
"=",
"json_data",
"[",
"\"address_info\"",
"]",
"prop",
".",
"address",
"=",
"address_info",
"[",
"\"address\"",
"]",
"prop",
".",
"block_id... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | Block.create_from_json | Deserialize block json data into a Block object
Args:
json_data (dict): The json data for this block
Returns:
Block object | housecanary/object.py | def create_from_json(cls, json_data):
"""Deserialize block json data into a Block object
Args:
json_data (dict): The json data for this block
Returns:
Block object
"""
block = Block()
block_info = json_data["block_info"]
block.block_id =... | def create_from_json(cls, json_data):
"""Deserialize block json data into a Block object
Args:
json_data (dict): The json data for this block
Returns:
Block object
"""
block = Block()
block_info = json_data["block_info"]
block.block_id =... | [
"Deserialize",
"block",
"json",
"data",
"into",
"a",
"Block",
"object"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L160-L179 | [
"def",
"create_from_json",
"(",
"cls",
",",
"json_data",
")",
":",
"block",
"=",
"Block",
"(",
")",
"block_info",
"=",
"json_data",
"[",
"\"block_info\"",
"]",
"block",
".",
"block_id",
"=",
"block_info",
"[",
"\"block_id\"",
"]",
"block",
".",
"num_bins",
... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | ZipCode.create_from_json | Deserialize zipcode json data into a ZipCode object
Args:
json_data (dict): The json data for this zipcode
Returns:
Zip object | housecanary/object.py | def create_from_json(cls, json_data):
"""Deserialize zipcode json data into a ZipCode object
Args:
json_data (dict): The json data for this zipcode
Returns:
Zip object
"""
zipcode = ZipCode()
zipcode.zipcode = json_data["zipcode_info"]["zipcode"... | def create_from_json(cls, json_data):
"""Deserialize zipcode json data into a ZipCode object
Args:
json_data (dict): The json data for this zipcode
Returns:
Zip object
"""
zipcode = ZipCode()
zipcode.zipcode = json_data["zipcode_info"]["zipcode"... | [
"Deserialize",
"zipcode",
"json",
"data",
"into",
"a",
"ZipCode",
"object"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L203-L219 | [
"def",
"create_from_json",
"(",
"cls",
",",
"json_data",
")",
":",
"zipcode",
"=",
"ZipCode",
"(",
")",
"zipcode",
".",
"zipcode",
"=",
"json_data",
"[",
"\"zipcode_info\"",
"]",
"[",
"\"zipcode\"",
"]",
"zipcode",
".",
"meta",
"=",
"json_data",
"[",
"\"me... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | Msa.create_from_json | Deserialize msa json data into a Msa object
Args:
json_data (dict): The json data for this msa
Returns:
Msa object | housecanary/object.py | def create_from_json(cls, json_data):
"""Deserialize msa json data into a Msa object
Args:
json_data (dict): The json data for this msa
Returns:
Msa object
"""
msa = Msa()
msa.msa = json_data["msa_info"]["msa"]
msa.meta = json_data["meta... | def create_from_json(cls, json_data):
"""Deserialize msa json data into a Msa object
Args:
json_data (dict): The json data for this msa
Returns:
Msa object
"""
msa = Msa()
msa.msa = json_data["msa_info"]["msa"]
msa.meta = json_data["meta... | [
"Deserialize",
"msa",
"json",
"data",
"into",
"a",
"Msa",
"object"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L243-L259 | [
"def",
"create_from_json",
"(",
"cls",
",",
"json_data",
")",
":",
"msa",
"=",
"Msa",
"(",
")",
"msa",
".",
"msa",
"=",
"json_data",
"[",
"\"msa_info\"",
"]",
"[",
"\"msa\"",
"]",
"msa",
".",
"meta",
"=",
"json_data",
"[",
"\"meta\"",
"]",
"if",
"\"m... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | starts_when | Start yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, start yielding
items. If it's not a callable, it will be converted
to one as `lambda condition: condition == item`.
Example:
... | src/ww/tools/iterables.py | def starts_when(iterable, condition):
# type: (Iterable, Union[Callable, Any]) -> Iterable
"""Start yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, start yielding
items. If it's not a callable, i... | def starts_when(iterable, condition):
# type: (Iterable, Union[Callable, Any]) -> Iterable
"""Start yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, start yielding
items. If it's not a callable, i... | [
"Start",
"yielding",
"items",
"when",
"a",
"condition",
"arise",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L49-L71 | [
"def",
"starts_when",
"(",
"iterable",
",",
"condition",
")",
":",
"# type: (Iterable, Union[Callable, Any]) -> Iterable",
"if",
"not",
"callable",
"(",
"condition",
")",
":",
"cond_value",
"=",
"condition",
"def",
"condition",
"(",
"x",
")",
":",
"return",
"x",
... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | stops_when | Stop yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, stop yielding
items. If it's not a callable, it will be converted
to one as `lambda condition: condition == item`.
Example:
... | src/ww/tools/iterables.py | def stops_when(iterable, condition):
# type: (Iterable, Union[Callable, Any]) -> Iterable
"""Stop yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, stop yielding
items. If it's not a callable, it w... | def stops_when(iterable, condition):
# type: (Iterable, Union[Callable, Any]) -> Iterable
"""Stop yielding items when a condition arise.
Args:
iterable: the iterable to filter.
condition: if the callable returns True once, stop yielding
items. If it's not a callable, it w... | [
"Stop",
"yielding",
"items",
"when",
"a",
"condition",
"arise",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L74-L96 | [
"def",
"stops_when",
"(",
"iterable",
",",
"condition",
")",
":",
"# type: (Iterable, Union[Callable, Any]) -> Iterable",
"if",
"not",
"callable",
"(",
"condition",
")",
":",
"cond_value",
"=",
"condition",
"def",
"condition",
"(",
"x",
")",
":",
"return",
"x",
... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | skip_duplicates | Returns a generator that will yield all objects from iterable, skipping
duplicates.
Duplicates are identified using the `key` function to calculate a
unique fingerprint. This does not use natural equality, but the
result use a set() to remove duplicates, so defining __eq__
on yo... | src/ww/tools/iterables.py | def skip_duplicates(iterable, key=None, fingerprints=()):
# type: (Iterable, Callable, Any) -> Iterable
"""
Returns a generator that will yield all objects from iterable, skipping
duplicates.
Duplicates are identified using the `key` function to calculate a
unique fingerprint. T... | def skip_duplicates(iterable, key=None, fingerprints=()):
# type: (Iterable, Callable, Any) -> Iterable
"""
Returns a generator that will yield all objects from iterable, skipping
duplicates.
Duplicates are identified using the `key` function to calculate a
unique fingerprint. T... | [
"Returns",
"a",
"generator",
"that",
"will",
"yield",
"all",
"objects",
"from",
"iterable",
"skipping",
"duplicates",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L99-L179 | [
"def",
"skip_duplicates",
"(",
"iterable",
",",
"key",
"=",
"None",
",",
"fingerprints",
"=",
"(",
")",
")",
":",
"# type: (Iterable, Callable, Any) -> Iterable",
"fingerprints",
"=",
"fingerprints",
"or",
"set",
"(",
")",
"fingerprint",
"=",
"None",
"# needed on ... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | chunks | Yields items from an iterator in iterable chunks. | src/ww/tools/iterables.py | def chunks(iterable, chunksize, cast=tuple):
# type: (Iterable, int, Callable) -> Iterable
"""
Yields items from an iterator in iterable chunks.
"""
it = iter(iterable)
while True:
yield cast(itertools.chain([next(it)],
itertools.islice(it, chunksize - 1))) | def chunks(iterable, chunksize, cast=tuple):
# type: (Iterable, int, Callable) -> Iterable
"""
Yields items from an iterator in iterable chunks.
"""
it = iter(iterable)
while True:
yield cast(itertools.chain([next(it)],
itertools.islice(it, chunksize - 1))) | [
"Yields",
"items",
"from",
"an",
"iterator",
"in",
"iterable",
"chunks",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L183-L191 | [
"def",
"chunks",
"(",
"iterable",
",",
"chunksize",
",",
"cast",
"=",
"tuple",
")",
":",
"# type: (Iterable, int, Callable) -> Iterable",
"it",
"=",
"iter",
"(",
"iterable",
")",
"while",
"True",
":",
"yield",
"cast",
"(",
"itertools",
".",
"chain",
"(",
"["... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | window | Yields iterms by bunch of a given size, but rolling only one item
in and out at a time when iterating.
>>> list(window([1, 2, 3]))
[(1, 2), (2, 3)]
By default, this will cast the window to a tuple before yielding it;
however, any function that will accept an iterable as its arg... | src/ww/tools/iterables.py | def window(iterable, size=2, cast=tuple):
# type: (Iterable, int, Callable) -> Iterable
"""
Yields iterms by bunch of a given size, but rolling only one item
in and out at a time when iterating.
>>> list(window([1, 2, 3]))
[(1, 2), (2, 3)]
By default, this will cast the... | def window(iterable, size=2, cast=tuple):
# type: (Iterable, int, Callable) -> Iterable
"""
Yields iterms by bunch of a given size, but rolling only one item
in and out at a time when iterating.
>>> list(window([1, 2, 3]))
[(1, 2), (2, 3)]
By default, this will cast the... | [
"Yields",
"iterms",
"by",
"bunch",
"of",
"a",
"given",
"size",
"but",
"rolling",
"only",
"one",
"item",
"in",
"and",
"out",
"at",
"a",
"time",
"when",
"iterating",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L194-L228 | [
"def",
"window",
"(",
"iterable",
",",
"size",
"=",
"2",
",",
"cast",
"=",
"tuple",
")",
":",
"# type: (Iterable, int, Callable) -> Iterable",
"iterable",
"=",
"iter",
"(",
"iterable",
")",
"d",
"=",
"deque",
"(",
"itertools",
".",
"islice",
"(",
"iterable",... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | at_index | Return the item at the index of this iterable or raises IndexError.
WARNING: this will consume generators.
Negative indices are allowed but be aware they will cause n items to
be held in memory, where n = abs(index) | src/ww/tools/iterables.py | def at_index(iterable, index):
# type: (Iterable[T], int) -> T
"""" Return the item at the index of this iterable or raises IndexError.
WARNING: this will consume generators.
Negative indices are allowed but be aware they will cause n items to
be held in memory, where n = abs(index)
... | def at_index(iterable, index):
# type: (Iterable[T], int) -> T
"""" Return the item at the index of this iterable or raises IndexError.
WARNING: this will consume generators.
Negative indices are allowed but be aware they will cause n items to
be held in memory, where n = abs(index)
... | [
"Return",
"the",
"item",
"at",
"the",
"index",
"of",
"this",
"iterable",
"or",
"raises",
"IndexError",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L231-L246 | [
"def",
"at_index",
"(",
"iterable",
",",
"index",
")",
":",
"# type: (Iterable[T], int) -> T",
"try",
":",
"if",
"index",
"<",
"0",
":",
"return",
"deque",
"(",
"iterable",
",",
"maxlen",
"=",
"abs",
"(",
"index",
")",
")",
".",
"popleft",
"(",
")",
"r... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | first_true | Return the first item of the iterable for which func(item) == True.
Or raises IndexError.
WARNING: this will consume generators. | src/ww/tools/iterables.py | def first_true(iterable, func):
# type: (Iterable[T], Callable) -> T
"""" Return the first item of the iterable for which func(item) == True.
Or raises IndexError.
WARNING: this will consume generators.
"""
try:
return next((x for x in iterable if func(x)))
except StopItera... | def first_true(iterable, func):
# type: (Iterable[T], Callable) -> T
"""" Return the first item of the iterable for which func(item) == True.
Or raises IndexError.
WARNING: this will consume generators.
"""
try:
return next((x for x in iterable if func(x)))
except StopItera... | [
"Return",
"the",
"first",
"item",
"of",
"the",
"iterable",
"for",
"which",
"func",
"(",
"item",
")",
"==",
"True",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L250-L262 | [
"def",
"first_true",
"(",
"iterable",
",",
"func",
")",
":",
"# type: (Iterable[T], Callable) -> T",
"try",
":",
"return",
"next",
"(",
"(",
"x",
"for",
"x",
"in",
"iterable",
"if",
"func",
"(",
"x",
")",
")",
")",
"except",
"StopIteration",
"as",
"e",
"... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | iterslice | Like itertools.islice, but accept int and callables.
If `start` is a callable, start the slice after the first time
start(item) == True.
If `stop` is a callable, stop the slice after the first time
stop(item) == True. | src/ww/tools/iterables.py | def iterslice(iterable, start=0, stop=None, step=1):
# type: (Iterable[T], int, int, int) -> Iterable[T]
""" Like itertools.islice, but accept int and callables.
If `start` is a callable, start the slice after the first time
start(item) == True.
If `stop` is a callable, stop the slice ... | def iterslice(iterable, start=0, stop=None, step=1):
# type: (Iterable[T], int, int, int) -> Iterable[T]
""" Like itertools.islice, but accept int and callables.
If `start` is a callable, start the slice after the first time
start(item) == True.
If `stop` is a callable, stop the slice ... | [
"Like",
"itertools",
".",
"islice",
"but",
"accept",
"int",
"and",
"callables",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L265-L293 | [
"def",
"iterslice",
"(",
"iterable",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
")",
":",
"# type: (Iterable[T], int, int, int) -> Iterable[T]",
"if",
"step",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"The step can not be negativ... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | firsts | Lazily return the first x items from this iterable or default. | src/ww/tools/iterables.py | def firsts(iterable, items=1, default=None):
# type: (Iterable[T], int, T) -> Iterable[T]
""" Lazily return the first x items from this iterable or default. """
try:
items = int(items)
except (ValueError, TypeError):
raise ValueError("items should be usable as an int but is currently "
... | def firsts(iterable, items=1, default=None):
# type: (Iterable[T], int, T) -> Iterable[T]
""" Lazily return the first x items from this iterable or default. """
try:
items = int(items)
except (ValueError, TypeError):
raise ValueError("items should be usable as an int but is currently "
... | [
"Lazily",
"return",
"the",
"first",
"x",
"items",
"from",
"this",
"iterable",
"or",
"default",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L309-L330 | [
"def",
"firsts",
"(",
"iterable",
",",
"items",
"=",
"1",
",",
"default",
"=",
"None",
")",
":",
"# type: (Iterable[T], int, T) -> Iterable[T]",
"try",
":",
"items",
"=",
"int",
"(",
"items",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"r... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | lasts | Lazily return the last x items from this iterable or default. | src/ww/tools/iterables.py | def lasts(iterable, items=1, default=None):
# type: (Iterable[T], int, T) -> Iterable[T]
""" Lazily return the last x items from this iterable or default. """
last_items = deque(iterable, maxlen=items)
for _ in range(items - len(last_items)):
yield default
for y in last_items:
yie... | def lasts(iterable, items=1, default=None):
# type: (Iterable[T], int, T) -> Iterable[T]
""" Lazily return the last x items from this iterable or default. """
last_items = deque(iterable, maxlen=items)
for _ in range(items - len(last_items)):
yield default
for y in last_items:
yie... | [
"Lazily",
"return",
"the",
"last",
"x",
"items",
"from",
"this",
"iterable",
"or",
"default",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L333-L343 | [
"def",
"lasts",
"(",
"iterable",
",",
"items",
"=",
"1",
",",
"default",
"=",
"None",
")",
":",
"# type: (Iterable[T], int, T) -> Iterable[T]",
"last_items",
"=",
"deque",
"(",
"iterable",
",",
"maxlen",
"=",
"items",
")",
"for",
"_",
"in",
"range",
"(",
"... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | is_legacy_server | Determine execution mode.
Legacy mode: <= v4.20181215 | src/ai/backend/client/session.py | def is_legacy_server():
'''Determine execution mode.
Legacy mode: <= v4.20181215
'''
with Session() as session:
ret = session.Kernel.hello()
bai_version = ret['version']
legacy = True if bai_version <= 'v4.20181215' else False
return legacy | def is_legacy_server():
'''Determine execution mode.
Legacy mode: <= v4.20181215
'''
with Session() as session:
ret = session.Kernel.hello()
bai_version = ret['version']
legacy = True if bai_version <= 'v4.20181215' else False
return legacy | [
"Determine",
"execution",
"mode",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/session.py#L18-L27 | [
"def",
"is_legacy_server",
"(",
")",
":",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"ret",
"=",
"session",
".",
"Kernel",
".",
"hello",
"(",
")",
"bai_version",
"=",
"ret",
"[",
"'version'",
"]",
"legacy",
"=",
"True",
"if",
"bai_version",
"<=... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Session.close | Terminates the session. It schedules the ``close()`` coroutine
of the underlying aiohttp session and then enqueues a sentinel
object to indicate termination. Then it waits until the worker
thread to self-terminate by joining. | src/ai/backend/client/session.py | def close(self):
'''
Terminates the session. It schedules the ``close()`` coroutine
of the underlying aiohttp session and then enqueues a sentinel
object to indicate termination. Then it waits until the worker
thread to self-terminate by joining.
'''
if self._cl... | def close(self):
'''
Terminates the session. It schedules the ``close()`` coroutine
of the underlying aiohttp session and then enqueues a sentinel
object to indicate termination. Then it waits until the worker
thread to self-terminate by joining.
'''
if self._cl... | [
"Terminates",
"the",
"session",
".",
"It",
"schedules",
"the",
"close",
"()",
"coroutine",
"of",
"the",
"underlying",
"aiohttp",
"session",
"and",
"then",
"enqueues",
"a",
"sentinel",
"object",
"to",
"indicate",
"termination",
".",
"Then",
"it",
"waits",
"unti... | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/session.py#L214-L226 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
":",
"return",
"self",
".",
"_closed",
"=",
"True",
"self",
".",
"_worker_thread",
".",
"work_queue",
".",
"put",
"(",
"self",
".",
"aiohttp_session",
".",
"close",
"(",
")",
")",
"... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | asyncio_run_forever | A proposed-but-not-implemented asyncio.run_forever() API based on
@vxgmichel's idea.
See discussions on https://github.com/python/asyncio/pull/465 | src/ai/backend/client/compat.py | def asyncio_run_forever(setup_coro, shutdown_coro, *,
stop_signals={signal.SIGINT}, debug=False):
'''
A proposed-but-not-implemented asyncio.run_forever() API based on
@vxgmichel's idea.
See discussions on https://github.com/python/asyncio/pull/465
'''
async def wait_for_... | def asyncio_run_forever(setup_coro, shutdown_coro, *,
stop_signals={signal.SIGINT}, debug=False):
'''
A proposed-but-not-implemented asyncio.run_forever() API based on
@vxgmichel's idea.
See discussions on https://github.com/python/asyncio/pull/465
'''
async def wait_for_... | [
"A",
"proposed",
"-",
"but",
"-",
"not",
"-",
"implemented",
"asyncio",
".",
"run_forever",
"()",
"API",
"based",
"on"
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/compat.py#L80-L111 | [
"def",
"asyncio_run_forever",
"(",
"setup_coro",
",",
"shutdown_coro",
",",
"*",
",",
"stop_signals",
"=",
"{",
"signal",
".",
"SIGINT",
"}",
",",
"debug",
"=",
"False",
")",
":",
"async",
"def",
"wait_for_stop",
"(",
")",
":",
"loop",
"=",
"current_loop",... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | LruCacheDB.clear | claar all the cache, and release memory | wrapcache/database/__init__.py | def clear(self):
'''
claar all the cache, and release memory
'''
for node in self.dli():
node.empty = True
node.key = None
node.value = None
self.head = _dlnode()
self.head.next = self.head
self.head.prev = self.head
self.listSize = 1
self.table.clear()
# status var
self.hit_cnt ... | def clear(self):
'''
claar all the cache, and release memory
'''
for node in self.dli():
node.empty = True
node.key = None
node.value = None
self.head = _dlnode()
self.head.next = self.head
self.head.prev = self.head
self.listSize = 1
self.table.clear()
# status var
self.hit_cnt ... | [
"claar",
"all",
"the",
"cache",
"and",
"release",
"memory"
] | hustcc/wrapcache | python | https://github.com/hustcc/wrapcache/blob/3c6f52bb81a278e1dd60c27abe87d169cb4395aa/wrapcache/database/__init__.py#L56-L75 | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"node",
"in",
"self",
".",
"dli",
"(",
")",
":",
"node",
".",
"empty",
"=",
"True",
"node",
".",
"key",
"=",
"None",
"node",
".",
"value",
"=",
"None",
"self",
".",
"head",
"=",
"_dlnode",
"(",
")",... | 3c6f52bb81a278e1dd60c27abe87d169cb4395aa |
train | LruCacheDB.pop | Delete the item | wrapcache/database/__init__.py | def pop(self, key, default = None):
"""Delete the item"""
node = self.get(key, None)
if node == None:
value = default
else:
value = node
try:
del self[key]
except:
return value
return value | def pop(self, key, default = None):
"""Delete the item"""
node = self.get(key, None)
if node == None:
value = default
else:
value = node
try:
del self[key]
except:
return value
return value | [
"Delete",
"the",
"item"
] | hustcc/wrapcache | python | https://github.com/hustcc/wrapcache/blob/3c6f52bb81a278e1dd60c27abe87d169cb4395aa/wrapcache/database/__init__.py#L195-L207 | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"node",
"=",
"self",
".",
"get",
"(",
"key",
",",
"None",
")",
"if",
"node",
"==",
"None",
":",
"value",
"=",
"default",
"else",
":",
"value",
"=",
"node",
"try",
":"... | 3c6f52bb81a278e1dd60c27abe87d169cb4395aa |
train | main | Main function.
:return:
None. | src/aoiklivereload/demo/bottle_demo.py | def main():
"""
Main function.
:return:
None.
"""
try:
# Get the `src` directory's absolute path
src_path = os.path.dirname(
# `aoiklivereload` directory's absolute path
os.path.dirname(
# `demo` directory's absolute path
... | def main():
"""
Main function.
:return:
None.
"""
try:
# Get the `src` directory's absolute path
src_path = os.path.dirname(
# `aoiklivereload` directory's absolute path
os.path.dirname(
# `demo` directory's absolute path
... | [
"Main",
"function",
"."
] | AoiKuiyuyou/AoikLiveReload | python | https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/src/aoiklivereload/demo/bottle_demo.py#L15-L84 | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Get the `src` directory's absolute path",
"src_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"# `aoiklivereload` directory's absolute path",
"os",
".",
"path",
".",
"dirname",
"(",
"# `demo` directory's absolute path",
... | 0d5adb12118a33749e6690a8165fdb769cff7d5c |
train | Kernel.get_or_create | Get-or-creates a compute session.
If *client_token* is ``None``, it creates a new compute session as long as
the server has enough resources and your API key has remaining quota.
If *client_token* is a valid string and there is an existing compute session
with the same token and the same... | src/ai/backend/client/kernel.py | async def get_or_create(cls, lang: str, *,
client_token: str = None,
mounts: Iterable[str] = None,
envs: Mapping[str, str] = None,
resources: Mapping[str, int] = None,
cluster_size... | async def get_or_create(cls, lang: str, *,
client_token: str = None,
mounts: Iterable[str] = None,
envs: Mapping[str, str] = None,
resources: Mapping[str, int] = None,
cluster_size... | [
"Get",
"-",
"or",
"-",
"creates",
"a",
"compute",
"session",
".",
"If",
"*",
"client_token",
"*",
"is",
"None",
"it",
"creates",
"a",
"new",
"compute",
"session",
"as",
"long",
"as",
"the",
"server",
"has",
"enough",
"resources",
"and",
"your",
"API",
... | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L51-L112 | [
"async",
"def",
"get_or_create",
"(",
"cls",
",",
"lang",
":",
"str",
",",
"*",
",",
"client_token",
":",
"str",
"=",
"None",
",",
"mounts",
":",
"Iterable",
"[",
"str",
"]",
"=",
"None",
",",
"envs",
":",
"Mapping",
"[",
"str",
",",
"str",
"]",
... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.destroy | Destroys the compute session.
Since the server literally kills the container(s), all ongoing executions are
forcibly interrupted. | src/ai/backend/client/kernel.py | async def destroy(self):
'''
Destroys the compute session.
Since the server literally kills the container(s), all ongoing executions are
forcibly interrupted.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
... | async def destroy(self):
'''
Destroys the compute session.
Since the server literally kills the container(s), all ongoing executions are
forcibly interrupted.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
... | [
"Destroys",
"the",
"compute",
"session",
".",
"Since",
"the",
"server",
"literally",
"kills",
"the",
"container",
"(",
"s",
")",
"all",
"ongoing",
"executions",
"are",
"forcibly",
"interrupted",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L119-L133 | [
"async",
"def",
"destroy",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"owner_access_key",
":",
"params",
"[",
"'owner_access_key'",
"]",
"=",
"self",
".",
"owner_access_key",
"rqst",
"=",
"Request",
"(",
"self",
".",
"session",
",... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.restart | Restarts the compute session.
The server force-destroys the current running container(s), but keeps their
temporary scratch directories intact. | src/ai/backend/client/kernel.py | async def restart(self):
'''
Restarts the compute session.
The server force-destroys the current running container(s), but keeps their
temporary scratch directories intact.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.own... | async def restart(self):
'''
Restarts the compute session.
The server force-destroys the current running container(s), but keeps their
temporary scratch directories intact.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.own... | [
"Restarts",
"the",
"compute",
"session",
".",
"The",
"server",
"force",
"-",
"destroys",
"the",
"current",
"running",
"container",
"(",
"s",
")",
"but",
"keeps",
"their",
"temporary",
"scratch",
"directories",
"intact",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L136-L149 | [
"async",
"def",
"restart",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"owner_access_key",
":",
"params",
"[",
"'owner_access_key'",
"]",
"=",
"self",
".",
"owner_access_key",
"rqst",
"=",
"Request",
"(",
"self",
".",
"session",
",... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.complete | Gets the auto-completion candidates from the given code string,
as if a user has pressed the tab key just after the code in
IDEs.
Depending on the language of the compute session, this feature
may not be supported. Unsupported sessions returns an empty list.
:param code: An (i... | src/ai/backend/client/kernel.py | async def complete(self, code: str, opts: dict = None) -> Iterable[str]:
'''
Gets the auto-completion candidates from the given code string,
as if a user has pressed the tab key just after the code in
IDEs.
Depending on the language of the compute session, this feature
m... | async def complete(self, code: str, opts: dict = None) -> Iterable[str]:
'''
Gets the auto-completion candidates from the given code string,
as if a user has pressed the tab key just after the code in
IDEs.
Depending on the language of the compute session, this feature
m... | [
"Gets",
"the",
"auto",
"-",
"completion",
"candidates",
"from",
"the",
"given",
"code",
"string",
"as",
"if",
"a",
"user",
"has",
"pressed",
"the",
"tab",
"key",
"just",
"after",
"the",
"code",
"in",
"IDEs",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L168-L200 | [
"async",
"def",
"complete",
"(",
"self",
",",
"code",
":",
"str",
",",
"opts",
":",
"dict",
"=",
"None",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"opts",
"=",
"{",
"}",
"if",
"opts",
"is",
"None",
"else",
"opts",
"params",
"=",
"{",
"}",
"i... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.get_info | Retrieves a brief information about the compute session. | src/ai/backend/client/kernel.py | async def get_info(self):
'''
Retrieves a brief information about the compute session.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
rqst = Request(self.session,
'GET', '/kernel/{}'.format(s... | async def get_info(self):
'''
Retrieves a brief information about the compute session.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
rqst = Request(self.session,
'GET', '/kernel/{}'.format(s... | [
"Retrieves",
"a",
"brief",
"information",
"about",
"the",
"compute",
"session",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L203-L214 | [
"async",
"def",
"get_info",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"owner_access_key",
":",
"params",
"[",
"'owner_access_key'",
"]",
"=",
"self",
".",
"owner_access_key",
"rqst",
"=",
"Request",
"(",
"self",
".",
"session",
"... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.execute | Executes a code snippet directly in the compute session or sends a set of
build/clean/execute commands to the compute session.
For more details about using this API, please refer :doc:`the official API
documentation <user-api/intro>`.
:param run_id: A unique identifier for a particular... | src/ai/backend/client/kernel.py | async def execute(self, run_id: str = None,
code: str = None,
mode: str = 'query',
opts: dict = None):
'''
Executes a code snippet directly in the compute session or sends a set of
build/clean/execute commands to the compute sessi... | async def execute(self, run_id: str = None,
code: str = None,
mode: str = 'query',
opts: dict = None):
'''
Executes a code snippet directly in the compute session or sends a set of
build/clean/execute commands to the compute sessi... | [
"Executes",
"a",
"code",
"snippet",
"directly",
"in",
"the",
"compute",
"session",
"or",
"sends",
"a",
"set",
"of",
"build",
"/",
"clean",
"/",
"execute",
"commands",
"to",
"the",
"compute",
"session",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L231-L304 | [
"async",
"def",
"execute",
"(",
"self",
",",
"run_id",
":",
"str",
"=",
"None",
",",
"code",
":",
"str",
"=",
"None",
",",
"mode",
":",
"str",
"=",
"'query'",
",",
"opts",
":",
"dict",
"=",
"None",
")",
":",
"opts",
"=",
"opts",
"if",
"opts",
"... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.upload | Uploads the given list of files to the compute session.
You may refer them in the batch-mode execution or from the code
executed in the server afterwards.
:param files: The list of file paths in the client-side.
If the paths include directories, the location of them in the compute
... | src/ai/backend/client/kernel.py | async def upload(self, files: Sequence[Union[str, Path]],
basedir: Union[str, Path] = None,
show_progress: bool = False):
'''
Uploads the given list of files to the compute session.
You may refer them in the batch-mode execution or from the code
... | async def upload(self, files: Sequence[Union[str, Path]],
basedir: Union[str, Path] = None,
show_progress: bool = False):
'''
Uploads the given list of files to the compute session.
You may refer them in the batch-mode execution or from the code
... | [
"Uploads",
"the",
"given",
"list",
"of",
"files",
"to",
"the",
"compute",
"session",
".",
"You",
"may",
"refer",
"them",
"in",
"the",
"batch",
"-",
"mode",
"execution",
"or",
"from",
"the",
"code",
"executed",
"in",
"the",
"server",
"afterwards",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L307-L361 | [
"async",
"def",
"upload",
"(",
"self",
",",
"files",
":",
"Sequence",
"[",
"Union",
"[",
"str",
",",
"Path",
"]",
"]",
",",
"basedir",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
"=",
"None",
",",
"show_progress",
":",
"bool",
"=",
"False",
")",
... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.download | Downloads the given list of files from the compute session.
:param files: The list of file paths in the compute session.
If they are relative paths, the path is calculated from
``/home/work`` in the compute session container.
:param dest: The destination directory in the client-... | src/ai/backend/client/kernel.py | async def download(self, files: Sequence[Union[str, Path]],
dest: Union[str, Path] = '.',
show_progress: bool = False):
'''
Downloads the given list of files from the compute session.
:param files: The list of file paths in the compute session.
... | async def download(self, files: Sequence[Union[str, Path]],
dest: Union[str, Path] = '.',
show_progress: bool = False):
'''
Downloads the given list of files from the compute session.
:param files: The list of file paths in the compute session.
... | [
"Downloads",
"the",
"given",
"list",
"of",
"files",
"from",
"the",
"compute",
"session",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L364-L418 | [
"async",
"def",
"download",
"(",
"self",
",",
"files",
":",
"Sequence",
"[",
"Union",
"[",
"str",
",",
"Path",
"]",
"]",
",",
"dest",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
"=",
"'.'",
",",
"show_progress",
":",
"bool",
"=",
"False",
")",
":... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.list_files | Gets the list of files in the given path inside the compute session
container.
:param path: The directory path in the compute session. | src/ai/backend/client/kernel.py | async def list_files(self, path: Union[str, Path] = '.'):
'''
Gets the list of files in the given path inside the compute session
container.
:param path: The directory path in the compute session.
'''
params = {}
if self.owner_access_key:
params['owne... | async def list_files(self, path: Union[str, Path] = '.'):
'''
Gets the list of files in the given path inside the compute session
container.
:param path: The directory path in the compute session.
'''
params = {}
if self.owner_access_key:
params['owne... | [
"Gets",
"the",
"list",
"of",
"files",
"in",
"the",
"given",
"path",
"inside",
"the",
"compute",
"session",
"container",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L421-L438 | [
"async",
"def",
"list_files",
"(",
"self",
",",
"path",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
"=",
"'.'",
")",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"owner_access_key",
":",
"params",
"[",
"'owner_access_key'",
"]",
"=",
"self",
".",... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.stream_pty | Opens a pseudo-terminal of the kernel (if supported) streamed via
websockets.
:returns: a :class:`StreamPty` object. | src/ai/backend/client/kernel.py | def stream_pty(self) -> 'StreamPty':
'''
Opens a pseudo-terminal of the kernel (if supported) streamed via
websockets.
:returns: a :class:`StreamPty` object.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
... | def stream_pty(self) -> 'StreamPty':
'''
Opens a pseudo-terminal of the kernel (if supported) streamed via
websockets.
:returns: a :class:`StreamPty` object.
'''
params = {}
if self.owner_access_key:
params['owner_access_key'] = self.owner_access_key
... | [
"Opens",
"a",
"pseudo",
"-",
"terminal",
"of",
"the",
"kernel",
"(",
"if",
"supported",
")",
"streamed",
"via",
"websockets",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L441-L454 | [
"def",
"stream_pty",
"(",
"self",
")",
"->",
"'StreamPty'",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"owner_access_key",
":",
"params",
"[",
"'owner_access_key'",
"]",
"=",
"self",
".",
"owner_access_key",
"request",
"=",
"Request",
"(",
"self",
".... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | Kernel.stream_execute | Executes a code snippet in the streaming mode.
Since the returned websocket represents a run loop, there is no need to
specify *run_id* explicitly. | src/ai/backend/client/kernel.py | def stream_execute(self, code: str = '', *,
mode: str = 'query',
opts: dict = None) -> WebSocketResponse:
'''
Executes a code snippet in the streaming mode.
Since the returned websocket represents a run loop, there is no need to
specify *run_... | def stream_execute(self, code: str = '', *,
mode: str = 'query',
opts: dict = None) -> WebSocketResponse:
'''
Executes a code snippet in the streaming mode.
Since the returned websocket represents a run loop, there is no need to
specify *run_... | [
"Executes",
"a",
"code",
"snippet",
"in",
"the",
"streaming",
"mode",
".",
"Since",
"the",
"returned",
"websocket",
"represents",
"a",
"run",
"loop",
"there",
"is",
"no",
"need",
"to",
"specify",
"*",
"run_id",
"*",
"explicitly",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L457-L492 | [
"def",
"stream_execute",
"(",
"self",
",",
"code",
":",
"str",
"=",
"''",
",",
"*",
",",
"mode",
":",
"str",
"=",
"'query'",
",",
"opts",
":",
"dict",
"=",
"None",
")",
"->",
"WebSocketResponse",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | init_interface | Grab the ~/.polyglot/.env file for variables
If you are running Polyglot v2 on this same machine
then it should already exist. If not create it. | polyinterface/polyinterface.py | def init_interface():
sys.stdout = LoggerWriter(LOGGER.debug)
sys.stderr = LoggerWriter(LOGGER.error)
"""
Grab the ~/.polyglot/.env file for variables
If you are running Polyglot v2 on this same machine
then it should already exist. If not create it.
"""
warnings.simplefilter('error', U... | def init_interface():
sys.stdout = LoggerWriter(LOGGER.debug)
sys.stderr = LoggerWriter(LOGGER.error)
"""
Grab the ~/.polyglot/.env file for variables
If you are running Polyglot v2 on this same machine
then it should already exist. If not create it.
"""
warnings.simplefilter('error', U... | [
"Grab",
"the",
"~",
"/",
".",
"polyglot",
"/",
".",
"env",
"file",
"for",
"variables",
"If",
"you",
"are",
"running",
"Polyglot",
"v2",
"on",
"this",
"same",
"machine",
"then",
"it",
"should",
"already",
"exist",
".",
"If",
"not",
"create",
"it",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L76-L112 | [
"def",
"init_interface",
"(",
")",
":",
"sys",
".",
"stdout",
"=",
"LoggerWriter",
"(",
"LOGGER",
".",
"debug",
")",
"sys",
".",
"stderr",
"=",
"LoggerWriter",
"(",
"LOGGER",
".",
"error",
")",
"warnings",
".",
"simplefilter",
"(",
"'error'",
",",
"UserW... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface._connect | The callback for when the client receives a CONNACK response from the server.
Subscribing in on_connect() means that if we lose the connection and
reconnect then subscriptions will be renewed.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for ... | polyinterface/polyinterface.py | def _connect(self, mqttc, userdata, flags, rc):
"""
The callback for when the client receives a CONNACK response from the server.
Subscribing in on_connect() means that if we lose the connection and
reconnect then subscriptions will be renewed.
:param mqttc: The client instance ... | def _connect(self, mqttc, userdata, flags, rc):
"""
The callback for when the client receives a CONNACK response from the server.
Subscribing in on_connect() means that if we lose the connection and
reconnect then subscriptions will be renewed.
:param mqttc: The client instance ... | [
"The",
"callback",
"for",
"when",
"the",
"client",
"receives",
"a",
"CONNACK",
"response",
"from",
"the",
"server",
".",
"Subscribing",
"in",
"on_connect",
"()",
"means",
"that",
"if",
"we",
"lose",
"the",
"connection",
"and",
"reconnect",
"then",
"subscriptio... | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L207-L239 | [
"def",
"_connect",
"(",
"self",
",",
"mqttc",
",",
"userdata",
",",
"flags",
",",
"rc",
")",
":",
"if",
"rc",
"==",
"0",
":",
"self",
".",
"connected",
"=",
"True",
"results",
"=",
"[",
"]",
"LOGGER",
".",
"info",
"(",
"\"MQTT Connected with result cod... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface._message | The callback for when a PUBLISH message is received from the server.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param flags: The flags set on the connection.
:param msg: Dictionary of MQTT received... | polyinterface/polyinterface.py | def _message(self, mqttc, userdata, msg):
"""
The callback for when a PUBLISH message is received from the server.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param flags: The flags set on t... | def _message(self, mqttc, userdata, msg):
"""
The callback for when a PUBLISH message is received from the server.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param flags: The flags set on t... | [
"The",
"callback",
"for",
"when",
"a",
"PUBLISH",
"message",
"is",
"received",
"from",
"the",
"server",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L241-L272 | [
"def",
"_message",
"(",
"self",
",",
"mqttc",
",",
"userdata",
",",
"msg",
")",
":",
"try",
":",
"inputCmds",
"=",
"[",
"'query'",
",",
"'command'",
",",
"'result'",
",",
"'status'",
",",
"'shortPoll'",
",",
"'longPoll'",
",",
"'delete'",
"]",
"parsed_ms... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface._disconnect | The callback for when a DISCONNECT occurs.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param rc: Result code of connection, 0 = Graceful, anything else is unclean | polyinterface/polyinterface.py | def _disconnect(self, mqttc, userdata, rc):
"""
The callback for when a DISCONNECT occurs.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param rc: Result code of connection, 0 = Graceful, anyt... | def _disconnect(self, mqttc, userdata, rc):
"""
The callback for when a DISCONNECT occurs.
:param mqttc: The client instance for this callback
:param userdata: The private userdata for the mqtt client. Not used in Polyglot
:param rc: Result code of connection, 0 = Graceful, anyt... | [
"The",
"callback",
"for",
"when",
"a",
"DISCONNECT",
"occurs",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L274-L292 | [
"def",
"_disconnect",
"(",
"self",
",",
"mqttc",
",",
"userdata",
",",
"rc",
")",
":",
"self",
".",
"connected",
"=",
"False",
"if",
"rc",
"!=",
"0",
":",
"LOGGER",
".",
"info",
"(",
"\"MQTT Unexpected disconnection. Trying reconnect.\"",
")",
"try",
":",
... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface._startMqtt | The client start method. Starts the thread for the MQTT Client
and publishes the connected message. | polyinterface/polyinterface.py | def _startMqtt(self):
"""
The client start method. Starts the thread for the MQTT Client
and publishes the connected message.
"""
LOGGER.info('Connecting to MQTT... {}:{}'.format(self._server, self._port))
try:
# self._mqttc.connect_async(str(self._server), in... | def _startMqtt(self):
"""
The client start method. Starts the thread for the MQTT Client
and publishes the connected message.
"""
LOGGER.info('Connecting to MQTT... {}:{}'.format(self._server, self._port))
try:
# self._mqttc.connect_async(str(self._server), in... | [
"The",
"client",
"start",
"method",
".",
"Starts",
"the",
"thread",
"for",
"the",
"MQTT",
"Client",
"and",
"publishes",
"the",
"connected",
"message",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L313-L326 | [
"def",
"_startMqtt",
"(",
"self",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Connecting to MQTT... {}:{}'",
".",
"format",
"(",
"self",
".",
"_server",
",",
"self",
".",
"_port",
")",
")",
"try",
":",
"# self._mqttc.connect_async(str(self._server), int(self._port), 10)... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.stop | The client stop method. If the client is currently connected
stop the thread and disconnect. Publish the disconnected
message if clean shutdown. | polyinterface/polyinterface.py | def stop(self):
"""
The client stop method. If the client is currently connected
stop the thread and disconnect. Publish the disconnected
message if clean shutdown.
"""
# self.loop.call_soon_threadsafe(self.loop.stop)
# self.loop.stop()
# self._longPoll.ca... | def stop(self):
"""
The client stop method. If the client is currently connected
stop the thread and disconnect. Publish the disconnected
message if clean shutdown.
"""
# self.loop.call_soon_threadsafe(self.loop.stop)
# self.loop.stop()
# self._longPoll.ca... | [
"The",
"client",
"stop",
"method",
".",
"If",
"the",
"client",
"is",
"currently",
"connected",
"stop",
"the",
"thread",
"and",
"disconnect",
".",
"Publish",
"the",
"disconnected",
"message",
"if",
"clean",
"shutdown",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L328-L347 | [
"def",
"stop",
"(",
"self",
")",
":",
"# self.loop.call_soon_threadsafe(self.loop.stop)",
"# self.loop.stop()",
"# self._longPoll.cancel()",
"# self._shortPoll.cancel()",
"if",
"self",
".",
"connected",
":",
"LOGGER",
".",
"info",
"(",
"'Disconnecting from MQTT... {}:{}'",
".... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.send | Formatted Message to send to Polyglot. Connection messages are sent automatically from this module
so this method is used to send commands to/from Polyglot and formats it for consumption | polyinterface/polyinterface.py | def send(self, message):
"""
Formatted Message to send to Polyglot. Connection messages are sent automatically from this module
so this method is used to send commands to/from Polyglot and formats it for consumption
"""
if not isinstance(message, dict) and self.connected:
... | def send(self, message):
"""
Formatted Message to send to Polyglot. Connection messages are sent automatically from this module
so this method is used to send commands to/from Polyglot and formats it for consumption
"""
if not isinstance(message, dict) and self.connected:
... | [
"Formatted",
"Message",
"to",
"send",
"to",
"Polyglot",
".",
"Connection",
"messages",
"are",
"sent",
"automatically",
"from",
"this",
"module",
"so",
"this",
"method",
"is",
"used",
"to",
"send",
"commands",
"to",
"/",
"from",
"Polyglot",
"and",
"formats",
... | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L349-L361 | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"isinstance",
"(",
"message",
",",
"dict",
")",
"and",
"self",
".",
"connected",
":",
"warnings",
".",
"warn",
"(",
"'payload not a dictionary'",
")",
"return",
"False",
"try",
":",
"mess... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.addNode | Add a node to the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required. | polyinterface/polyinterface.py | def addNode(self, node):
"""
Add a node to the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
"""
LOGGER.info('Adding node {}({})'.format(node.name, node.address))
message = {
'addnode... | def addNode(self, node):
"""
Add a node to the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
"""
LOGGER.info('Adding node {}({})'.format(node.name, node.address))
message = {
'addnode... | [
"Add",
"a",
"node",
"to",
"the",
"NodeServer"
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L363-L382 | [
"def",
"addNode",
"(",
"self",
",",
"node",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Adding node {}({})'",
".",
"format",
"(",
"node",
".",
"name",
",",
"node",
".",
"address",
")",
")",
"message",
"=",
"{",
"'addnode'",
":",
"{",
"'nodes'",
":",
"[",... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.saveCustomData | Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database. | polyinterface/polyinterface.py | def saveCustomData(self, data):
"""
Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database.
"""
LOGGER.info('Sending customData to Polyglot.')
message = { 'customdata': data }
... | def saveCustomData(self, data):
"""
Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database.
"""
LOGGER.info('Sending customData to Polyglot.')
message = { 'customdata': data }
... | [
"Send",
"custom",
"dictionary",
"to",
"Polyglot",
"to",
"save",
"and",
"be",
"retrieved",
"on",
"startup",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L384-L392 | [
"def",
"saveCustomData",
"(",
"self",
",",
"data",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending customData to Polyglot.'",
")",
"message",
"=",
"{",
"'customdata'",
":",
"data",
"}",
"self",
".",
"send",
"(",
"message",
")"
] | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.saveCustomParams | Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database. | polyinterface/polyinterface.py | def saveCustomParams(self, data):
"""
Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database.
"""
LOGGER.info('Sending customParams to Polyglot.')
message = { 'customparams': data }... | def saveCustomParams(self, data):
"""
Send custom dictionary to Polyglot to save and be retrieved on startup.
:param data: Dictionary of key value pairs to store in Polyglot database.
"""
LOGGER.info('Sending customParams to Polyglot.')
message = { 'customparams': data }... | [
"Send",
"custom",
"dictionary",
"to",
"Polyglot",
"to",
"save",
"and",
"be",
"retrieved",
"on",
"startup",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L394-L402 | [
"def",
"saveCustomParams",
"(",
"self",
",",
"data",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending customParams to Polyglot.'",
")",
"message",
"=",
"{",
"'customparams'",
":",
"data",
"}",
"self",
".",
"send",
"(",
"message",
")"
] | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.addNotice | Add custom notice to front-end for this NodeServers
:param data: String of characters to add as a notification in the front-end. | polyinterface/polyinterface.py | def addNotice(self, data):
"""
Add custom notice to front-end for this NodeServers
:param data: String of characters to add as a notification in the front-end.
"""
LOGGER.info('Sending addnotice to Polyglot: {}'.format(data))
message = { 'addnotice': data }
self.... | def addNotice(self, data):
"""
Add custom notice to front-end for this NodeServers
:param data: String of characters to add as a notification in the front-end.
"""
LOGGER.info('Sending addnotice to Polyglot: {}'.format(data))
message = { 'addnotice': data }
self.... | [
"Add",
"custom",
"notice",
"to",
"front",
"-",
"end",
"for",
"this",
"NodeServers"
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L404-L412 | [
"def",
"addNotice",
"(",
"self",
",",
"data",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending addnotice to Polyglot: {}'",
".",
"format",
"(",
"data",
")",
")",
"message",
"=",
"{",
"'addnotice'",
":",
"data",
"}",
"self",
".",
"send",
"(",
"message",
")... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.removeNotice | Add custom notice to front-end for this NodeServers
:param data: Index of notices list to remove. | polyinterface/polyinterface.py | def removeNotice(self, data):
"""
Add custom notice to front-end for this NodeServers
:param data: Index of notices list to remove.
"""
LOGGER.info('Sending removenotice to Polyglot for index {}'.format(data))
message = { 'removenotice': data }
self.send(message) | def removeNotice(self, data):
"""
Add custom notice to front-end for this NodeServers
:param data: Index of notices list to remove.
"""
LOGGER.info('Sending removenotice to Polyglot for index {}'.format(data))
message = { 'removenotice': data }
self.send(message) | [
"Add",
"custom",
"notice",
"to",
"front",
"-",
"end",
"for",
"this",
"NodeServers"
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L414-L422 | [
"def",
"removeNotice",
"(",
"self",
",",
"data",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending removenotice to Polyglot for index {}'",
".",
"format",
"(",
"data",
")",
")",
"message",
"=",
"{",
"'removenotice'",
":",
"data",
"}",
"self",
".",
"send",
"(",... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.delNode | Delete a node from the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required. | polyinterface/polyinterface.py | def delNode(self, address):
"""
Delete a node from the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
"""
LOGGER.info('Removing node {}'.format(address))
message = {
'removenode': {
... | def delNode(self, address):
"""
Delete a node from the NodeServer
:param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
"""
LOGGER.info('Removing node {}'.format(address))
message = {
'removenode': {
... | [
"Delete",
"a",
"node",
"from",
"the",
"NodeServer"
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L439-L451 | [
"def",
"delNode",
"(",
"self",
",",
"address",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Removing node {}'",
".",
"format",
"(",
"address",
")",
")",
"message",
"=",
"{",
"'removenode'",
":",
"{",
"'address'",
":",
"address",
"}",
"}",
"self",
".",
"send... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.getNode | Get Node by Address of existing nodes. | polyinterface/polyinterface.py | def getNode(self, address):
"""
Get Node by Address of existing nodes.
"""
try:
for node in self.config['nodes']:
if node['address'] == address:
return node
return False
except KeyError:
LOGGER.error('Usually... | def getNode(self, address):
"""
Get Node by Address of existing nodes.
"""
try:
for node in self.config['nodes']:
if node['address'] == address:
return node
return False
except KeyError:
LOGGER.error('Usually... | [
"Get",
"Node",
"by",
"Address",
"of",
"existing",
"nodes",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L453-L464 | [
"def",
"getNode",
"(",
"self",
",",
"address",
")",
":",
"try",
":",
"for",
"node",
"in",
"self",
".",
"config",
"[",
"'nodes'",
"]",
":",
"if",
"node",
"[",
"'address'",
"]",
"==",
"address",
":",
"return",
"node",
"return",
"False",
"except",
"KeyE... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.inConfig | Save incoming config received from Polyglot to Interface.config and then do any functions
that are waiting on the config to be received. | polyinterface/polyinterface.py | def inConfig(self, config):
"""
Save incoming config received from Polyglot to Interface.config and then do any functions
that are waiting on the config to be received.
"""
self.config = config
self.isyVersion = config['isyVersion']
try:
for watcher in... | def inConfig(self, config):
"""
Save incoming config received from Polyglot to Interface.config and then do any functions
that are waiting on the config to be received.
"""
self.config = config
self.isyVersion = config['isyVersion']
try:
for watcher in... | [
"Save",
"incoming",
"config",
"received",
"from",
"Polyglot",
"to",
"Interface",
".",
"config",
"and",
"then",
"do",
"any",
"functions",
"that",
"are",
"waiting",
"on",
"the",
"config",
"to",
"be",
"received",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L466-L480 | [
"def",
"inConfig",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
"=",
"config",
"self",
".",
"isyVersion",
"=",
"config",
"[",
"'isyVersion'",
"]",
"try",
":",
"for",
"watcher",
"in",
"self",
".",
"__configObservers",
":",
"watcher",
"(",
... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Interface.save_typed_params | Send custom parameters descriptions to Polyglot to be used
in front end UI configuration screen
Accepts list of objects with the followin properties
name - used as a key when data is sent from UI
title - displayed in UI
defaultValue - optionanl
type - opti... | polyinterface/polyinterface.py | def save_typed_params(self, data):
"""
Send custom parameters descriptions to Polyglot to be used
in front end UI configuration screen
Accepts list of objects with the followin properties
name - used as a key when data is sent from UI
title - displayed in UI
... | def save_typed_params(self, data):
"""
Send custom parameters descriptions to Polyglot to be used
in front end UI configuration screen
Accepts list of objects with the followin properties
name - used as a key when data is sent from UI
title - displayed in UI
... | [
"Send",
"custom",
"parameters",
"descriptions",
"to",
"Polyglot",
"to",
"be",
"used",
"in",
"front",
"end",
"UI",
"configuration",
"screen",
"Accepts",
"list",
"of",
"objects",
"with",
"the",
"followin",
"properties",
"name",
"-",
"used",
"as",
"a",
"key",
"... | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L519-L542 | [
"def",
"save_typed_params",
"(",
"self",
",",
"data",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Sending typed parameters to Polyglot.'",
")",
"if",
"type",
"(",
"data",
")",
"is",
"not",
"list",
":",
"data",
"=",
"[",
"data",
"]",
"message",
"=",
"{",
"'ty... | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Controller.delNode | Just send it along if requested, should be able to delete the node even if it isn't
in our config anywhere. Usually used for normalization. | polyinterface/polyinterface.py | def delNode(self, address):
"""
Just send it along if requested, should be able to delete the node even if it isn't
in our config anywhere. Usually used for normalization.
"""
if address in self.nodes:
del self.nodes[address]
self.poly.delNode(address) | def delNode(self, address):
"""
Just send it along if requested, should be able to delete the node even if it isn't
in our config anywhere. Usually used for normalization.
"""
if address in self.nodes:
del self.nodes[address]
self.poly.delNode(address) | [
"Just",
"send",
"it",
"along",
"if",
"requested",
"should",
"be",
"able",
"to",
"delete",
"the",
"node",
"even",
"if",
"it",
"isn",
"t",
"in",
"our",
"config",
"anywhere",
".",
"Usually",
"used",
"for",
"normalization",
"."
] | UniversalDevicesInc/polyglot-v2-python-interface | python | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L844-L851 | [
"def",
"delNode",
"(",
"self",
",",
"address",
")",
":",
"if",
"address",
"in",
"self",
".",
"nodes",
":",
"del",
"self",
".",
"nodes",
"[",
"address",
"]",
"self",
".",
"poly",
".",
"delNode",
"(",
"address",
")"
] | fe613135b762731a41a081222e43d2a8ae4fc53f |
train | Admin.query | Sends the GraphQL query and returns the response.
:param query: The GraphQL query string.
:param variables: An optional key-value dictionary
to fill the interpolated template variables
in the query.
:returns: The object parsed from the response JSON string. | src/ai/backend/client/admin.py | async def query(cls, query: str,
variables: Optional[Mapping[str, Any]] = None,
) -> Any:
'''
Sends the GraphQL query and returns the response.
:param query: The GraphQL query string.
:param variables: An optional key-value dictionary
... | async def query(cls, query: str,
variables: Optional[Mapping[str, Any]] = None,
) -> Any:
'''
Sends the GraphQL query and returns the response.
:param query: The GraphQL query string.
:param variables: An optional key-value dictionary
... | [
"Sends",
"the",
"GraphQL",
"query",
"and",
"returns",
"the",
"response",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/admin.py#L27-L47 | [
"async",
"def",
"query",
"(",
"cls",
",",
"query",
":",
"str",
",",
"variables",
":",
"Optional",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
")",
"->",
"Any",
":",
"gql_query",
"=",
"{",
"'query'",
":",
"query",
",",
"'va... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | get_readable_time_string | Returns human readable string from number of seconds | housecanary/utilities.py | def get_readable_time_string(seconds):
"""Returns human readable string from number of seconds"""
seconds = int(seconds)
minutes = seconds // 60
seconds = seconds % 60
hours = minutes // 60
minutes = minutes % 60
days = hours // 24
hours = hours % 24
result = ""
if days > 0:
... | def get_readable_time_string(seconds):
"""Returns human readable string from number of seconds"""
seconds = int(seconds)
minutes = seconds // 60
seconds = seconds % 60
hours = minutes // 60
minutes = minutes % 60
days = hours // 24
hours = hours % 24
result = ""
if days > 0:
... | [
"Returns",
"human",
"readable",
"string",
"from",
"number",
"of",
"seconds"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/utilities.py#L6-L26 | [
"def",
"get_readable_time_string",
"(",
"seconds",
")",
":",
"seconds",
"=",
"int",
"(",
"seconds",
")",
"minutes",
"=",
"seconds",
"//",
"60",
"seconds",
"=",
"seconds",
"%",
"60",
"hours",
"=",
"minutes",
"//",
"60",
"minutes",
"=",
"minutes",
"%",
"60... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | get_rate_limits | Returns a list of rate limit information from a given response's headers. | housecanary/utilities.py | def get_rate_limits(response):
"""Returns a list of rate limit information from a given response's headers."""
periods = response.headers['X-RateLimit-Period']
if not periods:
return []
rate_limits = []
periods = periods.split(',')
limits = response.headers['X-RateLimit-Limit'].split('... | def get_rate_limits(response):
"""Returns a list of rate limit information from a given response's headers."""
periods = response.headers['X-RateLimit-Period']
if not periods:
return []
rate_limits = []
periods = periods.split(',')
limits = response.headers['X-RateLimit-Limit'].split('... | [
"Returns",
"a",
"list",
"of",
"rate",
"limit",
"information",
"from",
"a",
"given",
"response",
"s",
"headers",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/utilities.py#L37-L73 | [
"def",
"get_rate_limits",
"(",
"response",
")",
":",
"periods",
"=",
"response",
".",
"headers",
"[",
"'X-RateLimit-Period'",
"]",
"if",
"not",
"periods",
":",
"return",
"[",
"]",
"rate_limits",
"=",
"[",
"]",
"periods",
"=",
"periods",
".",
"split",
"(",
... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | DictWrapper.isubset | Return key, self[key] as generator for key in keys.
Raise KeyError if a key does not exist
Args:
keys: Iterable containing keys
Example:
>>> from ww import d
>>> list(d({1: 1, 2: 2, 3: 3}).isubset(1, 3))
[(1, 1), (3, 3)] | src/ww/wrappers/dicts.py | def isubset(self, *keys):
# type: (*Hashable) -> ww.g
"""Return key, self[key] as generator for key in keys.
Raise KeyError if a key does not exist
Args:
keys: Iterable containing keys
Example:
>>> from ww import d
>>> list(d({1: 1, 2: 2, 3... | def isubset(self, *keys):
# type: (*Hashable) -> ww.g
"""Return key, self[key] as generator for key in keys.
Raise KeyError if a key does not exist
Args:
keys: Iterable containing keys
Example:
>>> from ww import d
>>> list(d({1: 1, 2: 2, 3... | [
"Return",
"key",
"self",
"[",
"key",
"]",
"as",
"generator",
"for",
"key",
"in",
"keys",
"."
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L18-L33 | [
"def",
"isubset",
"(",
"self",
",",
"*",
"keys",
")",
":",
"# type: (*Hashable) -> ww.g",
"return",
"ww",
".",
"g",
"(",
"(",
"key",
",",
"self",
"[",
"key",
"]",
")",
"for",
"key",
"in",
"keys",
")"
] | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | DictWrapper.swap | Swap key and value
/!\ Be carreful, if there are duplicate values, only one will
survive /!\
Example:
>>> from ww import d
>>> d({1: 2, 2: 2, 3: 3}).swap()
{2: 2, 3: 3} | src/ww/wrappers/dicts.py | def swap(self):
# type: () -> DictWrapper
"""Swap key and value
/!\ Be carreful, if there are duplicate values, only one will
survive /!\
Example:
>>> from ww import d
>>> d({1: 2, 2: 2, 3: 3}).swap()
{2: 2, 3: 3}
"""
return ... | def swap(self):
# type: () -> DictWrapper
"""Swap key and value
/!\ Be carreful, if there are duplicate values, only one will
survive /!\
Example:
>>> from ww import d
>>> d({1: 2, 2: 2, 3: 3}).swap()
{2: 2, 3: 3}
"""
return ... | [
"Swap",
"key",
"and",
"value"
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L52-L65 | [
"def",
"swap",
"(",
"self",
")",
":",
"# type: () -> DictWrapper",
"return",
"self",
".",
"__class__",
"(",
"(",
"v",
",",
"k",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
")"
] | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | DictWrapper.fromkeys | Create a new d from
Args:
iterable: Iterable containing keys
value: value to associate with each key.
If callable, will be value[key]
Returns: new DictWrapper
Example:
>>> from ww import d
>>> sorted(d.fromkeys('123', value=4).items... | src/ww/wrappers/dicts.py | def fromkeys(cls, iterable, value=None):
# TODO : type: (Iterable, Union[Any, Callable]) -> DictWrapper
# https://github.com/python/mypy/issues/2254
"""Create a new d from
Args:
iterable: Iterable containing keys
value: value to associate with each key.
... | def fromkeys(cls, iterable, value=None):
# TODO : type: (Iterable, Union[Any, Callable]) -> DictWrapper
# https://github.com/python/mypy/issues/2254
"""Create a new d from
Args:
iterable: Iterable containing keys
value: value to associate with each key.
... | [
"Create",
"a",
"new",
"d",
"from"
] | Tygs/ww | python | https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L94-L117 | [
"def",
"fromkeys",
"(",
"cls",
",",
"iterable",
",",
"value",
"=",
"None",
")",
":",
"# TODO : type: (Iterable, Union[Any, Callable]) -> DictWrapper",
"# https://github.com/python/mypy/issues/2254",
"if",
"not",
"callable",
"(",
"value",
")",
":",
"return",
"cls",
"(",
... | 6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4 |
train | main | Main function.
:return:
None. | src/aoiklivereload/demo/flask_demo.py | def main():
"""
Main function.
:return:
None.
"""
try:
# Get the `src` directory's absolute path
src_path = os.path.dirname(
# `aoiklivereload` directory's absolute path
os.path.dirname(
# `demo` directory's absolute path
... | def main():
"""
Main function.
:return:
None.
"""
try:
# Get the `src` directory's absolute path
src_path = os.path.dirname(
# `aoiklivereload` directory's absolute path
os.path.dirname(
# `demo` directory's absolute path
... | [
"Main",
"function",
"."
] | AoiKuiyuyou/AoikLiveReload | python | https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/src/aoiklivereload/demo/flask_demo.py#L15-L92 | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Get the `src` directory's absolute path",
"src_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"# `aoiklivereload` directory's absolute path",
"os",
".",
"path",
".",
"dirname",
"(",
"# `demo` directory's absolute path",
... | 0d5adb12118a33749e6690a8165fdb769cff7d5c |
train | get_excel_workbook | Generates an Excel workbook object given api_data returned by the Analytics API
Args:
api_data: Analytics API data as a list of dicts (one per identifier)
result_info_key: the key in api_data dicts that contains the data results
identifier_keys: the list of keys used as requested identifier... | housecanary/excel/analytics_data_excel.py | def get_excel_workbook(api_data, result_info_key, identifier_keys):
"""Generates an Excel workbook object given api_data returned by the Analytics API
Args:
api_data: Analytics API data as a list of dicts (one per identifier)
result_info_key: the key in api_data dicts that contains the data res... | def get_excel_workbook(api_data, result_info_key, identifier_keys):
"""Generates an Excel workbook object given api_data returned by the Analytics API
Args:
api_data: Analytics API data as a list of dicts (one per identifier)
result_info_key: the key in api_data dicts that contains the data res... | [
"Generates",
"an",
"Excel",
"workbook",
"object",
"given",
"api_data",
"returned",
"by",
"the",
"Analytics",
"API"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L30-L67 | [
"def",
"get_excel_workbook",
"(",
"api_data",
",",
"result_info_key",
",",
"identifier_keys",
")",
":",
"cleaned_data",
"=",
"[",
"]",
"for",
"item_data",
"in",
"api_data",
":",
"result_info",
"=",
"item_data",
".",
"pop",
"(",
"result_info_key",
",",
"{",
"}"... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | write_worksheets | Writes rest of the worksheets to workbook.
Args:
workbook: workbook to write into
data_list: Analytics API data as a list of dicts
result_info_key: the key in api_data dicts that contains the data results
identifier_keys: the list of keys used as requested identifiers
... | housecanary/excel/analytics_data_excel.py | def write_worksheets(workbook, data_list, result_info_key, identifier_keys):
"""Writes rest of the worksheets to workbook.
Args:
workbook: workbook to write into
data_list: Analytics API data as a list of dicts
result_info_key: the key in api_data dicts that contains the data results
... | def write_worksheets(workbook, data_list, result_info_key, identifier_keys):
"""Writes rest of the worksheets to workbook.
Args:
workbook: workbook to write into
data_list: Analytics API data as a list of dicts
result_info_key: the key in api_data dicts that contains the data results
... | [
"Writes",
"rest",
"of",
"the",
"worksheets",
"to",
"workbook",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L70-L106 | [
"def",
"write_worksheets",
"(",
"workbook",
",",
"data_list",
",",
"result_info_key",
",",
"identifier_keys",
")",
":",
"# we can use the first item to figure out the worksheet keys",
"worksheet_keys",
"=",
"get_worksheet_keys",
"(",
"data_list",
"[",
"0",
"]",
",",
"resu... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | create_property_nod_worksheets | Creates two worksheets out of the property/nod data because the data
doesn't come flat enough to make sense on one sheet.
Args:
workbook: the main workbook to add the sheets to
data_list: the main list of data
result_info_key: the key in api_data dicts that contains th... | housecanary/excel/analytics_data_excel.py | def create_property_nod_worksheets(workbook, data_list, result_info_key, identifier_keys):
"""Creates two worksheets out of the property/nod data because the data
doesn't come flat enough to make sense on one sheet.
Args:
workbook: the main workbook to add the sheets to
data_l... | def create_property_nod_worksheets(workbook, data_list, result_info_key, identifier_keys):
"""Creates two worksheets out of the property/nod data because the data
doesn't come flat enough to make sense on one sheet.
Args:
workbook: the main workbook to add the sheets to
data_l... | [
"Creates",
"two",
"worksheets",
"out",
"of",
"the",
"property",
"/",
"nod",
"data",
"because",
"the",
"data",
"doesn",
"t",
"come",
"flat",
"enough",
"to",
"make",
"sense",
"on",
"one",
"sheet",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L109-L144 | [
"def",
"create_property_nod_worksheets",
"(",
"workbook",
",",
"data_list",
",",
"result_info_key",
",",
"identifier_keys",
")",
":",
"nod_details_list",
"=",
"[",
"]",
"nod_default_history_list",
"=",
"[",
"]",
"for",
"prop_data",
"in",
"data_list",
":",
"nod_data"... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | get_worksheet_keys | Gets sorted keys from the dict, ignoring result_info_key and 'meta' key
Args:
data_dict: dict to pull keys from
Returns:
list of keys in the dict other than the result_info_key | housecanary/excel/analytics_data_excel.py | def get_worksheet_keys(data_dict, result_info_key):
"""Gets sorted keys from the dict, ignoring result_info_key and 'meta' key
Args:
data_dict: dict to pull keys from
Returns:
list of keys in the dict other than the result_info_key
"""
keys = set(data_dict.keys())
keys.remove(re... | def get_worksheet_keys(data_dict, result_info_key):
"""Gets sorted keys from the dict, ignoring result_info_key and 'meta' key
Args:
data_dict: dict to pull keys from
Returns:
list of keys in the dict other than the result_info_key
"""
keys = set(data_dict.keys())
keys.remove(re... | [
"Gets",
"sorted",
"keys",
"from",
"the",
"dict",
"ignoring",
"result_info_key",
"and",
"meta",
"key",
"Args",
":",
"data_dict",
":",
"dict",
"to",
"pull",
"keys",
"from"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L147-L159 | [
"def",
"get_worksheet_keys",
"(",
"data_dict",
",",
"result_info_key",
")",
":",
"keys",
"=",
"set",
"(",
"data_dict",
".",
"keys",
"(",
")",
")",
"keys",
".",
"remove",
"(",
"result_info_key",
")",
"if",
"'meta'",
"in",
"keys",
":",
"keys",
".",
"remove... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | get_keys | Gets all possible keys from a list of dicts, sorting by leading_columns first
Args:
data_list: list of dicts to pull keys from
leading_columns: list of keys to put first in the result
Returns:
list of keys to be included as columns in excel worksheet | housecanary/excel/analytics_data_excel.py | def get_keys(data_list, leading_columns=LEADING_COLUMNS):
"""Gets all possible keys from a list of dicts, sorting by leading_columns first
Args:
data_list: list of dicts to pull keys from
leading_columns: list of keys to put first in the result
Returns:
list of keys to be included ... | def get_keys(data_list, leading_columns=LEADING_COLUMNS):
"""Gets all possible keys from a list of dicts, sorting by leading_columns first
Args:
data_list: list of dicts to pull keys from
leading_columns: list of keys to put first in the result
Returns:
list of keys to be included ... | [
"Gets",
"all",
"possible",
"keys",
"from",
"a",
"list",
"of",
"dicts",
"sorting",
"by",
"leading_columns",
"first"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L162-L182 | [
"def",
"get_keys",
"(",
"data_list",
",",
"leading_columns",
"=",
"LEADING_COLUMNS",
")",
":",
"all_keys",
"=",
"set",
"(",
")",
".",
"union",
"(",
"*",
"(",
"list",
"(",
"d",
".",
"keys",
"(",
")",
")",
"for",
"d",
"in",
"data_list",
")",
")",
"le... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | write_data | Writes data into worksheet.
Args:
worksheet: worksheet to write into
data: data to be written | housecanary/excel/analytics_data_excel.py | def write_data(worksheet, data):
"""Writes data into worksheet.
Args:
worksheet: worksheet to write into
data: data to be written
"""
if not data:
return
if isinstance(data, list):
rows = data
else:
rows = [data]
if isinstance(rows[0], dict):
... | def write_data(worksheet, data):
"""Writes data into worksheet.
Args:
worksheet: worksheet to write into
data: data to be written
"""
if not data:
return
if isinstance(data, list):
rows = data
else:
rows = [data]
if isinstance(rows[0], dict):
... | [
"Writes",
"data",
"into",
"worksheet",
"."
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L185-L212 | [
"def",
"write_data",
"(",
"worksheet",
",",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
":",
"rows",
"=",
"data",
"else",
":",
"rows",
"=",
"[",
"data",
"]",
"if",
"isinstance",
"(",
"row... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | process_data | Given a key as the endpoint name, pulls the data for that endpoint out
of the data_list for each address, processes the data into a more
excel-friendly format and returns that data.
Args:
key: the endpoint name of the data to process
data_list: the main data list to take... | housecanary/excel/analytics_data_excel.py | def process_data(key, data_list, result_info_key, identifier_keys):
""" Given a key as the endpoint name, pulls the data for that endpoint out
of the data_list for each address, processes the data into a more
excel-friendly format and returns that data.
Args:
key: the endpoint n... | def process_data(key, data_list, result_info_key, identifier_keys):
""" Given a key as the endpoint name, pulls the data for that endpoint out
of the data_list for each address, processes the data into a more
excel-friendly format and returns that data.
Args:
key: the endpoint n... | [
"Given",
"a",
"key",
"as",
"the",
"endpoint",
"name",
"pulls",
"the",
"data",
"for",
"that",
"endpoint",
"out",
"of",
"the",
"data_list",
"for",
"each",
"address",
"processes",
"the",
"data",
"into",
"a",
"more",
"excel",
"-",
"friendly",
"format",
"and",
... | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L222-L297 | [
"def",
"process_data",
"(",
"key",
",",
"data_list",
",",
"result_info_key",
",",
"identifier_keys",
")",
":",
"master_data",
"=",
"[",
"]",
"for",
"item_data",
"in",
"data_list",
":",
"data",
"=",
"item_data",
"[",
"key",
"]",
"if",
"data",
"is",
"None",
... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | flatten_top_level_keys | Helper method to flatten a nested dict of dicts (one level)
Example:
{'a': {'b': 'bbb'}} becomes {'a_-_b': 'bbb'}
The separator '_-_' gets formatted later for the column headers
Args:
data: the dict to flatten
top_level_keys: a list of the top level key... | housecanary/excel/analytics_data_excel.py | def flatten_top_level_keys(data, top_level_keys):
""" Helper method to flatten a nested dict of dicts (one level)
Example:
{'a': {'b': 'bbb'}} becomes {'a_-_b': 'bbb'}
The separator '_-_' gets formatted later for the column headers
Args:
data: the dict to flatt... | def flatten_top_level_keys(data, top_level_keys):
""" Helper method to flatten a nested dict of dicts (one level)
Example:
{'a': {'b': 'bbb'}} becomes {'a_-_b': 'bbb'}
The separator '_-_' gets formatted later for the column headers
Args:
data: the dict to flatt... | [
"Helper",
"method",
"to",
"flatten",
"a",
"nested",
"dict",
"of",
"dicts",
"(",
"one",
"level",
")"
] | housecanary/hc-api-python | python | https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/excel/analytics_data_excel.py#L311-L332 | [
"def",
"flatten_top_level_keys",
"(",
"data",
",",
"top_level_keys",
")",
":",
"flattened_data",
"=",
"{",
"}",
"for",
"top_level_key",
"in",
"top_level_keys",
":",
"if",
"data",
"[",
"top_level_key",
"]",
"is",
"None",
":",
"flattened_data",
"[",
"top_level_key... | 2bb9e2208b34e8617575de45934357ee33b8531c |
train | check_database_connected | A Django check to see if connecting to the configured default
database backend succeeds. | src/dockerflow/django/checks.py | def check_database_connected(app_configs, **kwargs):
"""
A Django check to see if connecting to the configured default
database backend succeeds.
"""
errors = []
try:
connection.ensure_connection()
except OperationalError as e:
msg = 'Could not connect to database: {!s}'.for... | def check_database_connected(app_configs, **kwargs):
"""
A Django check to see if connecting to the configured default
database backend succeeds.
"""
errors = []
try:
connection.ensure_connection()
except OperationalError as e:
msg = 'Could not connect to database: {!s}'.for... | [
"A",
"Django",
"check",
"to",
"see",
"if",
"connecting",
"to",
"the",
"configured",
"default",
"database",
"backend",
"succeeds",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/checks.py#L26-L48 | [
"def",
"check_database_connected",
"(",
"app_configs",
",",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"try",
":",
"connection",
".",
"ensure_connection",
"(",
")",
"except",
"OperationalError",
"as",
"e",
":",
"msg",
"=",
"'Could not connect to da... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | check_migrations_applied | A Django check to see if all migrations have been applied correctly. | src/dockerflow/django/checks.py | def check_migrations_applied(app_configs, **kwargs):
"""
A Django check to see if all migrations have been applied correctly.
"""
from django.db.migrations.loader import MigrationLoader
errors = []
# Load migrations from disk/DB
try:
loader = MigrationLoader(connection, ignore_no_mi... | def check_migrations_applied(app_configs, **kwargs):
"""
A Django check to see if all migrations have been applied correctly.
"""
from django.db.migrations.loader import MigrationLoader
errors = []
# Load migrations from disk/DB
try:
loader = MigrationLoader(connection, ignore_no_mi... | [
"A",
"Django",
"check",
"to",
"see",
"if",
"all",
"migrations",
"have",
"been",
"applied",
"correctly",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/checks.py#L51-L80 | [
"def",
"check_migrations_applied",
"(",
"app_configs",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"django",
".",
"db",
".",
"migrations",
".",
"loader",
"import",
"MigrationLoader",
"errors",
"=",
"[",
"]",
"# Load migrations from disk/DB",
"try",
":",
"loader",... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | check_redis_connected | A Django check to connect to the default redis connection
using ``django_redis.get_redis_connection`` and see if Redis
responds to a ``PING`` command. | src/dockerflow/django/checks.py | def check_redis_connected(app_configs, **kwargs):
"""
A Django check to connect to the default redis connection
using ``django_redis.get_redis_connection`` and see if Redis
responds to a ``PING`` command.
"""
import redis
from django_redis import get_redis_connection
errors = []
try... | def check_redis_connected(app_configs, **kwargs):
"""
A Django check to connect to the default redis connection
using ``django_redis.get_redis_connection`` and see if Redis
responds to a ``PING`` command.
"""
import redis
from django_redis import get_redis_connection
errors = []
try... | [
"A",
"Django",
"check",
"to",
"connect",
"to",
"the",
"default",
"redis",
"connection",
"using",
"django_redis",
".",
"get_redis_connection",
"and",
"see",
"if",
"Redis",
"responds",
"to",
"a",
"PING",
"command",
"."
] | mozilla-services/python-dockerflow | python | https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/checks.py#L83-L109 | [
"def",
"check_redis_connected",
"(",
"app_configs",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"redis",
"from",
"django_redis",
"import",
"get_redis_connection",
"errors",
"=",
"[",
"]",
"try",
":",
"connection",
"=",
"get_redis_connection",
"(",
"'default'",
... | 43703c5e8934ba6901b0a1520d6da4ed6457208c |
train | get_realtime_alarm | Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of the target device
:param auth: requests auth o... | build/lib/pyhpeimc/plat/alarms.py | def get_realtime_alarm(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of... | def get_realtime_alarm(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of... | [
"Takes",
"in",
"no",
"param",
"as",
"input",
"to",
"fetch",
"RealTime",
"Alarms",
"from",
"HP",
"IMC",
"RESTFUL",
"API"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/alarms.py#L63-L100 | [
"def",
"get_realtime_alarm",
"(",
"username",
",",
"auth",
",",
"url",
")",
":",
"get_realtime_alarm_url",
"=",
"\"/imcrs/fault/faultRealTime?operatorName=\"",
"+",
"username",
"f_url",
"=",
"url",
"+",
"get_realtime_alarm_url",
"r",
"=",
"requests",
".",
"get",
"("... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_alarms | Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of the target device
:param auth: requests auth o... | build/lib/pyhpeimc/plat/alarms.py | def get_alarms(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of the tar... | def get_alarms(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param devId: int or str value of the tar... | [
"Takes",
"in",
"no",
"param",
"as",
"input",
"to",
"fetch",
"RealTime",
"Alarms",
"from",
"HP",
"IMC",
"RESTFUL",
"API"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/alarms.py#L103-L349 | [
"def",
"get_alarms",
"(",
"username",
",",
"auth",
",",
"url",
")",
":",
"get_alarms_url",
"=",
"\"/imcrs/fault/alarm?operatorName=\"",
"+",
"username",
"+",
"\"&recStatus=0&ackStatus=0&timeRange=0&size=50&desc=true\"",
"f_url",
"=",
"url",
"+",
"get_alarms_url",
"r",
"... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_dev_alarms | function takes the devId of a specific device and issues a RESTFUL call to get the current
alarms for the target device.
:param devid: int or str value of the target device
:param devip: str of ipv4 address of the target device
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.... | pyhpeimc/plat/alarms.py | def get_dev_alarms(auth, url, devid=None, devip=None):
"""
function takes the devId of a specific device and issues a RESTFUL call to get the current
alarms for the target device.
:param devid: int or str value of the target device
:param devip: str of ipv4 address of the target device
:param... | def get_dev_alarms(auth, url, devid=None, devip=None):
"""
function takes the devId of a specific device and issues a RESTFUL call to get the current
alarms for the target device.
:param devid: int or str value of the target device
:param devip: str of ipv4 address of the target device
:param... | [
"function",
"takes",
"the",
"devId",
"of",
"a",
"specific",
"device",
"and",
"issues",
"a",
"RESTFUL",
"call",
"to",
"get",
"the",
"current",
"alarms",
"for",
"the",
"target",
"device",
"."
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L20-L62 | [
"def",
"get_dev_alarms",
"(",
"auth",
",",
"url",
",",
"devid",
"=",
"None",
",",
"devip",
"=",
"None",
")",
":",
"# checks to see if the imc credentials are already available",
"if",
"devip",
"is",
"not",
"None",
":",
"devid",
"=",
"get_dev_details",
"(",
"devi... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_realtime_alarm | Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
... | pyhpeimc/plat/alarms.py | def get_realtime_alarm(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object... | def get_realtime_alarm(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object... | [
"Takes",
"in",
"no",
"param",
"as",
"input",
"to",
"fetch",
"RealTime",
"Alarms",
"from",
"HP",
"IMC",
"RESTFUL",
"API"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L65-L99 | [
"def",
"get_realtime_alarm",
"(",
"username",
",",
"auth",
",",
"url",
")",
":",
"f_url",
"=",
"url",
"+",
"\"/imcrs/fault/faultRealTime?operatorName=\"",
"+",
"username",
"response",
"=",
"requests",
".",
"get",
"(",
"f_url",
",",
"auth",
"=",
"auth",
",",
... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_alarms | Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
... | pyhpeimc/plat/alarms.py | def get_alarms(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object #usuall... | def get_alarms(username, auth, url):
"""Takes in no param as input to fetch RealTime Alarms from HP IMC RESTFUL API
:param username OpeatorName, String type. Required. Default Value "admin". Checks the operator
has the privileges to view the Real-Time Alarms.
:param auth: requests auth object #usuall... | [
"Takes",
"in",
"no",
"param",
"as",
"input",
"to",
"fetch",
"RealTime",
"Alarms",
"from",
"HP",
"IMC",
"RESTFUL",
"API"
] | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L102-L138 | [
"def",
"get_alarms",
"(",
"username",
",",
"auth",
",",
"url",
")",
":",
"f_url",
"=",
"url",
"+",
"\"/imcrs/fault/alarm?operatorName=\"",
"+",
"username",
"+",
"\"&recStatus=0&ackStatus=0&timeRange=0&size=50&desc=true\"",
"response",
"=",
"requests",
".",
"get",
"(",... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | get_alarm_details | function to take str input of alarm_id, issues a REST call to the IMC REST interface and
returns a dictionary object which contains the details of a specific alarm.
:param alarm_id: str number which represents the internal ID of a specific alarm
:param auth:
:param url:
:return: | pyhpeimc/plat/alarms.py | def get_alarm_details(alarm_id, auth, url):
"""
function to take str input of alarm_id, issues a REST call to the IMC REST interface and
returns a dictionary object which contains the details of a specific alarm.
:param alarm_id: str number which represents the internal ID of a specific alarm
:para... | def get_alarm_details(alarm_id, auth, url):
"""
function to take str input of alarm_id, issues a REST call to the IMC REST interface and
returns a dictionary object which contains the details of a specific alarm.
:param alarm_id: str number which represents the internal ID of a specific alarm
:para... | [
"function",
"to",
"take",
"str",
"input",
"of",
"alarm_id",
"issues",
"a",
"REST",
"call",
"to",
"the",
"IMC",
"REST",
"interface",
"and",
"returns",
"a",
"dictionary",
"object",
"which",
"contains",
"the",
"details",
"of",
"a",
"specific",
"alarm",
".",
"... | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L140-L155 | [
"def",
"get_alarm_details",
"(",
"alarm_id",
",",
"auth",
",",
"url",
")",
":",
"f_url",
"=",
"url",
"+",
"\"/imcrs/fault/alarm/\"",
"+",
"str",
"(",
"alarm_id",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"f_url",
",",
"auth",
"=",
"auth",
",",
... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | acknowledge_alarm | Function tasks input of str of alarm ID and sends to REST API. Function will acknowledge
designated alarm in the IMC alarm database.
:param alarm_id: str of alarm ID
param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth... | pyhpeimc/plat/alarms.py | def acknowledge_alarm(alarm_id, auth, url):
"""
Function tasks input of str of alarm ID and sends to REST API. Function will acknowledge
designated alarm in the IMC alarm database.
:param alarm_id: str of alarm ID
param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
... | def acknowledge_alarm(alarm_id, auth, url):
"""
Function tasks input of str of alarm ID and sends to REST API. Function will acknowledge
designated alarm in the IMC alarm database.
:param alarm_id: str of alarm ID
param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
... | [
"Function",
"tasks",
"input",
"of",
"str",
"of",
"alarm",
"ID",
"and",
"sends",
"to",
"REST",
"API",
".",
"Function",
"will",
"acknowledge",
"designated",
"alarm",
"in",
"the",
"IMC",
"alarm",
"database",
".",
":",
"param",
"alarm_id",
":",
"str",
"of",
... | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/alarms.py#L158-L175 | [
"def",
"acknowledge_alarm",
"(",
"alarm_id",
",",
"auth",
",",
"url",
")",
":",
"f_url",
"=",
"url",
"+",
"\"/imcrs/fault/alarm/acknowledge/\"",
"+",
"str",
"(",
"alarm_id",
")",
"response",
"=",
"requests",
".",
"put",
"(",
"f_url",
",",
"auth",
"=",
"aut... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | create_operator | Function takes input of dictionary operator with the following keys
operator = { "fullName" : "" ,
"sessionTimeout" : "",
"password" : "",
"operatorGroupId" : "",
"name" : "",
"desc" : "",
"defaultAcl" : "",
"authType" : ... | build/lib/pyhpeimc/plat/operator.py | def create_operator(operator, auth, url,headers=HEADERS):
"""
Function takes input of dictionary operator with the following keys
operator = { "fullName" : "" ,
"sessionTimeout" : "",
"password" : "",
"operatorGroupId" : "",
"name" : "",
"d... | def create_operator(operator, auth, url,headers=HEADERS):
"""
Function takes input of dictionary operator with the following keys
operator = { "fullName" : "" ,
"sessionTimeout" : "",
"password" : "",
"operatorGroupId" : "",
"name" : "",
"d... | [
"Function",
"takes",
"input",
"of",
"dictionary",
"operator",
"with",
"the",
"following",
"keys",
"operator",
"=",
"{",
"fullName",
":",
"sessionTimeout",
":",
"password",
":",
"operatorGroupId",
":",
"name",
":",
"desc",
":",
"defaultAcl",
":",
"authType",
":... | HPENetworking/PYHPEIMC | python | https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/operator.py#L18-L83 | [
"def",
"create_operator",
"(",
"operator",
",",
"auth",
",",
"url",
",",
"headers",
"=",
"HEADERS",
")",
":",
"create_operator_url",
"=",
"'/imcrs/plat/operator'",
"f_url",
"=",
"url",
"+",
"create_operator_url",
"payload",
"=",
"json",
".",
"dumps",
"(",
"ope... | 4fba31827573587e03a6233c7db60f188038c8e5 |
train | list | List virtual folders that belongs to the current user. | src/ai/backend/client/cli/vfolder.py | def list():
'''List virtual folders that belongs to the current user.'''
fields = [
('Name', 'name'),
('ID', 'id'),
('Owner', 'is_owner'),
('Permission', 'permission'),
]
with Session() as session:
try:
resp = session.VFolder.list()
if not ... | def list():
'''List virtual folders that belongs to the current user.'''
fields = [
('Name', 'name'),
('ID', 'id'),
('Owner', 'is_owner'),
('Permission', 'permission'),
]
with Session() as session:
try:
resp = session.VFolder.list()
if not ... | [
"List",
"virtual",
"folders",
"that",
"belongs",
"to",
"the",
"current",
"user",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/vfolder.py#L21-L40 | [
"def",
"list",
"(",
")",
":",
"fields",
"=",
"[",
"(",
"'Name'",
",",
"'name'",
")",
",",
"(",
"'ID'",
",",
"'id'",
")",
",",
"(",
"'Owner'",
",",
"'is_owner'",
")",
",",
"(",
"'Permission'",
",",
"'permission'",
")",
",",
"]",
"with",
"Session",
... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | list_hosts | List the hosts of virtual folders that is accessible to the current user. | src/ai/backend/client/cli/vfolder.py | def list_hosts():
'''List the hosts of virtual folders that is accessible to the current user.'''
with Session() as session:
try:
resp = session.VFolder.list_hosts()
print(f"Default vfolder host: {resp['default']}")
print(f"Usable hosts: {', '.join(resp['allowed'])}")... | def list_hosts():
'''List the hosts of virtual folders that is accessible to the current user.'''
with Session() as session:
try:
resp = session.VFolder.list_hosts()
print(f"Default vfolder host: {resp['default']}")
print(f"Usable hosts: {', '.join(resp['allowed'])}")... | [
"List",
"the",
"hosts",
"of",
"virtual",
"folders",
"that",
"is",
"accessible",
"to",
"the",
"current",
"user",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/vfolder.py#L44-L53 | [
"def",
"list_hosts",
"(",
")",
":",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"try",
":",
"resp",
"=",
"session",
".",
"VFolder",
".",
"list_hosts",
"(",
")",
"print",
"(",
"f\"Default vfolder host: {resp['default']}\"",
")",
"print",
"(",
"f\"Usabl... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | create | Create a new virtual folder.
\b
NAME: Name of a virtual folder.
HOST: Name of a virtual folder host in which the virtual folder will be created. | src/ai/backend/client/cli/vfolder.py | def create(name, host):
'''Create a new virtual folder.
\b
NAME: Name of a virtual folder.
HOST: Name of a virtual folder host in which the virtual folder will be created.
'''
with Session() as session:
try:
result = session.VFolder.create(name, host)
print('Virt... | def create(name, host):
'''Create a new virtual folder.
\b
NAME: Name of a virtual folder.
HOST: Name of a virtual folder host in which the virtual folder will be created.
'''
with Session() as session:
try:
result = session.VFolder.create(name, host)
print('Virt... | [
"Create",
"a",
"new",
"virtual",
"folder",
"."
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/vfolder.py#L59-L72 | [
"def",
"create",
"(",
"name",
",",
"host",
")",
":",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"try",
":",
"result",
"=",
"session",
".",
"VFolder",
".",
"create",
"(",
"name",
",",
"host",
")",
"print",
"(",
"'Virtual folder \"{0}\" is created.... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
train | delete | Delete the given virtual folder. This operation is irreversible!
NAME: Name of a virtual folder. | src/ai/backend/client/cli/vfolder.py | def delete(name):
'''Delete the given virtual folder. This operation is irreversible!
NAME: Name of a virtual folder.
'''
with Session() as session:
try:
session.VFolder(name).delete()
print_done('Deleted.')
except Exception as e:
print_error(e)
... | def delete(name):
'''Delete the given virtual folder. This operation is irreversible!
NAME: Name of a virtual folder.
'''
with Session() as session:
try:
session.VFolder(name).delete()
print_done('Deleted.')
except Exception as e:
print_error(e)
... | [
"Delete",
"the",
"given",
"virtual",
"folder",
".",
"This",
"operation",
"is",
"irreversible!"
] | lablup/backend.ai-client-py | python | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/vfolder.py#L77-L88 | [
"def",
"delete",
"(",
"name",
")",
":",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"try",
":",
"session",
".",
"VFolder",
"(",
"name",
")",
".",
"delete",
"(",
")",
"print_done",
"(",
"'Deleted.'",
")",
"except",
"Exception",
"as",
"e",
":",
... | a063d774fea6f4350b89498c40d3c837ec3029a7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.