repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
HPENetworking/PYHPEIMC
pyhpeimc/plat/system.py
delete_ssh_template
def delete_ssh_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific ssh template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url...
python
def delete_ssh_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific ssh template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url...
[ "def", "delete_ssh_template", "(", "auth", ",", "url", ",", "template_name", "=", "None", ",", "template_id", "=", "None", ")", ":", "try", ":", "if", "template_id", "is", "None", ":", "ssh_templates", "=", "get_ssh_template", "(", "auth", ",", "url", ")",...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific ssh template from the IMC system :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 :para...
[ "Takes", "template_name", "as", "input", "to", "issue", "RESTUL", "call", "to", "HP", "IMC", "which", "will", "delete", "the", "specific", "ssh", "template", "from", "the", "IMC", "system" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/system.py#L442-L472
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/system.py
get_snmp_templates
def get_snmp_templates(auth, url, template_name=None): """ Takes no input, or template_name as input to issue RESTUL 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.authclas...
python
def get_snmp_templates(auth, url, template_name=None): """ Takes no input, or template_name as input to issue RESTUL 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.authclas...
[ "def", "get_snmp_templates", "(", "auth", ",", "url", ",", "template_name", "=", "None", ")", ":", "f_url", "=", "url", "+", "\"/imcrs/plat/res/snmp?start=0&size=10000&desc=false&total=false\"", "response", "=", "requests", ".", "get", "(", "f_url", ",", "auth", "...
Takes no input, or template_name as input to issue RESTUL 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 :param template_name: str value of template name :retur...
[ "Takes", "no", "input", "or", "template_name", "as", "input", "to", "issue", "RESTUL", "call", "to", "HP", "IMC" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/system.py#L530-L566
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/system.py
modify_snmp_template
def modify_snmp_template(auth, url, snmp_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a snmp template. :param auth: :param url: :param ssh_template: Human readable label which is the na...
python
def modify_snmp_template(auth, url, snmp_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a snmp template. :param auth: :param url: :param ssh_template: Human readable label which is the na...
[ "def", "modify_snmp_template", "(", "auth", ",", "url", ",", "snmp_template", ",", "template_name", "=", "None", ",", "template_id", "=", "None", ")", ":", "if", "template_name", "is", "None", ":", "template_name", "=", "snmp_template", "[", "'name'", "]", "...
Function takes input of a dictionry containing the required key/value pair for the modification of a snmp template. :param auth: :param url: :param ssh_template: Human readable label which is the name of the specific ssh template :param template_id Internal IMC number which designates the specific ...
[ "Function", "takes", "input", "of", "a", "dictionry", "containing", "the", "required", "key", "/", "value", "pair", "for", "the", "modification", "of", "a", "snmp", "template", "." ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/system.py#L569-L619
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/system.py
delete_snmp_template
def delete_snmp_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific snmp template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param u...
python
def delete_snmp_template(auth, url, template_name= None, template_id= None): """ Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific snmp template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param u...
[ "def", "delete_snmp_template", "(", "auth", ",", "url", ",", "template_name", "=", "None", ",", "template_id", "=", "None", ")", ":", "try", ":", "if", "template_id", "is", "None", ":", "snmp_templates", "=", "get_snmp_templates", "(", "auth", ",", "url", ...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific snmp template from the IMC system :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 :par...
[ "Takes", "template_name", "as", "input", "to", "issue", "RESTUL", "call", "to", "HP", "IMC", "which", "will", "delete", "the", "specific", "snmp", "template", "from", "the", "IMC", "system" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/system.py#L622-L652
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/netassets.py
get_dev_asset_details
def get_dev_asset_details(ipaddress, auth, url): """Takes in ipaddress as input to fetch device assett details from HP IMC RESTFUL API :param ipaddress: IP address of the device you wish to gather the asset details :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :p...
python
def get_dev_asset_details(ipaddress, auth, url): """Takes in ipaddress as input to fetch device assett details from HP IMC RESTFUL API :param ipaddress: IP address of the device you wish to gather the asset details :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :p...
[ "def", "get_dev_asset_details", "(", "ipaddress", ",", "auth", ",", "url", ")", ":", "ipaddress", "=", "get_dev_details", "(", "ipaddress", ",", "auth", ",", "url", ")", "if", "isinstance", "(", "ipaddress", ",", "dict", ")", ":", "ipaddress", "=", "ipaddr...
Takes in ipaddress as input to fetch device assett details from HP IMC RESTFUL API :param ipaddress: IP address of the device you wish to gather the asset details :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url...
[ "Takes", "in", "ipaddress", "as", "input", "to", "fetch", "device", "assett", "details", "from", "HP", "IMC", "RESTFUL", "API" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/netassets.py#L21-L68
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/netassets.py
get_dev_asset_details_all
def get_dev_asset_details_all(auth, url): """Takes no input to fetch device assett details from HP IMC RESTFUL API :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 ...
python
def get_dev_asset_details_all(auth, url): """Takes no input to fetch device assett details from HP IMC RESTFUL API :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 ...
[ "def", "get_dev_asset_details_all", "(", "auth", ",", "url", ")", ":", "f_url", "=", "url", "+", "\"/imcrs/netasset/asset?start=0&size=15000\"", "response", "=", "requests", ".", "get", "(", "f_url", ",", "auth", "=", "auth", ",", "headers", "=", "HEADERS", ")...
Takes no input to fetch device assett details from HP IMC RESTFUL API :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 dictionatires containing the device asset deta...
[ "Takes", "no", "input", "to", "fetch", "device", "assett", "details", "from", "HP", "IMC", "RESTFUL", "API" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/netassets.py#L71-L102
train
lablup/backend.ai-client-py
src/ai/backend/client/cli/proxy.py
proxy
def proxy(ctx, bind, port): """ Run a non-encrypted non-authorized API proxy server. Use this only for development and testing! """ app = web.Application() app.on_startup.append(startup_proxy) app.on_cleanup.append(cleanup_proxy) app.router.add_route("GET", r'/stream/{path:.*$}', websoc...
python
def proxy(ctx, bind, port): """ Run a non-encrypted non-authorized API proxy server. Use this only for development and testing! """ app = web.Application() app.on_startup.append(startup_proxy) app.on_cleanup.append(cleanup_proxy) app.router.add_route("GET", r'/stream/{path:.*$}', websoc...
[ "def", "proxy", "(", "ctx", ",", "bind", ",", "port", ")", ":", "app", "=", "web", ".", "Application", "(", ")", "app", ".", "on_startup", ".", "append", "(", "startup_proxy", ")", "app", ".", "on_cleanup", ".", "append", "(", "cleanup_proxy", ")", "...
Run a non-encrypted non-authorized API proxy server. Use this only for development and testing!
[ "Run", "a", "non", "-", "encrypted", "non", "-", "authorized", "API", "proxy", "server", ".", "Use", "this", "only", "for", "development", "and", "testing!" ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/proxy.py#L194-L208
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
get_all_devs
def get_all_devs(auth, url, network_address=None, category=None, label=None): """Takes string input of IP address to issue RESTUL call to HP IMC\n :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.aut...
python
def get_all_devs(auth, url, network_address=None, category=None, label=None): """Takes string input of IP address to issue RESTUL call to HP IMC\n :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.aut...
[ "def", "get_all_devs", "(", "auth", ",", "url", ",", "network_address", "=", "None", ",", "category", "=", "None", ",", "label", "=", "None", ")", ":", "base_url", "=", "\"/imcrs/plat/res/device?resPrivilegeFilter=false\"", "end_url", "=", "\"&start=0&size=1000&orde...
Takes string input of IP address to issue RESTUL call to HP IMC\n :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 :param network_address: str IPv4 Network Address :param category:...
[ "Takes", "string", "input", "of", "IP", "address", "to", "issue", "RESTUL", "call", "to", "HP", "IMC", "\\", "n" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L174-L225
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
get_dev_details
def get_dev_details(ip_address, auth, url): """Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS...
python
def get_dev_details(ip_address, auth, url): """Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS...
[ "def", "get_dev_details", "(", "ip_address", ",", "auth", ",", "url", ")", ":", "get_dev_details_url", "=", "\"/imcrs/plat/res/device?resPrivilegeFilter=false&ip=\"", "+", "str", "(", "ip_address", ")", "+", "\"&start=0&size=1000&orderBy=id&desc=false&total=false\"", "f_url",...
Takes string input of IP address to issue RESTUL call to HP IMC :param ip_address: string object of dotted decimal notation of IPv4 address :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.aut...
[ "Takes", "string", "input", "of", "IP", "address", "to", "issue", "RESTUL", "call", "to", "HP", "IMC" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L228-L277
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
get_dev_interface
def get_dev_interface(auth, url, devid=None, devip=None): """ Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: optional devid as the input :param devip: str of ipv4 address of the target device :param auth: requests auth obje...
python
def get_dev_interface(auth, url, devid=None, devip=None): """ Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: optional devid as the input :param devip: str of ipv4 address of the target device :param auth: requests auth obje...
[ "def", "get_dev_interface", "(", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")", "[", "'id'", ...
Function takes devid as input to RESTFUL call to HP IMC platform and returns list of device interfaces :param devid: optional devid as the input :param devip: str of ipv4 address of the target device :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: ...
[ "Function", "takes", "devid", "as", "input", "to", "RESTFUL", "call", "to", "HP", "IMC", "platform", "and", "returns", "list", "of", "device", "interfaces" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L280-L327
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
get_dev_mac_learn
def get_dev_mac_learn(auth, url, devid=None, devip=None): """ function takes devid of specific device and issues a RESTFUL call to gather the current IP-MAC learning entries on the target device. :param devid: int value of the target device :param devip: ipv4 address of the target device :pa...
python
def get_dev_mac_learn(auth, url, devid=None, devip=None): """ function takes devid of specific device and issues a RESTFUL call to gather the current IP-MAC learning entries on the target device. :param devid: int value of the target device :param devip: ipv4 address of the target device :pa...
[ "def", "get_dev_mac_learn", "(", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")", "[", "'id'", ...
function takes devid of specific device and issues a RESTFUL call to gather the current IP-MAC learning entries on the target device. :param devid: int value of the target device :param devip: ipv4 address of the target device :param auth: requests auth object #usually auth.creds from auth pyhpeimc....
[ "function", "takes", "devid", "of", "specific", "device", "and", "issues", "a", "RESTFUL", "call", "to", "gather", "the", "current", "IP", "-", "MAC", "learning", "entries", "on", "the", "target", "device", "." ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L518-L565
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
run_dev_cmd
def run_dev_cmd(cmd_list, auth, url, devid=None, devip=None): """ Function takes devid of target device and a sequential list of strings which define the specific commands to be run on the target device and returns a str object containing the output of the commands. :param devid: int devid of the t...
python
def run_dev_cmd(cmd_list, auth, url, devid=None, devip=None): """ Function takes devid of target device and a sequential list of strings which define the specific commands to be run on the target device and returns a str object containing the output of the commands. :param devid: int devid of the t...
[ "def", "run_dev_cmd", "(", "cmd_list", ",", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")", "[...
Function takes devid of target device and a sequential list of strings which define the specific commands to be run on the target device and returns a str object containing the output of the commands. :param devid: int devid of the target device :param cmd_list: list of strings :param auth: reque...
[ "Function", "takes", "devid", "of", "target", "device", "and", "a", "sequential", "list", "of", "strings", "which", "define", "the", "specific", "commands", "to", "be", "run", "on", "the", "target", "device", "and", "returns", "a", "str", "object", "containi...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L568-L623
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
get_all_interface_details
def get_all_interface_details(auth, url, devid=None, devip=None): """ function takes the devId of a specific device and the ifindex value assigned to a specific interface and issues a RESTFUL call to get the interface details file as known by the HP IMC Base Platform ICC module for the target device. ...
python
def get_all_interface_details(auth, url, devid=None, devip=None): """ function takes the devId of a specific device and the ifindex value assigned to a specific interface and issues a RESTFUL call to get the interface details file as known by the HP IMC Base Platform ICC module for the target device. ...
[ "def", "get_all_interface_details", "(", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")", "[", "'...
function takes the devId of a specific device and the ifindex value assigned to a specific interface and issues a RESTFUL call to get the interface details file as known by the HP IMC Base Platform ICC module for the target device. :param auth: requests auth object #usually auth.creds from auth pyhpeimc.au...
[ "function", "takes", "the", "devId", "of", "a", "specific", "device", "and", "the", "ifindex", "value", "assigned", "to", "a", "specific", "interface", "and", "issues", "a", "RESTFUL", "call", "to", "get", "the", "interface", "details", "file", "as", "known"...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L629-L674
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
set_interface_down
def set_interface_down(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to " shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addres...
python
def set_interface_down(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to " shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addres...
[ "def", "set_interface_down", "(", "ifindex", ",", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")"...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to " shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 address of the target devices :param ifindex: int or str value of the target inte...
[ "function", "takest", "devid", "and", "ifindex", "of", "specific", "device", "and", "interface", "and", "issues", "a", "RESTFUL", "call", "to", "shut", "the", "specified", "interface", "on", "the", "target", "device", ".", ":", "param", "devid", ":", "int", ...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L726-L777
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
set_inteface_up
def set_inteface_up(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to "undo shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addr...
python
def set_inteface_up(ifindex, auth, url, devid=None, devip=None): """ function takest devid and ifindex of specific device and interface and issues a RESTFUL call to "undo shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 addr...
[ "def", "set_inteface_up", "(", "ifindex", ",", "auth", ",", "url", ",", "devid", "=", "None", ",", "devip", "=", "None", ")", ":", "if", "devip", "is", "not", "None", ":", "devid", "=", "get_dev_details", "(", "devip", ",", "auth", ",", "url", ")", ...
function takest devid and ifindex of specific device and interface and issues a RESTFUL call to "undo shut" the specified interface on the target device. :param devid: int or str value of the target device :param devip: ipv4 address of the target devices :param ifindex: int or str value of the target...
[ "function", "takest", "devid", "and", "ifindex", "of", "specific", "device", "and", "interface", "and", "issues", "a", "RESTFUL", "call", "to", "undo", "shut", "the", "specified", "interface", "on", "the", "target", "device", "." ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L780-L829
train
HPENetworking/PYHPEIMC
pyhpeimc/plat/device.py
_make_cmd_list
def _make_cmd_list(cmd_list): """ Helper function to easily create the proper json formated string from a list of strs :param cmd_list: list of strings :return: str json formatted """ cmd = '' for i in cmd_list: cmd = cmd + '"' + i + '",' cmd = cmd[:-1] return cmd
python
def _make_cmd_list(cmd_list): """ Helper function to easily create the proper json formated string from a list of strs :param cmd_list: list of strings :return: str json formatted """ cmd = '' for i in cmd_list: cmd = cmd + '"' + i + '",' cmd = cmd[:-1] return cmd
[ "def", "_make_cmd_list", "(", "cmd_list", ")", ":", "cmd", "=", "''", "for", "i", "in", "cmd_list", ":", "cmd", "=", "cmd", "+", "'\"'", "+", "i", "+", "'\",'", "cmd", "=", "cmd", "[", ":", "-", "1", "]", "return", "cmd" ]
Helper function to easily create the proper json formated string from a list of strs :param cmd_list: list of strings :return: str json formatted
[ "Helper", "function", "to", "easily", "create", "the", "proper", "json", "formated", "string", "from", "a", "list", "of", "strs", ":", "param", "cmd_list", ":", "list", "of", "strings", ":", "return", ":", "str", "json", "formatted" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/plat/device.py#L884-L894
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.create
async def create(cls, user_id: Union[int, str], is_active: bool = True, is_admin: bool = False, resource_policy: str = None, rate_limit: int = None, fields: Iterable[str] = None) -> dict: ''' Creates...
python
async def create(cls, user_id: Union[int, str], is_active: bool = True, is_admin: bool = False, resource_policy: str = None, rate_limit: int = None, fields: Iterable[str] = None) -> dict: ''' Creates...
[ "async", "def", "create", "(", "cls", ",", "user_id", ":", "Union", "[", "int", ",", "str", "]", ",", "is_active", ":", "bool", "=", "True", ",", "is_admin", ":", "bool", "=", "False", ",", "resource_policy", ":", "str", "=", "None", ",", "rate_limit...
Creates a new keypair with the given options. You need an admin privilege for this operation.
[ "Creates", "a", "new", "keypair", "with", "the", "given", "options", ".", "You", "need", "an", "admin", "privilege", "for", "this", "operation", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L24-L59
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.update
async def update(cls, access_key: str, is_active: bool = None, is_admin: bool = None, resource_policy: str = None, rate_limit: int = None) -> dict: """ Creates a new keypair with the given options. You need an ad...
python
async def update(cls, access_key: str, is_active: bool = None, is_admin: bool = None, resource_policy: str = None, rate_limit: int = None) -> dict: """ Creates a new keypair with the given options. You need an ad...
[ "async", "def", "update", "(", "cls", ",", "access_key", ":", "str", ",", "is_active", ":", "bool", "=", "None", ",", "is_admin", ":", "bool", "=", "None", ",", "resource_policy", ":", "str", "=", "None", ",", "rate_limit", ":", "int", "=", "None", "...
Creates a new keypair with the given options. You need an admin privilege for this operation.
[ "Creates", "a", "new", "keypair", "with", "the", "given", "options", ".", "You", "need", "an", "admin", "privilege", "for", "this", "operation", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L63-L93
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.delete
async def delete(cls, access_key: str): """ Deletes an existing keypair with given ACCESSKEY. """ q = 'mutation($access_key: String!) {' \ ' delete_keypair(access_key: $access_key) {' \ ' ok msg' \ ' }' \ '}' variables = { ...
python
async def delete(cls, access_key: str): """ Deletes an existing keypair with given ACCESSKEY. """ q = 'mutation($access_key: String!) {' \ ' delete_keypair(access_key: $access_key) {' \ ' ok msg' \ ' }' \ '}' variables = { ...
[ "async", "def", "delete", "(", "cls", ",", "access_key", ":", "str", ")", ":", "q", "=", "'mutation($access_key: String!) {'", "' delete_keypair(access_key: $access_key) {'", "' ok msg'", "' }'", "'}'", "variables", "=", "{", "'access_key'", ":", "access_key", ",...
Deletes an existing keypair with given ACCESSKEY.
[ "Deletes", "an", "existing", "keypair", "with", "given", "ACCESSKEY", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L97-L116
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.list
async def list(cls, user_id: Union[int, str] = None, is_active: bool = None, fields: Iterable[str] = None) -> Sequence[dict]: ''' Lists the keypairs. You need an admin privilege for this operation. ''' if fields is None: fields = ...
python
async def list(cls, user_id: Union[int, str] = None, is_active: bool = None, fields: Iterable[str] = None) -> Sequence[dict]: ''' Lists the keypairs. You need an admin privilege for this operation. ''' if fields is None: fields = ...
[ "async", "def", "list", "(", "cls", ",", "user_id", ":", "Union", "[", "int", ",", "str", "]", "=", "None", ",", "is_active", ":", "bool", "=", "None", ",", "fields", ":", "Iterable", "[", "str", "]", "=", "None", ")", "->", "Sequence", "[", "dic...
Lists the keypairs. You need an admin privilege for this operation.
[ "Lists", "the", "keypairs", ".", "You", "need", "an", "admin", "privilege", "for", "this", "operation", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L120-L158
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.info
async def info(self, fields: Iterable[str] = None) -> dict: ''' Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12 ''' if fields is None: fields = ( 'a...
python
async def info(self, fields: Iterable[str] = None) -> dict: ''' Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12 ''' if fields is None: fields = ( 'a...
[ "async", "def", "info", "(", "self", ",", "fields", ":", "Iterable", "[", "str", "]", "=", "None", ")", "->", "dict", ":", "if", "fields", "is", "None", ":", "fields", "=", "(", "'access_key'", ",", "'secret_key'", ",", "'is_active'", ",", "'is_admin'"...
Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12
[ "Returns", "the", "keypair", "s", "information", "such", "as", "resource", "limits", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L161-L186
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.activate
async def activate(cls, access_key: str) -> dict: ''' Activates this keypair. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, $input: ModifyKeyPairInput!) {' + \ ' modify_keypair(access_key: $access_key, props: $input) {' \ ...
python
async def activate(cls, access_key: str) -> dict: ''' Activates this keypair. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, $input: ModifyKeyPairInput!) {' + \ ' modify_keypair(access_key: $access_key, props: $input) {' \ ...
[ "async", "def", "activate", "(", "cls", ",", "access_key", ":", "str", ")", "->", "dict", ":", "q", "=", "'mutation($access_key: String!, $input: ModifyKeyPairInput!) {'", "+", "' modify_keypair(access_key: $access_key, props: $input) {'", "' ok msg'", "' }'", "'}'", "...
Activates this keypair. You need an admin privilege for this operation.
[ "Activates", "this", "keypair", ".", "You", "need", "an", "admin", "privilege", "for", "this", "operation", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L190-L216
train
lablup/backend.ai-client-py
src/ai/backend/client/keypair.py
KeyPair.deactivate
async def deactivate(cls, access_key: str) -> dict: ''' Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, ...
python
async def deactivate(cls, access_key: str) -> dict: ''' Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation. ''' q = 'mutation($access_key: String!, ...
[ "async", "def", "deactivate", "(", "cls", ",", "access_key", ":", "str", ")", "->", "dict", ":", "q", "=", "'mutation($access_key: String!, $input: ModifyKeyPairInput!) {'", "+", "' modify_keypair(access_key: $access_key, props: $input) {'", "' ok msg'", "' }'", "'}'", ...
Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation.
[ "Deactivates", "this", "keypair", ".", "Deactivated", "keypairs", "cannot", "make", "any", "API", "requests", "unless", "activated", "again", "by", "an", "administrator", ".", "You", "need", "an", "admin", "privilege", "for", "this", "operation", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/keypair.py#L220-L248
train
HPENetworking/PYHPEIMC
build/lib/pyhpimc/plat/termaccess.py
add_ip_scope
def add_ip_scope(auth, url,startIp, endIp, name, description): """ Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param startIp: str Start of IP address scope ex. '10.101.0.1' :param endIp: str End of I...
python
def add_ip_scope(auth, url,startIp, endIp, name, description): """ Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param startIp: str Start of IP address scope ex. '10.101.0.1' :param endIp: str End of I...
[ "def", "add_ip_scope", "(", "auth", ",", "url", ",", "startIp", ",", "endIp", ",", "name", ",", "description", ")", ":", "if", "auth", "is", "None", "or", "url", "is", "None", ":", "# checks to see if the imc credentials are already available", "set_imc_creds", ...
Function takes input of four strings Start Ip, endIp, name, and description to add new Ip Scope to terminal access in the HPE IMC base platform :param startIp: str Start of IP address scope ex. '10.101.0.1' :param endIp: str End of IP address scope ex. '10.101.0.254' :param name: str Name of the owner o...
[ "Function", "takes", "input", "of", "four", "strings", "Start", "Ip", "endIp", "name", "and", "description", "to", "add", "new", "Ip", "Scope", "to", "terminal", "access", "in", "the", "HPE", "IMC", "base", "platform", ":", "param", "startIp", ":", "str", ...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/plat/termaccess.py#L106-L142
train
lablup/backend.ai-client-py
src/ai/backend/client/resource.py
Resource.check_presets
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()
python
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", ")", ":", "rqst", "=", "Request", "(", "cls", ".", "session", ",", "'POST'", ",", "'/resource/check-presets'", ")", "async", "with", "rqst", ".", "fetch", "(", ")", "as", "resp", ":", "return", "await", "resp"...
Lists all resource presets in the current scaling group with additiona information.
[ "Lists", "all", "resource", "presets", "in", "the", "current", "scaling", "group", "with", "additiona", "information", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/resource.py#L31-L38
train
HPENetworking/PYHPEIMC
build/lib/pyhpeimc/plat/perf.py
add_perf_task
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...
python
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", ")", ":", "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...
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 ...
[ "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...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/perf.py#L19-L54
train
HPENetworking/PYHPEIMC
build/lib/pyhpeimc/plat/perf.py
get_perf_task
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: ...
python
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", ")", ":", "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...
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...
[ "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" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/perf.py#L56-L92
train
HPENetworking/PYHPEIMC
build/lib/pyhpeimc/plat/vrm.py
get_vm_host_info
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...
python
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", ")", ":", "hostId", "=", "get_dev_details", "(", "hostip", ",", "auth", ",", "url", ")", "[", "'id'", "]", "get_vm_host_info_url", "=", "\"/imcrs/vrm/host?hostId=\"", "+", "str", "(", "hostId...
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...
[ "function", "takes", "hostId", "as", "input", "to", "RESTFUL", "call", "to", "HP", "IMC" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpeimc/plat/vrm.py#L18-L80
train
HPENetworking/PYHPEIMC
pyhpeimc/wsm/acinfo.py
get_ac_info_all
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 ...
python
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", ")", ":", "f_url", "=", "url", "+", "\"/imcrs/wlan/acInfo/queryAcBasicInfo\"", "response", "=", "requests", ".", "get", "(", "f_url", ",", "auth", "=", "auth", ",", "headers", "=", "HEADERS", ")", "try", "...
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 ...
[ "function", "takes", "no", "input", "as", "input", "to", "RESTFUL", "call", "to", "HP", "IMC" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/pyhpeimc/wsm/acinfo.py#L18-L50
train
HPENetworking/PYHPEIMC
build/lib/pyhpimc/auth.py
set_imc_creds
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...
python
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", ")", ":", "global", "auth", ",", "url", "if", "h_url", "is", "None", ":", "imc_...
This function prompts user for IMC server information and credentuials and stores values in url and auth global variables
[ "This", "function", "prompts", "user", "for", "IMC", "server", "information", "and", "credentuials", "and", "stores", "values", "in", "url", "and", "auth", "global", "variables" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L78-L110
train
HPENetworking/PYHPEIMC
build/lib/pyhpimc/auth.py
print_to_file
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 ...
python
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", ")", ":", "with", "open", "(", "'pyoutput.txt'", ",", "'w'", ")", "as", "fh", ":", "x", "=", "None", "if", "type", "(", "object", ")", "is", "list", ":", "x", "=", "json", ".", "dumps", "(", "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", ...
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L119-L133
train
HPENetworking/PYHPEIMC
build/lib/pyhpimc/auth.py
IMCAuth.get_auth
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...
python
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", ")", ":", "url", "=", "self", ".", "h_url", "+", "self", ".", "server", "+", "\":\"", "+", "self", ".", "port", "auth", "=", "requests", ".", "auth", ".", "HTTPDigestAuth", "(", "self", ".", "username", ",", "self", ...
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object :return:
[ "This", "method", "requests", "an", "authentication", "object", "from", "the", "HPE", "IMC", "NMS", "and", "returns", "an", "HTTPDigest", "Auth", "Object", ":", "return", ":" ]
4fba31827573587e03a6233c7db60f188038c8e5
https://github.com/HPENetworking/PYHPEIMC/blob/4fba31827573587e03a6233c7db60f188038c8e5/build/lib/pyhpimc/auth.py#L55-L73
train
mozilla-services/python-dockerflow
src/dockerflow/version.py
get_version
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') ...
python
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", ")", ":", "version_json", "=", "os", ".", "path", ".", "join", "(", "root", ",", "'version.json'", ")", "if", "os", ".", "path", ".", "exists", "(", "version_json", ")", ":", "with", "open", "(", "version_json", ",", ...
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
[ "Load", "and", "return", "the", "contents", "of", "version", ".", "json", "." ]
43703c5e8934ba6901b0a1520d6da4ed6457208c
https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/version.py#L10-L23
train
housecanary/hc-api-python
housecanary/apiclient.py
ApiClient.fetch
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...
python
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", ")", ":", "endpoint_url", "=", "constants", ".", "URL_PREFIX", "+", "\"/\"", "+", "self", ".", "_version", "+", "\"/\"", "+", "endpoint_name", "if",...
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...
[ "Calls", "this", "instance", "s", "request_client", "s", "post", "method", "with", "the", "specified", "component", "endpoint" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L61-L117
train
housecanary/hc-api-python
housecanary/apiclient.py
ApiClient.fetch_synchronous
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...
python
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", ")", ":", "endpoint_url", "=", "constants", ".", "URL_PREFIX", "+", "\"/\"", "+", "self", ".", "_version", "+", "\"/\"", "+", "endpoint_name", "if", "query_params"...
Calls this instance's request_client's get method with the specified component endpoint
[ "Calls", "this", "instance", "s", "request_client", "s", "get", "method", "with", "the", "specified", "component", "endpoint" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L119-L128
train
housecanary/hc-api-python
housecanary/apiclient.py
ComponentWrapper.get_identifier_input
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...
python
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", ")", ":", "identifier_input", "=", "[", "]", "if", "isinstance", "(", "identifier_data", ",", "list", ")", "and", "len", "(", "identifier_data", ")", ">", "0", ":", "# if list, convert each item...
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.
[ "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", "." ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L143-L157
train
housecanary/hc-api-python
housecanary/apiclient.py
ComponentWrapper.fetch_identifier_component
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...
python
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", ")", ":", "if", "query_params", "is", "None", ":", "query_params", "=", "{", "}", "identifier_input", "=", "self", ".", "get_identif...
Common method for handling parameters before passing to api_client
[ "Common", "method", "for", "handling", "parameters", "before", "passing", "to", "api_client" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L159-L167
train
housecanary/hc-api-python
housecanary/apiclient.py
PropertyComponentWrapper._convert_to_identifier_json
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: ...
python
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", ")", ":", "if", "isinstance", "(", "address_data", ",", "str", ")", ":", "# allow just passing a slug string.", "return", "{", "\"slug\"", ":", "address_data", "}", "if", "isinstance", "(", "a...
Convert input address data into json format
[ "Convert", "input", "address", "data", "into", "json", "format" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L218-L250
train
housecanary/hc-api-python
housecanary/apiclient.py
PropertyComponentWrapper.value_report
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...
python
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\"", ")", ":", "query_params", "=", "{", "\"report_type\"", ":", "report_type", ",", "\"format\"", ":", "format_type", ",",...
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".
[ "Call", "the", "value_report", "component" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L413-L433
train
housecanary/hc-api-python
housecanary/apiclient.py
PropertyComponentWrapper.rental_report
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". ""...
python
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\"", ")", ":", "# only json is supported by rental report.", "query_params", "=", "{", "\"format\"", ":", "format_type", ",", "\"address\"", ":", "address", ",", "...
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" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L435-L455
train
housecanary/hc-api-python
housecanary/apiclient.py
ZipComponentWrapper.component_mget
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...
python
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", ")", ":", "if", "not", "isinstance", "(", "components", ",", "list", ")", ":", "print", "(", "\"Components param must be a list\"", ")", "return", "query_params", "=", "{", "\"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" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/apiclient.py#L645-L660
train
mozilla-services/python-dockerflow
src/dockerflow/django/views.py
version
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)
python
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", ")", ":", "version_json", "=", "import_string", "(", "version_callback", ")", "(", "settings", ".", "BASE_DIR", ")", "if", "version_json", "is", "None", ":", "return", "HttpResponseNotFound", "(", "'version.json not found'", ")", ...
Returns the contents of version.json or a 404.
[ "Returns", "the", "contents", "of", "version", ".", "json", "or", "a", "404", "." ]
43703c5e8934ba6901b0a1520d6da4ed6457208c
https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/views.py#L20-L28
train
mozilla-services/python-dockerflow
src/dockerflow/django/views.py
heartbeat
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...
python
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", ")", ":", "all_checks", "=", "checks", ".", "registry", ".", "registry", ".", "get_checks", "(", "include_deployment_checks", "=", "not", "settings", ".", "DEBUG", ",", ")", "details", "=", "{", "}", "statuses", "=", "{"...
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.
[ "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", "." ]
43703c5e8934ba6901b0a1520d6da4ed6457208c
https://github.com/mozilla-services/python-dockerflow/blob/43703c5e8934ba6901b0a1520d6da4ed6457208c/src/dockerflow/django/views.py#L40-L75
train
housecanary/hc-api-python
housecanary/object.py
_create_component_results
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, ...
python
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", ")", ":", "component_results", "=", "[", "]", "for", "key", ",", "value", "in", "list", "(", "json_data", ".", "items", "(", ")", ")", ":", "if", "key", "not", "in", "[", "result_ke...
Returns a list of ComponentResult from the json_data
[ "Returns", "a", "list", "of", "ComponentResult", "from", "the", "json_data" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L13-L27
train
housecanary/hc-api-python
housecanary/object.py
HouseCanaryObject.has_error
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 ...
python
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", ")", ":", "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. Returns: boolean
[ "Returns", "whether", "there", "was", "a", "business", "logic", "error", "when", "fetching", "data", "for", "any", "components", "for", "this", "property", "." ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L42-L53
train
housecanary/hc-api-python
housecanary/object.py
HouseCanaryObject.get_errors
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...
python
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", ")", ":", "return", "[", "{", "cr", ".", "component_name", ":", "cr", ".", "get_error", "(", ")", "}", "for", "cr", "in", "self", ".", "component_results", "if", "cr", ".", "has_error", "(", ")", "]" ]
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.
[ "If", "there", "were", "any", "business", "errors", "fetching", "data", "for", "this", "property", "returns", "the", "error", "messages", "." ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L55-L64
train
housecanary/hc-api-python
housecanary/object.py
Property.create_from_json
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"] ...
python
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", ")", ":", "prop", "=", "Property", "(", ")", "address_info", "=", "json_data", "[", "\"address_info\"", "]", "prop", ".", "address", "=", "address_info", "[", "\"address\"", "]", "prop", ".", "block_id...
Deserialize property json data into a Property object Args: json_data (dict): The json data for this property Returns: Property object
[ "Deserialize", "property", "json", "data", "into", "a", "Property", "object" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L102-L134
train
housecanary/hc-api-python
housecanary/object.py
Block.create_from_json
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 =...
python
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", ")", ":", "block", "=", "Block", "(", ")", "block_info", "=", "json_data", "[", "\"block_info\"", "]", "block", ".", "block_id", "=", "block_info", "[", "\"block_id\"", "]", "block", ".", "num_bins", ...
Deserialize block json data into a Block object Args: json_data (dict): The json data for this block Returns: Block object
[ "Deserialize", "block", "json", "data", "into", "a", "Block", "object" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L160-L179
train
housecanary/hc-api-python
housecanary/object.py
ZipCode.create_from_json
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"...
python
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", ")", ":", "zipcode", "=", "ZipCode", "(", ")", "zipcode", ".", "zipcode", "=", "json_data", "[", "\"zipcode_info\"", "]", "[", "\"zipcode\"", "]", "zipcode", ".", "meta", "=", "json_data", "[", "\"me...
Deserialize zipcode json data into a ZipCode object Args: json_data (dict): The json data for this zipcode Returns: Zip object
[ "Deserialize", "zipcode", "json", "data", "into", "a", "ZipCode", "object" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L203-L219
train
housecanary/hc-api-python
housecanary/object.py
Msa.create_from_json
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...
python
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", ")", ":", "msa", "=", "Msa", "(", ")", "msa", ".", "msa", "=", "json_data", "[", "\"msa_info\"", "]", "[", "\"msa\"", "]", "msa", ".", "meta", "=", "json_data", "[", "\"meta\"", "]", "if", "\"m...
Deserialize msa json data into a Msa object Args: json_data (dict): The json data for this msa Returns: Msa object
[ "Deserialize", "msa", "json", "data", "into", "a", "Msa", "object" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/object.py#L243-L259
train
Tygs/ww
src/ww/tools/iterables.py
starts_when
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...
python
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", "if", "not", "callable", "(", "condition", ")", ":", "cond_value", "=", "condition", "def", "condition", "(", "x", ")", ":", "return", "x", ...
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: ...
[ "Start", "yielding", "items", "when", "a", "condition", "arise", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L49-L71
train
Tygs/ww
src/ww/tools/iterables.py
stops_when
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...
python
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", "if", "not", "callable", "(", "condition", ")", ":", "cond_value", "=", "condition", "def", "condition", "(", "x", ")", ":", "return", "x", ...
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: ...
[ "Stop", "yielding", "items", "when", "a", "condition", "arise", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L74-L96
train
Tygs/ww
src/ww/tools/iterables.py
skip_duplicates
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...
python
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", "fingerprints", "=", "fingerprints", "or", "set", "(", ")", "fingerprint", "=", "None", "# needed on ...
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...
[ "Returns", "a", "generator", "that", "will", "yield", "all", "objects", "from", "iterable", "skipping", "duplicates", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L99-L179
train
Tygs/ww
src/ww/tools/iterables.py
chunks
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)))
python
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", "it", "=", "iter", "(", "iterable", ")", "while", "True", ":", "yield", "cast", "(", "itertools", ".", "chain", "(", "["...
Yields items from an iterator in iterable chunks.
[ "Yields", "items", "from", "an", "iterator", "in", "iterable", "chunks", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L183-L191
train
Tygs/ww
src/ww/tools/iterables.py
window
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...
python
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", "iterable", "=", "iter", "(", "iterable", ")", "d", "=", "deque", "(", "itertools", ".", "islice", "(", "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 window to a tuple before yielding it; however, any function that will accept an iterable as its arg...
[ "Yields", "iterms", "by", "bunch", "of", "a", "given", "size", "but", "rolling", "only", "one", "item", "in", "and", "out", "at", "a", "time", "when", "iterating", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L194-L228
train
Tygs/ww
src/ww/tools/iterables.py
at_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) ...
python
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", "try", ":", "if", "index", "<", "0", ":", "return", "deque", "(", "iterable", ",", "maxlen", "=", "abs", "(", "index", ")", ")", ".", "popleft", "(", ")", "r...
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", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L231-L246
train
Tygs/ww
src/ww/tools/iterables.py
first_true
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...
python
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", "try", ":", "return", "next", "(", "(", "x", "for", "x", "in", "iterable", "if", "func", "(", "x", ")", ")", ")", "except", "StopIteration", "as", "e", "...
Return the first item of the iterable for which func(item) == True. Or raises IndexError. WARNING: this will consume generators.
[ "Return", "the", "first", "item", "of", "the", "iterable", "for", "which", "func", "(", "item", ")", "==", "True", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L250-L262
train
Tygs/ww
src/ww/tools/iterables.py
iterslice
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 ...
python
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]", "if", "step", "<", "0", ":", "raise", "ValueError", "(", "\"The step can not be negativ...
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.
[ "Like", "itertools", ".", "islice", "but", "accept", "int", "and", "callables", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L265-L293
train
Tygs/ww
src/ww/tools/iterables.py
firsts
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 " ...
python
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]", "try", ":", "items", "=", "int", "(", "items", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "r...
Lazily return the first x items from this iterable or default.
[ "Lazily", "return", "the", "first", "x", "items", "from", "this", "iterable", "or", "default", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L309-L330
train
Tygs/ww
src/ww/tools/iterables.py
lasts
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...
python
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]", "last_items", "=", "deque", "(", "iterable", ",", "maxlen", "=", "items", ")", "for", "_", "in", "range", "(", "...
Lazily return the last x items from this iterable or default.
[ "Lazily", "return", "the", "last", "x", "items", "from", "this", "iterable", "or", "default", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/tools/iterables.py#L333-L343
train
lablup/backend.ai-client-py
src/ai/backend/client/session.py
is_legacy_server
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
python
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", "(", ")", ":", "with", "Session", "(", ")", "as", "session", ":", "ret", "=", "session", ".", "Kernel", ".", "hello", "(", ")", "bai_version", "=", "ret", "[", "'version'", "]", "legacy", "=", "True", "if", "bai_version", "<=...
Determine execution mode. Legacy mode: <= v4.20181215
[ "Determine", "execution", "mode", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/session.py#L18-L27
train
lablup/backend.ai-client-py
src/ai/backend/client/session.py
Session.close
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...
python
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", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "self", ".", "_worker_thread", ".", "work_queue", ".", "put", "(", "self", ".", "aiohttp_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.
[ "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...
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/session.py#L214-L226
train
lablup/backend.ai-client-py
src/ai/backend/client/compat.py
asyncio_run_forever
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_...
python
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", ")", ":", "async", "def", "wait_for_stop", "(", ")", ":", "loop", "=", "current_loop",...
A proposed-but-not-implemented asyncio.run_forever() API based on @vxgmichel's idea. See discussions on https://github.com/python/asyncio/pull/465
[ "A", "proposed", "-", "but", "-", "not", "-", "implemented", "asyncio", ".", "run_forever", "()", "API", "based", "on" ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/compat.py#L80-L111
train
hustcc/wrapcache
wrapcache/database/__init__.py
LruCacheDB.clear
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 ...
python
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", ")", ":", "for", "node", "in", "self", ".", "dli", "(", ")", ":", "node", ".", "empty", "=", "True", "node", ".", "key", "=", "None", "node", ".", "value", "=", "None", "self", ".", "head", "=", "_dlnode", "(", ")",...
claar all the cache, and release memory
[ "claar", "all", "the", "cache", "and", "release", "memory" ]
3c6f52bb81a278e1dd60c27abe87d169cb4395aa
https://github.com/hustcc/wrapcache/blob/3c6f52bb81a278e1dd60c27abe87d169cb4395aa/wrapcache/database/__init__.py#L56-L75
train
hustcc/wrapcache
wrapcache/database/__init__.py
LruCacheDB.pop
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
python
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", ")", ":", "node", "=", "self", ".", "get", "(", "key", ",", "None", ")", "if", "node", "==", "None", ":", "value", "=", "default", "else", ":", "value", "=", "node", "try", ":"...
Delete the item
[ "Delete", "the", "item" ]
3c6f52bb81a278e1dd60c27abe87d169cb4395aa
https://github.com/hustcc/wrapcache/blob/3c6f52bb81a278e1dd60c27abe87d169cb4395aa/wrapcache/database/__init__.py#L195-L207
train
AoiKuiyuyou/AoikLiveReload
src/aoiklivereload/demo/bottle_demo.py
main
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 ...
python
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", "(", ")", ":", "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. :return: None.
[ "Main", "function", "." ]
0d5adb12118a33749e6690a8165fdb769cff7d5c
https://github.com/AoiKuiyuyou/AoikLiveReload/blob/0d5adb12118a33749e6690a8165fdb769cff7d5c/src/aoiklivereload/demo/bottle_demo.py#L15-L84
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.get_or_create
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...
python
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", "]", ...
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...
[ "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", ...
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L51-L112
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.destroy
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 ...
python
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", ")", ":", "params", "=", "{", "}", "if", "self", ".", "owner_access_key", ":", "params", "[", "'owner_access_key'", "]", "=", "self", ".", "owner_access_key", "rqst", "=", "Request", "(", "self", ".", "session", ",...
Destroys the compute session. Since the server literally kills the container(s), all ongoing executions are forcibly interrupted.
[ "Destroys", "the", "compute", "session", ".", "Since", "the", "server", "literally", "kills", "the", "container", "(", "s", ")", "all", "ongoing", "executions", "are", "forcibly", "interrupted", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L119-L133
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.restart
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...
python
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", ")", ":", "params", "=", "{", "}", "if", "self", ".", "owner_access_key", ":", "params", "[", "'owner_access_key'", "]", "=", "self", ".", "owner_access_key", "rqst", "=", "Request", "(", "self", ".", "session", ",...
Restarts the compute session. The server force-destroys the current running container(s), but keeps their temporary scratch directories intact.
[ "Restarts", "the", "compute", "session", ".", "The", "server", "force", "-", "destroys", "the", "current", "running", "container", "(", "s", ")", "but", "keeps", "their", "temporary", "scratch", "directories", "intact", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L136-L149
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.complete
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...
python
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", "]", ":", "opts", "=", "{", "}", "if", "opts", "is", "None", "else", "opts", "params", "=", "{", "}", "i...
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...
[ "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", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L168-L200
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.get_info
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...
python
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", ")", ":", "params", "=", "{", "}", "if", "self", ".", "owner_access_key", ":", "params", "[", "'owner_access_key'", "]", "=", "self", ".", "owner_access_key", "rqst", "=", "Request", "(", "self", ".", "session", "...
Retrieves a brief information about the compute session.
[ "Retrieves", "a", "brief", "information", "about", "the", "compute", "session", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L203-L214
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.execute
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...
python
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", ")", ":", "opts", "=", "opts", "if", "opts", "...
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...
[ "Executes", "a", "code", "snippet", "directly", "in", "the", "compute", "session", "or", "sends", "a", "set", "of", "build", "/", "clean", "/", "execute", "commands", "to", "the", "compute", "session", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L231-L304
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.upload
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 ...
python
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 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 ...
[ "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", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L307-L361
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.download
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. ...
python
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. 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-...
[ "Downloads", "the", "given", "list", "of", "files", "from", "the", "compute", "session", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L364-L418
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.list_files
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...
python
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", "]", "=", "'.'", ")", ":", "params", "=", "{", "}", "if", "self", ".", "owner_access_key", ":", "params", "[", "'owner_access_key'", "]", "=", "self", ".",...
Gets the list of files in the given path inside the compute session container. :param path: The directory path in the compute session.
[ "Gets", "the", "list", "of", "files", "in", "the", "given", "path", "inside", "the", "compute", "session", "container", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L421-L438
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.stream_pty
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 ...
python
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'", ":", "params", "=", "{", "}", "if", "self", ".", "owner_access_key", ":", "params", "[", "'owner_access_key'", "]", "=", "self", ".", "owner_access_key", "request", "=", "Request", "(", "self", "....
Opens a pseudo-terminal of the kernel (if supported) streamed via websockets. :returns: a :class:`StreamPty` object.
[ "Opens", "a", "pseudo", "-", "terminal", "of", "the", "kernel", "(", "if", "supported", ")", "streamed", "via", "websockets", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L441-L454
train
lablup/backend.ai-client-py
src/ai/backend/client/kernel.py
Kernel.stream_execute
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_...
python
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", ":", "params", "=", "{", "}", "if", "self", ".", "...
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.
[ "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", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/kernel.py#L457-L492
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
init_interface
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...
python
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", ")", "warnings", ".", "simplefilter", "(", "'error'", ",", "UserW...
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.
[ "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", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L76-L112
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface._connect
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 ...
python
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", ")", ":", "if", "rc", "==", "0", ":", "self", ".", "connected", "=", "True", "results", "=", "[", "]", "LOGGER", ".", "info", "(", "\"MQTT Connected with result cod...
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 ...
[ "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...
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L207-L239
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface._message
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...
python
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", ")", ":", "try", ":", "inputCmds", "=", "[", "'query'", ",", "'command'", ",", "'result'", ",", "'status'", ",", "'shortPoll'", ",", "'longPoll'", ",", "'delete'", "]", "parsed_ms...
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...
[ "The", "callback", "for", "when", "a", "PUBLISH", "message", "is", "received", "from", "the", "server", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L241-L272
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface._disconnect
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...
python
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", ")", ":", "self", ".", "connected", "=", "False", "if", "rc", "!=", "0", ":", "LOGGER", ".", "info", "(", "\"MQTT Unexpected disconnection. Trying reconnect.\"", ")", "try", ":", ...
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
[ "The", "callback", "for", "when", "a", "DISCONNECT", "occurs", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L274-L292
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface._startMqtt
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...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Connecting to MQTT... {}:{}'", ".", "format", "(", "self", ".", "_server", ",", "self", ".", "_port", ")", ")", "try", ":", "# self._mqttc.connect_async(str(self._server), int(self._port), 10)...
The client start method. Starts the thread for the MQTT Client and publishes the connected message.
[ "The", "client", "start", "method", ".", "Starts", "the", "thread", "for", "the", "MQTT", "Client", "and", "publishes", "the", "connected", "message", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L313-L326
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.stop
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...
python
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", ")", ":", "# 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... {}:{}'", "....
The client stop method. If the client is currently connected stop the thread and disconnect. Publish the disconnected message if clean shutdown.
[ "The", "client", "stop", "method", ".", "If", "the", "client", "is", "currently", "connected", "stop", "the", "thread", "and", "disconnect", ".", "Publish", "the", "disconnected", "message", "if", "clean", "shutdown", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L328-L347
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.send
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: ...
python
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", ")", ":", "if", "not", "isinstance", "(", "message", ",", "dict", ")", "and", "self", ".", "connected", ":", "warnings", ".", "warn", "(", "'payload not a dictionary'", ")", "return", "False", "try", ":", "mess...
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
[ "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", ...
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L349-L361
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.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...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Adding node {}({})'", ".", "format", "(", "node", ".", "name", ",", "node", ".", "address", ")", ")", "message", "=", "{", "'addnode'", ":", "{", "'nodes'", ":", "[",...
Add a node to the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
[ "Add", "a", "node", "to", "the", "NodeServer" ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L363-L382
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.saveCustomData
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 } ...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Sending customData to Polyglot.'", ")", "message", "=", "{", "'customdata'", ":", "data", "}", "self", ".", "send", "(", "message", ")" ]
Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of key value pairs to store in Polyglot database.
[ "Send", "custom", "dictionary", "to", "Polyglot", "to", "save", "and", "be", "retrieved", "on", "startup", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L384-L392
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.saveCustomParams
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 }...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Sending customParams to Polyglot.'", ")", "message", "=", "{", "'customparams'", ":", "data", "}", "self", ".", "send", "(", "message", ")" ]
Send custom dictionary to Polyglot to save and be retrieved on startup. :param data: Dictionary of key value pairs to store in Polyglot database.
[ "Send", "custom", "dictionary", "to", "Polyglot", "to", "save", "and", "be", "retrieved", "on", "startup", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L394-L402
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.addNotice
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....
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Sending addnotice to Polyglot: {}'", ".", "format", "(", "data", ")", ")", "message", "=", "{", "'addnotice'", ":", "data", "}", "self", ".", "send", "(", "message", ")...
Add custom notice to front-end for this NodeServers :param data: String of characters to add as a notification in the front-end.
[ "Add", "custom", "notice", "to", "front", "-", "end", "for", "this", "NodeServers" ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L404-L412
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.removeNotice
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)
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Sending removenotice to Polyglot for index {}'", ".", "format", "(", "data", ")", ")", "message", "=", "{", "'removenotice'", ":", "data", "}", "self", ".", "send", "(",...
Add custom notice to front-end for this NodeServers :param data: Index of notices list to remove.
[ "Add", "custom", "notice", "to", "front", "-", "end", "for", "this", "NodeServers" ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L414-L422
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.delNode
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': { ...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Removing node {}'", ".", "format", "(", "address", ")", ")", "message", "=", "{", "'removenode'", ":", "{", "'address'", ":", "address", "}", "}", "self", ".", "send...
Delete a node from the NodeServer :param node: Dictionary of node settings. Keys: address, name, node_def_id, primary, and drivers are required.
[ "Delete", "a", "node", "from", "the", "NodeServer" ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L439-L451
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.getNode
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...
python
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", ")", ":", "try", ":", "for", "node", "in", "self", ".", "config", "[", "'nodes'", "]", ":", "if", "node", "[", "'address'", "]", "==", "address", ":", "return", "node", "return", "False", "except", "KeyE...
Get Node by Address of existing nodes.
[ "Get", "Node", "by", "Address", "of", "existing", "nodes", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L453-L464
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.inConfig
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...
python
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", ")", ":", "self", ".", "config", "=", "config", "self", ".", "isyVersion", "=", "config", "[", "'isyVersion'", "]", "try", ":", "for", "watcher", "in", "self", ".", "__configObservers", ":", "watcher", "(", ...
Save incoming config received from Polyglot to Interface.config and then do any functions that are waiting on the config to be received.
[ "Save", "incoming", "config", "received", "from", "Polyglot", "to", "Interface", ".", "config", "and", "then", "do", "any", "functions", "that", "are", "waiting", "on", "the", "config", "to", "be", "received", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L466-L480
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Interface.save_typed_params
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 ...
python
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", ")", ":", "LOGGER", ".", "info", "(", "'Sending typed parameters to Polyglot.'", ")", "if", "type", "(", "data", ")", "is", "not", "list", ":", "data", "=", "[", "data", "]", "message", "=", "{", "'ty...
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...
[ "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", "...
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L519-L542
train
UniversalDevicesInc/polyglot-v2-python-interface
polyinterface/polyinterface.py
Controller.delNode
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)
python
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", ")", ":", "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.
[ "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", "." ]
fe613135b762731a41a081222e43d2a8ae4fc53f
https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L844-L851
train
lablup/backend.ai-client-py
src/ai/backend/client/admin.py
Admin.query
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 ...
python
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", ":", "gql_query", "=", "{", "'query'", ":", "query", ",", "'va...
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.
[ "Sends", "the", "GraphQL", "query", "and", "returns", "the", "response", "." ]
a063d774fea6f4350b89498c40d3c837ec3029a7
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/admin.py#L27-L47
train
housecanary/hc-api-python
housecanary/utilities.py
get_readable_time_string
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: ...
python
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", ")", ":", "seconds", "=", "int", "(", "seconds", ")", "minutes", "=", "seconds", "//", "60", "seconds", "=", "seconds", "%", "60", "hours", "=", "minutes", "//", "60", "minutes", "=", "minutes", "%", "60...
Returns human readable string from number of seconds
[ "Returns", "human", "readable", "string", "from", "number", "of", "seconds" ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/utilities.py#L6-L26
train
housecanary/hc-api-python
housecanary/utilities.py
get_rate_limits
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('...
python
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", ")", ":", "periods", "=", "response", ".", "headers", "[", "'X-RateLimit-Period'", "]", "if", "not", "periods", ":", "return", "[", "]", "rate_limits", "=", "[", "]", "periods", "=", "periods", ".", "split", "(", ...
Returns a list of rate limit information from a given response's headers.
[ "Returns", "a", "list", "of", "rate", "limit", "information", "from", "a", "given", "response", "s", "headers", "." ]
2bb9e2208b34e8617575de45934357ee33b8531c
https://github.com/housecanary/hc-api-python/blob/2bb9e2208b34e8617575de45934357ee33b8531c/housecanary/utilities.py#L37-L73
train
Tygs/ww
src/ww/wrappers/dicts.py
DictWrapper.isubset
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...
python
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", "ww", ".", "g", "(", "(", "key", ",", "self", "[", "key", "]", ")", "for", "key", "in", "keys", ")" ]
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)]
[ "Return", "key", "self", "[", "key", "]", "as", "generator", "for", "key", "in", "keys", "." ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L18-L33
train
Tygs/ww
src/ww/wrappers/dicts.py
DictWrapper.swap
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 ...
python
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", "return", "self", ".", "__class__", "(", "(", "v", ",", "k", ")", "for", "k", ",", "v", "in", "self", ".", "items", "(", ")", ")" ]
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}
[ "Swap", "key", "and", "value" ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L52-L65
train
Tygs/ww
src/ww/wrappers/dicts.py
DictWrapper.fromkeys
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. ...
python
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", "if", "not", "callable", "(", "value", ")", ":", "return", "cls", "(", ...
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...
[ "Create", "a", "new", "d", "from" ]
6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/dicts.py#L94-L117
train