idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
15,800 | def upload ( self , file_obj ) : return self . _client . upload_object ( self . _instance , self . _bucket , self . name , file_obj ) | Replace the content of this object . |
15,801 | def moving_average ( arr : np . ndarray , n : int = 3 ) -> np . ndarray : ret = np . cumsum ( arr , dtype = float ) ret [ n : ] = ret [ n : ] - ret [ : - n ] return ret [ n - 1 : ] / n | Calculate the moving overage over an array . |
15,802 | def recursive_getattr ( obj : Any , attr : str , * args ) -> Any : def _getattr ( obj , attr ) : return getattr ( obj , attr , * args ) return functools . reduce ( _getattr , [ obj ] + attr . split ( '.' ) ) | Recursive getattar . |
15,803 | def recursive_setattr ( obj : Any , attr : str , val : Any ) -> Any : pre , _ , post = attr . rpartition ( '.' ) return setattr ( recursive_getattr ( obj , pre ) if pre else obj , post , val ) | Recusrive setattr . |
15,804 | def recursive_getitem ( d : Mapping [ str , Any ] , keys : Union [ str , Sequence [ str ] ] ) -> Any : if isinstance ( keys , str ) : return d [ keys ] else : return functools . reduce ( operator . getitem , keys , d ) | Recursively retrieve an item from a nested dict . |
15,805 | def get_array_for_fit ( observables : dict , track_pt_bin : int , jet_pt_bin : int ) -> histogram . Histogram1D : for name , observable in observables . items ( ) : if observable . track_pt_bin == track_pt_bin and observable . jet_pt_bin == jet_pt_bin : return histogram . Histogram1D . from_existing_hist ( observable .... | Get a Histogram1D associated with the selected jet and track pt bins . |
15,806 | def epcrparsethreads ( self ) : from Bio import SeqIO for sample in self . metadata : if sample . general . bestassemblyfile != 'NA' : threads = Thread ( target = self . epcrparse , args = ( ) ) threads . setDaemon ( True ) threads . start ( ) for sample in self . metadata : if sample . general . bestassemblyfile != 'N... | Parse the ePCR results and run BLAST on the parsed results |
15,807 | def epcrparse ( self ) : from Bio . Blast . Applications import NcbiblastnCommandline while True : sample , record , line = self . epcrparsequeue . get ( ) gene , chromosome , strand , start , end , m_match , gaps , act_len_exp_len = line . split ( '\t' ) genesequence = record [ chromosome ] [ int ( start ) - 1 : int (... | Run BLAST and record results to the object |
15,808 | def report ( self ) : data = '' for sample in self . metadata : if sample [ self . analysistype ] . primers != 'NA' : sample [ self . analysistype ] . report = os . path . join ( sample [ self . analysistype ] . reportdir , '{}_{}.csv' . format ( sample . name , self . analysistype ) ) strainspecific = 'Strain,{},\n{},... | Create reports of the findings |
15,809 | def setup_environment ( ) : osinter = ostool . get_interface ( ) pypath = osinter . get_maya_envpath ( ) for p in sys . path : pypath = os . pathsep . join ( ( pypath , p ) ) os . environ [ 'PYTHONPATH' ] = pypath | Set up neccessary environment variables |
15,810 | def execute_mayapy ( args , wait = True ) : osinter = ostool . get_interface ( ) mayapy = osinter . get_maya_python ( ) allargs = [ mayapy ] allargs . extend ( args ) print "Executing mayapy with: %s" % allargs mayapyprocess = subprocess . Popen ( allargs ) if wait : rc = mayapyprocess . wait ( ) print "Process mayapy ... | Execute mayapython with the given arguments capture and return the output |
15,811 | def setDoc ( self , doc ) : self . ui . overAtten . setNum ( doc [ 'overloaded_attenuation' ] ) self . ui . componentDetails . clearDoc ( ) self . ui . componentDetails . setDoc ( doc [ 'components' ] ) | Presents the documentation |
15,812 | def increase_by_changes ( self , changes_amount , ratio ) : increases = round ( changes_amount * ratio ) return self . increase ( int ( increases ) ) | Increase version by amount of changes |
15,813 | def wrap_maya_ui ( mayaname ) : ptr = apiUI . MQtUtil . findControl ( mayaname ) if ptr is None : ptr = apiUI . MQtUtil . findLayout ( mayaname ) if ptr is None : ptr = apiUI . MQtUtil . findMenuItem ( mayaname ) if ptr is not None : return wrap ( long ( ptr ) ) | Given the name of a Maya UI element of any type return the corresponding QWidget or QAction . If the object does not exist returns None |
15,814 | def query_args ( self , name ) : sql = 'select type, id from code_items ' 'where kind = 22 and name = ?' logging . debug ( '%s %s' , sql , ( name , ) ) self . cursor . execute ( sql , ( name , ) ) func = self . cursor . fetchone ( ) if func : sql = 'select param_number, type, name ' 'from code_items where parent_id = ?... | Query the return type and argument list of the specified function in the specified database . |
15,815 | def query_info ( self , name , like , kind ) : kind = self . _make_kind_id ( kind ) sql = 'select name, kind, file_id, type ' 'from code_items ' 'where name {} ?' . format ( 'like' if like else '=' ) args = ( name , ) if like : sql += ' escape ?' args = ( name , '\\' ) if kind : sql += ' and kind = ?' args = ( name , k... | Query the information of the name in the database . |
15,816 | def query_names ( self , name , like , kind ) : kind = self . _make_kind_id ( kind ) sql = 'select id, name from files ' 'where leaf_name {} ?' . format ( 'like' if like else '=' ) args = ( name , ) if like : sql += ' escape ?' args = ( name , '\\' ) logging . debug ( '%s %s' , sql , args ) self . cursor . execute ( sq... | Query function declarations in the files . |
15,817 | def query_struct ( self , name ) : sql = 'select id, file_id, name from code_items ' 'where name = ?' self . cursor . execute ( sql , ( name , ) ) for i in self . cursor . fetchall ( ) : sql = 'select id, type, name from code_items ' 'where parent_id = ?' self . cursor . execute ( sql , ( i [ 0 ] , ) ) members = self .... | Query struct . |
15,818 | def file_id_to_name ( self , file_id ) : sql = 'select name from files where id = ?' logging . debug ( '%s %s' , sql , ( file_id , ) ) self . cursor . execute ( sql , ( file_id , ) ) name = self . cursor . fetchone ( ) if name : return name [ 0 ] return '' | Convert a file id to the file name . |
15,819 | def _make_kind_id ( self , name_or_id ) : if not name_or_id : return None if name_or_id . isdigit ( ) : return name_or_id return self . kind_name_to_id ( name_or_id ) | Make kind_id from kind_name or kind_id . |
15,820 | def query_kinds ( self , kind ) : logging . debug ( _ ( 'querying %s' ) , kind ) if kind is None : return self . _kind_id_to_name . items ( ) if kind . isdigit ( ) : kind_name = self . kind_id_to_name ( int ( kind ) ) if kind_name : kind = ( kind , kind_name ) else : logging . warning ( _ ( 'id not found: %s' ) , kind ... | Query kinds . |
15,821 | def _init_kind_converter ( self ) : from . . utils import invert_dict kinds = self . session . query ( Kind ) . all ( ) self . _kind_id_to_name = { kind . id : kind . name for kind in kinds } self . _kind_name_to_id = invert_dict ( self . _kind_id_to_name ) | Make a dictionary mapping kind ids to the names . |
15,822 | def make_export ( self , exports ) : sql = 'drop table if exists export' logging . debug ( sql ) self . cursor . execute ( sql ) sql = 'create table if not exists export ' '(func text unique, module text)' logging . debug ( sql ) self . cursor . execute ( sql ) for module in exports : logging . debug ( _ ( 'insering ex... | Populate library exported function data . |
15,823 | def query_func_module ( self , func ) : exp = self . session . query ( Export ) . filter_by ( func = func ) . first ( ) if exp : return exp logging . debug ( _ ( 'Function not found: %s' ) , func ) alt = func + 'A' exp = self . session . query ( Export ) . filter_by ( func = alt ) . first ( ) if exp : logging . warning... | Query the module name of the specified function . |
15,824 | def query_module_funcs ( self , module ) : funcs = self . session . query ( Export ) . filter_by ( module = module ) . all ( ) return funcs | Query the functions in the specified module . |
15,825 | def _build_named_object_ids ( parameters ) : if isinstance ( parameters , str ) : return [ _build_named_object_id ( parameters ) ] return [ _build_named_object_id ( parameter ) for parameter in parameters ] | Builds a list of NamedObjectId . |
15,826 | def _build_command_ids ( issued_commands ) : if isinstance ( issued_commands , IssuedCommand ) : entry = issued_commands . _proto . commandQueueEntry return [ entry . cmdId ] else : return [ issued_command . _proto . commandQueueEntry . cmdId for issued_command in issued_commands ] | Builds a list of CommandId . |
15,827 | def _cache_key ( cmd_id ) : return '{}__{}__{}__{}' . format ( cmd_id . generationTime , cmd_id . origin , cmd_id . sequenceNumber , cmd_id . commandName ) | commandId is a tuple . Make a unique key for it . |
15,828 | def get_command_history ( self , issued_command ) : entry = issued_command . _proto . commandQueueEntry key = self . _cache_key ( entry . cmdId ) if key in self . _cache : return self . _cache [ key ] return None | Gets locally cached CommandHistory for the specified command . |
15,829 | def add ( self , parameters , abort_on_invalid = True , send_from_cache = True ) : assert self . subscription_id != - 1 if not parameters : return options = web_pb2 . ParameterSubscriptionRequest ( ) options . subscriptionId = self . subscription_id options . abortOnInvalid = abort_on_invalid options . sendFromCache = ... | Add one or more parameters to this subscription . |
15,830 | def remove ( self , parameters ) : assert self . subscription_id != - 1 if not parameters : return options = web_pb2 . ParameterSubscriptionRequest ( ) options . subscriptionId = self . subscription_id options . id . extend ( _build_named_object_ids ( parameters ) ) self . _manager . send ( 'unsubscribe' , options ) | Remove one or more parameters from this subscription . |
15,831 | def set_parameter_value ( self , parameter , value ) : parameter = adapt_name_for_rest ( parameter ) url = '/processors/{}/{}/parameters{}' . format ( self . _instance , self . _processor , parameter ) req = _build_value_proto ( value ) self . _client . put_proto ( url , data = req . SerializeToString ( ) ) | Sets the value of the specified parameter . |
15,832 | def set_parameter_values ( self , values ) : req = rest_pb2 . BulkSetParameterValueRequest ( ) for key in values : item = req . request . add ( ) item . id . MergeFrom ( _build_named_object_id ( key ) ) item . value . MergeFrom ( _build_value_proto ( values [ key ] ) ) url = '/processors/{}/{}/parameters/mset' . format... | Sets the value of multiple parameters . |
15,833 | def issue_command ( self , command , args = None , dry_run = False , comment = None ) : req = rest_pb2 . IssueCommandRequest ( ) req . sequenceNumber = SequenceGenerator . next ( ) req . origin = socket . gethostname ( ) req . dryRun = dry_run if comment : req . comment = comment if args : for key in args : assignment ... | Issue the given command |
15,834 | def list_alarms ( self , start = None , stop = None ) : params = { 'order' : 'asc' } if start is not None : params [ 'start' ] = to_isostring ( start ) if stop is not None : params [ 'stop' ] = to_isostring ( stop ) url = '/processors/{}/{}/alarms' . format ( self . _instance , self . _processor ) response = self . _cl... | Lists the active alarms . |
15,835 | def set_default_calibrator ( self , parameter , type , data ) : req = mdb_pb2 . ChangeParameterRequest ( ) req . action = mdb_pb2 . ChangeParameterRequest . SET_DEFAULT_CALIBRATOR if type : _add_calib ( req . defaultCalibrator , type , data ) url = '/mdb/{}/{}/parameters/{}' . format ( self . _instance , self . _proces... | Apply a calibrator while processing raw values of the specified parameter . If there is already a default calibrator associated to this parameter that calibrator gets replaced . |
15,836 | def reset_calibrators ( self , parameter ) : req = mdb_pb2 . ChangeParameterRequest ( ) req . action = mdb_pb2 . ChangeParameterRequest . RESET_CALIBRATORS calib_info = req . defaultCalibrator url = '/mdb/{}/{}/parameters/{}' . format ( self . _instance , self . _processor , parameter ) response = self . _client . post... | Reset all calibrators for the specified parameter to their original MDB value . |
15,837 | def set_default_alarm_ranges ( self , parameter , watch = None , warning = None , distress = None , critical = None , severe = None , min_violations = 1 ) : req = mdb_pb2 . ChangeParameterRequest ( ) req . action = mdb_pb2 . ChangeParameterRequest . SET_DEFAULT_ALARMS if ( watch or warning or distress or critical or se... | Generate out - of - limit alarms for a parameter using the specified alarm ranges . |
15,838 | def reset_alarm_ranges ( self , parameter ) : req = mdb_pb2 . ChangeParameterRequest ( ) req . action = mdb_pb2 . ChangeParameterRequest . RESET_ALARMS url = '/mdb/{}/{}/parameters/{}' . format ( self . _instance , self . _processor , parameter ) response = self . _client . post_proto ( url , data = req . SerializeToSt... | Reset all alarm limits for the specified parameter to their original MDB value . |
15,839 | def acknowledge_alarm ( self , alarm , comment = None ) : url = '/processors/{}/{}/parameters{}/alarms/{}' . format ( self . _instance , self . _processor , alarm . name , alarm . sequence_number ) req = rest_pb2 . EditAlarmRequest ( ) req . state = 'acknowledged' if comment is not None : req . comment = comment self .... | Acknowledges a specific alarm associated with a parameter . |
15,840 | def create_command_history_subscription ( self , issued_command = None , on_data = None , timeout = 60 ) : options = web_pb2 . CommandHistorySubscriptionRequest ( ) options . ignorePastCommands = True if issued_command : options . commandId . extend ( _build_command_ids ( issued_command ) ) manager = WebSocketSubscript... | Create a new command history subscription . |
15,841 | def create_parameter_subscription ( self , parameters , on_data = None , abort_on_invalid = True , update_on_expiration = False , send_from_cache = True , timeout = 60 ) : options = web_pb2 . ParameterSubscriptionRequest ( ) options . subscriptionId = - 1 options . abortOnInvalid = abort_on_invalid options . updateOnEx... | Create a new parameter subscription . |
15,842 | def create_alarm_subscription ( self , on_data = None , timeout = 60 ) : manager = WebSocketSubscriptionManager ( self . _client , resource = 'alarms' ) subscription = AlarmSubscription ( manager ) wrapped_callback = functools . partial ( _wrap_callback_parse_alarm_data , subscription , on_data ) manager . open ( wrapp... | Create a new alarm subscription . |
15,843 | def get_by ( self , name ) : return next ( ( item for item in self if item . name == name ) , None ) | get element by name |
15,844 | def fastqc ( self ) : while True : threadlock = threading . Lock ( ) ( sample , systemcall , outputdir , fastqcreads ) = self . qcqueue . get ( ) try : _ = glob ( os . path . join ( outputdir , '*.html' ) ) [ 0 ] except IndexError : make_path ( outputdir ) outstr = str ( ) errstr = str ( ) out , err = run_subprocess ( ... | Run fastqc system calls |
15,845 | def trimquality ( self ) : logging . info ( "Trimming fastq files" ) with progressbar ( self . metadata ) as bar : for sample in bar : if type ( sample . general . fastqfiles ) is list : fastqfiles = sorted ( sample . general . fastqfiles ) outputdir = sample . general . outputdirectory cleanforward = os . path . join ... | Uses bbduk from the bbmap tool suite to quality and adapter trim |
15,846 | def contamination_finder ( self , input_path = None , report_path = None ) : logging . info ( 'Calculating contamination in reads' ) if input_path is not None : input_dir = input_path else : input_dir = self . path if report_path is not None : reportpath = report_path else : reportpath = os . path . join ( input_dir , ... | Helper function to get confindr integrated into the assembly pipeline |
15,847 | def estimate_genome_size ( self ) : logging . info ( 'Estimating genome size using kmercountexact' ) for sample in self . metadata : sample [ self . analysistype ] . peaksfile = os . path . join ( sample [ self . analysistype ] . outputdir , 'peaks.txt' ) out , err , cmd = bbtools . kmercountexact ( forward_in = sorted... | Use kmercountexact from the bbmap suite of tools to estimate the size of the genome |
15,848 | def error_correction ( self ) : logging . info ( 'Error correcting reads' ) for sample in self . metadata : sample . general . trimmedcorrectedfastqfiles = [ fastq . split ( '.fastq.gz' ) [ 0 ] + '_trimmed_corrected.fastq.gz' for fastq in sorted ( sample . general . fastqfiles ) ] try : if not os . path . isfile ( samp... | Use tadpole from the bbmap suite of tools to perform error correction of the reads |
15,849 | def normalise_reads ( self ) : logging . info ( 'Normalising reads to a kmer depth of 100' ) for sample in self . metadata : sample . general . normalisedreads = [ fastq . split ( '.fastq.gz' ) [ 0 ] + '_normalised.fastq.gz' for fastq in sorted ( sample . general . fastqfiles ) ] try : out , err , cmd = bbtools . bbnor... | Use bbnorm from the bbmap suite of tools to perform read normalisation |
15,850 | def merge_pairs ( self ) : logging . info ( 'Merging paired reads' ) for sample in self . metadata : if len ( sample . general . fastqfiles ) == 2 : sample . general . mergedreads = os . path . join ( sample . general . outputdirectory , '{}_paired.fastq.gz' . format ( sample . name ) ) sample . general . unmergedforwa... | Use bbmerge from the bbmap suite of tools to merge paired - end reads |
15,851 | def main ( self ) : self . fasta_records ( ) self . fasta_stats ( ) self . find_largest_contig ( ) self . find_genome_length ( ) self . find_num_contigs ( ) self . find_n50 ( ) self . perform_pilon ( ) self . clear_attributes ( ) | Run all the methods required for pipeline outputs |
15,852 | def fasta_records ( self ) : for sample in self . metadata : setattr ( sample , self . analysistype , GenObject ( ) ) try : record_dict = SeqIO . to_dict ( SeqIO . parse ( sample . general . bestassemblyfile , "fasta" ) ) except FileNotFoundError : record_dict = dict ( ) sample [ self . analysistype ] . record_dict = r... | Use SeqIO to create dictionaries of all records for each FASTA file |
15,853 | def fasta_stats ( self ) : for sample in self . metadata : contig_lengths = list ( ) fasta_sequence = str ( ) for contig , record in sample [ self . analysistype ] . record_dict . items ( ) : contig_lengths . append ( len ( record . seq ) ) fasta_sequence += record . seq sample [ self . analysistype ] . contig_lengths ... | Parse the lengths of all contigs for each sample as well as the total GC% |
15,854 | def find_largest_contig ( self ) : for sample in self . metadata : sample [ self . analysistype ] . longest_contig = sample [ self . analysistype ] . contig_lengths | Determine the largest contig for each strain |
15,855 | def find_genome_length ( self ) : for sample in self . metadata : sample [ self . analysistype ] . genome_length = sum ( sample [ self . analysistype ] . contig_lengths ) | Determine the total length of all the contigs for each strain |
15,856 | def find_num_contigs ( self ) : for sample in self . metadata : sample [ self . analysistype ] . num_contigs = len ( sample [ self . analysistype ] . contig_lengths ) | Count the total number of contigs for each strain |
15,857 | def find_n50 ( self ) : for sample in self . metadata : sample [ self . analysistype ] . n50 = '-' currentlength = 0 for contig_length in sample [ self . analysistype ] . contig_lengths : currentlength += contig_length if currentlength >= sample [ self . analysistype ] . genome_length * 0.5 : sample [ self . analysisty... | Calculate the N50 for each strain . N50 is defined as the largest contig such that at least half of the total genome size is contained in contigs equal to or larger than this contig |
15,858 | def perform_pilon ( self ) : for sample in self . metadata : try : if sample [ self . analysistype ] . num_contigs > 500 or sample . confindr . contam_status == 'Contaminated' : sample . general . polish = False else : sample . general . polish = True except AttributeError : sample . general . polish = True | Determine if pilon polishing should be attempted . Do not perform polishing if confindr determines that the sample is contaminated or if there are > 500 contigs |
15,859 | def clear_attributes ( self ) : for sample in self . metadata : try : delattr ( sample [ self . analysistype ] , 'record_dict' ) delattr ( sample [ self . analysistype ] , 'contig_lengths' ) delattr ( sample [ self . analysistype ] , 'longest_contig' ) except AttributeError : pass | Remove the record_dict attribute from the object as SeqRecords are not JSON - serializable . Also remove the contig_lengths and longest_contig attributes as they are large lists that make the . json file ugly |
15,860 | def run_qaml ( self ) : logging . info ( 'Running GenomeQAML quality assessment' ) qaml_call = 'classify.py -t {tf} -r {rf}' . format ( tf = self . qaml_path , rf = self . qaml_report ) make_path ( self . reportpath ) if not os . path . isfile ( self . qaml_report ) : out , err = run_subprocess ( qaml_call ) self . thr... | Create and run the GenomeQAML system call |
15,861 | def parse_qaml ( self ) : logging . info ( 'Parsing GenomeQAML outputs' ) nesteddictionary = dict ( ) dictionary = pandas . read_csv ( self . qaml_report ) . to_dict ( ) for header in dictionary : for sample , value in dictionary [ header ] . items ( ) : try : nesteddictionary [ sample ] . update ( { header : value } )... | Parse the GenomeQAML report and populate metadata objects |
15,862 | def init ( self , ) : self . gw = None pm = MayaPluginManager . get ( ) genesis = pm . get_plugin ( "Genesis" ) self . GenesisWin = self . subclass_genesis ( genesis . GenesisWin ) | Initialize the plugin . Do nothing . |
15,863 | def save_lastfile ( self , tfi ) : tf = models . TaskFile . objects . get ( task = tfi . task , version = tfi . version , releasetype = tfi . releasetype , descriptor = tfi . descriptor , typ = tfi . typ ) c = self . get_config ( ) c [ 'lastfile' ] = tf . pk c . write ( ) | Save the taskfile in the config |
15,864 | def subclass_genesis ( self , genesisclass ) : class MayaGenesisWin ( genesisclass ) : def open_shot ( self , taskfile ) : return self . open_file ( taskfile ) def save_shot ( self , jbfile , tf ) : self . update_scene_node ( tf ) self . save_file ( jbfile ) def open_asset ( self , taskfile ) : return self . open_file ... | Subclass the given genesis class and implement all abstract methods |
15,865 | def stash_calibration ( self , attenuations , freqs , frange , calname ) : self . calibration_vector = attenuations self . calibration_freqs = freqs self . calibration_frange = frange self . calname = calname | Save it for later |
15,866 | def set_stim_by_index ( self , index ) : self . stimulus . clearComponents ( ) self . stimulus . insertComponent ( self . stim_components [ index ] ) | Sets the stimulus to be generated to the one referenced by index |
15,867 | def process_calibration ( self , save = True ) : if not self . save_data : raise Exception ( "Cannot process an unsaved calibration" ) avg_signal = np . mean ( self . datafile . get_data ( self . current_dataset_name + '/signal' ) , axis = 0 ) diffdB = attenuation_curve ( self . stimulus . signal ( ) [ 0 ] , avg_signal... | processes calibration control signal . Determines transfer function of speaker to get frequency vs . attenuation curve . |
15,868 | def setModel ( self , model ) : "Sets the StimulusModel for this editor" self . _model = model self . ui . aofsSpnbx . setValue ( model . samplerate ( ) ) | Sets the StimulusModel for this editor |
15,869 | def setStimIndex ( self , row , stimIndex ) : "Change out the component type in row to the one indexed by stimIndex" newcomp = self . _allComponents [ row ] [ stimIndex ] self . _model . removeComponent ( row , 1 ) self . _model . insertComponent ( newcomp , row , 1 ) | Change out the component type in row to the one indexed by stimIndex |
15,870 | def addComponentEditor ( self ) : row = self . _model . rowCount ( ) comp_stack_editor = ExploreComponentEditor ( ) self . ui . trackStack . addWidget ( comp_stack_editor ) idx_button = IndexButton ( row ) idx_button . pickMe . connect ( self . ui . trackStack . setCurrentIndex ) self . trackBtnGroup . addButton ( idx_... | Adds a new component to the model and an editor for this component to this editor |
15,871 | def list_space_systems ( self , page_size = None ) : params = { } if page_size is not None : params [ 'limit' ] = page_size return pagination . Iterator ( client = self . _client , path = '/mdb/{}/space-systems' . format ( self . _instance ) , params = params , response_class = mdb_pb2 . ListSpaceSystemsResponse , item... | Lists the space systems visible to this client . |
15,872 | def get_space_system ( self , name ) : url = '/mdb/{}/space-systems{}' . format ( self . _instance , name ) response = self . _client . get_proto ( url ) message = mdb_pb2 . SpaceSystemInfo ( ) message . ParseFromString ( response . content ) return SpaceSystem ( message ) | Gets a single space system by its unique name . |
15,873 | def list_parameters ( self , parameter_type = None , page_size = None ) : params = { 'details' : True } if parameter_type is not None : params [ 'type' ] = parameter_type if page_size is not None : params [ 'limit' ] = page_size return pagination . Iterator ( client = self . _client , path = '/mdb/{}/parameters' . form... | Lists the parameters visible to this client . |
15,874 | def get_parameter ( self , name ) : name = adapt_name_for_rest ( name ) url = '/mdb/{}/parameters{}' . format ( self . _instance , name ) response = self . _client . get_proto ( url ) message = mdb_pb2 . ParameterInfo ( ) message . ParseFromString ( response . content ) return Parameter ( message ) | Gets a single parameter by its name . |
15,875 | def list_containers ( self , page_size = None ) : params = { } if page_size is not None : params [ 'limit' ] = page_size return pagination . Iterator ( client = self . _client , path = '/mdb/{}/containers' . format ( self . _instance ) , params = params , response_class = mdb_pb2 . ListContainersResponse , items_key = ... | Lists the containers visible to this client . |
15,876 | def get_container ( self , name ) : name = adapt_name_for_rest ( name ) url = '/mdb/{}/containers{}' . format ( self . _instance , name ) response = self . _client . get_proto ( url ) message = mdb_pb2 . ContainerInfo ( ) message . ParseFromString ( response . content ) return Container ( message ) | Gets a single container by its unique name . |
15,877 | def list_commands ( self , page_size = None ) : params = { } if page_size is not None : params [ 'limit' ] = page_size return pagination . Iterator ( client = self . _client , path = '/mdb/{}/commands' . format ( self . _instance ) , params = params , response_class = mdb_pb2 . ListCommandsResponse , items_key = 'comma... | Lists the commands visible to this client . |
15,878 | def get_command ( self , name ) : name = adapt_name_for_rest ( name ) url = '/mdb/{}/commands{}' . format ( self . _instance , name ) response = self . _client . get_proto ( url ) message = mdb_pb2 . CommandInfo ( ) message . ParseFromString ( response . content ) return Command ( message ) | Gets a single command by its unique name . |
15,879 | def list_algorithms ( self , page_size = None ) : params = { } if page_size is not None : params [ 'limit' ] = page_size return pagination . Iterator ( client = self . _client , path = '/mdb/{}/algorithms' . format ( self . _instance ) , params = params , response_class = mdb_pb2 . ListAlgorithmsResponse , items_key = ... | Lists the algorithms visible to this client . |
15,880 | def get_algorithm ( self , name ) : name = adapt_name_for_rest ( name ) url = '/mdb/{}/algorithms{}' . format ( self . _instance , name ) response = self . _client . get_proto ( url ) message = mdb_pb2 . AlgorithmInfo ( ) message . ParseFromString ( response . content ) return Algorithm ( message ) | Gets a single algorithm by its unique name . |
15,881 | def list_buckets ( self , instance ) : response = self . _client . get_proto ( path = '/buckets/' + instance ) message = rest_pb2 . ListBucketsResponse ( ) message . ParseFromString ( response . content ) buckets = getattr ( message , 'bucket' ) return iter ( [ Bucket ( bucket , instance , self ) for bucket in buckets ... | List the buckets for an instance . |
15,882 | def list_objects ( self , instance , bucket_name , prefix = None , delimiter = None ) : url = '/buckets/{}/{}' . format ( instance , bucket_name ) params = { } if prefix is not None : params [ 'prefix' ] = prefix if delimiter is not None : params [ 'delimiter' ] = delimiter response = self . _client . get_proto ( path ... | List the objects for a bucket . |
15,883 | def create_bucket ( self , instance , bucket_name ) : req = rest_pb2 . CreateBucketRequest ( ) req . name = bucket_name url = '/buckets/{}' . format ( instance ) self . _client . post_proto ( url , data = req . SerializeToString ( ) ) | Create a new bucket in the specified instance . |
15,884 | def remove_bucket ( self , instance , bucket_name ) : url = '/buckets/{}/{}' . format ( instance , bucket_name ) self . _client . delete_proto ( url ) | Remove a bucket from the specified instance . |
15,885 | def upload_object ( self , instance , bucket_name , object_name , file_obj , content_type = None ) : url = '/buckets/{}/{}/{}' . format ( instance , bucket_name , object_name ) with open ( file_obj , 'rb' ) as f : if content_type : files = { object_name : ( object_name , f , content_type ) } else : files = { object_nam... | Upload an object to a bucket . |
15,886 | def remove_object ( self , instance , bucket_name , object_name ) : url = '/buckets/{}/{}/{}' . format ( instance , bucket_name , object_name ) self . _client . delete_proto ( url ) | Remove an object from a bucket . |
15,887 | def get_now_utc ( ) : ZERO = datetime . timedelta ( 0 ) class UTC ( datetime . tzinfo ) : def utcoffset ( self , dt ) : return ZERO def tzname ( self , dt ) : return "UTC" def dst ( self , dt ) : return ZERO now = datetime . datetime . now ( UTC ( ) ) return now | date in UTC ISO format |
15,888 | def get ( self , position ) : counter = 0 current_node = self . head while current_node is not None and counter <= position : if counter == position : return current_node . val current_node = current_node . next_node counter += 1 return None | Gets value at index |
15,889 | def insert_first ( self , val ) : self . head = Node ( val , next_node = self . head ) return True | Insert in head |
15,890 | def insert ( self , val , position = 0 ) : if position <= 0 : return self . insert_first ( val ) counter = 0 last_node = self . head current_node = self . head while current_node is not None and counter <= position : if counter == position : last_node . next_node = Node ( val , current_node ) return True last_node = cu... | Insert in position |
15,891 | def remove ( self , position ) : if position <= 0 : return self . remove_first ( ) if position >= self . length ( ) - 1 : return self . remove_last ( ) counter = 0 last_node = self . head current_node = self . head while current_node is not None and counter <= position : if counter == position : last_node . next_node =... | Removes at index |
15,892 | def to_lst ( self ) : out = [ ] node = self . head while node is not None : out . append ( node . val ) node = node . next_node return out | Cycle all items and puts them in a list |
15,893 | def execute ( self , func , * args , ** kwargs ) : return [ func ( item , * args , ** kwargs ) for item in self . to_lst ( ) ] | Executes function on each item |
15,894 | def from_specification ( specification , env_prefix = None , separator = '.' , parent_names = None ) : items = { } for item_name , item_info in six . iteritems ( specification ) : names = copy . copy ( parent_names ) if parent_names else [ ] items [ item_name ] = _generate_item ( item_name , item_info , env_prefix , se... | Used to create YapconfItems from a specification dictionary . |
15,895 | def update_default ( self , new_default , respect_none = False ) : if new_default is not None : self . default = new_default elif new_default is None and respect_none : self . default = None | Update our current default with the new_default . |
15,896 | def migrate_config ( self , current_config , config_to_migrate , always_update , update_defaults ) : value = self . _search_config_for_possible_names ( current_config ) self . _update_config ( config_to_migrate , value , always_update , update_defaults ) | Migrate config value in current_config updating config_to_migrate . |
15,897 | def add_argument ( self , parser , bootstrap = False ) : if self . cli_expose : args = self . _get_argparse_names ( parser . prefix_chars ) kwargs = self . _get_argparse_kwargs ( bootstrap ) parser . add_argument ( * args , ** kwargs ) | Add this item as an argument to the given parser . |
15,898 | def get_config_value ( self , overrides , skip_environment = False ) : label , override , key = self . _search_overrides ( overrides , skip_environment ) if override is None and self . default is None and self . required : raise YapconfItemNotFound ( 'Could not find config value for {0}' . format ( self . fq_name ) , s... | Get the configuration value from all overrides . |
15,899 | def add_argument ( self , parser , bootstrap = False ) : tmp_default = self . default exclusive_grp = parser . add_mutually_exclusive_group ( ) self . default = True args = self . _get_argparse_names ( parser . prefix_chars ) kwargs = self . _get_argparse_kwargs ( bootstrap ) exclusive_grp . add_argument ( * args , ** ... | Add boolean item as an argument to the given parser . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.