repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
qubole/qds-sdk-py
qds_sdk/cluster.py
Cluster.restore_point
def restore_point(cls, cluster_id_label, s3_location, backup_id, table_names, overwrite=True, automatic=True): """ Restoring cluster from a given hbase snapshot id """ conn = Qubole.agent(version=Cluster.api_version) parameters = {} parameters['s3_location'] = s3_location...
python
def restore_point(cls, cluster_id_label, s3_location, backup_id, table_names, overwrite=True, automatic=True): """ Restoring cluster from a given hbase snapshot id """ conn = Qubole.agent(version=Cluster.api_version) parameters = {} parameters['s3_location'] = s3_location...
[ "def", "restore_point", "(", "cls", ",", "cluster_id_label", ",", "s3_location", ",", "backup_id", ",", "table_names", ",", "overwrite", "=", "True", ",", "automatic", "=", "True", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", "version", "=", "Cluste...
Restoring cluster from a given hbase snapshot id
[ "Restoring", "cluster", "from", "a", "given", "hbase", "snapshot", "id" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L682-L693
train
qubole/qds-sdk-py
qds_sdk/cluster.py
Cluster.update_snapshot_schedule
def update_snapshot_schedule(cls, cluster_id_label, s3_location=None, frequency_unit=None, frequency_num=None, status=None): """ Update for snapshot schedule """ conn = Qubole.agent(version=Cluster.api_version) data = {} if s3_location is not None: data["s3_l...
python
def update_snapshot_schedule(cls, cluster_id_label, s3_location=None, frequency_unit=None, frequency_num=None, status=None): """ Update for snapshot schedule """ conn = Qubole.agent(version=Cluster.api_version) data = {} if s3_location is not None: data["s3_l...
[ "def", "update_snapshot_schedule", "(", "cls", ",", "cluster_id_label", ",", "s3_location", "=", "None", ",", "frequency_unit", "=", "None", ",", "frequency_num", "=", "None", ",", "status", "=", "None", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ...
Update for snapshot schedule
[ "Update", "for", "snapshot", "schedule" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L704-L719
train
qubole/qds-sdk-py
qds_sdk/cluster.py
ClusterInfo.set_spot_instance_settings
def set_spot_instance_settings(self, maximum_bid_price_percentage=None, timeout_for_request=None, maximum_spot_instance_percentage=None): """ Purchase options for spot instances. Valid only when `slave_request_type` is hybrid ...
python
def set_spot_instance_settings(self, maximum_bid_price_percentage=None, timeout_for_request=None, maximum_spot_instance_percentage=None): """ Purchase options for spot instances. Valid only when `slave_request_type` is hybrid ...
[ "def", "set_spot_instance_settings", "(", "self", ",", "maximum_bid_price_percentage", "=", "None", ",", "timeout_for_request", "=", "None", ",", "maximum_spot_instance_percentage", "=", "None", ")", ":", "self", ".", "hadoop_settings", "[", "'spot_instance_settings'", ...
Purchase options for spot instances. Valid only when `slave_request_type` is hybrid or spot. `maximum_bid_price_percentage`: Maximum value to bid for spot instances, expressed as a percentage of the base price for the slave node instance type. `timeout_for_request`: Tim...
[ "Purchase", "options", "for", "spot", "instances", ".", "Valid", "only", "when", "slave_request_type", "is", "hybrid", "or", "spot", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L883-L904
train
qubole/qds-sdk-py
qds_sdk/cluster.py
ClusterInfo.set_stable_spot_instance_settings
def set_stable_spot_instance_settings(self, maximum_bid_price_percentage=None, timeout_for_request=None, allow_fallback=True): """ Purchase options for stable spot instances. `maximum_bid_price_percentage`: Maxi...
python
def set_stable_spot_instance_settings(self, maximum_bid_price_percentage=None, timeout_for_request=None, allow_fallback=True): """ Purchase options for stable spot instances. `maximum_bid_price_percentage`: Maxi...
[ "def", "set_stable_spot_instance_settings", "(", "self", ",", "maximum_bid_price_percentage", "=", "None", ",", "timeout_for_request", "=", "None", ",", "allow_fallback", "=", "True", ")", ":", "self", ".", "hadoop_settings", "[", "'stable_spot_instance_settings'", "]",...
Purchase options for stable spot instances. `maximum_bid_price_percentage`: Maximum value to bid for stable node spot instances, expressed as a percentage of the base price (applies to both master and slave nodes). `timeout_for_request`: Timeout for a stable node spot instance ...
[ "Purchase", "options", "for", "stable", "spot", "instances", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L907-L926
train
qubole/qds-sdk-py
qds_sdk/cluster.py
ClusterInfoV13.minimal_payload
def minimal_payload(self): """ This method can be used to create the payload which is sent while creating or updating a cluster. """ payload_dict = self.__dict__ payload_dict.pop("api_version", None) return util._make_minimal(payload_dict)
python
def minimal_payload(self): """ This method can be used to create the payload which is sent while creating or updating a cluster. """ payload_dict = self.__dict__ payload_dict.pop("api_version", None) return util._make_minimal(payload_dict)
[ "def", "minimal_payload", "(", "self", ")", ":", "payload_dict", "=", "self", ".", "__dict__", "payload_dict", ".", "pop", "(", "\"api_version\"", ",", "None", ")", "return", "util", ".", "_make_minimal", "(", "payload_dict", ")" ]
This method can be used to create the payload which is sent while creating or updating a cluster.
[ "This", "method", "can", "be", "used", "to", "create", "the", "payload", "which", "is", "sent", "while", "creating", "or", "updating", "a", "cluster", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/cluster.py#L1307-L1314
train
qubole/qds-sdk-py
qds_sdk/connection.py
Connection._handle_error
def _handle_error(response): """Raise exceptions in response to any http errors Args: response: A Response object Raises: BadRequest: if HTTP error code 400 returned. UnauthorizedAccess: if HTTP error code 401 returned. ForbiddenAccess: if HTTP e...
python
def _handle_error(response): """Raise exceptions in response to any http errors Args: response: A Response object Raises: BadRequest: if HTTP error code 400 returned. UnauthorizedAccess: if HTTP error code 401 returned. ForbiddenAccess: if HTTP e...
[ "def", "_handle_error", "(", "response", ")", ":", "code", "=", "response", ".", "status_code", "if", "200", "<=", "code", "<", "400", ":", "return", "if", "code", "==", "400", ":", "sys", ".", "stderr", ".", "write", "(", "response", ".", "text", "+...
Raise exceptions in response to any http errors Args: response: A Response object Raises: BadRequest: if HTTP error code 400 returned. UnauthorizedAccess: if HTTP error code 401 returned. ForbiddenAccess: if HTTP error code 403 returned. Reso...
[ "Raise", "exceptions", "in", "response", "to", "any", "http", "errors" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/connection.py#L111-L165
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.createTemplate
def createTemplate(data): """ Create a new template. Args: `data`: json data required for creating a template Returns: Dictionary containing the details of the template with its ID. """ conn = Qubole.agent() return conn.post(Template.rest_...
python
def createTemplate(data): """ Create a new template. Args: `data`: json data required for creating a template Returns: Dictionary containing the details of the template with its ID. """ conn = Qubole.agent() return conn.post(Template.rest_...
[ "def", "createTemplate", "(", "data", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "return", "conn", ".", "post", "(", "Template", ".", "rest_entity_path", ",", "data", ")" ]
Create a new template. Args: `data`: json data required for creating a template Returns: Dictionary containing the details of the template with its ID.
[ "Create", "a", "new", "template", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L162-L172
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.editTemplate
def editTemplate(id, data): """ Edit an existing template. Args: `id`: ID of the template to edit `data`: json data to be updated Returns: Dictionary containing the updated details of the template. """ conn = Qubole.agent() r...
python
def editTemplate(id, data): """ Edit an existing template. Args: `id`: ID of the template to edit `data`: json data to be updated Returns: Dictionary containing the updated details of the template. """ conn = Qubole.agent() r...
[ "def", "editTemplate", "(", "id", ",", "data", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "return", "conn", ".", "put", "(", "Template", ".", "element_path", "(", "id", ")", ",", "data", ")" ]
Edit an existing template. Args: `id`: ID of the template to edit `data`: json data to be updated Returns: Dictionary containing the updated details of the template.
[ "Edit", "an", "existing", "template", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L175-L186
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.viewTemplate
def viewTemplate(id): """ View an existing Template details. Args: `id`: ID of the template to fetch Returns: Dictionary containing the details of the template. """ conn = Qubole.agent() return conn.get(Template.element_path(id))
python
def viewTemplate(id): """ View an existing Template details. Args: `id`: ID of the template to fetch Returns: Dictionary containing the details of the template. """ conn = Qubole.agent() return conn.get(Template.element_path(id))
[ "def", "viewTemplate", "(", "id", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "return", "conn", ".", "get", "(", "Template", ".", "element_path", "(", "id", ")", ")" ]
View an existing Template details. Args: `id`: ID of the template to fetch Returns: Dictionary containing the details of the template.
[ "View", "an", "existing", "Template", "details", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L204-L215
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.submitTemplate
def submitTemplate(id, data={}): """ Submit an existing Template. Args: `id`: ID of the template to submit `data`: json data containing the input_vars Returns: Dictionary containing Command Object details. """ conn = Qubole.agent() ...
python
def submitTemplate(id, data={}): """ Submit an existing Template. Args: `id`: ID of the template to submit `data`: json data containing the input_vars Returns: Dictionary containing Command Object details. """ conn = Qubole.agent() ...
[ "def", "submitTemplate", "(", "id", ",", "data", "=", "{", "}", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "path", "=", "str", "(", "id", ")", "+", "\"/run\"", "return", "conn", ".", "post", "(", "Template", ".", "element_path", "(", ...
Submit an existing Template. Args: `id`: ID of the template to submit `data`: json data containing the input_vars Returns: Dictionary containing Command Object details.
[ "Submit", "an", "existing", "Template", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L218-L230
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.runTemplate
def runTemplate(id, data={}): """ Run an existing Template and waits for the Result. Prints result to stdout. Args: `id`: ID of the template to run `data`: json data containing the input_vars Returns: An integer as status (0: succe...
python
def runTemplate(id, data={}): """ Run an existing Template and waits for the Result. Prints result to stdout. Args: `id`: ID of the template to run `data`: json data containing the input_vars Returns: An integer as status (0: succe...
[ "def", "runTemplate", "(", "id", ",", "data", "=", "{", "}", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "path", "=", "str", "(", "id", ")", "+", "\"/run\"", "res", "=", "conn", ".", "post", "(", "Template", ".", "element_path", "(",...
Run an existing Template and waits for the Result. Prints result to stdout. Args: `id`: ID of the template to run `data`: json data containing the input_vars Returns: An integer as status (0: success, 1: failure)
[ "Run", "an", "existing", "Template", "and", "waits", "for", "the", "Result", ".", "Prints", "result", "to", "stdout", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L233-L255
train
qubole/qds-sdk-py
qds_sdk/template.py
Template.listTemplates
def listTemplates(data={}): """ Fetch existing Templates details. Args: `data`: dictionary containing the value of page number and per-page value Returns: Dictionary containing paging_info and command_templates details """ conn = Qubole.agent() ...
python
def listTemplates(data={}): """ Fetch existing Templates details. Args: `data`: dictionary containing the value of page number and per-page value Returns: Dictionary containing paging_info and command_templates details """ conn = Qubole.agent() ...
[ "def", "listTemplates", "(", "data", "=", "{", "}", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "url_path", "=", "Template", ".", "rest_entity_path", "page_attr", "=", "[", "]", "if", "\"page\"", "in", "data", "and", "data", "[", "\"page\"...
Fetch existing Templates details. Args: `data`: dictionary containing the value of page number and per-page value Returns: Dictionary containing paging_info and command_templates details
[ "Fetch", "existing", "Templates", "details", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/template.py#L269-L288
train
qubole/qds-sdk-py
qds_sdk/dbtaps.py
DbTapCmdLine.edit
def edit(args): tap = DbTap.find(args.id) """ Carefully setup a dict """ options = {} if not args.name is None: options["db_name"]=args.name if args.host is not None: options["db_host"]=args.host if args.user is not None: options["db_us...
python
def edit(args): tap = DbTap.find(args.id) """ Carefully setup a dict """ options = {} if not args.name is None: options["db_name"]=args.name if args.host is not None: options["db_host"]=args.host if args.user is not None: options["db_us...
[ "def", "edit", "(", "args", ")", ":", "tap", "=", "DbTap", ".", "find", "(", "args", ".", "id", ")", "options", "=", "{", "}", "if", "not", "args", ".", "name", "is", "None", ":", "options", "[", "\"db_name\"", "]", "=", "args", ".", "name", "i...
Carefully setup a dict
[ "Carefully", "setup", "a", "dict" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/dbtaps.py#L135-L154
train
qubole/qds-sdk-py
qds_sdk/app.py
App.create
def create(cls, name, config=None, kind="spark"): """ Create a new app. Args: `name`: the name of the app `config`: a dictionary of key-value pairs `kind`: kind of the app (default=spark) """ conn = Qubole.agent() return conn.post(cl...
python
def create(cls, name, config=None, kind="spark"): """ Create a new app. Args: `name`: the name of the app `config`: a dictionary of key-value pairs `kind`: kind of the app (default=spark) """ conn = Qubole.agent() return conn.post(cl...
[ "def", "create", "(", "cls", ",", "name", ",", "config", "=", "None", ",", "kind", "=", "\"spark\"", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "return", "conn", ".", "post", "(", "cls", ".", "rest_entity_path", ",", "data", "=", "{",...
Create a new app. Args: `name`: the name of the app `config`: a dictionary of key-value pairs `kind`: kind of the app (default=spark)
[ "Create", "a", "new", "app", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/app.py#L127-L140
train
qubole/qds-sdk-py
qds_sdk/qubole.py
Qubole.configure
def configure(cls, api_token, api_url="https://api.qubole.com/api/", version="v1.2", poll_interval=5, skip_ssl_cert_check=False, cloud_name="AWS"): """ Set parameters governing interaction with QDS Args: `api_token`: authorization token for QDS. r...
python
def configure(cls, api_token, api_url="https://api.qubole.com/api/", version="v1.2", poll_interval=5, skip_ssl_cert_check=False, cloud_name="AWS"): """ Set parameters governing interaction with QDS Args: `api_token`: authorization token for QDS. r...
[ "def", "configure", "(", "cls", ",", "api_token", ",", "api_url", "=", "\"https://api.qubole.com/api/\"", ",", "version", "=", "\"v1.2\"", ",", "poll_interval", "=", "5", ",", "skip_ssl_cert_check", "=", "False", ",", "cloud_name", "=", "\"AWS\"", ")", ":", "c...
Set parameters governing interaction with QDS Args: `api_token`: authorization token for QDS. required `api_url`: the base URL for QDS API. configurable for testing only `version`: QDS REST api version. Will be used throughout unless overridden in Qubole.agent(..) ...
[ "Set", "parameters", "governing", "interaction", "with", "QDS" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/qubole.py#L36-L63
train
qubole/qds-sdk-py
qds_sdk/clusterv2.py
ClusterCmdLine.get_cluster_request_parameters
def get_cluster_request_parameters(cluster_info, cloud_config, engine_config): ''' Use this to return final minimal request from cluster_info, cloud_config or engine_config objects Alternatively call util._make_minimal if only one object needs to be implemented ''' cluster_reque...
python
def get_cluster_request_parameters(cluster_info, cloud_config, engine_config): ''' Use this to return final minimal request from cluster_info, cloud_config or engine_config objects Alternatively call util._make_minimal if only one object needs to be implemented ''' cluster_reque...
[ "def", "get_cluster_request_parameters", "(", "cluster_info", ",", "cloud_config", ",", "engine_config", ")", ":", "cluster_request", "=", "{", "}", "cloud_config", "=", "util", ".", "_make_minimal", "(", "cloud_config", ".", "__dict__", ")", "if", "bool", "(", ...
Use this to return final minimal request from cluster_info, cloud_config or engine_config objects Alternatively call util._make_minimal if only one object needs to be implemented
[ "Use", "this", "to", "return", "final", "minimal", "request", "from", "cluster_info", "cloud_config", "or", "engine_config", "objects", "Alternatively", "call", "util", ".", "_make_minimal", "if", "only", "one", "object", "needs", "to", "be", "implemented" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/clusterv2.py#L131-L145
train
qubole/qds-sdk-py
qds_sdk/clusterv2.py
ClusterV2.create
def create(cls, cluster_info): """ Create a new cluster using information provided in `cluster_info`. """ conn = Qubole.agent(version="v2") return conn.post(cls.rest_entity_path, data=cluster_info)
python
def create(cls, cluster_info): """ Create a new cluster using information provided in `cluster_info`. """ conn = Qubole.agent(version="v2") return conn.post(cls.rest_entity_path, data=cluster_info)
[ "def", "create", "(", "cls", ",", "cluster_info", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", "version", "=", "\"v2\"", ")", "return", "conn", ".", "post", "(", "cls", ".", "rest_entity_path", ",", "data", "=", "cluster_info", ")" ]
Create a new cluster using information provided in `cluster_info`.
[ "Create", "a", "new", "cluster", "using", "information", "provided", "in", "cluster_info", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/clusterv2.py#L713-L718
train
qubole/qds-sdk-py
qds_sdk/commands.py
_download_to_local
def _download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=None): ''' Downloads the contents of all objects in s3_path into fp Args: `boto_conn`: S3 connection object `s3_path`: S3 path to be downloaded `fp`: The file object where data is to be downloaded ''' #Pr...
python
def _download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=None): ''' Downloads the contents of all objects in s3_path into fp Args: `boto_conn`: S3 connection object `s3_path`: S3 path to be downloaded `fp`: The file object where data is to be downloaded ''' #Pr...
[ "def", "_download_to_local", "(", "boto_conn", ",", "s3_path", ",", "fp", ",", "num_result_dir", ",", "delim", "=", "None", ")", ":", "#Progress bar to display download progress", "def", "_callback", "(", "downloaded", ",", "total", ")", ":", "'''\n Call func...
Downloads the contents of all objects in s3_path into fp Args: `boto_conn`: S3 connection object `s3_path`: S3 path to be downloaded `fp`: The file object where data is to be downloaded
[ "Downloads", "the", "contents", "of", "all", "objects", "in", "s3_path", "into", "fp" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L1415-L1489
train
qubole/qds-sdk-py
qds_sdk/commands.py
Command.cancel_id
def cancel_id(cls, id): """ Cancels command denoted by this id Args: `id`: command id """ conn = Qubole.agent() data = {"status": "kill"} return conn.put(cls.element_path(id), data)
python
def cancel_id(cls, id): """ Cancels command denoted by this id Args: `id`: command id """ conn = Qubole.agent() data = {"status": "kill"} return conn.put(cls.element_path(id), data)
[ "def", "cancel_id", "(", "cls", ",", "id", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "data", "=", "{", "\"status\"", ":", "\"kill\"", "}", "return", "conn", ".", "put", "(", "cls", ".", "element_path", "(", "id", ")", ",", "data", ...
Cancels command denoted by this id Args: `id`: command id
[ "Cancels", "command", "denoted", "by", "this", "id" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L181-L190
train
qubole/qds-sdk-py
qds_sdk/commands.py
Command.get_log_id
def get_log_id(cls, id): """ Fetches log for the command represented by this id Args: `id`: command id """ conn = Qubole.agent() r = conn.get_raw(cls.element_path(id) + "/logs") return r.text
python
def get_log_id(cls, id): """ Fetches log for the command represented by this id Args: `id`: command id """ conn = Qubole.agent() r = conn.get_raw(cls.element_path(id) + "/logs") return r.text
[ "def", "get_log_id", "(", "cls", ",", "id", ")", ":", "conn", "=", "Qubole", ".", "agent", "(", ")", "r", "=", "conn", ".", "get_raw", "(", "cls", ".", "element_path", "(", "id", ")", "+", "\"/logs\"", ")", "return", "r", ".", "text" ]
Fetches log for the command represented by this id Args: `id`: command id
[ "Fetches", "log", "for", "the", "command", "represented", "by", "this", "id" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L199-L208
train
qubole/qds-sdk-py
qds_sdk/commands.py
Command.get_log
def get_log(self): """ Fetches log for the command represented by this object Returns: The log as a string """ log_path = self.meta_data['logs_resource'] conn = Qubole.agent() r = conn.get_raw(log_path) return r.text
python
def get_log(self): """ Fetches log for the command represented by this object Returns: The log as a string """ log_path = self.meta_data['logs_resource'] conn = Qubole.agent() r = conn.get_raw(log_path) return r.text
[ "def", "get_log", "(", "self", ")", ":", "log_path", "=", "self", ".", "meta_data", "[", "'logs_resource'", "]", "conn", "=", "Qubole", ".", "agent", "(", ")", "r", "=", "conn", ".", "get_raw", "(", "log_path", ")", "return", "r", ".", "text" ]
Fetches log for the command represented by this object Returns: The log as a string
[ "Fetches", "log", "for", "the", "command", "represented", "by", "this", "object" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L210-L220
train
qubole/qds-sdk-py
qds_sdk/commands.py
Command.get_results
def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=None, arguments=[]): """ Fetches the result for the command represented by this object get_results will retrieve results of the command and write to stdout by default. Optionally one can write to a filestream...
python
def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=None, arguments=[]): """ Fetches the result for the command represented by this object get_results will retrieve results of the command and write to stdout by default. Optionally one can write to a filestream...
[ "def", "get_results", "(", "self", ",", "fp", "=", "sys", ".", "stdout", ",", "inline", "=", "True", ",", "delim", "=", "None", ",", "fetch", "=", "True", ",", "qlog", "=", "None", ",", "arguments", "=", "[", "]", ")", ":", "result_path", "=", "s...
Fetches the result for the command represented by this object get_results will retrieve results of the command and write to stdout by default. Optionally one can write to a filestream specified in `fp`. The `inline` argument decides whether the result can be returned as a CRLF separated string....
[ "Fetches", "the", "result", "for", "the", "command", "represented", "by", "this", "object" ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L257-L333
train
qubole/qds-sdk-py
qds_sdk/util.py
pluralize
def pluralize(singular): """Convert singular word to its plural form. Args: singular: A word in its singular form. Returns: The word in its plural form. """ if singular in UNCOUNTABLES: return singular for i in IRREGULAR: if i[0] == singular: return ...
python
def pluralize(singular): """Convert singular word to its plural form. Args: singular: A word in its singular form. Returns: The word in its plural form. """ if singular in UNCOUNTABLES: return singular for i in IRREGULAR: if i[0] == singular: return ...
[ "def", "pluralize", "(", "singular", ")", ":", "if", "singular", "in", "UNCOUNTABLES", ":", "return", "singular", "for", "i", "in", "IRREGULAR", ":", "if", "i", "[", "0", "]", "==", "singular", ":", "return", "i", "[", "1", "]", "for", "i", "in", "...
Convert singular word to its plural form. Args: singular: A word in its singular form. Returns: The word in its plural form.
[ "Convert", "singular", "word", "to", "its", "plural", "form", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/util.py#L85-L101
train
qubole/qds-sdk-py
qds_sdk/util.py
singularize
def singularize(plural): """Convert plural word to its singular form. Args: plural: A word in its plural form. Returns: The word in its singular form. """ if plural in UNCOUNTABLES: return plural for i in IRREGULAR: if i[1] == plural: return i[0] ...
python
def singularize(plural): """Convert plural word to its singular form. Args: plural: A word in its plural form. Returns: The word in its singular form. """ if plural in UNCOUNTABLES: return plural for i in IRREGULAR: if i[1] == plural: return i[0] ...
[ "def", "singularize", "(", "plural", ")", ":", "if", "plural", "in", "UNCOUNTABLES", ":", "return", "plural", "for", "i", "in", "IRREGULAR", ":", "if", "i", "[", "1", "]", "==", "plural", ":", "return", "i", "[", "0", "]", "for", "i", "in", "SINGUL...
Convert plural word to its singular form. Args: plural: A word in its plural form. Returns: The word in its singular form.
[ "Convert", "plural", "word", "to", "its", "singular", "form", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/util.py#L104-L120
train
qubole/qds-sdk-py
qds_sdk/util.py
camelize
def camelize(word): """Convert a word from lower_with_underscores to CamelCase. Args: word: The string to convert. Returns: The modified string. """ return ''.join(w[0].upper() + w[1:] for w in re.sub('[^A-Z^a-z^0-9^:]+', ' ', word).split(' '))
python
def camelize(word): """Convert a word from lower_with_underscores to CamelCase. Args: word: The string to convert. Returns: The modified string. """ return ''.join(w[0].upper() + w[1:] for w in re.sub('[^A-Z^a-z^0-9^:]+', ' ', word).split(' '))
[ "def", "camelize", "(", "word", ")", ":", "return", "''", ".", "join", "(", "w", "[", "0", "]", ".", "upper", "(", ")", "+", "w", "[", "1", ":", "]", "for", "w", "in", "re", ".", "sub", "(", "'[^A-Z^a-z^0-9^:]+'", ",", "' '", ",", "word", ")"...
Convert a word from lower_with_underscores to CamelCase. Args: word: The string to convert. Returns: The modified string.
[ "Convert", "a", "word", "from", "lower_with_underscores", "to", "CamelCase", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/util.py#L123-L132
train
qubole/qds-sdk-py
qds_sdk/util.py
_make_minimal
def _make_minimal(dictionary): """ This function removes all the keys whose value is either None or an empty dictionary. """ new_dict = {} for key, value in dictionary.items(): if value is not None: if isinstance(value, dict): new_value = _make_minimal(value) ...
python
def _make_minimal(dictionary): """ This function removes all the keys whose value is either None or an empty dictionary. """ new_dict = {} for key, value in dictionary.items(): if value is not None: if isinstance(value, dict): new_value = _make_minimal(value) ...
[ "def", "_make_minimal", "(", "dictionary", ")", ":", "new_dict", "=", "{", "}", "for", "key", ",", "value", "in", "dictionary", ".", "items", "(", ")", ":", "if", "value", "is", "not", "None", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ...
This function removes all the keys whose value is either None or an empty dictionary.
[ "This", "function", "removes", "all", "the", "keys", "whose", "value", "is", "either", "None", "or", "an", "empty", "dictionary", "." ]
77210fb64e5a7d567aedeea3b742a1d872fd0e5e
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/util.py#L146-L160
train
iopipe/iopipe-python
iopipe/contrib/profiler/request.py
upload_profiler_report
def upload_profiler_report(url, filename, config): """ Uploads a profiler report to IOpipe :param url: The signed URL :param filename: The profiler report file :param config: The IOpipe config """ try: logger.debug("Uploading profiler report to IOpipe") with open(filename, "...
python
def upload_profiler_report(url, filename, config): """ Uploads a profiler report to IOpipe :param url: The signed URL :param filename: The profiler report file :param config: The IOpipe config """ try: logger.debug("Uploading profiler report to IOpipe") with open(filename, "...
[ "def", "upload_profiler_report", "(", "url", ",", "filename", ",", "config", ")", ":", "try", ":", "logger", ".", "debug", "(", "\"Uploading profiler report to IOpipe\"", ")", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "data", ":", "response", ...
Uploads a profiler report to IOpipe :param url: The signed URL :param filename: The profiler report file :param config: The IOpipe config
[ "Uploads", "a", "profiler", "report", "to", "IOpipe" ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/contrib/profiler/request.py#L12-L33
train
iopipe/iopipe-python
iopipe/mock_system.py
read_pid_stat
def read_pid_stat(pid): """ Mocks read_pid_stat as this is a Linux-specific operation. """ return { "utime": random.randint(0, 999999999), "stime": random.randint(0, 999999999), "cutime": random.randint(0, 999999999), "cstime": random.randint(0, 999999999), }
python
def read_pid_stat(pid): """ Mocks read_pid_stat as this is a Linux-specific operation. """ return { "utime": random.randint(0, 999999999), "stime": random.randint(0, 999999999), "cutime": random.randint(0, 999999999), "cstime": random.randint(0, 999999999), }
[ "def", "read_pid_stat", "(", "pid", ")", ":", "return", "{", "\"utime\"", ":", "random", ".", "randint", "(", "0", ",", "999999999", ")", ",", "\"stime\"", ":", "random", ".", "randint", "(", "0", ",", "999999999", ")", ",", "\"cutime\"", ":", "random"...
Mocks read_pid_stat as this is a Linux-specific operation.
[ "Mocks", "read_pid_stat", "as", "this", "is", "a", "Linux", "-", "specific", "operation", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/mock_system.py#L40-L49
train
iopipe/iopipe-python
iopipe/mock_system.py
read_stat
def read_stat(): """ Mocks read_stat as this is a Linux-specific operation. """ return [ { "times": { "user": random.randint(0, 999999999), "nice": random.randint(0, 999999999), "sys": random.randint(0, 999999999), "idle...
python
def read_stat(): """ Mocks read_stat as this is a Linux-specific operation. """ return [ { "times": { "user": random.randint(0, 999999999), "nice": random.randint(0, 999999999), "sys": random.randint(0, 999999999), "idle...
[ "def", "read_stat", "(", ")", ":", "return", "[", "{", "\"times\"", ":", "{", "\"user\"", ":", "random", ".", "randint", "(", "0", ",", "999999999", ")", ",", "\"nice\"", ":", "random", ".", "randint", "(", "0", ",", "999999999", ")", ",", "\"sys\"",...
Mocks read_stat as this is a Linux-specific operation.
[ "Mocks", "read_stat", "as", "this", "is", "a", "Linux", "-", "specific", "operation", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/mock_system.py#L63-L77
train
iopipe/iopipe-python
iopipe/agent.py
IOpipeCore.load_plugins
def load_plugins(self, plugins): """ Loads plugins that match the `Plugin` interface and are instantiated. :param plugins: A list of plugin instances. """ def instantiate(plugin): return plugin() if inspect.isclass(plugin) else plugin loaded_plugins = [] ...
python
def load_plugins(self, plugins): """ Loads plugins that match the `Plugin` interface and are instantiated. :param plugins: A list of plugin instances. """ def instantiate(plugin): return plugin() if inspect.isclass(plugin) else plugin loaded_plugins = [] ...
[ "def", "load_plugins", "(", "self", ",", "plugins", ")", ":", "def", "instantiate", "(", "plugin", ")", ":", "return", "plugin", "(", ")", "if", "inspect", ".", "isclass", "(", "plugin", ")", "else", "plugin", "loaded_plugins", "=", "[", "]", "plugins_se...
Loads plugins that match the `Plugin` interface and are instantiated. :param plugins: A list of plugin instances.
[ "Loads", "plugins", "that", "match", "the", "Plugin", "interface", "and", "are", "instantiated", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/agent.py#L198-L220
train
iopipe/iopipe-python
iopipe/agent.py
IOpipeCore.run_hooks
def run_hooks(self, name, event=None, context=None): """ Runs plugin hooks for each registered plugin. """ hooks = { "pre:setup": lambda p: p.pre_setup(self), "post:setup": lambda p: p.post_setup(self), "pre:invoke": lambda p: p.pre_invoke(event, conte...
python
def run_hooks(self, name, event=None, context=None): """ Runs plugin hooks for each registered plugin. """ hooks = { "pre:setup": lambda p: p.pre_setup(self), "post:setup": lambda p: p.post_setup(self), "pre:invoke": lambda p: p.pre_invoke(event, conte...
[ "def", "run_hooks", "(", "self", ",", "name", ",", "event", "=", "None", ",", "context", "=", "None", ")", ":", "hooks", "=", "{", "\"pre:setup\"", ":", "lambda", "p", ":", "p", ".", "pre_setup", "(", "self", ")", ",", "\"post:setup\"", ":", "lambda"...
Runs plugin hooks for each registered plugin.
[ "Runs", "plugin", "hooks", "for", "each", "registered", "plugin", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/agent.py#L222-L244
train
iopipe/iopipe-python
iopipe/agent.py
IOpipeCore.wait_for_futures
def wait_for_futures(self): """ Wait for all futures to complete. This should be done at the end of an an invocation. """ [future for future in futures.as_completed(self.futures)] self.futures = []
python
def wait_for_futures(self): """ Wait for all futures to complete. This should be done at the end of an an invocation. """ [future for future in futures.as_completed(self.futures)] self.futures = []
[ "def", "wait_for_futures", "(", "self", ")", ":", "[", "future", "for", "future", "in", "futures", ".", "as_completed", "(", "self", ".", "futures", ")", "]", "self", ".", "futures", "=", "[", "]" ]
Wait for all futures to complete. This should be done at the end of an an invocation.
[ "Wait", "for", "all", "futures", "to", "complete", ".", "This", "should", "be", "done", "at", "the", "end", "of", "an", "an", "invocation", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/agent.py#L260-L266
train
iopipe/iopipe-python
iopipe/agent.py
IOpipeCore.validate_context
def validate_context(self, context): """ Checks to see if we're working with a valid lambda context object. :returns: True if valid, False if not :rtype: bool """ return all( [ hasattr(context, attr) for attr in [ ...
python
def validate_context(self, context): """ Checks to see if we're working with a valid lambda context object. :returns: True if valid, False if not :rtype: bool """ return all( [ hasattr(context, attr) for attr in [ ...
[ "def", "validate_context", "(", "self", ",", "context", ")", ":", "return", "all", "(", "[", "hasattr", "(", "context", ",", "attr", ")", "for", "attr", "in", "[", "\"aws_request_id\"", ",", "\"function_name\"", ",", "\"function_version\"", ",", "\"get_remaini...
Checks to see if we're working with a valid lambda context object. :returns: True if valid, False if not :rtype: bool
[ "Checks", "to", "see", "if", "we", "re", "working", "with", "a", "valid", "lambda", "context", "object", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/agent.py#L268-L289
train
iopipe/iopipe-python
iopipe/contrib/trace/auto_http.py
patch_session_send
def patch_session_send(context, http_filter): """ Monkey patches requests' Session class, if available. Overloads the send method to add tracing and metrics collection. """ if Session is None: return def send(self, *args, **kwargs): id = ensure_utf8(str(uuid.uuid4())) wi...
python
def patch_session_send(context, http_filter): """ Monkey patches requests' Session class, if available. Overloads the send method to add tracing and metrics collection. """ if Session is None: return def send(self, *args, **kwargs): id = ensure_utf8(str(uuid.uuid4())) wi...
[ "def", "patch_session_send", "(", "context", ",", "http_filter", ")", ":", "if", "Session", "is", "None", ":", "return", "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "id", "=", "ensure_utf8", "(", "str", "(", "uuid...
Monkey patches requests' Session class, if available. Overloads the send method to add tracing and metrics collection.
[ "Monkey", "patches", "requests", "Session", "class", "if", "available", ".", "Overloads", "the", "send", "method", "to", "add", "tracing", "and", "metrics", "collection", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/contrib/trace/auto_http.py#L63-L80
train
iopipe/iopipe-python
iopipe/contrib/trace/auto_http.py
patch_botocore_session_send
def patch_botocore_session_send(context, http_filter): """ Monkey patches botocore's vendored requests, if available. Overloads the Session class' send method to add tracing and metric collection. """ if BotocoreSession is None: return def send(self, *args, **kwargs): id = str(u...
python
def patch_botocore_session_send(context, http_filter): """ Monkey patches botocore's vendored requests, if available. Overloads the Session class' send method to add tracing and metric collection. """ if BotocoreSession is None: return def send(self, *args, **kwargs): id = str(u...
[ "def", "patch_botocore_session_send", "(", "context", ",", "http_filter", ")", ":", "if", "BotocoreSession", "is", "None", ":", "return", "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "id", "=", "str", "(", "uuid", "....
Monkey patches botocore's vendored requests, if available. Overloads the Session class' send method to add tracing and metric collection.
[ "Monkey", "patches", "botocore", "s", "vendored", "requests", "if", "available", ".", "Overloads", "the", "Session", "class", "send", "method", "to", "add", "tracing", "and", "metric", "collection", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/contrib/trace/auto_http.py#L83-L100
train
iopipe/iopipe-python
iopipe/contrib/trace/auto_http.py
collect_metrics_for_response
def collect_metrics_for_response(http_response, context, trace, http_filter): """ Collects relevant metrics from a requests Response object and adds them to the IOpipe context. """ http_response = copy.deepcopy(http_response) if http_filter is not None and callable(http_filter): http_res...
python
def collect_metrics_for_response(http_response, context, trace, http_filter): """ Collects relevant metrics from a requests Response object and adds them to the IOpipe context. """ http_response = copy.deepcopy(http_response) if http_filter is not None and callable(http_filter): http_res...
[ "def", "collect_metrics_for_response", "(", "http_response", ",", "context", ",", "trace", ",", "http_filter", ")", ":", "http_response", "=", "copy", ".", "deepcopy", "(", "http_response", ")", "if", "http_filter", "is", "not", "None", "and", "callable", "(", ...
Collects relevant metrics from a requests Response object and adds them to the IOpipe context.
[ "Collects", "relevant", "metrics", "from", "a", "requests", "Response", "object", "and", "adds", "them", "to", "the", "IOpipe", "context", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/contrib/trace/auto_http.py#L125-L178
train
iopipe/iopipe-python
iopipe/plugins.py
get_plugin_meta
def get_plugin_meta(plugins): """ Returns meta data about plugins. :param plugins: A list of plugins. :type plugins: list :returns: A list of dicts containing plugin meta data. :rtype: list """ return [ { "name": p.name, "version": p.version, ...
python
def get_plugin_meta(plugins): """ Returns meta data about plugins. :param plugins: A list of plugins. :type plugins: list :returns: A list of dicts containing plugin meta data. :rtype: list """ return [ { "name": p.name, "version": p.version, ...
[ "def", "get_plugin_meta", "(", "plugins", ")", ":", "return", "[", "{", "\"name\"", ":", "p", ".", "name", ",", "\"version\"", ":", "p", ".", "version", ",", "\"homepage\"", ":", "p", ".", "homepage", ",", "\"enabled\"", ":", "p", ".", "enabled", ",", ...
Returns meta data about plugins. :param plugins: A list of plugins. :type plugins: list :returns: A list of dicts containing plugin meta data. :rtype: list
[ "Returns", "meta", "data", "about", "plugins", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/plugins.py#L4-L22
train
iopipe/iopipe-python
iopipe/plugins.py
is_plugin
def is_plugin(plugin): """ Returns true if the plugin implements the `Plugin` interface. :param plugin: The plugin to check. :returns: True if plugin, False otherwise. :rtype: bool """ try: return isinstance(plugin, Plugin) or issubclass(plugin, Plugin) except TypeError: ...
python
def is_plugin(plugin): """ Returns true if the plugin implements the `Plugin` interface. :param plugin: The plugin to check. :returns: True if plugin, False otherwise. :rtype: bool """ try: return isinstance(plugin, Plugin) or issubclass(plugin, Plugin) except TypeError: ...
[ "def", "is_plugin", "(", "plugin", ")", ":", "try", ":", "return", "isinstance", "(", "plugin", ",", "Plugin", ")", "or", "issubclass", "(", "plugin", ",", "Plugin", ")", "except", "TypeError", ":", "return", "False" ]
Returns true if the plugin implements the `Plugin` interface. :param plugin: The plugin to check. :returns: True if plugin, False otherwise. :rtype: bool
[ "Returns", "true", "if", "the", "plugin", "implements", "the", "Plugin", "interface", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/plugins.py#L25-L36
train
iopipe/iopipe-python
iopipe/plugins.py
with_metaclass
def with_metaclass(meta, *bases): """Python 2 and 3 compatible way to do meta classes""" class metaclass(meta): def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, "temporary_class", (), {})
python
def with_metaclass(meta, *bases): """Python 2 and 3 compatible way to do meta classes""" class metaclass(meta): def __new__(cls, name, this_bases, d): return meta(name, bases, d) return type.__new__(metaclass, "temporary_class", (), {})
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "class", "metaclass", "(", "meta", ")", ":", "def", "__new__", "(", "cls", ",", "name", ",", "this_bases", ",", "d", ")", ":", "return", "meta", "(", "name", ",", "bases", ",", "d",...
Python 2 and 3 compatible way to do meta classes
[ "Python", "2", "and", "3", "compatible", "way", "to", "do", "meta", "classes" ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/plugins.py#L39-L46
train
iopipe/iopipe-python
iopipe/report.py
Report.extract_context_data
def extract_context_data(self): """ Returns the contents of a AWS Lambda context. :returns: A dict of relevant context data. :rtype: dict """ data = {} for k, v in { # camel case names in the report to align with AWS standards "functionNam...
python
def extract_context_data(self): """ Returns the contents of a AWS Lambda context. :returns: A dict of relevant context data. :rtype: dict """ data = {} for k, v in { # camel case names in the report to align with AWS standards "functionNam...
[ "def", "extract_context_data", "(", "self", ")", ":", "data", "=", "{", "}", "for", "k", ",", "v", "in", "{", "# camel case names in the report to align with AWS standards", "\"functionName\"", ":", "\"function_name\"", ",", "\"functionVersion\"", ":", "\"function_versi...
Returns the contents of a AWS Lambda context. :returns: A dict of relevant context data. :rtype: dict
[ "Returns", "the", "contents", "of", "a", "AWS", "Lambda", "context", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/report.py#L82-L117
train
iopipe/iopipe-python
iopipe/report.py
Report.retain_error
def retain_error(self, error, frame=None): """ Adds details of an error to the report. :param error: The error exception to add to the report. """ if frame is None: stack = traceback.format_exc() self.labels.add("@iopipe/error") else: ...
python
def retain_error(self, error, frame=None): """ Adds details of an error to the report. :param error: The error exception to add to the report. """ if frame is None: stack = traceback.format_exc() self.labels.add("@iopipe/error") else: ...
[ "def", "retain_error", "(", "self", ",", "error", ",", "frame", "=", "None", ")", ":", "if", "frame", "is", "None", ":", "stack", "=", "traceback", ".", "format_exc", "(", ")", "self", ".", "labels", ".", "add", "(", "\"@iopipe/error\"", ")", "else", ...
Adds details of an error to the report. :param error: The error exception to add to the report.
[ "Adds", "details", "of", "an", "error", "to", "the", "report", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/report.py#L119-L136
train
iopipe/iopipe-python
iopipe/report.py
Report.prepare
def prepare(self, error=None, frame=None): """ Prepare the report to be sent to IOpipe. :param error: An optional error to add to report. :param frame: A stack frame to add to report in the event of a timeout. """ if error: self.retain_error(error, frame) ...
python
def prepare(self, error=None, frame=None): """ Prepare the report to be sent to IOpipe. :param error: An optional error to add to report. :param frame: A stack frame to add to report in the event of a timeout. """ if error: self.retain_error(error, frame) ...
[ "def", "prepare", "(", "self", ",", "error", "=", "None", ",", "frame", "=", "None", ")", ":", "if", "error", ":", "self", ".", "retain_error", "(", "error", ",", "frame", ")", "self", ".", "report", "[", "\"environment\"", "]", "[", "\"host\"", "]",...
Prepare the report to be sent to IOpipe. :param error: An optional error to add to report. :param frame: A stack frame to add to report in the event of a timeout.
[ "Prepare", "the", "report", "to", "be", "sent", "to", "IOpipe", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/report.py#L138-L182
train
iopipe/iopipe-python
iopipe/report.py
Report.send
def send(self): """ Sends the report to IOpipe. """ if self.sent is True: return self.sent = True logger.debug("Sending report to IOpipe:") logger.debug(json.dumps(self.report, indent=2, sort_keys=True)) self.client.submit_future(send_report,...
python
def send(self): """ Sends the report to IOpipe. """ if self.sent is True: return self.sent = True logger.debug("Sending report to IOpipe:") logger.debug(json.dumps(self.report, indent=2, sort_keys=True)) self.client.submit_future(send_report,...
[ "def", "send", "(", "self", ")", ":", "if", "self", ".", "sent", "is", "True", ":", "return", "self", ".", "sent", "=", "True", "logger", ".", "debug", "(", "\"Sending report to IOpipe:\"", ")", "logger", ".", "debug", "(", "json", ".", "dumps", "(", ...
Sends the report to IOpipe.
[ "Sends", "the", "report", "to", "IOpipe", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/report.py#L184-L195
train
iopipe/iopipe-python
iopipe/send_report.py
send_report
def send_report(report, config): """ Sends the report to IOpipe's collector. :param report: The report to be sent. :param config: The IOpipe agent configuration. """ headers = {"Authorization": "Bearer {}".format(config["token"])} url = "https://{host}{path}".format(**config) try: ...
python
def send_report(report, config): """ Sends the report to IOpipe's collector. :param report: The report to be sent. :param config: The IOpipe agent configuration. """ headers = {"Authorization": "Bearer {}".format(config["token"])} url = "https://{host}{path}".format(**config) try: ...
[ "def", "send_report", "(", "report", ",", "config", ")", ":", "headers", "=", "{", "\"Authorization\"", ":", "\"Bearer {}\"", ".", "format", "(", "config", "[", "\"token\"", "]", ")", "}", "url", "=", "\"https://{host}{path}\"", ".", "format", "(", "*", "*...
Sends the report to IOpipe's collector. :param report: The report to be sent. :param config: The IOpipe agent configuration.
[ "Sends", "the", "report", "to", "IOpipe", "s", "collector", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/send_report.py#L12-L30
train
iopipe/iopipe-python
iopipe/contrib/logger/request.py
upload_log_data
def upload_log_data(url, stream_or_file, config): """ Uploads log data to IOpipe. :param url: The signed URL :param stream_or_file: The log data stream or file :param config: The IOpipe config """ try: logger.debug("Uploading log data to IOpipe") if isinstance(stream_or_file...
python
def upload_log_data(url, stream_or_file, config): """ Uploads log data to IOpipe. :param url: The signed URL :param stream_or_file: The log data stream or file :param config: The IOpipe config """ try: logger.debug("Uploading log data to IOpipe") if isinstance(stream_or_file...
[ "def", "upload_log_data", "(", "url", ",", "stream_or_file", ",", "config", ")", ":", "try", ":", "logger", ".", "debug", "(", "\"Uploading log data to IOpipe\"", ")", "if", "isinstance", "(", "stream_or_file", ",", "StringIO", ")", ":", "stream_or_file", ".", ...
Uploads log data to IOpipe. :param url: The signed URL :param stream_or_file: The log data stream or file :param config: The IOpipe config
[ "Uploads", "log", "data", "to", "IOpipe", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/contrib/logger/request.py#L14-L44
train
iopipe/iopipe-python
iopipe/signer.py
get_signer_hostname
def get_signer_hostname(): """ Returns the IOpipe signer hostname for a region :returns: The signer hostname :rtype str """ region = os.getenv("AWS_REGION", "") region = region if region and region in SUPPORTED_REGIONS else "us-west-2" return "signer.{region}.iopipe.com".format(region=r...
python
def get_signer_hostname(): """ Returns the IOpipe signer hostname for a region :returns: The signer hostname :rtype str """ region = os.getenv("AWS_REGION", "") region = region if region and region in SUPPORTED_REGIONS else "us-west-2" return "signer.{region}.iopipe.com".format(region=r...
[ "def", "get_signer_hostname", "(", ")", ":", "region", "=", "os", ".", "getenv", "(", "\"AWS_REGION\"", ",", "\"\"", ")", "region", "=", "region", "if", "region", "and", "region", "in", "SUPPORTED_REGIONS", "else", "\"us-west-2\"", "return", "\"signer.{region}.i...
Returns the IOpipe signer hostname for a region :returns: The signer hostname :rtype str
[ "Returns", "the", "IOpipe", "signer", "hostname", "for", "a", "region" ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/signer.py#L15-L24
train
iopipe/iopipe-python
iopipe/signer.py
get_signed_request
def get_signed_request(config, context, extension): """ Returns a signed request URL from IOpipe :param config: The IOpipe config :param context: The AWS context to request a signed URL :param extension: The extension of the file to sign :returns: A signed request URL :rtype: str """ ...
python
def get_signed_request(config, context, extension): """ Returns a signed request URL from IOpipe :param config: The IOpipe config :param context: The AWS context to request a signed URL :param extension: The extension of the file to sign :returns: A signed request URL :rtype: str """ ...
[ "def", "get_signed_request", "(", "config", ",", "context", ",", "extension", ")", ":", "url", "=", "\"https://{hostname}/\"", ".", "format", "(", "hostname", "=", "get_signer_hostname", "(", ")", ")", "try", ":", "logger", ".", "debug", "(", "\"Requesting sig...
Returns a signed request URL from IOpipe :param config: The IOpipe config :param context: The AWS context to request a signed URL :param extension: The extension of the file to sign :returns: A signed request URL :rtype: str
[ "Returns", "a", "signed", "request", "URL", "from", "IOpipe" ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/signer.py#L27-L60
train
iopipe/iopipe-python
acceptance/serverless-layers/handler.py
handler
def handler(event, context): """Sample pure Lambda function Parameters ---------- event: dict, required API Gateway Lambda Proxy Input Format { "resource": "Resource path", "path": "Path parameter", "httpMethod": "Incoming request's method name" ...
python
def handler(event, context): """Sample pure Lambda function Parameters ---------- event: dict, required API Gateway Lambda Proxy Input Format { "resource": "Resource path", "path": "Path parameter", "httpMethod": "Incoming request's method name" ...
[ "def", "handler", "(", "event", ",", "context", ")", ":", "try", ":", "ip", "=", "requests", ".", "get", "(", "\"http://checkip.amazonaws.com/\"", ")", "except", "requests", ".", "RequestException", "as", "e", ":", "# Send some context about this error to Lambda Log...
Sample pure Lambda function Parameters ---------- event: dict, required API Gateway Lambda Proxy Input Format { "resource": "Resource path", "path": "Path parameter", "httpMethod": "Incoming request's method name" "headers": {Incoming request...
[ "Sample", "pure", "Lambda", "function" ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/acceptance/serverless-layers/handler.py#L6-L87
train
iopipe/iopipe-python
iopipe/system.py
read_meminfo
def read_meminfo(): """ Returns system memory usage information. :returns: The system memory usage. :rtype: dict """ data = {} with open("/proc/meminfo", "rb") as meminfo_file: for row in meminfo_file: fields = row.split() # Example content: # Mem...
python
def read_meminfo(): """ Returns system memory usage information. :returns: The system memory usage. :rtype: dict """ data = {} with open("/proc/meminfo", "rb") as meminfo_file: for row in meminfo_file: fields = row.split() # Example content: # Mem...
[ "def", "read_meminfo", "(", ")", ":", "data", "=", "{", "}", "with", "open", "(", "\"/proc/meminfo\"", ",", "\"rb\"", ")", "as", "meminfo_file", ":", "for", "row", "in", "meminfo_file", ":", "fields", "=", "row", ".", "split", "(", ")", "# Example conten...
Returns system memory usage information. :returns: The system memory usage. :rtype: dict
[ "Returns", "system", "memory", "usage", "information", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/system.py#L50-L67
train
iopipe/iopipe-python
iopipe/system.py
read_pid_stat
def read_pid_stat(pid="self"): """ Returns system process stat information. :param pid: The process ID. :returns: The system stat information. :rtype: dict """ with open("/proc/%s/stat" % (pid,), "rb") as f: stat = f.readline().split() return { "utime": int(stat[13]), ...
python
def read_pid_stat(pid="self"): """ Returns system process stat information. :param pid: The process ID. :returns: The system stat information. :rtype: dict """ with open("/proc/%s/stat" % (pid,), "rb") as f: stat = f.readline().split() return { "utime": int(stat[13]), ...
[ "def", "read_pid_stat", "(", "pid", "=", "\"self\"", ")", ":", "with", "open", "(", "\"/proc/%s/stat\"", "%", "(", "pid", ",", ")", ",", "\"rb\"", ")", "as", "f", ":", "stat", "=", "f", ".", "readline", "(", ")", ".", "split", "(", ")", "return", ...
Returns system process stat information. :param pid: The process ID. :returns: The system stat information. :rtype: dict
[ "Returns", "system", "process", "stat", "information", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/system.py#L70-L85
train
iopipe/iopipe-python
iopipe/system.py
read_pid_status
def read_pid_status(pid="self"): """ Returns the system process sstatus. :param pid: The process ID. :returns: The system process status. :rtype: dict """ data = {} with open("/proc/%s/status" % (pid,), "rb") as status_file: for row in status_file: fields = row.split...
python
def read_pid_status(pid="self"): """ Returns the system process sstatus. :param pid: The process ID. :returns: The system process status. :rtype: dict """ data = {} with open("/proc/%s/status" % (pid,), "rb") as status_file: for row in status_file: fields = row.split...
[ "def", "read_pid_status", "(", "pid", "=", "\"self\"", ")", ":", "data", "=", "{", "}", "with", "open", "(", "\"/proc/%s/status\"", "%", "(", "pid", ",", ")", ",", "\"rb\"", ")", "as", "status_file", ":", "for", "row", "in", "status_file", ":", "fields...
Returns the system process sstatus. :param pid: The process ID. :returns: The system process status. :rtype: dict
[ "Returns", "the", "system", "process", "sstatus", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/system.py#L88-L105
train
iopipe/iopipe-python
iopipe/system.py
read_stat
def read_stat(): """ Returns the system stat information. :returns: The system stat information. :rtype: list """ data = [] with open("/proc/stat", "rb") as stat_file: for line in stat_file: cpu_stat = line.split() if cpu_stat[0][:3] != b"cpu": ...
python
def read_stat(): """ Returns the system stat information. :returns: The system stat information. :rtype: list """ data = [] with open("/proc/stat", "rb") as stat_file: for line in stat_file: cpu_stat = line.split() if cpu_stat[0][:3] != b"cpu": ...
[ "def", "read_stat", "(", ")", ":", "data", "=", "[", "]", "with", "open", "(", "\"/proc/stat\"", ",", "\"rb\"", ")", "as", "stat_file", ":", "for", "line", "in", "stat_file", ":", "cpu_stat", "=", "line", ".", "split", "(", ")", "if", "cpu_stat", "["...
Returns the system stat information. :returns: The system stat information. :rtype: list
[ "Returns", "the", "system", "stat", "information", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/system.py#L108-L135
train
iopipe/iopipe-python
iopipe/config.py
set_config
def set_config(**config): """ Returns IOpipe configuration options, setting defaults as necessary. """ config.setdefault("debug", bool(strtobool(os.getenv("IOPIPE_DEBUG", "false")))) config.setdefault("enabled", bool(strtobool(os.getenv("IOPIPE_ENABLED", "true")))) config.setdefault("host", get_...
python
def set_config(**config): """ Returns IOpipe configuration options, setting defaults as necessary. """ config.setdefault("debug", bool(strtobool(os.getenv("IOPIPE_DEBUG", "false")))) config.setdefault("enabled", bool(strtobool(os.getenv("IOPIPE_ENABLED", "true")))) config.setdefault("host", get_...
[ "def", "set_config", "(", "*", "*", "config", ")", ":", "config", ".", "setdefault", "(", "\"debug\"", ",", "bool", "(", "strtobool", "(", "os", ".", "getenv", "(", "\"IOPIPE_DEBUG\"", ",", "\"false\"", ")", ")", ")", ")", "config", ".", "setdefault", ...
Returns IOpipe configuration options, setting defaults as necessary.
[ "Returns", "IOpipe", "configuration", "options", "setting", "defaults", "as", "necessary", "." ]
4eb653977341bc67f8b1b87aedb3aaaefc25af61
https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/config.py#L8-L59
train
pief/python-netsnmpagent
netsnmpapi.py
b
def b(s): """ Encodes Unicode strings to byte strings, if necessary. """ return s if isinstance(s, bytes) else s.encode(locale.getpreferredencoding())
python
def b(s): """ Encodes Unicode strings to byte strings, if necessary. """ return s if isinstance(s, bytes) else s.encode(locale.getpreferredencoding())
[ "def", "b", "(", "s", ")", ":", "return", "s", "if", "isinstance", "(", "s", ",", "bytes", ")", "else", "s", ".", "encode", "(", "locale", ".", "getpreferredencoding", "(", ")", ")" ]
Encodes Unicode strings to byte strings, if necessary.
[ "Encodes", "Unicode", "strings", "to", "byte", "strings", "if", "necessary", "." ]
b1aad1c7f034509c40d9ab17d59be32e809bd31d
https://github.com/pief/python-netsnmpagent/blob/b1aad1c7f034509c40d9ab17d59be32e809bd31d/netsnmpapi.py#L16-L19
train
pief/python-netsnmpagent
examples/threading_agent.py
LogMsg
def LogMsg(msg): """ Writes a formatted log message with a timestamp to stdout. """ global headerlogged if headerlogged == 0: print("{0:<8} {1:<90} {2}".format( "Time", "MainThread", "UpdateSNMPObjsThread" )) print("{0:-^120}".format("-")) headerlogged = 1 threadname = threading.currentThread()....
python
def LogMsg(msg): """ Writes a formatted log message with a timestamp to stdout. """ global headerlogged if headerlogged == 0: print("{0:<8} {1:<90} {2}".format( "Time", "MainThread", "UpdateSNMPObjsThread" )) print("{0:-^120}".format("-")) headerlogged = 1 threadname = threading.currentThread()....
[ "def", "LogMsg", "(", "msg", ")", ":", "global", "headerlogged", "if", "headerlogged", "==", "0", ":", "print", "(", "\"{0:<8} {1:<90} {2}\"", ".", "format", "(", "\"Time\"", ",", "\"MainThread\"", ",", "\"UpdateSNMPObjsThread\"", ")", ")", "print", "(", "\"{0...
Writes a formatted log message with a timestamp to stdout.
[ "Writes", "a", "formatted", "log", "message", "with", "a", "timestamp", "to", "stdout", "." ]
b1aad1c7f034509c40d9ab17d59be32e809bd31d
https://github.com/pief/python-netsnmpagent/blob/b1aad1c7f034509c40d9ab17d59be32e809bd31d/examples/threading_agent.py#L70-L104
train
pief/python-netsnmpagent
examples/threading_agent.py
UpdateSNMPObjs
def UpdateSNMPObjs(): """ Function that does the actual data update. """ global threadingString LogMsg("Beginning data update.") data = "" # Obtain the data by calling an external command. We don't use # subprocess.check_output() here for compatibility with Python versions # older than 2.7. LogMsg("Calling e...
python
def UpdateSNMPObjs(): """ Function that does the actual data update. """ global threadingString LogMsg("Beginning data update.") data = "" # Obtain the data by calling an external command. We don't use # subprocess.check_output() here for compatibility with Python versions # older than 2.7. LogMsg("Calling e...
[ "def", "UpdateSNMPObjs", "(", ")", ":", "global", "threadingString", "LogMsg", "(", "\"Beginning data update.\"", ")", "data", "=", "\"\"", "# Obtain the data by calling an external command. We don't use", "# subprocess.check_output() here for compatibility with Python versions", "# ...
Function that does the actual data update.
[ "Function", "that", "does", "the", "actual", "data", "update", "." ]
b1aad1c7f034509c40d9ab17d59be32e809bd31d
https://github.com/pief/python-netsnmpagent/blob/b1aad1c7f034509c40d9ab17d59be32e809bd31d/examples/threading_agent.py#L131-L157
train
pief/python-netsnmpagent
netsnmpagent.py
netsnmpAgent.getRegistered
def getRegistered(self, context = ""): """ Returns a dictionary with the currently registered SNMP objects. Returned is a dictionary objects for the specified "context", which defaults to the default context. """ myobjs = {} try: # Python 2.x objs_iterator = self._objs[context].iteritems() ex...
python
def getRegistered(self, context = ""): """ Returns a dictionary with the currently registered SNMP objects. Returned is a dictionary objects for the specified "context", which defaults to the default context. """ myobjs = {} try: # Python 2.x objs_iterator = self._objs[context].iteritems() ex...
[ "def", "getRegistered", "(", "self", ",", "context", "=", "\"\"", ")", ":", "myobjs", "=", "{", "}", "try", ":", "# Python 2.x", "objs_iterator", "=", "self", ".", "_objs", "[", "context", "]", ".", "iteritems", "(", ")", "except", "AttributeError", ":",...
Returns a dictionary with the currently registered SNMP objects. Returned is a dictionary objects for the specified "context", which defaults to the default context.
[ "Returns", "a", "dictionary", "with", "the", "currently", "registered", "SNMP", "objects", "." ]
b1aad1c7f034509c40d9ab17d59be32e809bd31d
https://github.com/pief/python-netsnmpagent/blob/b1aad1c7f034509c40d9ab17d59be32e809bd31d/netsnmpagent.py#L696-L713
train
pief/python-netsnmpagent
netsnmpagent.py
netsnmpAgent.start
def start(self): """ Starts the agent. Among other things, this means connecting to the master agent, if configured that way. """ if self._status != netsnmpAgentStatus.CONNECTED \ and self._status != netsnmpAgentStatus.RECONNECTING: self._status = netsnmpAgentStatus.FIRSTCONNECT libnsa.init_snmp(b(se...
python
def start(self): """ Starts the agent. Among other things, this means connecting to the master agent, if configured that way. """ if self._status != netsnmpAgentStatus.CONNECTED \ and self._status != netsnmpAgentStatus.RECONNECTING: self._status = netsnmpAgentStatus.FIRSTCONNECT libnsa.init_snmp(b(se...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_status", "!=", "netsnmpAgentStatus", ".", "CONNECTED", "and", "self", ".", "_status", "!=", "netsnmpAgentStatus", ".", "RECONNECTING", ":", "self", ".", "_status", "=", "netsnmpAgentStatus", ".", "F...
Starts the agent. Among other things, this means connecting to the master agent, if configured that way.
[ "Starts", "the", "agent", ".", "Among", "other", "things", "this", "means", "connecting", "to", "the", "master", "agent", "if", "configured", "that", "way", "." ]
b1aad1c7f034509c40d9ab17d59be32e809bd31d
https://github.com/pief/python-netsnmpagent/blob/b1aad1c7f034509c40d9ab17d59be32e809bd31d/netsnmpagent.py#L715-L726
train
tonycpsu/panwid
panwid/scroll.py
Scrollable._adjust_trim_top
def _adjust_trim_top(self, canv, size): """Adjust self._trim_top according to self._scroll_action""" action = self._scroll_action self._scroll_action = None maxcol, maxrow = size trim_top = self._trim_top canv_rows = canv.rows() if trim_top < 0: # Ne...
python
def _adjust_trim_top(self, canv, size): """Adjust self._trim_top according to self._scroll_action""" action = self._scroll_action self._scroll_action = None maxcol, maxrow = size trim_top = self._trim_top canv_rows = canv.rows() if trim_top < 0: # Ne...
[ "def", "_adjust_trim_top", "(", "self", ",", "canv", ",", "size", ")", ":", "action", "=", "self", ".", "_scroll_action", "self", ".", "_scroll_action", "=", "None", "maxcol", ",", "maxrow", "=", "size", "trim_top", "=", "self", ".", "_trim_top", "canv_row...
Adjust self._trim_top according to self._scroll_action
[ "Adjust", "self", ".", "_trim_top", "according", "to", "self", ".", "_scroll_action" ]
e83a1f612cf5c53de88a7180c1b84b3b7b85460a
https://github.com/tonycpsu/panwid/blob/e83a1f612cf5c53de88a7180c1b84b3b7b85460a/panwid/scroll.py#L177-L224
train
tonycpsu/panwid
panwid/scroll.py
Scrollable.rows_max
def rows_max(self, size=None, focus=False): """Return the number of rows for `size` If `size` is not given, the currently rendered number of rows is returned. """ if size is not None: ow = self._original_widget ow_size = self._get_original_widget_size(size) ...
python
def rows_max(self, size=None, focus=False): """Return the number of rows for `size` If `size` is not given, the currently rendered number of rows is returned. """ if size is not None: ow = self._original_widget ow_size = self._get_original_widget_size(size) ...
[ "def", "rows_max", "(", "self", ",", "size", "=", "None", ",", "focus", "=", "False", ")", ":", "if", "size", "is", "not", "None", ":", "ow", "=", "self", ".", "_original_widget", "ow_size", "=", "self", ".", "_get_original_widget_size", "(", "size", "...
Return the number of rows for `size` If `size` is not given, the currently rendered number of rows is returned.
[ "Return", "the", "number", "of", "rows", "for", "size" ]
e83a1f612cf5c53de88a7180c1b84b3b7b85460a
https://github.com/tonycpsu/panwid/blob/e83a1f612cf5c53de88a7180c1b84b3b7b85460a/panwid/scroll.py#L257-L272
train
tonycpsu/panwid
panwid/scroll.py
ScrollBar.scrolling_base_widget
def scrolling_base_widget(self): """Nearest `original_widget` that is compatible with the scrolling API""" def orig_iter(w): while hasattr(w, 'original_widget'): w = w.original_widget yield w yield w def is_scrolling_widget(w): ...
python
def scrolling_base_widget(self): """Nearest `original_widget` that is compatible with the scrolling API""" def orig_iter(w): while hasattr(w, 'original_widget'): w = w.original_widget yield w yield w def is_scrolling_widget(w): ...
[ "def", "scrolling_base_widget", "(", "self", ")", ":", "def", "orig_iter", "(", "w", ")", ":", "while", "hasattr", "(", "w", ",", "'original_widget'", ")", ":", "w", "=", "w", ".", "original_widget", "yield", "w", "yield", "w", "def", "is_scrolling_widget"...
Nearest `original_widget` that is compatible with the scrolling API
[ "Nearest", "original_widget", "that", "is", "compatible", "with", "the", "scrolling", "API" ]
e83a1f612cf5c53de88a7180c1b84b3b7b85460a
https://github.com/tonycpsu/panwid/blob/e83a1f612cf5c53de88a7180c1b84b3b7b85460a/panwid/scroll.py#L389-L403
train
kyuupichan/aiorpcX
aiorpcx/curio.py
ignore_after
def ignore_after(seconds, coro=None, *args, timeout_result=None): '''Execute the specified coroutine and return its result. Issue a cancellation request after seconds have elapsed. When a timeout occurs, no exception is raised. Instead, timeout_result is returned. If coro is None, the result is an ...
python
def ignore_after(seconds, coro=None, *args, timeout_result=None): '''Execute the specified coroutine and return its result. Issue a cancellation request after seconds have elapsed. When a timeout occurs, no exception is raised. Instead, timeout_result is returned. If coro is None, the result is an ...
[ "def", "ignore_after", "(", "seconds", ",", "coro", "=", "None", ",", "*", "args", ",", "timeout_result", "=", "None", ")", ":", "if", "coro", ":", "return", "_ignore_after_func", "(", "seconds", ",", "False", ",", "coro", ",", "args", ",", "timeout_resu...
Execute the specified coroutine and return its result. Issue a cancellation request after seconds have elapsed. When a timeout occurs, no exception is raised. Instead, timeout_result is returned. If coro is None, the result is an asynchronous context manager that applies a timeout to a block of sta...
[ "Execute", "the", "specified", "coroutine", "and", "return", "its", "result", ".", "Issue", "a", "cancellation", "request", "after", "seconds", "have", "elapsed", ".", "When", "a", "timeout", "occurs", "no", "exception", "is", "raised", ".", "Instead", "timeou...
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L392-L411
train
kyuupichan/aiorpcX
aiorpcx/curio.py
TaskGroup._add_task
def _add_task(self, task): '''Add an already existing task to the task group.''' if hasattr(task, '_task_group'): raise RuntimeError('task is already part of a group') if self._closed: raise RuntimeError('task group is closed') task._task_group = self if t...
python
def _add_task(self, task): '''Add an already existing task to the task group.''' if hasattr(task, '_task_group'): raise RuntimeError('task is already part of a group') if self._closed: raise RuntimeError('task group is closed') task._task_group = self if t...
[ "def", "_add_task", "(", "self", ",", "task", ")", ":", "if", "hasattr", "(", "task", ",", "'_task_group'", ")", ":", "raise", "RuntimeError", "(", "'task is already part of a group'", ")", "if", "self", ".", "_closed", ":", "raise", "RuntimeError", "(", "'t...
Add an already existing task to the task group.
[ "Add", "an", "already", "existing", "task", "to", "the", "task", "group", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L118-L129
train
kyuupichan/aiorpcX
aiorpcx/curio.py
TaskGroup.next_done
async def next_done(self): '''Returns the next completed task. Returns None if no more tasks remain. A TaskGroup may also be used as an asynchronous iterator. ''' if not self._done and self._pending: self._done_event.clear() await self._done_event.wait() ...
python
async def next_done(self): '''Returns the next completed task. Returns None if no more tasks remain. A TaskGroup may also be used as an asynchronous iterator. ''' if not self._done and self._pending: self._done_event.clear() await self._done_event.wait() ...
[ "async", "def", "next_done", "(", "self", ")", ":", "if", "not", "self", ".", "_done", "and", "self", ".", "_pending", ":", "self", ".", "_done_event", ".", "clear", "(", ")", "await", "self", ".", "_done_event", ".", "wait", "(", ")", "if", "self", ...
Returns the next completed task. Returns None if no more tasks remain. A TaskGroup may also be used as an asynchronous iterator.
[ "Returns", "the", "next", "completed", "task", ".", "Returns", "None", "if", "no", "more", "tasks", "remain", ".", "A", "TaskGroup", "may", "also", "be", "used", "as", "an", "asynchronous", "iterator", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L155-L164
train
kyuupichan/aiorpcX
aiorpcx/curio.py
TaskGroup.join
async def join(self): '''Wait for tasks in the group to terminate according to the wait policy for the group. If the join() operation itself is cancelled, all remaining tasks in the group are also cancelled. If a TaskGroup is used as a context manager, the join() method ...
python
async def join(self): '''Wait for tasks in the group to terminate according to the wait policy for the group. If the join() operation itself is cancelled, all remaining tasks in the group are also cancelled. If a TaskGroup is used as a context manager, the join() method ...
[ "async", "def", "join", "(", "self", ")", ":", "def", "errored", "(", "task", ")", ":", "return", "not", "task", ".", "cancelled", "(", ")", "and", "task", ".", "exception", "(", ")", "try", ":", "if", "self", ".", "_wait", "in", "(", "all", ",",...
Wait for tasks in the group to terminate according to the wait policy for the group. If the join() operation itself is cancelled, all remaining tasks in the group are also cancelled. If a TaskGroup is used as a context manager, the join() method is called on context-exit. ...
[ "Wait", "for", "tasks", "in", "the", "group", "to", "terminate", "according", "to", "the", "wait", "policy", "for", "the", "group", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L176-L211
train
kyuupichan/aiorpcX
aiorpcx/curio.py
TaskGroup.cancel_remaining
async def cancel_remaining(self): '''Cancel all remaining tasks.''' self._closed = True task_list = list(self._pending) for task in task_list: task.cancel() for task in task_list: with suppress(CancelledError): await task
python
async def cancel_remaining(self): '''Cancel all remaining tasks.''' self._closed = True task_list = list(self._pending) for task in task_list: task.cancel() for task in task_list: with suppress(CancelledError): await task
[ "async", "def", "cancel_remaining", "(", "self", ")", ":", "self", ".", "_closed", "=", "True", "task_list", "=", "list", "(", "self", ".", "_pending", ")", "for", "task", "in", "task_list", ":", "task", ".", "cancel", "(", ")", "for", "task", "in", ...
Cancel all remaining tasks.
[ "Cancel", "all", "remaining", "tasks", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/curio.py#L213-L221
train
kyuupichan/aiorpcX
aiorpcx/socks.py
SOCKSProxy._connect_one
async def _connect_one(self, remote_address): '''Connect to the proxy and perform a handshake requesting a connection. Return the open socket on success, or the exception on failure. ''' loop = asyncio.get_event_loop() for info in await loop.getaddrinfo(str(self.address.host), ...
python
async def _connect_one(self, remote_address): '''Connect to the proxy and perform a handshake requesting a connection. Return the open socket on success, or the exception on failure. ''' loop = asyncio.get_event_loop() for info in await loop.getaddrinfo(str(self.address.host), ...
[ "async", "def", "_connect_one", "(", "self", ",", "remote_address", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "for", "info", "in", "await", "loop", ".", "getaddrinfo", "(", "str", "(", "self", ".", "address", ".", "host", ")", ...
Connect to the proxy and perform a handshake requesting a connection. Return the open socket on success, or the exception on failure.
[ "Connect", "to", "the", "proxy", "and", "perform", "a", "handshake", "requesting", "a", "connection", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/socks.py#L300-L323
train
kyuupichan/aiorpcX
aiorpcx/socks.py
SOCKSProxy._connect
async def _connect(self, remote_addresses): '''Connect to the proxy and perform a handshake requesting a connection to each address in addresses. Return an (open_socket, remote_address) pair on success. ''' assert remote_addresses exceptions = [] for remote_addr...
python
async def _connect(self, remote_addresses): '''Connect to the proxy and perform a handshake requesting a connection to each address in addresses. Return an (open_socket, remote_address) pair on success. ''' assert remote_addresses exceptions = [] for remote_addr...
[ "async", "def", "_connect", "(", "self", ",", "remote_addresses", ")", ":", "assert", "remote_addresses", "exceptions", "=", "[", "]", "for", "remote_address", "in", "remote_addresses", ":", "sock", "=", "await", "self", ".", "_connect_one", "(", "remote_address...
Connect to the proxy and perform a handshake requesting a connection to each address in addresses. Return an (open_socket, remote_address) pair on success.
[ "Connect", "to", "the", "proxy", "and", "perform", "a", "handshake", "requesting", "a", "connection", "to", "each", "address", "in", "addresses", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/socks.py#L325-L342
train
kyuupichan/aiorpcX
aiorpcx/socks.py
SOCKSProxy._detect_proxy
async def _detect_proxy(self): '''Return True if it appears we can connect to a SOCKS proxy, otherwise False. ''' if self.protocol is SOCKS4a: remote_address = NetAddress('www.apple.com', 80) else: remote_address = NetAddress('8.8.8.8', 53) sock =...
python
async def _detect_proxy(self): '''Return True if it appears we can connect to a SOCKS proxy, otherwise False. ''' if self.protocol is SOCKS4a: remote_address = NetAddress('www.apple.com', 80) else: remote_address = NetAddress('8.8.8.8', 53) sock =...
[ "async", "def", "_detect_proxy", "(", "self", ")", ":", "if", "self", ".", "protocol", "is", "SOCKS4a", ":", "remote_address", "=", "NetAddress", "(", "'www.apple.com'", ",", "80", ")", "else", ":", "remote_address", "=", "NetAddress", "(", "'8.8.8.8'", ",",...
Return True if it appears we can connect to a SOCKS proxy, otherwise False.
[ "Return", "True", "if", "it", "appears", "we", "can", "connect", "to", "a", "SOCKS", "proxy", "otherwise", "False", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/socks.py#L344-L360
train
kyuupichan/aiorpcX
aiorpcx/socks.py
SOCKSProxy.auto_detect_at_host
async def auto_detect_at_host(cls, host, ports, auth): '''Try to detect a SOCKS proxy on a host on one of the ports. Calls auto_detect_address for the ports in order. Returning a SOCKSProxy does not mean it is functioning - for example, it may have no network connectivity. If no proxy...
python
async def auto_detect_at_host(cls, host, ports, auth): '''Try to detect a SOCKS proxy on a host on one of the ports. Calls auto_detect_address for the ports in order. Returning a SOCKSProxy does not mean it is functioning - for example, it may have no network connectivity. If no proxy...
[ "async", "def", "auto_detect_at_host", "(", "cls", ",", "host", ",", "ports", ",", "auth", ")", ":", "for", "port", "in", "ports", ":", "proxy", "=", "await", "cls", ".", "auto_detect_at_address", "(", "NetAddress", "(", "host", ",", "port", ")", ",", ...
Try to detect a SOCKS proxy on a host on one of the ports. Calls auto_detect_address for the ports in order. Returning a SOCKSProxy does not mean it is functioning - for example, it may have no network connectivity. If no proxy is detected return None.
[ "Try", "to", "detect", "a", "SOCKS", "proxy", "on", "a", "host", "on", "one", "of", "the", "ports", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/socks.py#L380-L393
train
kyuupichan/aiorpcX
aiorpcx/session.py
Connector.create_connection
async def create_connection(self): '''Initiate a connection.''' connector = self.proxy or self.loop return await connector.create_connection( self.session_factory, self.host, self.port, **self.kwargs)
python
async def create_connection(self): '''Initiate a connection.''' connector = self.proxy or self.loop return await connector.create_connection( self.session_factory, self.host, self.port, **self.kwargs)
[ "async", "def", "create_connection", "(", "self", ")", ":", "connector", "=", "self", ".", "proxy", "or", "self", ".", "loop", "return", "await", "connector", ".", "create_connection", "(", "self", ".", "session_factory", ",", "self", ".", "host", ",", "se...
Initiate a connection.
[ "Initiate", "a", "connection", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L73-L77
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.data_received
def data_received(self, framed_message): '''Called by asyncio when a message comes in.''' if self.verbosity >= 4: self.logger.debug(f'Received framed message {framed_message}') self.recv_size += len(framed_message) self.bump_cost(len(framed_message) * self.bw_cost_per_byte) ...
python
def data_received(self, framed_message): '''Called by asyncio when a message comes in.''' if self.verbosity >= 4: self.logger.debug(f'Received framed message {framed_message}') self.recv_size += len(framed_message) self.bump_cost(len(framed_message) * self.bw_cost_per_byte) ...
[ "def", "data_received", "(", "self", ",", "framed_message", ")", ":", "if", "self", ".", "verbosity", ">=", "4", ":", "self", ".", "logger", ".", "debug", "(", "f'Received framed message {framed_message}'", ")", "self", ".", "recv_size", "+=", "len", "(", "f...
Called by asyncio when a message comes in.
[ "Called", "by", "asyncio", "when", "a", "message", "comes", "in", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L224-L230
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.pause_writing
def pause_writing(self): '''Transport calls when the send buffer is full.''' if not self.is_closing(): self._can_send.clear() self.transport.pause_reading()
python
def pause_writing(self): '''Transport calls when the send buffer is full.''' if not self.is_closing(): self._can_send.clear() self.transport.pause_reading()
[ "def", "pause_writing", "(", "self", ")", ":", "if", "not", "self", ".", "is_closing", "(", ")", ":", "self", ".", "_can_send", ".", "clear", "(", ")", "self", ".", "transport", ".", "pause_reading", "(", ")" ]
Transport calls when the send buffer is full.
[ "Transport", "calls", "when", "the", "send", "buffer", "is", "full", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L232-L236
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.resume_writing
def resume_writing(self): '''Transport calls when the send buffer has room.''' if not self._can_send.is_set(): self._can_send.set() self.transport.resume_reading()
python
def resume_writing(self): '''Transport calls when the send buffer has room.''' if not self._can_send.is_set(): self._can_send.set() self.transport.resume_reading()
[ "def", "resume_writing", "(", "self", ")", ":", "if", "not", "self", ".", "_can_send", ".", "is_set", "(", ")", ":", "self", ".", "_can_send", ".", "set", "(", ")", "self", ".", "transport", ".", "resume_reading", "(", ")" ]
Transport calls when the send buffer has room.
[ "Transport", "calls", "when", "the", "send", "buffer", "has", "room", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L238-L242
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.connection_made
def connection_made(self, transport): '''Called by asyncio when a connection is established. Derived classes overriding this method must call this first.''' self.transport = transport # If the Socks proxy was used then _proxy and _remote_address are already set if self._proxy is...
python
def connection_made(self, transport): '''Called by asyncio when a connection is established. Derived classes overriding this method must call this first.''' self.transport = transport # If the Socks proxy was used then _proxy and _remote_address are already set if self._proxy is...
[ "def", "connection_made", "(", "self", ",", "transport", ")", ":", "self", ".", "transport", "=", "transport", "# If the Socks proxy was used then _proxy and _remote_address are already set", "if", "self", ".", "_proxy", "is", "None", ":", "# This would throw if called on a...
Called by asyncio when a connection is established. Derived classes overriding this method must call this first.
[ "Called", "by", "asyncio", "when", "a", "connection", "is", "established", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L244-L255
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.connection_lost
def connection_lost(self, exc): '''Called by asyncio when the connection closes. Tear down things done in connection_made.''' # Work around uvloop bug; see https://github.com/MagicStack/uvloop/issues/246 if self.transport: self.transport = None self.closed_event....
python
def connection_lost(self, exc): '''Called by asyncio when the connection closes. Tear down things done in connection_made.''' # Work around uvloop bug; see https://github.com/MagicStack/uvloop/issues/246 if self.transport: self.transport = None self.closed_event....
[ "def", "connection_lost", "(", "self", ",", "exc", ")", ":", "# Work around uvloop bug; see https://github.com/MagicStack/uvloop/issues/246", "if", "self", ".", "transport", ":", "self", ".", "transport", "=", "None", "self", ".", "closed_event", ".", "set", "(", ")...
Called by asyncio when the connection closes. Tear down things done in connection_made.
[ "Called", "by", "asyncio", "when", "the", "connection", "closes", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L257-L269
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.recalc_concurrency
def recalc_concurrency(self): '''Call to recalculate sleeps and concurrency for the session. Called automatically if cost has drifted significantly. Otherwise can be called at regular intervals if desired. ''' # Refund resource usage proportionally to elapsed time; the bump pas...
python
def recalc_concurrency(self): '''Call to recalculate sleeps and concurrency for the session. Called automatically if cost has drifted significantly. Otherwise can be called at regular intervals if desired. ''' # Refund resource usage proportionally to elapsed time; the bump pas...
[ "def", "recalc_concurrency", "(", "self", ")", ":", "# Refund resource usage proportionally to elapsed time; the bump passed is negative", "now", "=", "time", ".", "time", "(", ")", "self", ".", "cost", "=", "max", "(", "0", ",", "self", ".", "cost", "-", "(", "...
Call to recalculate sleeps and concurrency for the session. Called automatically if cost has drifted significantly. Otherwise can be called at regular intervals if desired.
[ "Call", "to", "recalculate", "sleeps", "and", "concurrency", "for", "the", "session", ".", "Called", "automatically", "if", "cost", "has", "drifted", "significantly", ".", "Otherwise", "can", "be", "called", "at", "regular", "intervals", "if", "desired", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L282-L305
train
kyuupichan/aiorpcX
aiorpcx/session.py
SessionBase.close
async def close(self, *, force_after=30): '''Close the connection and return when closed.''' if self.transport: self.transport.close() try: async with timeout_after(force_after): await self.closed_event.wait() except TaskTimeout: ...
python
async def close(self, *, force_after=30): '''Close the connection and return when closed.''' if self.transport: self.transport.close() try: async with timeout_after(force_after): await self.closed_event.wait() except TaskTimeout: ...
[ "async", "def", "close", "(", "self", ",", "*", ",", "force_after", "=", "30", ")", ":", "if", "self", ".", "transport", ":", "self", ".", "transport", ".", "close", "(", ")", "try", ":", "async", "with", "timeout_after", "(", "force_after", ")", ":"...
Close the connection and return when closed.
[ "Close", "the", "connection", "and", "return", "when", "closed", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L342-L351
train
kyuupichan/aiorpcX
aiorpcx/session.py
RPCSession.send_request
async def send_request(self, method, args=()): '''Send an RPC request over the network.''' message, event = self.connection.send_request(Request(method, args)) return await self._send_concurrent(message, event, 1)
python
async def send_request(self, method, args=()): '''Send an RPC request over the network.''' message, event = self.connection.send_request(Request(method, args)) return await self._send_concurrent(message, event, 1)
[ "async", "def", "send_request", "(", "self", ",", "method", ",", "args", "=", "(", ")", ")", ":", "message", ",", "event", "=", "self", ".", "connection", ".", "send_request", "(", "Request", "(", "method", ",", "args", ")", ")", "return", "await", "...
Send an RPC request over the network.
[ "Send", "an", "RPC", "request", "over", "the", "network", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L631-L634
train
kyuupichan/aiorpcX
aiorpcx/session.py
RPCSession.send_notification
async def send_notification(self, method, args=()): '''Send an RPC notification over the network.''' message = self.connection.send_notification(Notification(method, args)) await self._send_message(message)
python
async def send_notification(self, method, args=()): '''Send an RPC notification over the network.''' message = self.connection.send_notification(Notification(method, args)) await self._send_message(message)
[ "async", "def", "send_notification", "(", "self", ",", "method", ",", "args", "=", "(", ")", ")", ":", "message", "=", "self", ".", "connection", ".", "send_notification", "(", "Notification", "(", "method", ",", "args", ")", ")", "await", "self", ".", ...
Send an RPC notification over the network.
[ "Send", "an", "RPC", "notification", "over", "the", "network", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L636-L639
train
kyuupichan/aiorpcX
aiorpcx/session.py
Server.close
async def close(self): '''Close the listening socket. This does not close any ServerSession objects created to handle incoming connections. ''' if self.server: self.server.close() await self.server.wait_closed() self.server = None
python
async def close(self): '''Close the listening socket. This does not close any ServerSession objects created to handle incoming connections. ''' if self.server: self.server.close() await self.server.wait_closed() self.server = None
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "server", ":", "self", ".", "server", ".", "close", "(", ")", "await", "self", ".", "server", ".", "wait_closed", "(", ")", "self", ".", "server", "=", "None" ]
Close the listening socket. This does not close any ServerSession objects created to handle incoming connections.
[ "Close", "the", "listening", "socket", ".", "This", "does", "not", "close", "any", "ServerSession", "objects", "created", "to", "handle", "incoming", "connections", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/session.py#L674-L681
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPC._message_to_payload
def _message_to_payload(cls, message): '''Returns a Python object or a ProtocolError.''' try: return json.loads(message.decode()) except UnicodeDecodeError: message = 'messages must be encoded in UTF-8' except json.JSONDecodeError: message = 'invalid J...
python
def _message_to_payload(cls, message): '''Returns a Python object or a ProtocolError.''' try: return json.loads(message.decode()) except UnicodeDecodeError: message = 'messages must be encoded in UTF-8' except json.JSONDecodeError: message = 'invalid J...
[ "def", "_message_to_payload", "(", "cls", ",", "message", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "message", ".", "decode", "(", ")", ")", "except", "UnicodeDecodeError", ":", "message", "=", "'messages must be encoded in UTF-8'", "except", ...
Returns a Python object or a ProtocolError.
[ "Returns", "a", "Python", "object", "or", "a", "ProtocolError", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L223-L231
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPC.batch_message
def batch_message(cls, batch, request_ids): '''Convert a request Batch to a message.''' assert isinstance(batch, Batch) if not cls.allow_batches: raise ProtocolError.invalid_request( 'protocol does not permit batches') id_iter = iter(request_ids) rm = ...
python
def batch_message(cls, batch, request_ids): '''Convert a request Batch to a message.''' assert isinstance(batch, Batch) if not cls.allow_batches: raise ProtocolError.invalid_request( 'protocol does not permit batches') id_iter = iter(request_ids) rm = ...
[ "def", "batch_message", "(", "cls", ",", "batch", ",", "request_ids", ")", ":", "assert", "isinstance", "(", "batch", ",", "Batch", ")", "if", "not", "cls", ".", "allow_batches", ":", "raise", "ProtocolError", ".", "invalid_request", "(", "'protocol does not p...
Convert a request Batch to a message.
[ "Convert", "a", "request", "Batch", "to", "a", "message", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L305-L316
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPC.batch_message_from_parts
def batch_message_from_parts(cls, messages): '''Convert messages, one per batch item, into a batch message. At least one message must be passed. ''' # Comma-separate the messages and wrap the lot in square brackets middle = b', '.join(messages) if not middle: ...
python
def batch_message_from_parts(cls, messages): '''Convert messages, one per batch item, into a batch message. At least one message must be passed. ''' # Comma-separate the messages and wrap the lot in square brackets middle = b', '.join(messages) if not middle: ...
[ "def", "batch_message_from_parts", "(", "cls", ",", "messages", ")", ":", "# Comma-separate the messages and wrap the lot in square brackets", "middle", "=", "b', '", ".", "join", "(", "messages", ")", "if", "not", "middle", ":", "raise", "ProtocolError", ".", "empty_...
Convert messages, one per batch item, into a batch message. At least one message must be passed.
[ "Convert", "messages", "one", "per", "batch", "item", "into", "a", "batch", "message", ".", "At", "least", "one", "message", "must", "be", "passed", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L319-L327
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPC.encode_payload
def encode_payload(cls, payload): '''Encode a Python object as JSON and convert it to bytes.''' try: return json.dumps(payload).encode() except TypeError: msg = f'JSON payload encoding error: {payload}' raise ProtocolError(cls.INTERNAL_ERROR, msg) from None
python
def encode_payload(cls, payload): '''Encode a Python object as JSON and convert it to bytes.''' try: return json.dumps(payload).encode() except TypeError: msg = f'JSON payload encoding error: {payload}' raise ProtocolError(cls.INTERNAL_ERROR, msg) from None
[ "def", "encode_payload", "(", "cls", ",", "payload", ")", ":", "try", ":", "return", "json", ".", "dumps", "(", "payload", ")", ".", "encode", "(", ")", "except", "TypeError", ":", "msg", "=", "f'JSON payload encoding error: {payload}'", "raise", "ProtocolErro...
Encode a Python object as JSON and convert it to bytes.
[ "Encode", "a", "Python", "object", "as", "JSON", "and", "convert", "it", "to", "bytes", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L330-L336
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPCAutoDetect.detect_protocol
def detect_protocol(cls, message): '''Attempt to detect the protocol from the message.''' main = cls._message_to_payload(message) def protocol_for_payload(payload): if not isinstance(payload, dict): return JSONRPCLoose # Will error # Obey an explicit "j...
python
def detect_protocol(cls, message): '''Attempt to detect the protocol from the message.''' main = cls._message_to_payload(message) def protocol_for_payload(payload): if not isinstance(payload, dict): return JSONRPCLoose # Will error # Obey an explicit "j...
[ "def", "detect_protocol", "(", "cls", ",", "message", ")", ":", "main", "=", "cls", ".", "_message_to_payload", "(", "message", ")", "def", "protocol_for_payload", "(", "payload", ")", ":", "if", "not", "isinstance", "(", "payload", ",", "dict", ")", ":", ...
Attempt to detect the protocol from the message.
[ "Attempt", "to", "detect", "the", "protocol", "from", "the", "message", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L544-L576
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPCConnection.receive_message
def receive_message(self, message): '''Call with an unframed message received from the network. Raises: ProtocolError if the message violates the protocol in some way. However, if it happened in a response that can be paired with a request, the ProtocolError is instead set in the ...
python
def receive_message(self, message): '''Call with an unframed message received from the network. Raises: ProtocolError if the message violates the protocol in some way. However, if it happened in a response that can be paired with a request, the ProtocolError is instead set in the ...
[ "def", "receive_message", "(", "self", ",", "message", ")", ":", "if", "self", ".", "_protocol", "is", "JSONRPCAutoDetect", ":", "self", ".", "_protocol", "=", "JSONRPCAutoDetect", ".", "detect_protocol", "(", "message", ")", "try", ":", "item", ",", "reques...
Call with an unframed message received from the network. Raises: ProtocolError if the message violates the protocol in some way. However, if it happened in a response that can be paired with a request, the ProtocolError is instead set in the result attribute of the send_request() that ...
[ "Call", "with", "an", "unframed", "message", "received", "from", "the", "network", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L706-L737
train
kyuupichan/aiorpcX
aiorpcx/jsonrpc.py
JSONRPCConnection.cancel_pending_requests
def cancel_pending_requests(self): '''Cancel all pending requests.''' exception = CancelledError() for _request, event in self._requests.values(): event.result = exception event.set() self._requests.clear()
python
def cancel_pending_requests(self): '''Cancel all pending requests.''' exception = CancelledError() for _request, event in self._requests.values(): event.result = exception event.set() self._requests.clear()
[ "def", "cancel_pending_requests", "(", "self", ")", ":", "exception", "=", "CancelledError", "(", ")", "for", "_request", ",", "event", "in", "self", ".", "_requests", ".", "values", "(", ")", ":", "event", ".", "result", "=", "exception", "event", ".", ...
Cancel all pending requests.
[ "Cancel", "all", "pending", "requests", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/jsonrpc.py#L739-L745
train
kyuupichan/aiorpcX
aiorpcx/util.py
is_valid_hostname
def is_valid_hostname(hostname): '''Return True if hostname is valid, otherwise False.''' if not isinstance(hostname, str): raise TypeError('hostname must be a string') # strip exactly one dot from the right, if present if hostname and hostname[-1] == ".": hostname = hostname[:-1] if...
python
def is_valid_hostname(hostname): '''Return True if hostname is valid, otherwise False.''' if not isinstance(hostname, str): raise TypeError('hostname must be a string') # strip exactly one dot from the right, if present if hostname and hostname[-1] == ".": hostname = hostname[:-1] if...
[ "def", "is_valid_hostname", "(", "hostname", ")", ":", "if", "not", "isinstance", "(", "hostname", ",", "str", ")", ":", "raise", "TypeError", "(", "'hostname must be a string'", ")", "# strip exactly one dot from the right, if present", "if", "hostname", "and", "host...
Return True if hostname is valid, otherwise False.
[ "Return", "True", "if", "hostname", "is", "valid", "otherwise", "False", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L47-L60
train
kyuupichan/aiorpcX
aiorpcx/util.py
classify_host
def classify_host(host): '''Host is an IPv4Address, IPv6Address or a string. If an IPv4Address or IPv6Address return it. Otherwise convert the string to an IPv4Address or IPv6Address object if possible and return it. Otherwise return the original string if it is a valid hostname. Raise ValueErro...
python
def classify_host(host): '''Host is an IPv4Address, IPv6Address or a string. If an IPv4Address or IPv6Address return it. Otherwise convert the string to an IPv4Address or IPv6Address object if possible and return it. Otherwise return the original string if it is a valid hostname. Raise ValueErro...
[ "def", "classify_host", "(", "host", ")", ":", "if", "isinstance", "(", "host", ",", "(", "IPv4Address", ",", "IPv6Address", ")", ")", ":", "return", "host", "if", "is_valid_hostname", "(", "host", ")", ":", "return", "host", "return", "ip_address", "(", ...
Host is an IPv4Address, IPv6Address or a string. If an IPv4Address or IPv6Address return it. Otherwise convert the string to an IPv4Address or IPv6Address object if possible and return it. Otherwise return the original string if it is a valid hostname. Raise ValueError if a string cannot be interpre...
[ "Host", "is", "an", "IPv4Address", "IPv6Address", "or", "a", "string", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L63-L77
train
kyuupichan/aiorpcX
aiorpcx/util.py
validate_port
def validate_port(port): '''Validate port and return it as an integer. A string, or its representation as an integer, is accepted.''' if not isinstance(port, (str, int)): raise TypeError(f'port must be an integer or string: {port}') if isinstance(port, str) and port.isdigit(): port = in...
python
def validate_port(port): '''Validate port and return it as an integer. A string, or its representation as an integer, is accepted.''' if not isinstance(port, (str, int)): raise TypeError(f'port must be an integer or string: {port}') if isinstance(port, str) and port.isdigit(): port = in...
[ "def", "validate_port", "(", "port", ")", ":", "if", "not", "isinstance", "(", "port", ",", "(", "str", ",", "int", ")", ")", ":", "raise", "TypeError", "(", "f'port must be an integer or string: {port}'", ")", "if", "isinstance", "(", "port", ",", "str", ...
Validate port and return it as an integer. A string, or its representation as an integer, is accepted.
[ "Validate", "port", "and", "return", "it", "as", "an", "integer", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L80-L90
train
kyuupichan/aiorpcX
aiorpcx/util.py
validate_protocol
def validate_protocol(protocol): '''Validate a protocol, a string, and return it.''' if not re.match(PROTOCOL_REGEX, protocol): raise ValueError(f'invalid protocol: {protocol}') return protocol.lower()
python
def validate_protocol(protocol): '''Validate a protocol, a string, and return it.''' if not re.match(PROTOCOL_REGEX, protocol): raise ValueError(f'invalid protocol: {protocol}') return protocol.lower()
[ "def", "validate_protocol", "(", "protocol", ")", ":", "if", "not", "re", ".", "match", "(", "PROTOCOL_REGEX", ",", "protocol", ")", ":", "raise", "ValueError", "(", "f'invalid protocol: {protocol}'", ")", "return", "protocol", ".", "lower", "(", ")" ]
Validate a protocol, a string, and return it.
[ "Validate", "a", "protocol", "a", "string", "and", "return", "it", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L93-L97
train
kyuupichan/aiorpcX
aiorpcx/util.py
is_async_call
def is_async_call(func): '''inspect.iscoroutinefunction that looks through partials.''' while isinstance(func, partial): func = func.func return inspect.iscoroutinefunction(func)
python
def is_async_call(func): '''inspect.iscoroutinefunction that looks through partials.''' while isinstance(func, partial): func = func.func return inspect.iscoroutinefunction(func)
[ "def", "is_async_call", "(", "func", ")", ":", "while", "isinstance", "(", "func", ",", "partial", ")", ":", "func", "=", "func", ".", "func", "return", "inspect", ".", "iscoroutinefunction", "(", "func", ")" ]
inspect.iscoroutinefunction that looks through partials.
[ "inspect", ".", "iscoroutinefunction", "that", "looks", "through", "partials", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L261-L265
train
kyuupichan/aiorpcX
aiorpcx/util.py
Service.from_string
def from_string(cls, string, *, default_func=None): '''Construct a Service from a string. If default_func is provided and any ServicePart is missing, it is called with default_func(protocol, part) to obtain the missing part. ''' if not isinstance(string, str): raise ...
python
def from_string(cls, string, *, default_func=None): '''Construct a Service from a string. If default_func is provided and any ServicePart is missing, it is called with default_func(protocol, part) to obtain the missing part. ''' if not isinstance(string, str): raise ...
[ "def", "from_string", "(", "cls", ",", "string", ",", "*", ",", "default_func", "=", "None", ")", ":", "if", "not", "isinstance", "(", "string", ",", "str", ")", ":", "raise", "TypeError", "(", "f'service must be a string: {string}'", ")", "parts", "=", "s...
Construct a Service from a string. If default_func is provided and any ServicePart is missing, it is called with default_func(protocol, part) to obtain the missing part.
[ "Construct", "a", "Service", "from", "a", "string", "." ]
707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0
https://github.com/kyuupichan/aiorpcX/blob/707c989ed1c67ac9a40cd20b0161b1ce1f4d7db0/aiorpcx/util.py#L218-L244
train
monarch-initiative/dipper
dipper/sources/OMIA.py
OMIA.scrub
def scrub(self): """ The XML file seems to have mixed-encoding; we scrub out the control characters from the file for processing. i.e.?i omia.xml:1555328.28: PCDATA invalid Char value 2 <field name="journal">Bulletin et Memoires de la Societe Centrale de Medi...
python
def scrub(self): """ The XML file seems to have mixed-encoding; we scrub out the control characters from the file for processing. i.e.?i omia.xml:1555328.28: PCDATA invalid Char value 2 <field name="journal">Bulletin et Memoires de la Societe Centrale de Medi...
[ "def", "scrub", "(", "self", ")", ":", "LOG", ".", "info", "(", "\"Scrubbing out the nasty characters that break our parser.\"", ")", "myfile", "=", "'/'", ".", "join", "(", "(", "self", ".", "rawdir", ",", "self", ".", "files", "[", "'data'", "]", "[", "'...
The XML file seems to have mixed-encoding; we scrub out the control characters from the file for processing. i.e.?i omia.xml:1555328.28: PCDATA invalid Char value 2 <field name="journal">Bulletin et Memoires de la Societe Centrale de Medic :return:
[ "The", "XML", "file", "seems", "to", "have", "mixed", "-", "encoding", ";", "we", "scrub", "out", "the", "control", "characters", "from", "the", "file", "for", "processing", "." ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIA.py#L202-L234
train
monarch-initiative/dipper
dipper/sources/OMIA.py
OMIA.process_associations
def process_associations(self, limit): """ Loop through the xml file and process the article-breed, article-phene, breed-phene, phene-gene associations, and the external links to LIDA. :param limit: :return: """ myfile = '/'.join((self.rawdir, self.files['data'...
python
def process_associations(self, limit): """ Loop through the xml file and process the article-breed, article-phene, breed-phene, phene-gene associations, and the external links to LIDA. :param limit: :return: """ myfile = '/'.join((self.rawdir, self.files['data'...
[ "def", "process_associations", "(", "self", ",", "limit", ")", ":", "myfile", "=", "'/'", ".", "join", "(", "(", "self", ".", "rawdir", ",", "self", ".", "files", "[", "'data'", "]", "[", "'file'", "]", ")", ")", "f", "=", "gzip", ".", "open", "(...
Loop through the xml file and process the article-breed, article-phene, breed-phene, phene-gene associations, and the external links to LIDA. :param limit: :return:
[ "Loop", "through", "the", "xml", "file", "and", "process", "the", "article", "-", "breed", "article", "-", "phene", "breed", "-", "phene", "phene", "-", "gene", "associations", "and", "the", "external", "links", "to", "LIDA", "." ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIA.py#L362-L390
train
monarch-initiative/dipper
dipper/sources/OMIA.py
OMIA._process_article_phene_row
def _process_article_phene_row(self, row): """ Linking articles to species-specific phenes. :param row: :return: """ # article_id, phene_id, added_by # look up the article in the hashmap phenotype_id = self.id_hash['phene'].get(row['phene_id']) ar...
python
def _process_article_phene_row(self, row): """ Linking articles to species-specific phenes. :param row: :return: """ # article_id, phene_id, added_by # look up the article in the hashmap phenotype_id = self.id_hash['phene'].get(row['phene_id']) ar...
[ "def", "_process_article_phene_row", "(", "self", ",", "row", ")", ":", "# article_id, phene_id, added_by", "# look up the article in the hashmap", "phenotype_id", "=", "self", ".", "id_hash", "[", "'phene'", "]", ".", "get", "(", "row", "[", "'phene_id'", "]", ")",...
Linking articles to species-specific phenes. :param row: :return:
[ "Linking", "articles", "to", "species", "-", "specific", "phenes", "." ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIA.py#L645-L667
train
monarch-initiative/dipper
dipper/sources/OMIA.py
OMIA.filter_keep_phenotype_entry_ids
def filter_keep_phenotype_entry_ids(self, entry): ''' doubt this should be kept ''' omim_id = str(entry['mimNumber']) otype = self.globaltt['obsolete'] if omim_id in self.omim_type: otype = self.omim_type[omim_id] if otype == self.globaltt['obs...
python
def filter_keep_phenotype_entry_ids(self, entry): ''' doubt this should be kept ''' omim_id = str(entry['mimNumber']) otype = self.globaltt['obsolete'] if omim_id in self.omim_type: otype = self.omim_type[omim_id] if otype == self.globaltt['obs...
[ "def", "filter_keep_phenotype_entry_ids", "(", "self", ",", "entry", ")", ":", "omim_id", "=", "str", "(", "entry", "[", "'mimNumber'", "]", ")", "otype", "=", "self", ".", "globaltt", "[", "'obsolete'", "]", "if", "omim_id", "in", "self", ".", "omim_type"...
doubt this should be kept
[ "doubt", "this", "should", "be", "kept" ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/OMIA.py#L825-L841
train
monarch-initiative/dipper
dipper/sources/ClinVarXML_alpha.py
make_spo
def make_spo(sub, prd, obj): ''' Decorates the three given strings as a line of ntriples ''' # To establish string as a curie and expand, # we use a global curie_map(.yaml) # sub are allways uri (unless a bnode) # prd are allways uri (unless prd is 'a') # should fail loudly if curie do...
python
def make_spo(sub, prd, obj): ''' Decorates the three given strings as a line of ntriples ''' # To establish string as a curie and expand, # we use a global curie_map(.yaml) # sub are allways uri (unless a bnode) # prd are allways uri (unless prd is 'a') # should fail loudly if curie do...
[ "def", "make_spo", "(", "sub", ",", "prd", ",", "obj", ")", ":", "# To establish string as a curie and expand,", "# we use a global curie_map(.yaml)", "# sub are allways uri (unless a bnode)", "# prd are allways uri (unless prd is 'a')", "# should fail loudly if curie does not exist", ...
Decorates the three given strings as a line of ntriples
[ "Decorates", "the", "three", "given", "strings", "as", "a", "line", "of", "ntriples" ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ClinVarXML_alpha.py#L183-L244
train
monarch-initiative/dipper
dipper/sources/ClinVarXML_alpha.py
write_spo
def write_spo(sub, prd, obj): ''' write triples to a buffer incase we decide to drop them ''' rcvtriples.append(make_spo(sub, prd, obj))
python
def write_spo(sub, prd, obj): ''' write triples to a buffer incase we decide to drop them ''' rcvtriples.append(make_spo(sub, prd, obj))
[ "def", "write_spo", "(", "sub", ",", "prd", ",", "obj", ")", ":", "rcvtriples", ".", "append", "(", "make_spo", "(", "sub", ",", "prd", ",", "obj", ")", ")" ]
write triples to a buffer incase we decide to drop them
[ "write", "triples", "to", "a", "buffer", "incase", "we", "decide", "to", "drop", "them" ]
24cc80db355bbe15776edc5c7b41e0886959ba41
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ClinVarXML_alpha.py#L247-L251
train