sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def virtualenv_setup( ctx, python, inputs=None, outputs=None, touch=None, check_import=False, pip_setup_file=None, pip_setup_touch=None, cache_key=None, always=False, ): """ Create task that sets up `virtualenv` package. :param ctx: BuildContext object. :param p...
Create task that sets up `virtualenv` package. :param ctx: BuildContext object. :param python: Python program path. :param inputs: Input items list to add to created task. See :paramref:`create_cmd_task.inputs` for allowed item types. :param outputs: Output items list to add to created task...
entailment
def create_venv( ctx, python, venv_path, inputs=None, outputs=None, pip_setup_file=None, pip_setup_touch=None, virtualenv_setup_touch=None, task_name=None, cache_key=None, always=False, ): """ Create task that sets up virtual environment. :param ctx: BuildContext...
Create task that sets up virtual environment. :param ctx: BuildContext object. :param python: Python program path. :param venv_path: Virtual environment directory relative path relative to top directory. :param inputs: Input items list to add to created task. See :paramref:`create_c...
entailment
def pip_ins_req( ctx, python, req_path, venv_path=None, inputs=None, outputs=None, touch=None, check_import=False, check_import_module=None, pip_setup_file=None, pip_setup_touch=None, virtualenv_setup_touch=None, always=False, ): """ Create task that uses give...
Create task that uses given virtual environment's `pip` to sets up \ packages listed in given requirements file. :param ctx: BuildContext object. :param python: Python program path used to set up `pip` and `virtualenv`. :param req_path: Requirements file relative path relative to top directory. ...
entailment
def git_clean(ctx): """ Delete all files untracked by git. :param ctx: Context object. :return: None. """ # Get command parts cmd_part_s = [ # Program path 'git', # Clean untracked files 'clean', # Remove all untracked files '-x', ...
Delete all files untracked by git. :param ctx: Context object. :return: None.
entailment
def run(self): """ Run command. :return: Command exit code. """ # Print task title print_title(self._task_name_title) # Get context object ctx = self._ctx # Get command parts cmd_part_s = self._parts # Print title print_...
Run command. :return: Command exit code.
entailment
def get_ac_info_all(auth, url): """ function takes no input as input to RESTFUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list of dictionaries ...
function takes no input as input to RESTFUL call to HP IMC :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 ...
entailment
def addvlan(self, vlanid, vlan_name): """ Function operates on the IMCDev object. Takes input of vlanid (1-4094), str of vlan_name, auth and url to execute the create_dev_vlan method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :para...
Function operates on the IMCDev object. Takes input of vlanid (1-4094), str of vlan_name, auth and url to execute the create_dev_vlan method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :param vlanid: str of VLANId ( valid 1-4094 ) :param vl...
entailment
def delvlan(self, vlanid): """ Function operates on the IMCDev object. Takes input of vlanid (1-4094), auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :param vlanid: str of VLANId ( va...
Function operates on the IMCDev object. Takes input of vlanid (1-4094), auth and url to execute the delete_dev_vlans method on the IMCDev object. Device must be supported in the HPE IMC Platform VLAN Manager module. :param vlanid: str of VLANId ( valid 1-4094 ) :return:
entailment
def getipmacarp(self): """ Function operates on the IMCDev object and updates the ipmacarp attribute :return: """ self.ipmacarp = get_ip_mac_arp_list(self.auth, self.url, devid = self.devid)
Function operates on the IMCDev object and updates the ipmacarp attribute :return:
entailment
def down(self): """ Function operates on the IMCInterface object and configures the interface into an administratively down state and refreshes contents of self.adminstatus :return: """ set_interface_down(self.ifIndex, self.auth, self.url, devip=self.ip) self.admi...
Function operates on the IMCInterface object and configures the interface into an administratively down state and refreshes contents of self.adminstatus :return:
entailment
def up(self): """ Function operates on the IMCInterface object and configures the interface into an administratively up state and refreshes contents of self.adminstatus :return: """ set_interface_up(self.ifIndex, self.auth, self.url, devip=...
Function operates on the IMCInterface object and configures the interface into an administratively up state and refreshes contents of self.adminstatus :return:
entailment
def allocate_ip(self, hostipaddress, name, description): """ Object method takes in input of hostipaddress, name and description and adds them to the parent ip scope. :param hostipaddress: str of ipv4 address of the target host ip record :param name: str of the name of the owner ...
Object method takes in input of hostipaddress, name and description and adds them to the parent ip scope. :param hostipaddress: str of ipv4 address of the target host ip record :param name: str of the name of the owner of the target host ip record :param description: str of a description...
entailment
def deallocate_ip(self, hostipaddress): """ Object method takes in input of hostip address,removes them from the parent ip scope. :param hostid: str of the hostid of the target host ip record :return: """ delete_host_from_segment(hostipaddress, self.netaddr, self.auth, ...
Object method takes in input of hostip address,removes them from the parent ip scope. :param hostid: str of the hostid of the target host ip record :return:
entailment
def gethosts(self): """ Method gets all hosts currently allocated to the target scope and refreashes the self.hosts attributes of the object :return: """ self.hosts = get_ip_scope_hosts(self.auth, self.url, self.id)
Method gets all hosts currently allocated to the target scope and refreashes the self.hosts attributes of the object :return:
entailment
def nextfreeip(self): """ Method searches for the next free ip address in the scope object and returns it as a str value. :return: """ allocated_ips = [ipaddress.ip_address(host['ip']) for host in self.hosts] for ip in self.netaddr: if str(ip).split('....
Method searches for the next free ip address in the scope object and returns it as a str value. :return:
entailment
def addchild(self, startip, endip, name, description): """ Method takes inpur of str startip, str endip, name, and description and adds a child scope. The startip and endip MUST be in the IP address range of the parent scope. :param startip: str of ipv4 address of the first address in th...
Method takes inpur of str startip, str endip, name, and description and adds a child scope. The startip and endip MUST be in the IP address range of the parent scope. :param startip: str of ipv4 address of the first address in the child scope :param endip: str of ipv4 address of the last address...
entailment
def get_telnet_template(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.authcla...
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...
entailment
def modify_telnet_template(auth, url, telnet_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a telnet template. :param auth: :param url: :param telnet_template: Human readable label which ...
Function takes input of a dictionry containing the required key/value pair for the modification of a telnet template. :param auth: :param url: :param telnet_template: Human readable label which is the name of the specific telnet template :param template_id Internal IMC number which designates the s...
entailment
def delete_telnet_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 telnet template from the IMC system :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :par...
Takes template_name as input to issue RESTUL call to HP IMC which will delete the specific telnet 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 :p...
entailment
def create_ssh_template(auth, url, ssh_template ): """ Function takes input of a dictionry containing the required key/value pair for the creation of a ssh template. :param auth: :param url: :param ssh: dictionary of valid JSON which complains to API schema :return: int value of HTTP respon...
Function takes input of a dictionry containing the required key/value pair for the creation of a ssh template. :param auth: :param url: :param ssh: dictionary of valid JSON which complains to API schema :return: int value of HTTP response code 201 for proper creation or 404 for failed creation ...
entailment
def get_ssh_template(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.authclass ...
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...
entailment
def modify_ssh_template(auth, url, ssh_template, template_name= None, template_id = None): """ Function takes input of a dictionry containing the required key/value pair for the modification of a ssh template. :param auth: :param url: :param ssh_template: Human readable label which is the name ...
Function takes input of a dictionry containing the required key/value pair for the modification of a ssh 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 s...
entailment
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...
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...
entailment
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...
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...
entailment
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...
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 ...
entailment
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...
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...
entailment
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...
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...
entailment
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 ...
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...
entailment
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...
Run a non-encrypted non-authorized API proxy server. Use this only for development and testing!
entailment
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...
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:...
entailment
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...
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...
entailment
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...
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: ...
entailment
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...
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....
entailment
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...
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...
entailment
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. ...
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...
entailment
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...
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...
entailment
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...
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...
entailment
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
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
entailment
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...
Creates a new keypair with the given options. You need an admin privilege for this operation.
entailment
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...
Creates a new keypair with the given options. You need an admin privilege for this operation.
entailment
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 = { ...
Deletes an existing keypair with given ACCESSKEY.
entailment
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 = ...
Lists the keypairs. You need an admin privilege for this operation.
entailment
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...
Returns the keypair's information such as resource limits. :param fields: Additional per-agent query fields to fetch. .. versionadded:: 18.12
entailment
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) {' \ ...
Activates this keypair. You need an admin privilege for this operation.
entailment
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!, ...
Deactivates this keypair. Deactivated keypairs cannot make any API requests unless activated again by an administrator. You need an admin privilege for this operation.
entailment
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...
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...
entailment
async def check_presets(cls): ''' Lists all resource presets in the current scaling group with additiona information. ''' rqst = Request(cls.session, 'POST', '/resource/check-presets') async with rqst.fetch() as resp: return await resp.json()
Lists all resource presets in the current scaling group with additiona information.
entailment
def add_perf_task(task, auth, url): """ function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into JSON and issues a RESTFUL call to create the performance task. device. :param task: dictionary containing all required fields f...
function takes the a python dict containing all necessary fields for a performance tasks, transforms the dict into JSON and issues a RESTFUL call to create the performance task. device. :param task: dictionary containing all required fields for performance tasks :param auth: requests ...
entailment
def get_perf_task(task_name, auth, url): """ function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call to the IMC REST service. It will return a list :param task_name: str containing the name of the performance task :param auth: ...
function takes the a str object containing the name of an existing performance tasks and issues a RESTFUL call to the IMC REST service. It will return a list :param task_name: str containing the name of the performance task :param auth: requests auth object #usually auth.creds from auth pyhpei...
entailment
def get_vm_host_info(hostip, auth, url): """ function takes hostId as input to RESTFUL call to HP IMC :param hostip: int or string of hostip of Hypervisor host :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually aut...
function takes hostId as input to RESTFUL call to HP IMC :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...
entailment
def get_ac_info_all(auth, url): """ function takes no input as input to RESTFUL call to HP IMC :param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class :param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass :return: list of dictionaries ...
function takes no input as input to RESTFUL call to HP IMC :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 ...
entailment
def set_imc_creds(h_url=None, imc_server=None, imc_port=None, imc_user=None,imc_pw=None): """ This function prompts user for IMC server information and credentuials and stores values in url and auth global variables""" global auth, url if h_url is None: imc_protocol = input( "What protoc...
This function prompts user for IMC server information and credentuials and stores values in url and auth global variables
entailment
def print_to_file(object): """ Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt :param: Object: object of type str, list, or dict :return: No return. Just prints out to file handler and save to current working directory as pyoutput.txt ...
Function takes in object of type str, list, or dict and prints out to current working directory as pyoutput.txt :param: Object: object of type str, list, or dict :return: No return. Just prints out to file handler and save to current working directory as pyoutput.txt
entailment
def get_auth(self): """ This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object :return: """ url = self.h_url + self.server + ":" + self.port auth = requests.auth.HTTPDigestAuth(self.username,self.password) auth_url...
This method requests an authentication object from the HPE IMC NMS and returns an HTTPDigest Auth Object :return:
entailment
def get_version(root): """ Load and return the contents of version.json. :param root: The root path that the ``version.json`` file will be opened :type root: str :returns: Content of ``version.json`` or None :rtype: dict or None """ version_json = os.path.join(root, 'version.json') ...
Load and return the contents of version.json. :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
entailment
def fetch(self, endpoint_name, identifier_input, query_params=None): """Calls this instance's request_client's post method with the specified component endpoint Args: - endpoint_name (str) - The endpoint to call like "property/value". - identifier_input - One or more ide...
Calls this instance's request_client's post method with the specified component endpoint 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...
entailment
def fetch_synchronous(self, endpoint_name, query_params=None): """Calls this instance's request_client's get method with the specified component endpoint""" endpoint_url = constants.URL_PREFIX + "/" + self._version + "/" + endpoint_name if query_params is None: query_params...
Calls this instance's request_client's get method with the specified component endpoint
entailment
def get_identifier_input(self, identifier_data): """Convert the various formats of input identifier_data into the proper json format expected by the ApiClient fetch method, which is a list of dicts.""" identifier_input = [] if isinstance(identifier_data, list) and len(identifie...
Convert the various formats of input identifier_data into the proper json format expected by the ApiClient fetch method, which is a list of dicts.
entailment
def fetch_identifier_component(self, endpoint_name, identifier_data, query_params=None): """Common method for handling parameters before passing to api_client""" if query_params is None: query_params = {} identifier_input = self.get_identifier_input(identifier_data) return...
Common method for handling parameters before passing to api_client
entailment
def _convert_to_identifier_json(self, address_data): """Convert input address data into json format""" if isinstance(address_data, str): # allow just passing a slug string. return {"slug": address_data} if isinstance(address_data, tuple) and len(address_data) > 0: ...
Convert input address data into json format
entailment
def value_report(self, address, zipcode, report_type="full", format_type="json"): """Call the value_report component Value Report only supports a single address. Args: - address - zipcode Kwargs: - report_type - "full" or "summary". Default is "full...
Call the value_report component 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".
entailment
def rental_report(self, address, zipcode, format_type="json"): """Call the rental_report component Rental Report only supports a single address. Args: - address - zipcode Kwargs: - format_type - "json", "xlsx" or "all". Default is "json". ""...
Call the rental_report component Rental Report only supports a single address. Args: - address - zipcode Kwargs: - format_type - "json", "xlsx" or "all". Default is "json".
entailment
def component_mget(self, zip_data, components): """Call the zip component_mget endpoint Args: - zip_data - As described in the class docstring. - components - A list of strings for each component to include in the request. Example: ["zip/details", "zip/volatility...
Call the zip component_mget endpoint 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"]
entailment
def version(request): """ Returns the contents of version.json or a 404. """ version_json = import_string(version_callback)(settings.BASE_DIR) if version_json is None: return HttpResponseNotFound('version.json not found') else: return JsonResponse(version_json)
Returns the contents of version.json or a 404.
entailment
def heartbeat(request): """ Runs all the Django checks and returns a JsonResponse with either a status code of 200 or 500 depending on the results of the checks. Any check that returns a warning or worse (error, critical) will return a 500 response. """ all_checks = checks.registry.registry...
Runs all the Django checks and returns a JsonResponse with either a status code of 200 or 500 depending on the results of the checks. Any check that returns a warning or worse (error, critical) will return a 500 response.
entailment
def _create_component_results(json_data, result_key): """ Returns a list of ComponentResult from the json_data""" component_results = [] for key, value in list(json_data.items()): if key not in [result_key, "meta"]: component_result = ComponentResult( key, ...
Returns a list of ComponentResult from the json_data
entailment
def has_error(self): """Returns whether there was a business logic error when fetching data for any components for this property. Returns: boolean """ return next( (True for cr in self.component_results if cr.has_error()), False ...
Returns whether there was a business logic error when fetching data for any components for this property. Returns: boolean
entailment
def get_errors(self): """If there were any business errors fetching data for this property, returns the error messages. Returns: string - the error message, or None if there was no error. """ return [{cr.component_name: cr.get_error()} for cr in self...
If there were any business errors fetching data for this property, returns the error messages. Returns: string - the error message, or None if there was no error.
entailment
def create_from_json(cls, json_data): """Deserialize property json data into a Property object Args: json_data (dict): The json data for this property Returns: Property object """ prop = Property() address_info = json_data["address_info"] ...
Deserialize property json data into a Property object Args: json_data (dict): The json data for this property Returns: Property object
entailment
def create_from_json(cls, json_data): """Deserialize block json data into a Block object Args: json_data (dict): The json data for this block Returns: Block object """ block = Block() block_info = json_data["block_info"] block.block_id =...
Deserialize block json data into a Block object Args: json_data (dict): The json data for this block Returns: Block object
entailment
def create_from_json(cls, json_data): """Deserialize zipcode json data into a ZipCode object Args: json_data (dict): The json data for this zipcode Returns: Zip object """ zipcode = ZipCode() zipcode.zipcode = json_data["zipcode_info"]["zipcode"...
Deserialize zipcode json data into a ZipCode object Args: json_data (dict): The json data for this zipcode Returns: Zip object
entailment
def create_from_json(cls, json_data): """Deserialize msa json data into a Msa object Args: json_data (dict): The json data for this msa Returns: Msa object """ msa = Msa() msa.msa = json_data["msa_info"]["msa"] msa.meta = json_data["meta...
Deserialize msa json data into a Msa object Args: json_data (dict): The json data for this msa Returns: Msa object
entailment
def starts_when(iterable, condition): # type: (Iterable, Union[Callable, Any]) -> Iterable """Start yielding items when a condition arise. Args: iterable: the iterable to filter. condition: if the callable returns True once, start yielding items. If it's not a callable, i...
Start yielding items when a condition arise. 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: ...
entailment
def stops_when(iterable, condition): # type: (Iterable, Union[Callable, Any]) -> Iterable """Stop yielding items when a condition arise. Args: iterable: the iterable to filter. condition: if the callable returns True once, stop yielding items. If it's not a callable, it w...
Stop yielding items when a condition arise. 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: ...
entailment
def skip_duplicates(iterable, key=None, fingerprints=()): # type: (Iterable, Callable, Any) -> Iterable """ Returns a generator that will yield all objects from iterable, skipping duplicates. Duplicates are identified using the `key` function to calculate a unique fingerprint. T...
Returns a generator that will yield all objects from iterable, skipping duplicates. 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...
entailment
def chunks(iterable, chunksize, cast=tuple): # type: (Iterable, int, Callable) -> Iterable """ Yields items from an iterator in iterable chunks. """ it = iter(iterable) while True: yield cast(itertools.chain([next(it)], itertools.islice(it, chunksize - 1)))
Yields items from an iterator in iterable chunks.
entailment
def window(iterable, size=2, cast=tuple): # type: (Iterable, int, Callable) -> Iterable """ Yields iterms by bunch of a given size, but rolling only one item in and out at a time when iterating. >>> list(window([1, 2, 3])) [(1, 2), (2, 3)] By default, this will cast the...
Yields iterms by bunch of a given size, but rolling only one item in and out at a time when iterating. >>> 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...
entailment
def at_index(iterable, index): # type: (Iterable[T], int) -> T """" Return the item at the index of this iterable or raises IndexError. WARNING: this will consume generators. Negative indices are allowed but be aware they will cause n items to be held in memory, where n = abs(index) ...
Return the item at the index of this iterable or raises IndexError. 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)
entailment
def first_true(iterable, func): # type: (Iterable[T], Callable) -> T """" Return the first item of the iterable for which func(item) == True. Or raises IndexError. WARNING: this will consume generators. """ try: return next((x for x in iterable if func(x))) except StopItera...
Return the first item of the iterable for which func(item) == True. Or raises IndexError. WARNING: this will consume generators.
entailment
def iterslice(iterable, start=0, stop=None, step=1): # type: (Iterable[T], int, int, int) -> Iterable[T] """ Like itertools.islice, but accept int and callables. If `start` is a callable, start the slice after the first time start(item) == True. If `stop` is a callable, stop the slice ...
Like itertools.islice, but accept int and callables. 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.
entailment
def firsts(iterable, items=1, default=None): # type: (Iterable[T], int, T) -> Iterable[T] """ Lazily return the first x items from this iterable or default. """ try: items = int(items) except (ValueError, TypeError): raise ValueError("items should be usable as an int but is currently " ...
Lazily return the first x items from this iterable or default.
entailment
def lasts(iterable, items=1, default=None): # type: (Iterable[T], int, T) -> Iterable[T] """ Lazily return the last x items from this iterable or default. """ last_items = deque(iterable, maxlen=items) for _ in range(items - len(last_items)): yield default for y in last_items: yie...
Lazily return the last x items from this iterable or default.
entailment
def is_legacy_server(): '''Determine execution mode. Legacy mode: <= v4.20181215 ''' with Session() as session: ret = session.Kernel.hello() bai_version = ret['version'] legacy = True if bai_version <= 'v4.20181215' else False return legacy
Determine execution mode. Legacy mode: <= v4.20181215
entailment
def close(self): ''' Terminates the session. It schedules the ``close()`` coroutine of the underlying aiohttp session and then enqueues a sentinel object to indicate termination. Then it waits until the worker thread to self-terminate by joining. ''' if self._cl...
Terminates the session. It schedules the ``close()`` coroutine of the underlying aiohttp session and then enqueues a sentinel object to indicate termination. Then it waits until the worker thread to self-terminate by joining.
entailment
def asyncio_run_forever(setup_coro, shutdown_coro, *, stop_signals={signal.SIGINT}, debug=False): ''' A proposed-but-not-implemented asyncio.run_forever() API based on @vxgmichel's idea. See discussions on https://github.com/python/asyncio/pull/465 ''' async def wait_for_...
A proposed-but-not-implemented asyncio.run_forever() API based on @vxgmichel's idea. See discussions on https://github.com/python/asyncio/pull/465
entailment
def clear(self): ''' claar all the cache, and release memory ''' for node in self.dli(): node.empty = True node.key = None node.value = None self.head = _dlnode() self.head.next = self.head self.head.prev = self.head self.listSize = 1 self.table.clear() # status var self.hit_cnt ...
claar all the cache, and release memory
entailment
def pop(self, key, default = None): """Delete the item""" node = self.get(key, None) if node == None: value = default else: value = node try: del self[key] except: return value return value
Delete the item
entailment
def main(): """ Main function. :return: None. """ try: # Get the `src` directory's absolute path src_path = os.path.dirname( # `aoiklivereload` directory's absolute path os.path.dirname( # `demo` directory's absolute path ...
Main function. :return: None.
entailment
async def get_or_create(cls, lang: str, *, client_token: str = None, mounts: Iterable[str] = None, envs: Mapping[str, str] = None, resources: Mapping[str, int] = None, cluster_size...
Get-or-creates a compute session. If *client_token* is ``None``, it creates a new compute session as long as the server has enough resources and your API 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...
entailment
async def destroy(self): ''' Destroys the compute session. Since the server literally kills the container(s), all ongoing executions are forcibly interrupted. ''' params = {} if self.owner_access_key: params['owner_access_key'] = self.owner_access_key ...
Destroys the compute session. Since the server literally kills the container(s), all ongoing executions are forcibly interrupted.
entailment
async def restart(self): ''' Restarts the compute session. The server force-destroys the current running container(s), but keeps their temporary scratch directories intact. ''' params = {} if self.owner_access_key: params['owner_access_key'] = self.own...
Restarts the compute session. The server force-destroys the current running container(s), but keeps their temporary scratch directories intact.
entailment
async def complete(self, code: str, opts: dict = None) -> Iterable[str]: ''' Gets the auto-completion candidates from the given code string, as if a user has pressed the tab key just after the code in IDEs. Depending on the language of the compute session, this feature m...
Gets the auto-completion candidates from the given code string, as if a user has pressed the tab key just after the code in IDEs. Depending on the language of the compute session, this feature may not be supported. Unsupported sessions returns an empty list. :param code: An (i...
entailment
async def get_info(self): ''' Retrieves a brief information about the compute session. ''' params = {} if self.owner_access_key: params['owner_access_key'] = self.owner_access_key rqst = Request(self.session, 'GET', '/kernel/{}'.format(s...
Retrieves a brief information about the compute session.
entailment
async def execute(self, run_id: str = None, code: str = None, mode: str = 'query', opts: dict = None): ''' Executes a code snippet directly in the compute session or sends a set of build/clean/execute commands to the compute sessi...
Executes a code snippet directly in the compute session or sends a set of build/clean/execute commands to the compute session. 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...
entailment
async def upload(self, files: Sequence[Union[str, Path]], basedir: Union[str, Path] = None, show_progress: bool = False): ''' Uploads the given list of files to the compute session. You may refer them in the batch-mode execution or from the code ...
Uploads the given list of files to the compute session. You may refer them in the batch-mode execution or from the code executed in the server afterwards. :param files: The list of file paths in the client-side. If the paths include directories, the location of them in the compute ...
entailment
async def download(self, files: Sequence[Union[str, Path]], dest: Union[str, Path] = '.', show_progress: bool = False): ''' Downloads the given list of files from the compute session. :param files: The list of file paths in the compute session. ...
Downloads the given list of files from the compute session. :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-...
entailment
async def list_files(self, path: Union[str, Path] = '.'): ''' Gets the list of files in the given path inside the compute session container. :param path: The directory path in the compute session. ''' params = {} if self.owner_access_key: params['owne...
Gets the list of files in the given path inside the compute session container. :param path: The directory path in the compute session.
entailment
def stream_pty(self) -> 'StreamPty': ''' Opens a pseudo-terminal of the kernel (if supported) streamed via websockets. :returns: a :class:`StreamPty` object. ''' params = {} if self.owner_access_key: params['owner_access_key'] = self.owner_access_key ...
Opens a pseudo-terminal of the kernel (if supported) streamed via websockets. :returns: a :class:`StreamPty` object.
entailment
def stream_execute(self, code: str = '', *, mode: str = 'query', opts: dict = None) -> WebSocketResponse: ''' Executes a code snippet in the streaming mode. Since the returned websocket represents a run loop, there is no need to specify *run_...
Executes a code snippet in the streaming mode. Since the returned websocket represents a run loop, there is no need to specify *run_id* explicitly.
entailment
def init_interface(): sys.stdout = LoggerWriter(LOGGER.debug) sys.stderr = LoggerWriter(LOGGER.error) """ Grab the ~/.polyglot/.env file for variables If you are running Polyglot v2 on this same machine then it should already exist. If not create it. """ warnings.simplefilter('error', U...
Grab the ~/.polyglot/.env file for variables If you are running Polyglot v2 on this same machine then it should already exist. If not create it.
entailment