docstring
stringlengths
52
499
function
stringlengths
67
35.2k
__index_level_0__
int64
52.6k
1.16M
The duration property. Args: value (string). the property value.
def duration(self, value): if value == self._defaults['duration'] and 'duration' in self._values: del self._values['duration'] else: self._values['duration'] = value
490,647
The network_connect property. Args: value (string). the property value.
def network_connect(self, value): if value == self._defaults['networkConnect'] and 'networkConnect' in self._values: del self._values['networkConnect'] else: self._values['networkConnect'] = value
490,648
The sent_request property. Args: value (string). the property value.
def sent_request(self, value): if value == self._defaults['sentRequest'] and 'sentRequest' in self._values: del self._values['sentRequest'] else: self._values['sentRequest'] = value
490,649
The received_response property. Args: value (string). the property value.
def received_response(self, value): if value == self._defaults['receivedResponse'] and 'receivedResponse' in self._values: del self._values['receivedResponse'] else: self._values['receivedResponse'] = value
490,650
The dom_processing property. Args: value (string). the property value.
def dom_processing(self, value): if value == self._defaults['domProcessing'] and 'domProcessing' in self._values: del self._values['domProcessing'] else: self._values['domProcessing'] = value
490,651
The referrer_uri property. Args: value (string). the property value.
def referrer_uri(self, value): if value == self._defaults['referrerUri'] and 'referrerUri' in self._values: del self._values['referrerUri'] else: self._values['referrerUri'] = value
490,652
The outer_id property. Args: value (int). the property value.
def outer_id(self, value): if value == self._defaults['outerId'] and 'outerId' in self._values: del self._values['outerId'] else: self._values['outerId'] = value
490,653
The has_full_stack property. Args: value (bool). the property value.
def has_full_stack(self, value): if value == self._defaults['hasFullStack'] and 'hasFullStack' in self._values: del self._values['hasFullStack'] else: self._values['hasFullStack'] = value
490,654
The stack property. Args: value (string). the property value.
def stack(self, value): if value == self._defaults['stack'] and 'stack' in self._values: del self._values['stack'] else: self._values['stack'] = value
490,655
The parsed_stack property. Args: value (list). the property value.
def parsed_stack(self, value): if value == self._defaults['parsedStack'] and 'parsedStack' in self._values: del self._values['parsedStack'] else: self._values['parsedStack'] = value
490,657
The result_code property. Args: value (string). the property value.
def result_code(self, value): if value == self._defaults['resultCode'] and 'resultCode' in self._values: del self._values['resultCode'] else: self._values['resultCode'] = value
490,658
The success property. Args: value (bool). the property value.
def success(self, value): if value == self._defaults['success'] and 'success' in self._values: del self._values['success'] else: self._values['success'] = value
490,659
The target property. Args: value (string). the property value.
def target(self, value): if value == self._defaults['target'] and 'target' in self._values: del self._values['target'] else: self._values['target'] = value
490,660
The type property. Args: value (string). the property value.
def type(self, value): if value == self._defaults['type'] and 'type' in self._values: del self._values['type'] else: self._values['type'] = value
490,661
The assembly property. Args: value (string). the property value.
def assembly(self, value): if value == self._defaults['assembly'] and 'assembly' in self._values: del self._values['assembly'] else: self._values['assembly'] = value
490,662
The file_name property. Args: value (string). the property value.
def file_name(self, value): if value == self._defaults['fileName'] and 'fileName' in self._values: del self._values['fileName'] else: self._values['fileName'] = value
490,663
The line property. Args: value (int). the property value.
def line(self, value): if value == self._defaults['line'] and 'line' in self._values: del self._values['line'] else: self._values['line'] = value
490,664
The is_first property. Args: value (string). the property value.
def is_first(self, value): if value == self._defaults['ai.session.isFirst'] and 'ai.session.isFirst' in self._values: del self._values['ai.session.isFirst'] else: self._values['ai.session.isFirst'] = value
490,665
Return video input option. Params: param - parameter, such as 'DayNightColor' profile - 'Day', 'Night' or 'Normal'
def video_in_option(self, param, profile='Day'): if profile == 'Day': field = param else: field = '{}Options.{}'.format(profile, param) return utils.pretty( [opt for opt in self.video_in_options.split() if '].{}='.format(field) in opt][0]...
490,909
Three-dimensional orientation. Move to the rectangle with screen coordinate [startX, startY], [endX, endY] Params: action - start or stop channel - channel index, start with 1 startX, startY, endX and endY - range is 0-8192
def move_directly(self, channel=1, startpoint_x=None, startpoint_y=None, endpoint_x=None, endpoint_y=None): if startpoint_x is None or startpoint_y is None or \ endpoint_x is None or endpoint_y is None: raise RuntimeError("Required arg...
490,948
According with API: The time format is "Y-M-D H-m-S". It is not be effected by Locales. TimeFormat in SetLocalesConfig Params: date = "Y-M-D H-m-S" Example: 2016-10-28 13:48:00 Return: True
def current_time(self, date): ret = self.command( 'global.cgi?action=setCurrentTime&time={0}'.format(date) ) if "ok" in ret.content.decode('utf-8').lower(): return True return False
490,949
Return RTSP streaming url Params: channelno: integer, the video channel index which starts from 1, default 1 if not specified. typeno: the stream type, default 0 if not specified. It can be the following value: 0-Main Stre...
def rtsp_url(self, channelno=None, typeno=None): if channelno is None: channelno = 1 if typeno is None: typeno = 0 cmd = 'cam/realmonitor?channel={0}&subtype={1}'.format( channelno, typeno) try: port = ':' + [x.split('=')[1] for...
490,954
Return MJPEG streaming url Params: channelno: integer, the video channel index which starts from 1, default 1 if not specified. typeno: the stream type, default 0 if not specified. It can be the following value: 0-Main Str...
def mjpeg_url(self, channelno=None, typeno=None): if channelno is None: channelno = 0 if typeno is None: typeno = 1 cmd = "mjpg/video.cgi?channel={0}&subtype={1}".format( channelno, typeno) return '{0}{1}'.format(self._base_url, cmd)
490,955
Scan cameras in a range of ips Params: subnet - subnet, i.e: 192.168.1.0/24 if mask not used, assuming mask 24 timeout_sec - timeout in sec Returns:
def scan_devices(self, subnet, timeout=None): # Maximum range from mask # Format is mask: max_range max_range = { 16: 256, 24: 256, 25: 128, 27: 32, 28: 16, 29: 8, 30: 4, 31: 2 } ...
490,961
Given training vectors, run k-means for each sub-space and create codewords for each sub-space. This function should be run once first of all. Args: vecs (np.ndarray): Training vectors with shape=(N, D) and dtype=np.float32. iter (int): The number of iteration for k-mea...
def fit(self, vecs, iter=20, seed=123): assert vecs.dtype == np.float32 assert vecs.ndim == 2 N, D = vecs.shape assert self.Ks < N, "the number of training vector should be more than Ks" assert D % self.M == 0, "input dimension must be dividable by M" self.Ds = i...
491,567
Encode input vectors into PQ-codes. Args: vecs (np.ndarray): Input vectors with shape=(N, D) and dtype=np.float32. Returns: np.ndarray: PQ codes with shape=(N, M) and dtype=self.code_dtype
def encode(self, vecs): assert vecs.dtype == np.float32 assert vecs.ndim == 2 N, D = vecs.shape assert D == self.Ds * self.M, "input dimension must be Ds * M" # codes[n][m] : code of n-th vec, m-th subspace codes = np.empty((N, self.M), dtype=self.code_dtype) ...
491,568
Given PQ-codes, reconstruct original D-dimensional vectors approximately by fetching the codewords. Args: codes (np.ndarray): PQ-cdoes with shape=(N, M) and dtype=self.code_dtype. Each row is a PQ-code Returns: np.ndarray: Reconstructed vectors with shap...
def decode(self, codes): assert codes.ndim == 2 N, M = codes.shape assert M == self.M assert codes.dtype == self.code_dtype vecs = np.empty((N, self.Ds * self.M), dtype=np.float32) for m in range(self.M): vecs[:, m * self.Ds : (m+1) * self.Ds] = self...
491,569
Given PQ-codes, compute Asymmetric Distances between the query (self.dtable) and the PQ-codes. Args: codes (np.ndarray): PQ codes with shape=(N, M) and dtype=pq.code_dtype where pq is a pq instance that creates the codes Returns: np.ndarray: Asymmetric D...
def adist(self, codes): assert codes.ndim == 2 N, M = codes.shape assert M == self.dtable.shape[0] # Fetch distance values using codes. The following codes are dists = np.sum(self.dtable[range(M), codes], axis=1) # The above line is equivalent to the following...
491,572
Rotate input vector(s) by the rotation matrix.` Args: vecs (np.ndarray): Input vector(s) with dtype=np.float32. The shape can be a single vector (D, ) or several vectors (N, D) Returns: np.ndarray: Rotated vectors with the same shape and dtype to the input vecs.
def rotate(self, vecs): assert vecs.dtype == np.float32 assert vecs.ndim in [1, 2] if vecs.ndim == 2: return vecs @ self.R elif vecs.ndim == 1: return (vecs.reshape(1, -1) @ self.R).reshape(-1)
491,576
Given PQ-codes, reconstruct original D-dimensional vectors via :func:`PQ.decode`, and applying an inverse-rotation. Args: codes (np.ndarray): PQ-cdoes with shape=(N, M) and dtype=self.code_dtype. Each row is a PQ-code Returns: np.ndarray: Reconstructed v...
def decode(self, codes): # Because R is a rotation matrix (R^t * R = I), R^-1 should be R^t return self.pq.decode(codes) @ self.R.T
491,577
Instantiate the object from a protocol buffer. Args: pb (protobuf) Save a reference to the protocol buffer on the object.
def from_pb(cls, pb): obj = cls._from_pb(pb) obj._pb = pb return obj
492,334
Launch a job on CodaLab (optionally upload code that the job depends on). Args: job_name: name of the job cmd: command to execute code_dir: path to code folder. If None, no code is uploaded. excludes: file types to exclude from the upload dependencies: list of other bundles ...
def launch_job(job_name, cmd=None, code_dir=None, excludes='*.ipynb .git .ipynb_checkpoints', dependencies=tuple(), queue='john', image='codalab/python', memory='18g', debug=False, tail=False): print 'Remember to set up SSH tunnel and LOG IN through the command line...
492,415
Parse command line arguments to construct a dictionary of cluster parameters that can be used to determine which clusters to list. Args: `args`: sequence of arguments Returns: Dictionary that can be used to determine which clusters to list
def _parse_list(cls, args): argparser = ArgumentParser(prog="cluster list") group = argparser.add_mutually_exclusive_group() group.add_argument("--id", dest="cluster_id", help="show cluster with this id") group.add_argument("--label", dest="label", ...
493,477
Parse command line arguments to determine cluster parameters that can be used to create or update a cluster. Args: `args`: sequence of arguments `action`: "create", "update" or "clone" Returns: Object that contains cluster parameters
def _parse_create_update(cls, args, action, api_version): argparser = ArgumentParser(prog="cluster %s" % action) create_required = False label_required = False if action == "create": create_required = True elif action == "update": argparser.add_...
493,484
Reassign a label from one cluster to another. Args: `destination_cluster`: id/label of the cluster to move the label to `label`: label to be moved from the source cluster
def reassign_label(cls, destination_cluster, label): conn = Qubole.agent(version=Cluster.api_version) data = { "destination_cluster": destination_cluster, "label": label } return conn.put(cls.rest_entity_path + "/reassign-label", d...
493,487
Create a new template. Args: `data`: json data required for creating a template Returns: Dictionary containing the details of the template with its ID.
def createTemplate(data): conn = Qubole.agent() return conn.post(Template.rest_entity_path, data)
493,548
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.
def editTemplate(id, data): conn = Qubole.agent() return conn.put(Template.element_path(id), data)
493,549
View an existing Template details. Args: `id`: ID of the template to fetch Returns: Dictionary containing the details of the template.
def viewTemplate(id): conn = Qubole.agent() return conn.get(Template.element_path(id))
493,550
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.
def submitTemplate(id, data={}): conn = Qubole.agent() path = str(id) + "/run" return conn.post(Template.element_path(path), data)
493,551
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)
def runTemplate(id, data={}): conn = Qubole.agent() path = str(id) + "/run" res = conn.post(Template.element_path(path), data) cmdType = res['command_type'] cmdId = res['id'] cmdClass = eval(cmdType) cmd = cmdClass.find(cmdId) while not Command.is...
493,552
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
def listTemplates(data={}): conn = Qubole.agent() url_path = Template.rest_entity_path page_attr = [] if "page" in data and data["page"] is not None: page_attr.append("page=%s" % data["page"]) if "per_page" in data and data["per_page"] is not None: ...
493,554
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)
def create(cls, name, config=None, kind="spark"): conn = Qubole.agent() return conn.post(cls.rest_entity_path, data={'name': name, 'config': config, 'kind': kind})
493,641
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(..) ...
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"): cls._auth = QuboleAuth(api_token) cls.api_token = api_token cls.version = version cls.baseurl ...
493,650
Shows a report by issuing a GET request to the /reports/report_name endpoint. Args: `report_name`: the name of the report to show `data`: the parameters for the report
def show(cls, report_name, data): conn = Qubole.agent() return conn.get(cls.element_path(report_name), data)
493,657
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
def _download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=None): #Progress bar to display download progress def _callback(downloaded, total): if (total is 0) or (downloaded == total): return progress = downloaded*100/total sys.stderr.write('\r[{0}] {1...
493,685
Create a command object by issuing a POST request to the /command endpoint Note - this does not wait for the command to complete Args: `**kwargs`: keyword arguments specific to command type Returns: Command object
def create(cls, **kwargs): conn = Qubole.agent() if kwargs.get('command_type') is None: kwargs['command_type'] = cls.__name__ if kwargs.get('tags') is not None: kwargs['tags'] = kwargs['tags'].split(',') return cls(conn.post(cls.rest_entity_path, data=k...
493,688
Create a command object by issuing a POST request to the /command endpoint Waits until the command is complete. Repeatedly polls to check status Args: `**kwargs`: keyword arguments specific to command type Returns: Command object
def run(cls, **kwargs): # vars to keep track of actual logs bytes (err, tmp) and new bytes seen in each iteration err_pointer, tmp_pointer, new_bytes = 0, 0, 0 print_logs_live = kwargs.pop("print_logs_live", None) # We don't want to send this to the API. cmd = cls.create(**kwa...
493,689
Cancels command denoted by this id Args: `id`: command id
def cancel_id(cls, id): conn = Qubole.agent() data = {"status": "kill"} return conn.put(cls.element_path(id), data)
493,690
Fetches log for the command represented by this id Args: `id`: command id
def get_log_id(cls, id): conn = Qubole.agent() r = conn.get_raw(cls.element_path(id) + "/logs") return r.text
493,691
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) except OptionParsingError as e: raise ParseError(e.msg, cls.optparser.format_help()) except OptionParsingExit as e: return None SparkCommand.validate_program(options)...
493,699
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): parsed = {} try: (options, args) = cls.optparser.parse_args(args) except OptionParsingError as e: raise ParseError(e.msg, cls.optparser.format_help()) except OptionParsingExit as e: return None parsed['label'] =...
493,700
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) if options.inline is None and options.script_location is None: raise ParseError("One of script or it's location" " must be specified", ...
493,701
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) if options.latin_statements is None and options.script_location is None: raise ParseError("One of script or it's location" " must be specified", ...
493,702
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) if options.mode not in ["1", "2"]: raise ParseError("mode must be either '1' or '2'", cls.optparser.format_help()) if (options.dbtap_id is N...
493,703
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) if options.mode not in ["1", "2"]: raise ParseError("mode must be either '1' or '2'", cls.optparser.format_help()) if (options.dbtap_id is N...
493,704
Parse command line arguments to construct a dictionary of command parameters that can be used to create a command Args: `args`: sequence of arguments Returns: Dictionary that can be used in create method Raises: ParseError: when the arguments are no...
def parse(cls, args): try: (options, args) = cls.optparser.parse_args(args) if options.db_tap_id is None: raise ParseError("db_tap_id is required", cls.optparser.format_help()) if options.query is None and options.scr...
493,706
Convert singular word to its plural form. Args: singular: A word in its singular form. Returns: The word in its plural form.
def pluralize(singular): if singular in UNCOUNTABLES: return singular for i in IRREGULAR: if i[0] == singular: return i[1] for i in PLURALIZE_PATTERNS: if re.search(i[0], singular): return re.sub(i[0], i[1], singular)
493,709
Convert plural word to its singular form. Args: plural: A word in its plural form. Returns: The word in its singular form.
def singularize(plural): if plural in UNCOUNTABLES: return plural for i in IRREGULAR: if i[1] == plural: return i[0] for i in SINGULARIZE_PATTERNS: if re.search(i[0], plural): return re.sub(i[0], i[1], plural) return plural
493,710
Convert a word from lower_with_underscores to CamelCase. Args: word: The string to convert. Returns: The modified string.
def camelize(word): return ''.join(w[0].upper() + w[1:] for w in re.sub('[^A-Z^a-z^0-9^:]+', ' ', word).split(' '))
493,711
Create a new class. Args: `mcs`: The metaclass. `name`: The name of the class. `bases`: List of base classes from which mcs inherits. `new_attrs`: The class attribute dictionary.
def __new__(mcs, name, bases, new_attrs): if 'rest_entity_path' not in new_attrs: new_attrs['rest_entity_path'] = util.pluralize(util.underscore(name)) return type.__new__(mcs, name, bases, new_attrs)
493,767
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) rgd_file = '/'.join( (self.rawdir, self.files['rat_gene2mammalian_phenotype']['file'])) # ontobio gafparser implemented here p = GafParser() assocs =...
494,371
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) sgd_file = '/'.join((self.rawdir, self.files['sgd_phenotype']['file'])) columns = [ 'Feature Name', 'Feature Type', 'Gene Name', 'SGDID', 'Reference', 'E...
494,519
Override Source.fetch() Fetches resources from String We also fetch ensembl to determine if protein pairs are from the same species Args: :param is_dl_forced (bool): Force download Returns: :return None
def fetch(self, is_dl_forced=False): file_paths = self._get_file_paths(self.tax_ids, 'protein_links') self.get_files(is_dl_forced, file_paths) self.get_files(is_dl_forced, self.id_map_files)
494,537
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) protein_paths = self._get_file_paths(self.tax_ids, 'protein_links') col = ['NCBI taxid', 'entrez', 'STRING'] for taxon in protein_paths: ensembl = Ensembl(se...
494,538
Assemble file paths from tax ids Args: :param tax_ids (list) list of taxa Returns: :return file dict
def _get_file_paths(self, tax_ids, file_type): file_paths = dict() if file_type not in self.files: raise KeyError("file type {} not configured".format(file_type)) for taxon in tax_ids: file_paths[taxon] = { 'file': "{}.{}".format(taxon, self.files...
494,540
Override Source.parse() Parses version and interaction information from CTD Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) LOG.info("Parsing files...") # pub_map = dict() # file_path = '/'.join((self.rawdir, # self.static_files['publications']['file'])) # if os.path.exists(fi...
494,606
Parses files in CTD.files dictionary Args: :param limit (int): limit the number of rows processed :param file (str): file name (must be defined in CTD.file) Returns: :return None
def _parse_ctd_file(self, limit, file): row_count = 0 version_pattern = re.compile(r'^# Report created: (.+)$') is_versioned = False file_path = '/'.join((self.rawdir, file)) with gzip.open(file_path, 'rt') as tsvfile: reader = csv.reader(tsvfile, delimiter="...
494,607
Process row of CTD data from CTD_genes_pathways.tsv.gz and generate triples Args: :param row (list): row of CTD data Returns: :return None
def _process_pathway(self, row): model = Model(self.graph) self._check_list_len(row, 4) (gene_symbol, gene_id, pathway_name, pathway_id) = row if self.test_mode and (int(gene_id) not in self.test_geneids): return entrez_id = 'NCBIGene:' + gene_id p...
494,608
Make a reified association given an array of pubmed identifiers. Args: :param subject_id id of the subject of the association (gene/chem) :param object_id id of the object of the association (disease) :param rel_id relationship id :param pubmed_ids an array of...
def _make_association(self, subject_id, object_id, rel_id, pubmed_ids): # TODO pass in the relevant Assoc class rather than relying on G2P assoc = G2PAssoc(self.graph, self.name, subject_id, object_id, rel_id) if pubmed_ids is not None and len(pubmed_ids) > 0: for pmid in p...
494,612
Take a list of pubmed IDs and add PMID prefix Args: :param pubmed_ids - string representing publication ids seperated by a | symbol Returns: :return list: Pubmed curies
def _process_pubmed_ids(pubmed_ids): if pubmed_ids.strip() == '': id_list = [] else: id_list = pubmed_ids.split('|') for (i, val) in enumerate(id_list): id_list[i] = 'PMID:' + val return id_list
494,613
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) ensembl_file = '/'.join((self.rawdir, self.files['ensembl2pathway']['file'])) self._parse_reactome_association_file( ensembl_file, limit, subject_prefix='ENSEMBL', o...
494,693
Override Source.parse() Args: :param limit (int, optional) limit the number of rows processed Returns: :return None
def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) phenotype_file = '/'.join( (self.rawdir, self.files['patient_phenotypes']['file'])) variant_file = '/'.join((self.rawdir, self.files['patient_variants']['file'])) ...
494,732
Return next chunk of data that we would from the file pointer. Args: fp: file-like object previously_read_position: file pointer position that we have read from chunk_size: desired read chunk_size Returns: (bytestring, int): data that has been read in, the file pointer position...
def _get_next_chunk(fp, previously_read_position, chunk_size): seek_position, read_size = _get_what_to_read_next(fp, previously_read_position, chunk_size) fp.seek(seek_position) read_content = fp.read(read_size) read_position = seek_position return read_content, read_position
494,975
Return information on which file pointer position to read from and how many bytes. Args: fp past_read_positon (int): The file pointer position that has been read previously chunk_size(int): ideal io chunk_size Returns: (int, int): The next seek position, how many bytes to read ...
def _get_what_to_read_next(fp, previously_read_position, chunk_size): seek_position = max(previously_read_position - chunk_size, 0) read_size = chunk_size # examples: say, our new_lines are potentially "\r\n", "\n", "\r" # find a reading point where it is not "\n", rewind further if necessary ...
494,976
Return -1 if read_buffer does not contain new line otherwise the position of the rightmost newline. Args: read_buffer (bytestring) Returns: int: The right most position of new line character in read_buffer if found, else -1
def _find_furthest_new_line(read_buffer): new_line_positions = [read_buffer.rfind(n) for n in new_lines_bytes] return max(new_line_positions)
494,978
Add additional bytes content as read from the read_position. Args: content (bytes): data to be added to buffer working BufferWorkSpac. read_position (int): where in the file pointer the data was read from.
def add_to_buffer(self, content, read_position): self.read_position = read_position if self.read_buffer is None: self.read_buffer = content else: self.read_buffer = content + self.read_buffer
494,980
Constructor for FileReadBackwards. Args: path: Path to the file to be read encoding (str): Encoding chunk_size (int): How many bytes to read at a time
def __init__(self, path, encoding="utf-8", chunk_size=io.DEFAULT_BUFFER_SIZE): if encoding.lower() not in supported_encodings: error_message = "{0} encoding was not supported/tested.".format(encoding) error_message += "Supported encodings are '{0}'".format(",".join(supported_enc...
494,984
Constructor for FileReadBackwardsIterator Args: fp (File): A file that we wish to start reading backwards from encoding (str): Encoding of the file chunk_size (int): How many bytes to read at a time
def __init__(self, fp, encoding, chunk_size): self.path = fp.name self.encoding = encoding self.chunk_size = chunk_size self.__fp = fp self.__buf = BufferWorkSpace(self.__fp, self.chunk_size)
494,986
Gets a list of visual content objects describing each rack within the data center. The response aggregates data center and rack data with a specified metric (peak24HourTemp) to provide simplified access to display data for the data center. Args: id_or_uri: Can be either the resource...
def get_visual_content(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/visualContent" return self._client.get(uri)
495,158
Adds a data center resource based upon the attributes specified. Args: information: Data center information timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. ...
def add(self, information, timeout=-1): return self._client.create(information, timeout=timeout)
495,159
Updates the specified data center resource. Args: resource (dict): Object to update. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. Returns: ...
def update(self, resource, timeout=-1): return self._client.update(resource, timeout=timeout)
495,160
Gets all drive enclosures that match the filter. The search is case-insensitive. Args: Field: field name to filter. Value: value to filter. Returns: list: A list of drive enclosures.
def get_by(self, field, value): return self._client.get_by(field=field, value=value)
495,162
Use to get the drive enclosure I/O adapter port to SAS interconnect port connectivity. Args: id_or_uri: Can be either the resource ID or the resource URI. Returns: dict: Drive Enclosure Port Map
def get_port_map(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + self.PORT_MAP_PATH return self._client.get(id_or_uri=uri)
495,163
Refreshes a drive enclosure. Args: id_or_uri: Can be either the resource ID or the resource URI. configuration: Configuration timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops ...
def refresh_state(self, id_or_uri, configuration, timeout=-1): uri = self._client.build_uri(id_or_uri) + self.REFRESH_STATE_PATH return self._client.update(resource=configuration, uri=uri, timeout=timeout)
495,164
Gets the particular Image Streamer resource based on its ID or URI. Args: id_or_uri: Can be either the Os Deployment Server ID or the URI fields: Specifies which fields should be returned in the result. Returns: dict: Image Streamer ...
def get_appliance(self, id_or_uri, fields=''): uri = self.URI + '/image-streamer-appliances/' + extract_id_from_uri(id_or_uri) if fields: uri += '?fields=' + fields return self._client.get(uri)
495,170
Gets the particular Image Streamer resource based on its name. Args: appliance_name: The Image Streamer resource name. Returns: dict: Image Streamer resource.
def get_appliance_by_name(self, appliance_name): appliances = self.get_appliances() if appliances: for appliance in appliances: if appliance['name'] == appliance_name: return appliance return None
495,171
Gets a list of Storage pools. Returns a list of storage pools belonging to the storage system referred by the Path property {ID} parameter or URI. Args: id_or_uri: Can be either the storage system ID (serial number) or the storage system URI. Returns: dict: Host types.
def get_storage_pools(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/storage-pools" return self._client.get(uri)
495,172
Gets all ports or a specific managed target port for the specified storage system. Args: id_or_uri: Can be either the storage system id or the storage system uri. port_id_or_uri: Can be either the port id or the port uri. Returns: dict: Managed ports.
def get_managed_ports(self, id_or_uri, port_id_or_uri=''): if port_id_or_uri: uri = self._client.build_uri(port_id_or_uri) if "/managedPorts" not in uri: uri = self._client.build_uri(id_or_uri) + "/managedPorts" + "/" + port_id_or_uri else: u...
495,173
Retrieve a storage system by its IP. Works only with API version <= 300. Args: ip_hostname: Storage system IP or hostname. Returns: dict
def get_by_ip_hostname(self, ip_hostname): resources = self._client.get_all() resources_filtered = [x for x in resources if x['credentials']['ip_hostname'] == ip_hostname] if resources_filtered: return resources_filtered[0] else: return None
495,174
Retrieve a storage system by its hostname. Works only in API500 onwards. Args: hostname: Storage system hostname. Returns: dict
def get_by_hostname(self, hostname): resources = self._client.get_all() resources_filtered = [x for x in resources if x['hostname'] == hostname] if resources_filtered: return resources_filtered[0] else: return None
495,175
Gets the reserved vlan ID range for the fabric. Note: This method is only available on HPE Synergy. Args: id_or_uri: ID or URI of fabric. Returns: dict: vlan-pool
def get_reserved_vlan_range(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range" return self._client.get(uri)
495,179
Updates the reserved vlan ID range for the fabric. Note: This method is only available on HPE Synergy. Args: id_or_uri: ID or URI of fabric. vlan_pool (dict): vlan-pool data to update. force: If set to true, the operation completes despite any problems ...
def update_reserved_vlan_range(self, id_or_uri, vlan_pool, force=False): uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range" return self._client.update(resource=vlan_pool, uri=uri, force=force, default_values=self.DEFAULT_VALUES)
495,180
Get the role by its URI or Name. Args: name_or_uri: Can be either the Name or the URI. Returns: dict: Role
def get(self, name_or_uri): name_or_uri = quote(name_or_uri) return self._client.get(name_or_uri)
495,181
Gets the list of drives allocated to this SAS logical JBOD. Args: id_or_uri: Can be either the SAS logical JBOD ID or the SAS logical JBOD URI. Returns: list: A list of Drives
def get_drives(self, id_or_uri): uri = self._client.build_uri(id_or_uri=id_or_uri) + self.DRIVES_PATH return self._client.get(id_or_uri=uri)
495,183
Enables or disables a range. Args: information (dict): Information to update. id_or_uri: ID or URI of range. timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its c...
def enable(self, information, id_or_uri, timeout=-1): uri = self._client.build_uri(id_or_uri) return self._client.update(information, uri, timeout=timeout)
495,185
Asynchronously applies or re-applies the logical interconnect configuration to all managed interconnects. Args: timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion. R...
def update_configuration(self, timeout=-1): uri = "{}/configuration".format(self.data["uri"]) return self._helper.update(None, uri=uri, timeout=timeout)
495,193
Updates the SNMP configuration of a logical interconnect. Changes to the SNMP configuration are asynchronously applied to all managed interconnects. Args: configuration: snmp configuration. Returns: dict: The Logical Interconnect.
def update_snmp_configuration(self, configuration, timeout=-1): data = configuration.copy() if 'type' not in data: data['type'] = 'snmp-configuration' uri = "{}{}".format(self.data["uri"], self.SNMP_CONFIGURATION_PATH) return self._helper.update(data, uri=uri, timeo...
495,195
Updates the port monitor configuration of a logical interconnect. Args: resource: Port monitor configuration. Returns: dict: Port monitor configuration.
def update_port_monitor(self, resource, timeout=-1): data = resource.copy() if 'type' not in data: data['type'] = 'port-monitor' uri = "{}{}".format(self.data["uri"], self.PORT_MONITOR_PATH) return self._helper.update(data, uri=uri, timeout=timeout)
495,198
Installs firmware to a logical interconnect. The three operations that are supported for the firmware update are Stage (uploads firmware to the interconnect), Activate (installs firmware on the interconnect), and Update (which does a Stage and Activate in a sequential manner). Args: ...
def install_firmware(self, firmware_information): firmware_uri = self._helper.build_subresource_uri(self.data["uri"], subresource_path=self.FIRMWARE_PATH) return self._helper.update(firmware_information, firmware_uri)
495,202
Generates the forwarding information base dump file for a logical interconnect. Args: timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView, just stops waiting for its completion. Returns: Inter...
def create_forwarding_information_base(self, timeout=-1): uri = "{}{}".format(self.data["uri"], self.FORWARDING_INFORMATION_PATH) return self._helper.do_post(uri, None, timeout, None)
495,204