idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
39,100 | def print_graph ( self , format : str = 'turtle' ) -> str : print ( self . g . serialize ( format = format ) . decode ( 'utf-8' ) ) | prints serialized formated rdflib Graph |
39,101 | def updateTerms ( self , data : list , LIMIT : int = 20 , _print : bool = True , crawl : bool = False , ) -> list : url_base = self . base_url + '/api/1/term/edit/{id}' merged_data = [ ] old_data = self . identifierSearches ( [ d [ 'id' ] for d in data ] , LIMIT = LIMIT , _print = _print , crawl = crawl , ) for d in da... | Updates existing entities |
39,102 | def getAnnotations_via_tid ( self , tids , LIMIT = 25 , _print = True , crawl = False ) : url_base = self . base_url + '/api/1/term/get-annotations/{tid}?key=' + self . api_key urls = [ url_base . format ( tid = str ( tid ) ) for tid in tids ] return self . get ( urls , LIMIT = LIMIT , _print = _print , crawl = crawl ) | tids = list of term ids that possess the annoations |
39,103 | def getAnnotations_via_id ( self , annotation_ids , LIMIT = 25 , _print = True , crawl = False ) : url_base = self . base_url + '/api/1/term/get-annotation/{id}?key=' + self . api_key urls = [ url_base . format ( id = str ( annotation_id ) ) for annotation_id in annotation_ids ] return self . get ( urls , LIMIT = LIMIT... | tids = list of strings or ints that are the ids of the annotations themselves |
39,104 | def deleteAnnotations ( self , annotation_ids , LIMIT = 25 , _print = True , crawl = False , ) : url_base = self . base_url + '/api/1/term/edit-annotation/{annotation_id}' annotations = self . getAnnotations_via_id ( annotation_ids , LIMIT = LIMIT , _print = _print , crawl = crawl ) annotations_to_delete = [ ] for anno... | data = list of ids |
39,105 | def deprecate_entity ( self , ilx_id : str , note = None , ) -> None : term_id , term_version = [ ( d [ 'id' ] , d [ 'version' ] ) for d in self . ilxSearches ( [ ilx_id ] , crawl = True , _print = False ) . values ( ) ] [ 0 ] annotations = [ { 'tid' : term_id , 'annotation_tid' : '306375' , 'value' : 'True' , 'term_ve... | Tagged term in interlex to warn this term is no longer used |
39,106 | def force_add_term ( self , entity : dict ) : needed = set ( [ 'label' , 'type' , ] ) url_ilx_add = self . base_url + '/api/1/ilx/add' url_term_add = self . base_url + '/api/1/term/add' url_term_update = self . base_url + '/api/1/term/edit/{id}' if ( set ( list ( entity ) ) & needed ) != needed : exit ( 'You need keys:... | Need to add an entity that already has a label existing in InterLex? Well this is the function for you! |
39,107 | def create_html ( s1 , s2 , output = 'test.html' ) : html = difflib . HtmlDiff ( ) . make_file ( s1 . split ( ) , s2 . split ( ) ) with open ( output , 'w' ) as f : f . write ( html ) | creates basic html based on the diff of 2 strings |
39,108 | def traverse_data ( obj , key_target ) : if isinstance ( obj , str ) and '.json' in str ( obj ) : obj = json . load ( open ( obj , 'r' ) ) if isinstance ( obj , list ) : queue = obj . copy ( ) elif isinstance ( obj , dict ) : queue = [ obj . copy ( ) ] else : sys . exit ( 'obj needs to be a list or dict' ) count = 0 wh... | will traverse nested list and dicts until key_target equals the current dict key |
39,109 | def memoryCheck ( vms_max_kb ) : safety_factor = 1.2 vms_max = vms_max_kb vms_gigs = vms_max / 1024 ** 2 buffer = safety_factor * vms_max buffer_gigs = buffer / 1024 ** 2 vm = psutil . virtual_memory ( ) free_gigs = vm . available / 1024 ** 2 if vm . available < buffer : raise MemoryError ( 'Running this requires quite... | Lookup vms_max using getCurrentVMSKb |
39,110 | def _sequence_query ( self ) : klass = self . __class__ query = klass . select ( ) . where ( klass . sequence . is_null ( False ) ) seq_scope_field_names = ( self . __seq_scope_field_name__ or '' ) . split ( ',' ) for name in seq_scope_field_names : seq_scope_field = getattr ( klass , name , None ) if seq_scope_field :... | query all sequence rows |
39,111 | def add_types ( graph , phenotypes ) : collect = defaultdict ( set ) def recurse ( id_ , start , level = 0 ) : for t in graph . g . triples ( ( None , None , id_ ) ) : if level == 0 : if t [ 1 ] != rdflib . term . URIRef ( 'http://www.w3.org/2002/07/owl#someValuesFrom' ) : continue if type_check ( t , ( rdflib . term .... | Add disjoint union classes so that it is possible to see the invariants associated with individual phenotypes |
39,112 | def config ( self ) : config = { } if self . config_file . exists ( ) : with open ( self . config_file . as_posix ( ) , 'rt' ) as f : config = { k : self . _override [ k ] if k in self . _override else v for k , v in yaml . safe_load ( f ) . items ( ) } return config | Allows changing the config on the fly |
39,113 | def _get_service_account_info ( self ) : with open ( self . service_account_file , 'r' ) as f : info = json . load ( f ) self . service_account_email = info . get ( 'client_email' ) if not self . service_account_email : raise GCECloudException ( 'Service account JSON file is invalid for GCE. ' 'client_email key is expe... | Retrieve json dict from service account file . |
39,114 | def _get_driver ( self ) : ComputeEngine = get_driver ( Provider . GCE ) return ComputeEngine ( self . service_account_email , self . service_account_file , project = self . service_account_project ) | Get authenticated GCE driver . |
39,115 | def _get_ssh_public_key ( self ) : key = ipa_utils . generate_public_ssh_key ( self . ssh_private_key_file ) return '{user}:{key} {user}' . format ( user = self . ssh_user , key = key . decode ( ) ) | Generate SSH public key from private key . |
39,116 | def _validate_region ( self ) : if not self . region : raise GCECloudException ( 'Zone is required for GCE cloud framework: ' 'Example: us-west1-a' ) try : zone = self . compute_driver . ex_get_zone ( self . region ) except Exception : zone = None if not zone : raise GCECloudException ( '{region} is not a valid GCE zon... | Validate region was passed in and is a valid GCE zone . |
39,117 | def _set_instance_ip ( self ) : instance = self . _get_instance ( ) if instance . public_ips : self . instance_ip = instance . public_ips [ 0 ] elif instance . private_ips : self . instance_ip = instance . private_ips [ 0 ] else : raise GCECloudException ( 'IP address for instance: %s cannot be found.' % self . running... | Retrieve and set the instance ip address . |
39,118 | def grab_rdflib_graph_version ( g : Graph ) -> str : version = g . subject_objects ( predicate = URIRef ( OWL . versionIRI ) ) version = [ o for s , o in version ] if len ( version ) != 1 : print ( 'versioning isn\'t correct' ) else : version = str ( version [ 0 ] ) return version | Crap - shot for ontology iri if its properly in the header and correctly formated |
39,119 | def fix_ilx ( self , ilx_id : str ) -> str : ilx_id = ilx_id . replace ( 'http://uri.interlex.org/base/' , '' ) if ilx_id [ : 4 ] not in [ 'TMP:' , 'tmp_' , 'ILX:' , 'ilx_' ] : raise ValueError ( 'Need to provide ilx ID with format ilx_# or ILX:# for given ID ' + ilx_id ) return ilx_id . replace ( 'ILX:' , 'ilx_' ) . r... | Database only excepts lower case and underscore version of ID |
39,120 | def pull_int_tail ( self , string : str ) -> str : int_tail = '' for element in string [ : : - 1 ] : try : int ( element ) int_tail = element + int_tail except : pass return int_tail | Useful for IDs that have giberish in the front of the real ID |
39,121 | def curie_search ( self , curie : str ) -> dict : ilx_row = self . curie2row . get ( curie ) if not ilx_row : return None else : return ilx_row | Returns the row in InterLex associated with the curie |
39,122 | def fragment_search ( self , fragement : str ) -> List [ dict ] : fragement = self . extract_fragment ( fragement ) ilx_rows = self . fragment2rows . get ( fragement ) if not ilx_rows : return None else : return ilx_rows | Returns the rows in InterLex associated with the fragment |
39,123 | def label_search ( self , label : str ) -> List [ dict ] : ilx_rows = self . label2rows ( self . local_degrade ( label ) ) if not ilx_rows : return None else : return ilx_rows | Returns the rows in InterLex associated with that label |
39,124 | def readyup_entity ( self , label : str , type : str , uid : Union [ int , str ] = None , comment : str = None , definition : str = None , superclass : str = None , synonyms : list = None , existing_ids : List [ dict ] = None , ) -> dict : entity = dict ( label = label , type = type , ) if uid : entity [ 'uid' ] = uid ... | Setups the entity to be InterLex ready |
39,125 | def exhaustive_label_check ( self , ontology : pd . DataFrame , label_predicate = 'rdfs:label' , diff : bool = True , ) -> Tuple [ list ] : inside , outside = [ ] , [ ] header = [ 'Index' ] + list ( ontology . columns ) for row in ontology . itertuples ( ) : row = { header [ i ] : val for i , val in enumerate ( row ) }... | All entities with conflicting labels gets a full diff |
39,126 | def exhaustive_iri_check ( self , ontology : pd . DataFrame , iri_predicate : str , diff : bool = True , ) -> Tuple [ list ] : inside , outside = [ ] , [ ] header = [ 'Index' ] + list ( ontology . columns ) for row in ontology . itertuples ( ) : row = { header [ i ] : val for i , val in enumerate ( row ) } entity_iri =... | All entities with conflicting iris gets a full diff to see if they belong |
39,127 | def exhaustive_curie_check ( self , ontology : pd . DataFrame , curie_predicate : str , curie_prefix : str , diff : bool = True , ) -> Tuple [ list ] : inside , outside = [ ] , [ ] curie_prefix = curie_prefix . replace ( ':' , '' ) header = [ 'Index' ] + list ( ontology . columns ) for row in ontology . itertuples ( ) ... | All entities with conflicting curies gets a full diff to see if they belong |
39,128 | def exhaustive_fragment_check ( self , ontology : pd . DataFrame , iri_curie_fragment_predicate : str = 'iri' , cross_reference_iris : bool = False , cross_reference_fragments : bool = False , diff : bool = True , ) -> Tuple [ list ] : inside , outside = [ ] , [ ] header = [ 'Index' ] + list ( ontology . columns ) for ... | All entities with conflicting fragments gets a full diff to see if they belong |
39,129 | def exhaustive_ontology_ilx_diff_row_only ( self , ontology_row : dict ) -> dict : results = [ ] header = [ 'Index' ] + list ( self . existing_ids . columns ) for row in self . existing_ids . itertuples ( ) : row = { header [ i ] : val for i , val in enumerate ( row ) } check_list = [ { 'external_ontology_row' : ontolo... | WARNING RUNTIME IS AWEFUL |
39,130 | def combo_exhaustive_label_definition_check ( self , ontology : pd . DataFrame , label_predicate : str , definition_predicates : str , diff = True ) -> List [ List [ dict ] ] : inside , outside = [ ] , [ ] header = [ 'Index' ] + list ( ontology . columns ) for row in ontology . itertuples ( ) : row = { header [ i ] : v... | Combo of label & definition exhaustive check out of convenience |
39,131 | def clear_cache ( ip = None ) : if ip : with ignored ( Exception ) : client = CLIENT_CACHE [ ip ] del CLIENT_CACHE [ ip ] client . close ( ) else : for client in CLIENT_CACHE . values ( ) : with ignored ( Exception ) : client . close ( ) CLIENT_CACHE . clear ( ) | Clear the client cache or remove key matching the given ip . |
39,132 | def establish_ssh_connection ( ip , ssh_private_key_file , ssh_user , port , attempts = 5 , timeout = None ) : client = paramiko . SSHClient ( ) client . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) ) while attempts : try : client . connect ( ip , port = port , username = ssh_user , key_filename = ssh_pri... | Establish ssh connection and return paramiko client . |
39,133 | def execute_ssh_command ( client , cmd ) : try : stdin , stdout , stderr = client . exec_command ( cmd ) err = stderr . read ( ) out = stdout . read ( ) if err : raise IpaSSHException ( out . decode ( ) + err . decode ( ) ) except : raise return out . decode ( ) | Execute given command using paramiko . |
39,134 | def extract_archive ( client , archive_path , extract_path = None ) : command = 'tar -xf {path}' . format ( path = archive_path ) if extract_path : command += ' -C {extract_path}' . format ( extract_path = extract_path ) out = execute_ssh_command ( client , command ) return out | Extract the archive in current path using the provided client . |
39,135 | def generate_public_ssh_key ( ssh_private_key_file ) : try : with open ( ssh_private_key_file , "rb" ) as key_file : key = key_file . read ( ) except FileNotFoundError : raise IpaUtilsException ( 'SSH private key file: %s cannot be found.' % ssh_private_key_file ) try : private_key = serialization . load_pem_private_ke... | Generate SSH public key from private key file . |
39,136 | def get_config_values ( config_path , section , default = 'default' ) : values = { } if not os . path . isfile ( config_path ) : raise IpaUtilsException ( 'Config file not found: %s' % config_path ) config = configparser . ConfigParser ( ) try : config . read ( config_path ) except Exception : raise IpaUtilsException (... | Parse ini config file and return a dict of values . |
39,137 | def get_ssh_client ( ip , ssh_private_key_file , ssh_user = 'root' , port = 22 , timeout = 600 , wait_period = 10 ) : if ip in CLIENT_CACHE : return CLIENT_CACHE [ ip ] start = time . time ( ) end = start + timeout client = None while time . time ( ) < end : try : client = establish_ssh_connection ( ip , ssh_private_ke... | Attempt to establish and test ssh connection . |
39,138 | def get_yaml_config ( config_path ) : config_path = os . path . expanduser ( config_path ) if not os . path . isfile ( config_path ) : raise IpaUtilsException ( 'Config file not found: %s' % config_path ) with open ( config_path , 'r' ) as f : config = yaml . safe_load ( f ) return config | Load yaml config file and return dictionary . |
39,139 | def parse_sync_points ( names , tests ) : test_files = [ ] section = set ( ) for name in names : if name in SYNC_POINTS : if section : test_files . append ( section ) test_files . append ( name ) section = set ( ) else : section . add ( find_test_file ( name , tests ) ) if section : test_files . append ( section ) retu... | Slice list of test names on sync points . |
39,140 | def put_file ( client , source_file , destination_file ) : try : sftp_client = client . open_sftp ( ) sftp_client . put ( source_file , destination_file ) except Exception as error : raise IpaUtilsException ( 'Error copying file to instance: {0}.' . format ( error ) ) finally : with ignored ( Exception ) : sftp_client ... | Copy file to instance using Paramiko client connection . |
39,141 | def redirect_output ( fileobj ) : old = sys . stdout sys . stdout = fileobj try : yield fileobj finally : sys . stdout = old | Redirect standard out to file . |
39,142 | def ssh_config ( ssh_user , ssh_private_key_file ) : try : ssh_file = NamedTemporaryFile ( delete = False , mode = 'w+' ) ssh_file . write ( 'Host *\n' ) ssh_file . write ( ' IdentityFile %s\n' % ssh_private_key_file ) ssh_file . write ( ' User %s' % ssh_user ) ssh_file . close ( ) yield ssh_file . name finally :... | Create temporary ssh config file . |
39,143 | def update_history_log ( history_log , clear = False , description = None , test_log = None ) : if not test_log and not clear : raise IpaUtilsException ( 'A test log or clear flag must be provided.' ) if clear : with ignored ( OSError ) : os . remove ( history_log ) else : history_dir = os . path . dirname ( history_lo... | Update the history log file with item . If clear flag is provided the log file is deleted . |
39,144 | def create_pred2common ( self ) : self . pred2common = { } for common_name , ext_preds in self . common2preds . items ( ) : for pred in ext_preds : pred = pred . lower ( ) . strip ( ) self . pred2common [ pred ] = common_name | Takes list linked to common name and maps common name to accepted predicate and their respected suffixes to decrease sensitivity . |
39,145 | def clean_pred ( self , pred , ignore_warning = False ) : original_pred = pred pred = pred . lower ( ) . strip ( ) if 'http' in pred : pred = pred . split ( '/' ) [ - 1 ] elif ':' in pred : if pred [ - 1 ] != ':' : pred = pred . split ( ':' ) [ - 1 ] else : if not ignore_warning : exit ( 'Not a valid predicate: ' + ori... | Takes the predicate and returns the suffix lower case stripped version |
39,146 | def _create_network_interface ( self , ip_config_name , nic_name , public_ip , region , resource_group_name , subnet , accelerated_networking = False ) : nic_config = { 'location' : region , 'ip_configurations' : [ { 'name' : ip_config_name , 'private_ip_allocation_method' : 'Dynamic' , 'subnet' : { 'id' : subnet . id ... | Create a network interface in the resource group . |
39,147 | def _create_public_ip ( self , public_ip_name , resource_group_name , region ) : public_ip_config = { 'location' : region , 'public_ip_allocation_method' : 'Dynamic' } try : public_ip_setup = self . network . public_ip_addresses . create_or_update ( resource_group_name , public_ip_name , public_ip_config ) except Excep... | Create dynamic public IP address in the resource group . |
39,148 | def _create_resource_group ( self , region , resource_group_name ) : resource_group_config = { 'location' : region } try : self . resource . resource_groups . create_or_update ( resource_group_name , resource_group_config ) except Exception as error : raise AzureCloudException ( 'Unable to create resource group: {0}.' ... | Create resource group if it does not exist . |
39,149 | def _create_storage_profile ( self ) : if self . image_publisher : storage_profile = { 'image_reference' : { 'publisher' : self . image_publisher , 'offer' : self . image_offer , 'sku' : self . image_sku , 'version' : self . image_version } , } else : for image in self . compute . images . list ( ) : if image . name ==... | Create the storage profile for the instance . |
39,150 | def _create_subnet ( self , resource_group_name , subnet_id , vnet_name ) : subnet_config = { 'address_prefix' : '10.0.0.0/29' } try : subnet_setup = self . network . subnets . create_or_update ( resource_group_name , vnet_name , subnet_id , subnet_config ) except Exception as error : raise AzureCloudException ( 'Unabl... | Create a subnet in the provided vnet and resource group . |
39,151 | def _create_virtual_network ( self , region , resource_group_name , vnet_name ) : vnet_config = { 'location' : region , 'address_space' : { 'address_prefixes' : [ '10.0.0.0/27' ] } } try : vnet_setup = self . network . virtual_networks . create_or_update ( resource_group_name , vnet_name , vnet_config ) except Exceptio... | Create a vnet in the given resource group with default address space . |
39,152 | def _create_vm ( self , vm_config ) : try : vm_setup = self . compute . virtual_machines . create_or_update ( self . running_instance_id , self . running_instance_id , vm_config ) except Exception as error : raise AzureCloudException ( 'An exception occurred creating virtual machine: {0}' . format ( error ) ) vm_setup ... | Attempt to create or update VM instance based on vm_parameters config . |
39,153 | def _create_vm_config ( self , interface ) : self . _process_image_id ( ) hardware_profile = { 'vm_size' : self . instance_type or AZURE_DEFAULT_TYPE } network_profile = { 'network_interfaces' : [ { 'id' : interface . id , 'primary' : True } ] } storage_profile = self . _create_storage_profile ( ) os_profile = { 'compu... | Create the VM config dictionary . |
39,154 | def _get_instance ( self ) : try : instance = self . compute . virtual_machines . get ( self . running_instance_id , self . running_instance_id , expand = 'instanceView' ) except Exception as error : raise AzureCloudException ( 'Unable to retrieve instance: {0}' . format ( error ) ) return instance | Return the instance matching the running_instance_id . |
39,155 | def _get_instance_state ( self ) : instance = self . _get_instance ( ) statuses = instance . instance_view . statuses for status in statuses : if status . code . startswith ( 'PowerState' ) : return status . display_status | Retrieve state of instance . |
39,156 | def _get_management_client ( self , client_class ) : try : client = get_client_from_auth_file ( client_class , auth_path = self . service_account_file ) except ValueError as error : raise AzureCloudException ( 'Service account file format is invalid: {0}.' . format ( error ) ) except KeyError as error : raise AzureClou... | Return instance of resource management client . |
39,157 | def _launch_instance ( self ) : self . running_instance_id = ipa_utils . generate_instance_name ( 'azure-ipa-test' ) self . logger . debug ( 'ID of instance: %s' % self . running_instance_id ) self . _set_default_resource_names ( ) try : self . _create_resource_group ( self . region , self . running_instance_id ) if se... | Create new test instance in a resource group with the same name . |
39,158 | def _process_image_id ( self ) : try : image_info = self . image_id . strip ( ) . split ( ':' ) self . image_publisher = image_info [ 0 ] self . image_offer = image_info [ 1 ] self . image_sku = image_info [ 2 ] self . image_version = image_info [ 3 ] except Exception : self . image_publisher = None | Split image id into component values . |
39,159 | def _set_default_resource_names ( self ) : self . ip_config_name = '' . join ( [ self . running_instance_id , '-ip-config' ] ) self . nic_name = '' . join ( [ self . running_instance_id , '-nic' ] ) self . public_ip_name = '' . join ( [ self . running_instance_id , '-public-ip' ] ) | Generate names for resources based on the running_instance_id . |
39,160 | def _set_image_id ( self ) : instance = self . _get_instance ( ) image_info = instance . storage_profile . image_reference if image_info . publisher : self . image_id = ':' . join ( [ image_info . publisher , image_info . offer , image_info . sku , image_info . version ] ) else : self . image_id = image_info . id . rsp... | If an existing instance is used get image id from deployment . |
39,161 | def _set_instance_ip ( self ) : try : ip_address = self . network . public_ip_addresses . get ( self . running_instance_id , self . public_ip_name ) . ip_address except Exception : try : ip_address = self . network . network_interfaces . get ( self . running_instance_id , self . nic_name ) . ip_configurations [ 0 ] . p... | Get the IP address based on instance ID . |
39,162 | def _terminate_instance ( self ) : try : self . resource . resource_groups . delete ( self . running_instance_id ) except Exception as error : raise AzureCloudException ( 'Unable to terminate resource group: {0}.' . format ( error ) ) | Terminate the resource group and instance . |
39,163 | def preferred_change ( data ) : ranking = [ 'CHEBI' , 'NCBITaxon' , 'COGPO' , 'CAO' , 'DICOM' , 'UBERON' , 'NLX' , 'NLXANAT' , 'NLXCELL' , 'NLXFUNC' , 'NLXINV' , 'NLXORG' , 'NLXRES' , 'NLXSUB' 'BIRNLEX' , 'SAO' , 'NDA.CDE' , 'PR' , 'IAO' , 'NIFEXT' , 'OEN' , 'ILX' , ] mock_rank = ranking [ : : - 1 ] score = [ ] old_pre... | Determines preferred existing id based on curie prefix in the ranking list |
39,164 | def main ( context , no_color ) : if context . obj is None : context . obj = { } context . obj [ 'no_color' ] = no_color | Ipa provides a Python API and command line utility for testing images . |
39,165 | def results ( context , history_log ) : if context . obj is None : context . obj = { } context . obj [ 'history_log' ] = history_log if context . invoked_subcommand is None : context . invoke ( show , item = 1 ) | Process provided history log and results files . |
39,166 | def delete ( context , item ) : history_log = context . obj [ 'history_log' ] no_color = context . obj [ 'no_color' ] try : with open ( history_log , 'r+' ) as f : lines = f . readlines ( ) history = lines . pop ( len ( lines ) - item ) f . seek ( 0 ) f . write ( '' . join ( lines ) ) f . flush ( ) f . truncate ( ) exc... | Delete the specified history item from the history log . |
39,167 | def show ( context , log , results_file , verbose , item ) : history_log = context . obj [ 'history_log' ] no_color = context . obj [ 'no_color' ] if not results_file : try : with open ( history_log , 'r' ) as f : lines = f . readlines ( ) history = lines [ len ( lines ) - item ] except IndexError : echo_style ( 'Histo... | Print test results info from provided results json file . |
39,168 | def _get_ssh_client ( self ) : return ipa_utils . get_ssh_client ( self . instance_ip , self . ssh_private_key_file , self . ssh_user , timeout = self . timeout ) | Return a new or existing SSH client for given ip . |
39,169 | def _log_info ( self ) : if self . cloud == 'ssh' : self . results [ 'info' ] = { 'platform' : self . cloud , 'distro' : self . distro_name , 'image' : self . instance_ip , 'timestamp' : self . time_stamp , 'log_file' : self . log_file , 'results_file' : self . results_file } else : self . results [ 'info' ] = { 'platf... | Output test run information to top of log file . |
39,170 | def _write_to_log ( self , output ) : with open ( self . log_file , 'a' ) as log_file : log_file . write ( '\n' ) log_file . write ( output ) log_file . write ( '\n' ) | Write the output string to the log file . |
39,171 | def _merge_results ( self , results ) : self . results [ 'tests' ] += results [ 'tests' ] for key , value in results [ 'summary' ] . items ( ) : self . results [ 'summary' ] [ key ] += value | Combine results of test run with exisiting dict . |
39,172 | def _save_results ( self ) : with open ( self . results_file , 'w' ) as results_file : json . dump ( self . results , results_file ) | Save results dictionary to json file . |
39,173 | def _set_distro ( self ) : if self . distro_name == 'sles' : self . distro = SLES ( ) elif self . distro_name == 'opensuse_leap' : self . distro = openSUSE_Leap ( ) else : raise IpaCloudException ( 'Distribution: %s, not supported.' % self . distro_name ) | Determine distro for image and create instance of class . |
39,174 | def _set_results_dir ( self ) : if self . running_instance_id : self . results_dir = os . path . join ( self . results_dir , self . cloud , self . image_id , self . running_instance_id ) else : self . results_dir = os . path . join ( self . results_dir , self . cloud , self . instance_ip ) try : os . makedirs ( self . ... | Create results directory if not exists . |
39,175 | def _collect_vm_info ( self ) : self . logger . info ( 'Collecting basic info about VM' ) client = self . _get_ssh_client ( ) out = self . distro . get_vm_info ( client ) self . _write_to_log ( out ) | Gather basic info about VM |
39,176 | def _update_history ( self ) : ipa_utils . update_history_log ( self . history_log , description = self . description , test_log = self . log_file ) | Save the current test information to history json . |
39,177 | def _wait_on_instance ( self , state , timeout = 600 , wait_period = 10 ) : current_state = 'Undefined' start = time . time ( ) end = start + timeout while time . time ( ) < end : current_state = self . _get_instance_state ( ) if state . lower ( ) == current_state . lower ( ) : return time . sleep ( wait_period ) raise... | Wait until instance is in given state . |
39,178 | def execute_ssh_command ( self , client , command ) : try : out = ipa_utils . execute_ssh_command ( client , command ) except Exception as error : raise IpaCloudException ( 'Command: "{0}", failed execution: {1}.' . format ( command , error ) ) else : self . _write_to_log ( out ) | Execute the provided command and log output . |
39,179 | def extract_archive ( self , client , archive_path , extract_path = None ) : try : out = ipa_utils . extract_archive ( client , archive_path , extract_path ) except Exception as error : raise IpaCloudException ( 'Failed to extract archive, "{0}": {1}.' . format ( archive_path , error ) ) else : self . _write_to_log ( o... | Extract the archive files using the client in the current path . |
39,180 | def hard_reboot_instance ( self ) : self . _stop_instance ( ) self . _start_instance ( ) self . _set_instance_ip ( ) self . logger . debug ( 'IP of instance: %s' % self . instance_ip ) ipa_utils . clear_cache ( ) | Stop then start the instance . |
39,181 | def install_package ( self , client , package ) : try : out = self . distro . install_package ( client , package ) except Exception as error : raise IpaCloudException ( 'Failed installing package, "{0}"; {1}.' . format ( package , error ) ) else : self . _write_to_log ( out ) | Install package using distro specific install method . |
39,182 | def process_injection_file ( self , client ) : configuration = ipa_utils . get_yaml_config ( self . inject ) if configuration . get ( 'inject_packages' ) : inject_packages = configuration [ 'inject_packages' ] if not isinstance ( inject_packages , list ) : inject_packages = [ inject_packages ] for package in inject_pac... | Load yaml file and process injection configuration . |
39,183 | def put_file ( self , client , source_file ) : try : file_name = os . path . basename ( source_file ) ipa_utils . put_file ( client , source_file , file_name ) except Exception as error : raise IpaCloudException ( 'Failed copying file, "{0}"; {1}.' . format ( source_file , error ) ) else : return file_name | Put file on instance in default SSH directory . |
39,184 | def decodeIlxResp ( resp ) : lines = [ _ for _ in resp . text . split ( '\n' ) if _ ] if 'successfull' in lines [ 0 ] : return [ ( _ . split ( '"' ) [ 1 ] , ilxIdFix ( _ . split ( ': ' ) [ - 1 ] ) ) for _ in lines [ 1 : ] ] elif 'errors' in lines [ 0 ] : return [ ( _ . split ( '"' ) [ 1 ] , ilxIdFix ( _ . split ( '(' )... | We need this until we can get json back directly and this is SUPER nasty |
39,185 | def getSubOrder ( existing ) : alpha = list ( zip ( * sorted ( ( ( k , v [ 'rec' ] [ 'label' ] ) for k , v in existing . items ( ) ) , key = lambda a : a [ 1 ] ) ) ) [ 0 ] depths = { } def getDepth ( id_ ) : if id_ in depths : return depths [ id_ ] else : if id_ in existing : names_above = getDepth ( existing [ id_ ] [... | Alpha sort by the full chain of parents . |
39,186 | def ilx_conv ( graph , prefix , ilx_start ) : to_sub = set ( ) for subject in graph . subjects ( rdflib . RDF . type , rdflib . OWL . Class ) : if PREFIXES [ prefix ] in subject : to_sub . add ( subject ) ilx_base = 'ilx_{:0>7}' ILX_base = 'ILX:{:0>7}' ilx_labels = { } replace = { } for sub in sorted ( to_sub ) : ilx_f... | convert a set of temporary identifiers to ilx and modify the graph in place |
39,187 | def config ( remote_base = 'https://raw.githubusercontent.com/SciCrunch/NIF-Ontology/' , local_base = None , branch = devconfig . neurons_branch , core_graph_paths = [ 'ttl/phenotype-core.ttl' , 'ttl/phenotypes.ttl' ] , core_graph = None , in_graph_paths = tuple ( ) , out_graph_path = '/tmp/_Neurons.ttl' , out_imports ... | Wraps graphBase . configGraphIO to provide a set of sane defaults for input ontologies and output files . |
39,188 | def add_version_iri ( graph , epoch ) : for ont in graph . subjects ( rdf . type , owl . Ontology ) : for versionIRI in graph . objects ( ont , owl . versionIRI ) : graph . remove ( ( ont , owl . versionIRI , versionIRI ) ) t = ont , owl . versionIRI , make_version_iri_from_iri ( ont , epoch ) graph . add ( t ) | Also remove the previous versionIRI if there was one . |
39,189 | def auth ( self ) : if self . oauth : return self . oauth return ( self . username , self . password ) | Return credentials for current Bitbucket user . |
39,190 | def authorize ( self , consumer_key , consumer_secret , callback_url = None , access_token = None , access_token_secret = None ) : self . consumer_key = consumer_key self . consumer_secret = consumer_secret if not access_token and not access_token_secret : if not callback_url : return ( False , "Callback URL required" ... | Call this with your consumer key secret and callback URL to generate a token for verification . |
39,191 | def verify ( self , verifier , consumer_key = None , consumer_secret = None , access_token = None , access_token_secret = None ) : self . consumer_key = consumer_key or self . consumer_key self . consumer_secret = consumer_secret or self . consumer_secret self . access_token = access_token or self . access_token self .... | After converting the token into verifier call this to finalize the authorization . |
39,192 | def finalize_oauth ( self , access_token , access_token_secret ) : self . access_token = access_token self . access_token_secret = access_token_secret self . oauth = OAuth1 ( self . consumer_key , client_secret = self . consumer_secret , resource_owner_key = self . access_token , resource_owner_secret = self . access_t... | Called internally once auth process is complete . |
39,193 | def dispatch ( self , method , url , auth = None , params = None , ** kwargs ) : r = Request ( method = method , url = url , auth = auth , params = params , data = kwargs ) s = Session ( ) resp = s . send ( r . prepare ( ) ) status = resp . status_code text = resp . text error = resp . reason if status >= 200 and statu... | Send HTTP request with given method credentials and data to the given URL and return the success and the result on success . |
39,194 | def url ( self , action , ** kwargs ) : return self . URLS [ 'BASE' ] % self . URLS [ action ] % kwargs | Construct and return the URL for a specific API service . |
39,195 | def get_user ( self , username = None ) : username = username or self . username or '' url = self . url ( 'GET_USER' , username = username ) response = self . dispatch ( 'GET' , url ) try : return ( response [ 0 ] , response [ 1 ] [ 'user' ] ) except TypeError : pass return response | Returns user informations . If username is not defined tries to return own informations . |
39,196 | def get_tags ( self , repo_slug = None ) : repo_slug = repo_slug or self . repo_slug or '' url = self . url ( 'GET_TAGS' , username = self . username , repo_slug = repo_slug ) return self . dispatch ( 'GET' , url , auth = self . auth ) | Get a single repository on Bitbucket and return its tags . |
39,197 | def get_branches ( self , repo_slug = None ) : repo_slug = repo_slug or self . repo_slug or '' url = self . url ( 'GET_BRANCHES' , username = self . username , repo_slug = repo_slug ) return self . dispatch ( 'GET' , url , auth = self . auth ) | Get a single repository on Bitbucket and return its branches . |
39,198 | def get_privileges ( self ) : url = self . url ( 'GET_USER_PRIVILEGES' ) return self . dispatch ( 'GET' , url , auth = self . auth ) | Get privledges for this user . |
39,199 | def create ( self , repo_slug = None , key = None , label = None ) : key = '%s' % key repo_slug = repo_slug or self . bitbucket . repo_slug or '' url = self . bitbucket . url ( 'SET_DEPLOY_KEY' , username = self . bitbucket . username , repo_slug = repo_slug ) return self . bitbucket . dispatch ( 'POST' , url , auth = ... | Associate an ssh key with your repo and return it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.