repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
tgbugs/pyontutils
pyontutils/sheets.py
Sheet.fetch
def fetch(self, fetch_notes=None): """ update remote values (called automatically at __init__) """ if fetch_notes is None: fetch_notes = self.fetch_notes values, notes_index = get_sheet_values(self.name, self.sheet_name, spreadsheet_serv...
python
def fetch(self, fetch_notes=None): """ update remote values (called automatically at __init__) """ if fetch_notes is None: fetch_notes = self.fetch_notes values, notes_index = get_sheet_values(self.name, self.sheet_name, spreadsheet_serv...
[ "def", "fetch", "(", "self", ",", "fetch_notes", "=", "None", ")", ":", "if", "fetch_notes", "is", "None", ":", "fetch_notes", "=", "self", ".", "fetch_notes", "values", ",", "notes_index", "=", "get_sheet_values", "(", "self", ".", "name", ",", "self", ...
update remote values (called automatically at __init__)
[ "update", "remote", "values", "(", "called", "automatically", "at", "__init__", ")" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/sheets.py#L134-L144
tgbugs/pyontutils
neurondm/neurondm/build.py
add_types
def add_types(graph, phenotypes): # TODO missing expression phenotypes! also basket type somehow :( """ Add disjoint union classes so that it is possible to see the invariants associated with individual phenotypes """ collect = defaultdict(set) def recurse(id_, start, level=0): #print(leve...
python
def add_types(graph, phenotypes): # TODO missing expression phenotypes! also basket type somehow :( """ Add disjoint union classes so that it is possible to see the invariants associated with individual phenotypes """ collect = defaultdict(set) def recurse(id_, start, level=0): #print(leve...
[ "def", "add_types", "(", "graph", ",", "phenotypes", ")", ":", "# TODO missing expression phenotypes! also basket type somehow :(", "collect", "=", "defaultdict", "(", "set", ")", "def", "recurse", "(", "id_", ",", "start", ",", "level", "=", "0", ")", ":", "#pr...
Add disjoint union classes so that it is possible to see the invariants associated with individual phenotypes
[ "Add", "disjoint", "union", "classes", "so", "that", "it", "is", "possible", "to", "see", "the", "invariants", "associated", "with", "individual", "phenotypes" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/build.py#L144-L170
tgbugs/pyontutils
neurondm/neurondm/build.py
_rest_make_phenotypes
def _rest_make_phenotypes(): #phenotype sources neuroner = Path(devconfig.git_local_base, 'neuroNER/resources/bluima/neuroner/hbp_morphology_ontology.obo').as_posix() neuroner1 = Path(devconfig.git_local_base, 'neuroNER/resources/bluima/neuroner/hbp_electrophysiology_ontolog...
python
def _rest_make_phenotypes(): #phenotype sources neuroner = Path(devconfig.git_local_base, 'neuroNER/resources/bluima/neuroner/hbp_morphology_ontology.obo').as_posix() neuroner1 = Path(devconfig.git_local_base, 'neuroNER/resources/bluima/neuroner/hbp_electrophysiology_ontolog...
[ "def", "_rest_make_phenotypes", "(", ")", ":", "#phenotype sources", "neuroner", "=", "Path", "(", "devconfig", ".", "git_local_base", ",", "'neuroNER/resources/bluima/neuroner/hbp_morphology_ontology.obo'", ")", ".", "as_posix", "(", ")", "neuroner1", "=", "Path", "(",...
print stuff print('matches') pprint(exact) pprint(similar) #print('EXACT', exact) print() for k, v in s2.items(): print(k) for k, v2 in sorted(v.items()): print(' ', k, ':', v2) #
[ "print", "stuff", "print", "(", "matches", ")", "pprint", "(", "exact", ")", "pprint", "(", "similar", ")" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/build.py#L509-L730
tgbugs/pyontutils
pyontutils/config.py
DevConfig.config
def config(self): """ Allows changing the config on the fly """ # TODO more efficient to read once and put watch on the file config = {} if self.config_file.exists(): with open(self.config_file.as_posix(), 'rt') as f: # 3.5/pypy3 can't open Path directly conf...
python
def config(self): """ Allows changing the config on the fly """ # TODO more efficient to read once and put watch on the file config = {} if self.config_file.exists(): with open(self.config_file.as_posix(), 'rt') as f: # 3.5/pypy3 can't open Path directly conf...
[ "def", "config", "(", "self", ")", ":", "# TODO more efficient to read once and put watch on the file", "config", "=", "{", "}", "if", "self", ".", "config_file", ".", "exists", "(", ")", ":", "with", "open", "(", "self", ".", "config_file", ".", "as_posix", "...
Allows changing the config on the fly
[ "Allows", "changing", "the", "config", "on", "the", "fly" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/config.py#L234-L244
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._get_service_account_info
def _get_service_account_info(self): """Retrieve json dict from service account file.""" 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 GCECloudExc...
python
def _get_service_account_info(self): """Retrieve json dict from service account file.""" 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 GCECloudExc...
[ "def", "_get_service_account_info", "(", "self", ")", ":", "with", "open", "(", "self", ".", "service_account_file", ",", "'r'", ")", "as", "f", ":", "info", "=", "json", ".", "load", "(", "f", ")", "self", ".", "service_account_email", "=", "info", ".",...
Retrieve json dict from service account file.
[ "Retrieve", "json", "dict", "from", "service", "account", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L122-L141
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._get_driver
def _get_driver(self): """Get authenticated GCE driver.""" ComputeEngine = get_driver(Provider.GCE) return ComputeEngine( self.service_account_email, self.service_account_file, project=self.service_account_project )
python
def _get_driver(self): """Get authenticated GCE driver.""" ComputeEngine = get_driver(Provider.GCE) return ComputeEngine( self.service_account_email, self.service_account_file, project=self.service_account_project )
[ "def", "_get_driver", "(", "self", ")", ":", "ComputeEngine", "=", "get_driver", "(", "Provider", ".", "GCE", ")", "return", "ComputeEngine", "(", "self", ".", "service_account_email", ",", "self", ".", "service_account_file", ",", "project", "=", "self", ".",...
Get authenticated GCE driver.
[ "Get", "authenticated", "GCE", "driver", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L143-L150
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._get_instance
def _get_instance(self): """Retrieve instance matching instance_id.""" try: instance = self.compute_driver.ex_get_node( self.running_instance_id, zone=self.region ) except ResourceNotFoundError as e: raise GCECloudException( ...
python
def _get_instance(self): """Retrieve instance matching instance_id.""" try: instance = self.compute_driver.ex_get_node( self.running_instance_id, zone=self.region ) except ResourceNotFoundError as e: raise GCECloudException( ...
[ "def", "_get_instance", "(", "self", ")", ":", "try", ":", "instance", "=", "self", ".", "compute_driver", ".", "ex_get_node", "(", "self", ".", "running_instance_id", ",", "zone", "=", "self", ".", "region", ")", "except", "ResourceNotFoundError", "as", "e"...
Retrieve instance matching instance_id.
[ "Retrieve", "instance", "matching", "instance_id", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L152-L166
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._get_ssh_public_key
def _get_ssh_public_key(self): """Generate SSH public key from private key.""" key = ipa_utils.generate_public_ssh_key(self.ssh_private_key_file) return '{user}:{key} {user}'.format( user=self.ssh_user, key=key.decode() )
python
def _get_ssh_public_key(self): """Generate SSH public key from private key.""" key = ipa_utils.generate_public_ssh_key(self.ssh_private_key_file) return '{user}:{key} {user}'.format( user=self.ssh_user, key=key.decode() )
[ "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", ...
Generate SSH public key from private key.
[ "Generate", "SSH", "public", "key", "from", "private", "key", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L168-L174
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._launch_instance
def _launch_instance(self): """Launch an instance of the given image.""" metadata = {'key': 'ssh-keys', 'value': self.ssh_public_key} self.running_instance_id = ipa_utils.generate_instance_name( 'gce-ipa-test' ) self.logger.debug('ID of instance: %s' % self.running_in...
python
def _launch_instance(self): """Launch an instance of the given image.""" metadata = {'key': 'ssh-keys', 'value': self.ssh_public_key} self.running_instance_id = ipa_utils.generate_instance_name( 'gce-ipa-test' ) self.logger.debug('ID of instance: %s' % self.running_in...
[ "def", "_launch_instance", "(", "self", ")", ":", "metadata", "=", "{", "'key'", ":", "'ssh-keys'", ",", "'value'", ":", "self", ".", "ssh_public_key", "}", "self", ".", "running_instance_id", "=", "ipa_utils", ".", "generate_instance_name", "(", "'gce-ipa-test'...
Launch an instance of the given image.
[ "Launch", "an", "instance", "of", "the", "given", "image", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L194-L237
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._validate_region
def _validate_region(self): """Validate region was passed in and is a valid GCE zone.""" if not self.region: raise GCECloudException( 'Zone is required for GCE cloud framework: ' 'Example: us-west1-a' ) try: zone = self.compute...
python
def _validate_region(self): """Validate region was passed in and is a valid GCE zone.""" if not self.region: raise GCECloudException( 'Zone is required for GCE cloud framework: ' 'Example: us-west1-a' ) try: zone = self.compute...
[ "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", ".", ...
Validate region was passed in and is a valid GCE zone.
[ "Validate", "region", "was", "passed", "in", "and", "is", "a", "valid", "GCE", "zone", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L244-L263
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._set_instance_ip
def _set_instance_ip(self): """Retrieve and set the instance ip address.""" 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: ...
python
def _set_instance_ip(self): """Retrieve and set the instance ip address.""" 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: ...
[ "def", "_set_instance_ip", "(", "self", ")", ":", "instance", "=", "self", ".", "_get_instance", "(", ")", "if", "instance", ".", "public_ips", ":", "self", ".", "instance_ip", "=", "instance", ".", "public_ips", "[", "0", "]", "elif", "instance", ".", "...
Retrieve and set the instance ip address.
[ "Retrieve", "and", "set", "the", "instance", "ip", "address", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L274-L286
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._start_instance
def _start_instance(self): """Start the instance.""" instance = self._get_instance() self.compute_driver.ex_start_node(instance) self.compute_driver.wait_until_running( [instance], timeout=self.timeout )
python
def _start_instance(self): """Start the instance.""" instance = self._get_instance() self.compute_driver.ex_start_node(instance) self.compute_driver.wait_until_running( [instance], timeout=self.timeout )
[ "def", "_start_instance", "(", "self", ")", ":", "instance", "=", "self", ".", "_get_instance", "(", ")", "self", ".", "compute_driver", ".", "ex_start_node", "(", "instance", ")", "self", ".", "compute_driver", ".", "wait_until_running", "(", "[", "instance",...
Start the instance.
[ "Start", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L288-L295
SUSE-Enceladus/ipa
ipa/ipa_gce.py
GCECloud._stop_instance
def _stop_instance(self): """Stop the instance.""" instance = self._get_instance() self.compute_driver.ex_stop_node(instance) self._wait_on_instance('stopped', timeout=self.timeout)
python
def _stop_instance(self): """Stop the instance.""" instance = self._get_instance() self.compute_driver.ex_stop_node(instance) self._wait_on_instance('stopped', timeout=self.timeout)
[ "def", "_stop_instance", "(", "self", ")", ":", "instance", "=", "self", ".", "_get_instance", "(", ")", "self", ".", "compute_driver", ".", "ex_stop_node", "(", "instance", ")", "self", ".", "_wait_on_instance", "(", "'stopped'", ",", "timeout", "=", "self"...
Stop the instance.
[ "Stop", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_gce.py#L297-L301
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.grab_rdflib_graph_version
def grab_rdflib_graph_version(g: Graph) -> str: ''' Crap-shot for ontology iri if its properly in the header and correctly formated ''' version = g.subject_objects( predicate = URIRef( OWL.versionIRI ) ) version = [o for s, o in version] if len(version) != 1: print('versionin...
python
def grab_rdflib_graph_version(g: Graph) -> str: ''' Crap-shot for ontology iri if its properly in the header and correctly formated ''' version = g.subject_objects( predicate = URIRef( OWL.versionIRI ) ) version = [o for s, o in version] if len(version) != 1: print('versionin...
[ "def", "grab_rdflib_graph_version", "(", "g", ":", "Graph", ")", "->", "str", ":", "version", "=", "g", ".", "subject_objects", "(", "predicate", "=", "URIRef", "(", "OWL", ".", "versionIRI", ")", ")", "version", "=", "[", "o", "for", "s", ",", "o", ...
Crap-shot for ontology iri if its properly in the header and correctly formated
[ "Crap", "-", "shot", "for", "ontology", "iri", "if", "its", "properly", "in", "the", "header", "and", "correctly", "formated" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L33-L41
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.fix_ilx
def fix_ilx(self, ilx_id: str) -> str: ''' Database only excepts lower case and underscore version of ID ''' 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 w...
python
def fix_ilx(self, ilx_id: str) -> str: ''' Database only excepts lower case and underscore version of ID ''' 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 w...
[ "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:'", ",", "'t...
Database only excepts lower case and underscore version of ID
[ "Database", "only", "excepts", "lower", "case", "and", "underscore", "version", "of", "ID" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L43-L49
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.pull_int_tail
def pull_int_tail(self, string: str) -> str: ''' Useful for IDs that have giberish in the front of the real ID ''' int_tail = '' for element in string[::-1]: try: int(element) int_tail = element + int_tail except: pass ...
python
def pull_int_tail(self, string: str) -> str: ''' Useful for IDs that have giberish in the front of the real ID ''' int_tail = '' for element in string[::-1]: try: int(element) int_tail = element + int_tail except: pass ...
[ "def", "pull_int_tail", "(", "self", ",", "string", ":", "str", ")", "->", "str", ":", "int_tail", "=", "''", "for", "element", "in", "string", "[", ":", ":", "-", "1", "]", ":", "try", ":", "int", "(", "element", ")", "int_tail", "=", "element", ...
Useful for IDs that have giberish in the front of the real ID
[ "Useful", "for", "IDs", "that", "have", "giberish", "in", "the", "front", "of", "the", "real", "ID" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L51-L60
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.extract_fragment
def extract_fragment(self, iri: str) -> str: ''' Pulls only for code/ID from the iri I only add the str() conversion for the iri because rdflib objects need to be converted. ''' fragment = str(iri).rsplit('/')[-1].split(':', 1)[-1].split('#', 1)[-1].split('_', 1)[-1] return frag...
python
def extract_fragment(self, iri: str) -> str: ''' Pulls only for code/ID from the iri I only add the str() conversion for the iri because rdflib objects need to be converted. ''' fragment = str(iri).rsplit('/')[-1].split(':', 1)[-1].split('#', 1)[-1].split('_', 1)[-1] return frag...
[ "def", "extract_fragment", "(", "self", ",", "iri", ":", "str", ")", "->", "str", ":", "fragment", "=", "str", "(", "iri", ")", ".", "rsplit", "(", "'/'", ")", "[", "-", "1", "]", ".", "split", "(", "':'", ",", "1", ")", "[", "-", "1", "]", ...
Pulls only for code/ID from the iri I only add the str() conversion for the iri because rdflib objects need to be converted.
[ "Pulls", "only", "for", "code", "/", "ID", "from", "the", "iri" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L62-L68
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.curie_search
def curie_search(self, curie:str) -> dict: ''' Returns the row in InterLex associated with the curie Note: Pressumed to not have duplicate curies in InterLex Args: curie: The "prefix:fragment_id" of the existing_id pertaining to the ontology Returns: ...
python
def curie_search(self, curie:str) -> dict: ''' Returns the row in InterLex associated with the curie Note: Pressumed to not have duplicate curies in InterLex Args: curie: The "prefix:fragment_id" of the existing_id pertaining to the ontology Returns: ...
[ "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 Note: Pressumed to not have duplicate curies in InterLex Args: curie: The "prefix:fragment_id" of the existing_id pertaining to the ontology Returns: None or dict
[ "Returns", "the", "row", "in", "InterLex", "associated", "with", "the", "curie" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L70-L84
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.fragment_search
def fragment_search(self, fragement:str) -> List[dict]: ''' Returns the rows in InterLex associated with the fragment Note: Pressumed to have duplicate fragements in InterLex Args: fragment: The fragment_id of the curie pertaining to the ontology Returns: ...
python
def fragment_search(self, fragement:str) -> List[dict]: ''' Returns the rows in InterLex associated with the fragment Note: Pressumed to have duplicate fragements in InterLex Args: fragment: The fragment_id of the curie pertaining to the ontology Returns: ...
[ "def", "fragment_search", "(", "self", ",", "fragement", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "fragement", "=", "self", ".", "extract_fragment", "(", "fragement", ")", "ilx_rows", "=", "self", ".", "fragment2rows", ".", "get", "(", "frag...
Returns the rows in InterLex associated with the fragment Note: Pressumed to have duplicate fragements in InterLex Args: fragment: The fragment_id of the curie pertaining to the ontology Returns: None or List[dict]
[ "Returns", "the", "rows", "in", "InterLex", "associated", "with", "the", "fragment" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L86-L101
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.label_search
def label_search(self, label:str) -> List[dict]: ''' Returns the rows in InterLex associated with that label Note: Pressumed to have duplicated labels in InterLex Args: label: label of the entity you want to find Returns: None or List[dict] ''...
python
def label_search(self, label:str) -> List[dict]: ''' Returns the rows in InterLex associated with that label Note: Pressumed to have duplicated labels in InterLex Args: label: label of the entity you want to find Returns: None or List[dict] ''...
[ "def", "label_search", "(", "self", ",", "label", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "ilx_rows", "=", "self", ".", "label2rows", "(", "self", ".", "local_degrade", "(", "label", ")", ")", "if", "not", "ilx_rows", ":", "return", "No...
Returns the rows in InterLex associated with that label Note: Pressumed to have duplicated labels in InterLex Args: label: label of the entity you want to find Returns: None or List[dict]
[ "Returns", "the", "rows", "in", "InterLex", "associated", "with", "that", "label" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L103-L117
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.readyup_entity
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: ''' Setups the entity to b...
python
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: ''' Setups the entity to b...
[ "def", "readyup_entity", "(", "self", ",", "label", ":", "str", ",", "type", ":", "str", ",", "uid", ":", "Union", "[", "int", ",", "str", "]", "=", "None", ",", "comment", ":", "str", "=", "None", ",", "definition", ":", "str", "=", "None", ",",...
Setups the entity to be InterLex ready Args: label: name of entity type: entities type Can be any of the following: term, cde, fde, pde, annotation, relationship uid: usually fine and auto completes to api user ID, but if you provide one with a ...
[ "Setups", "the", "entity", "to", "be", "InterLex", "ready" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L119-L175
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.__exhaustive_diff
def __exhaustive_diff(self, check_list:List[dict]) -> List[List[dict]]: ''' Helper for exhaustive checks to see if there any matches at all besides the anchor OUTPUT: [ { 'external_ontology_row' : {}, 'interlex_row' ...
python
def __exhaustive_diff(self, check_list:List[dict]) -> List[List[dict]]: ''' Helper for exhaustive checks to see if there any matches at all besides the anchor OUTPUT: [ { 'external_ontology_row' : {}, 'interlex_row' ...
[ "def", "__exhaustive_diff", "(", "self", ",", "check_list", ":", "List", "[", "dict", "]", ")", "->", "List", "[", "List", "[", "dict", "]", "]", ":", "def", "compare_rows", "(", "external_row", ":", "dict", ",", "ilx_row", ":", "dict", ")", "->", "L...
Helper for exhaustive checks to see if there any matches at all besides the anchor OUTPUT: [ { 'external_ontology_row' : {}, 'interlex_row' : {}, 'same': {}, }, ...
[ "Helper", "for", "exhaustive", "checks", "to", "see", "if", "there", "any", "matches", "at", "all", "besides", "the", "anchor", "OUTPUT", ":", "[", "{", "external_ontology_row", ":", "{}", "interlex_row", ":", "{}", "same", ":", "{}", "}", "...", "]" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L177-L244
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.exhaustive_label_check
def exhaustive_label_check( self, ontology:pd.DataFrame, label_predicate='rdfs:label', diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting labels gets a full diff Args: on...
python
def exhaustive_label_check( self, ontology:pd.DataFrame, label_predicate='rdfs:label', diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting labels gets a full diff Args: on...
[ "def", "exhaustive_label_check", "(", "self", ",", "ontology", ":", "pd", ".", "DataFrame", ",", "label_predicate", "=", "'rdfs:label'", ",", "diff", ":", "bool", "=", "True", ",", ")", "->", "Tuple", "[", "list", "]", ":", "inside", ",", "outside", "=",...
All entities with conflicting labels gets a full diff Args: ontology: pandas DataFrame created from an ontology where the colnames are predicates and if classes exist it is also thrown into a the colnames. label_predicate: usually in qname form and is the...
[ "All", "entities", "with", "conflicting", "labels", "gets", "a", "full", "diff" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L246-L286
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.exhaustive_iri_check
def exhaustive_iri_check( self, ontology:pd.DataFrame, iri_predicate:str, diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting iris gets a full diff to see if they belong Args: o...
python
def exhaustive_iri_check( self, ontology:pd.DataFrame, iri_predicate:str, diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting iris gets a full diff to see if they belong Args: o...
[ "def", "exhaustive_iri_check", "(", "self", ",", "ontology", ":", "pd", ".", "DataFrame", ",", "iri_predicate", ":", "str", ",", "diff", ":", "bool", "=", "True", ",", ")", "->", "Tuple", "[", "list", "]", ":", "inside", ",", "outside", "=", "[", "]"...
All entities with conflicting iris gets a full diff to see if they belong Args: ontology: pandas DataFrame created from an ontology where the colnames are predicates and if classes exist it is also thrown into a the colnames. iri_predicate: usually in qna...
[ "All", "entities", "with", "conflicting", "iris", "gets", "a", "full", "diff", "to", "see", "if", "they", "belong" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L288-L329
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.exhaustive_curie_check
def exhaustive_curie_check( self, ontology:pd.DataFrame, curie_predicate:str, curie_prefix:str, diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting curies gets a full d...
python
def exhaustive_curie_check( self, ontology:pd.DataFrame, curie_predicate:str, curie_prefix:str, diff:bool=True, ) -> Tuple[list]: ''' All entities with conflicting curies gets a full d...
[ "def", "exhaustive_curie_check", "(", "self", ",", "ontology", ":", "pd", ".", "DataFrame", ",", "curie_predicate", ":", "str", ",", "curie_prefix", ":", "str", ",", "diff", ":", "bool", "=", "True", ",", ")", "->", "Tuple", "[", "list", "]", ":", "ins...
All entities with conflicting curies gets a full diff to see if they belong Args: ontology: pandas DataFrame created from an ontology where the colnames are predicates and if classes exist it is also thrown into a the colnames. curie_predicate: usually in...
[ "All", "entities", "with", "conflicting", "curies", "gets", "a", "full", "diff", "to", "see", "if", "they", "belong" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L331-L373
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.exhaustive_fragment_check
def exhaustive_fragment_check( self, ontology:pd.DataFrame, iri_curie_fragment_predicate:str = 'iri', cross_reference_iris:bool = False, cross_reference_fragments:bool = False, ...
python
def exhaustive_fragment_check( self, ontology:pd.DataFrame, iri_curie_fragment_predicate:str = 'iri', cross_reference_iris:bool = False, cross_reference_fragments:bool = False, ...
[ "def", "exhaustive_fragment_check", "(", "self", ",", "ontology", ":", "pd", ".", "DataFrame", ",", "iri_curie_fragment_predicate", ":", "str", "=", "'iri'", ",", "cross_reference_iris", ":", "bool", "=", "False", ",", "cross_reference_fragments", ":", "bool", "="...
All entities with conflicting fragments gets a full diff to see if they belong Args: ontology: pandas DataFrame created from an ontology where the colnames are predicates and if classes exist it is also thrown into a the colnames. iri_curie_fragment_predi...
[ "All", "entities", "with", "conflicting", "fragments", "gets", "a", "full", "diff", "to", "see", "if", "they", "belong" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L375-L421
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.exhaustive_ontology_ilx_diff_row_only
def exhaustive_ontology_ilx_diff_row_only( self, ontology_row: dict ) -> dict: ''' WARNING RUNTIME IS AWEFUL ''' 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)} ...
python
def exhaustive_ontology_ilx_diff_row_only( self, ontology_row: dict ) -> dict: ''' WARNING RUNTIME IS AWEFUL ''' 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)} ...
[ "def", "exhaustive_ontology_ilx_diff_row_only", "(", "self", ",", "ontology_row", ":", "dict", ")", "->", "dict", ":", "results", "=", "[", "]", "header", "=", "[", "'Index'", "]", "+", "list", "(", "self", ".", "existing_ids", ".", "columns", ")", "for", ...
WARNING RUNTIME IS AWEFUL
[ "WARNING", "RUNTIME", "IS", "AWEFUL" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L423-L439
tgbugs/pyontutils
ilxutils/ilxutils/interlex_ingestion.py
InterLexIngestion.combo_exhaustive_label_definition_check
def combo_exhaustive_label_definition_check( self, ontology: pd.DataFrame, label_predicate:str, definition_predicates:str, d...
python
def combo_exhaustive_label_definition_check( self, ontology: pd.DataFrame, label_predicate:str, definition_predicates:str, d...
[ "def", "combo_exhaustive_label_definition_check", "(", "self", ",", "ontology", ":", "pd", ".", "DataFrame", ",", "label_predicate", ":", "str", ",", "definition_predicates", ":", "str", ",", "diff", "=", "True", ")", "->", "List", "[", "List", "[", "dict", ...
Combo of label & definition exhaustive check out of convenience Args: ontology: pandas DataFrame created from an ontology where the colnames are predicates and if classes exist it is also thrown into a the colnames. label_predicate: usually in qname form ...
[ "Combo", "of", "label", "&", "definition", "exhaustive", "check", "out", "of", "convenience" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/interlex_ingestion.py#L441-L498
SUSE-Enceladus/ipa
ipa/ipa_utils.py
clear_cache
def clear_cache(ip=None): """Clear the client cache or remove key matching the given ip.""" if ip: with ignored(Exception): client = CLIENT_CACHE[ip] del CLIENT_CACHE[ip] client.close() else: for client in CLIENT_CACHE.values(): with ignored(Ex...
python
def clear_cache(ip=None): """Clear the client cache or remove key matching the given ip.""" if ip: with ignored(Exception): client = CLIENT_CACHE[ip] del CLIENT_CACHE[ip] client.close() else: for client in CLIENT_CACHE.values(): with ignored(Ex...
[ "def", "clear_cache", "(", "ip", "=", "None", ")", ":", "if", "ip", ":", "with", "ignored", "(", "Exception", ")", ":", "client", "=", "CLIENT_CACHE", "[", "ip", "]", "del", "CLIENT_CACHE", "[", "ip", "]", "client", ".", "close", "(", ")", "else", ...
Clear the client cache or remove key matching the given ip.
[ "Clear", "the", "client", "cache", "or", "remove", "key", "matching", "the", "given", "ip", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L47-L58
SUSE-Enceladus/ipa
ipa/ipa_utils.py
establish_ssh_connection
def establish_ssh_connection(ip, ssh_private_key_file, ssh_user, port, attempts=5, timeout=None): """ Establish ssh connection and return paramiko client. Raises:...
python
def establish_ssh_connection(ip, ssh_private_key_file, ssh_user, port, attempts=5, timeout=None): """ Establish ssh connection and return paramiko client. Raises:...
[ "def", "establish_ssh_connection", "(", "ip", ",", "ssh_private_key_file", ",", "ssh_user", ",", "port", ",", "attempts", "=", "5", ",", "timeout", "=", "None", ")", ":", "client", "=", "paramiko", ".", "SSHClient", "(", ")", "client", ".", "set_missing_host...
Establish ssh connection and return paramiko client. Raises: IpaSSHException: If connection cannot be established in given number of attempts.
[ "Establish", "ssh", "connection", "and", "return", "paramiko", "client", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L61-L94
SUSE-Enceladus/ipa
ipa/ipa_utils.py
execute_ssh_command
def execute_ssh_command(client, cmd): """ Execute given command using paramiko. Returns: String output of cmd execution. Raises: IpaSSHException: If stderr returns a non-empty string. """ try: stdin, stdout, stderr = client.exec_command(cmd) err = stderr.read() ...
python
def execute_ssh_command(client, cmd): """ Execute given command using paramiko. Returns: String output of cmd execution. Raises: IpaSSHException: If stderr returns a non-empty string. """ try: stdin, stdout, stderr = client.exec_command(cmd) err = stderr.read() ...
[ "def", "execute_ssh_command", "(", "client", ",", "cmd", ")", ":", "try", ":", "stdin", ",", "stdout", ",", "stderr", "=", "client", ".", "exec_command", "(", "cmd", ")", "err", "=", "stderr", ".", "read", "(", ")", "out", "=", "stdout", ".", "read",...
Execute given command using paramiko. Returns: String output of cmd execution. Raises: IpaSSHException: If stderr returns a non-empty string.
[ "Execute", "given", "command", "using", "paramiko", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L97-L114
SUSE-Enceladus/ipa
ipa/ipa_utils.py
extract_archive
def extract_archive(client, archive_path, extract_path=None): """ Extract the archive in current path using the provided client. If extract_path is provided extract the archive there. """ command = 'tar -xf {path}'.format(path=archive_path) if extract_path: command += ' -C {extract_pat...
python
def extract_archive(client, archive_path, extract_path=None): """ Extract the archive in current path using the provided client. If extract_path is provided extract the archive there. """ command = 'tar -xf {path}'.format(path=archive_path) if extract_path: command += ' -C {extract_pat...
[ "def", "extract_archive", "(", "client", ",", "archive_path", ",", "extract_path", "=", "None", ")", ":", "command", "=", "'tar -xf {path}'", ".", "format", "(", "path", "=", "archive_path", ")", "if", "extract_path", ":", "command", "+=", "' -C {extract_path}'"...
Extract the archive in current path using the provided client. If extract_path is provided extract the archive there.
[ "Extract", "the", "archive", "in", "current", "path", "using", "the", "provided", "client", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L150-L162
SUSE-Enceladus/ipa
ipa/ipa_utils.py
generate_public_ssh_key
def generate_public_ssh_key(ssh_private_key_file): """Generate SSH public key from 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...
python
def generate_public_ssh_key(ssh_private_key_file): """Generate SSH public key from 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...
[ "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", ":", "rai...
Generate SSH public key from private key file.
[ "Generate", "SSH", "public", "key", "from", "private", "key", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L196-L221
SUSE-Enceladus/ipa
ipa/ipa_utils.py
get_config_values
def get_config_values(config_path, section, default='default'): """ Parse ini config file and return a dict of values. The provided section overrides any values in default section. """ values = {} if not os.path.isfile(config_path): raise IpaUtilsException( 'Config file not...
python
def get_config_values(config_path, section, default='default'): """ Parse ini config file and return a dict of values. The provided section overrides any values in default section. """ values = {} if not os.path.isfile(config_path): raise IpaUtilsException( 'Config file not...
[ "def", "get_config_values", "(", "config_path", ",", "section", ",", "default", "=", "'default'", ")", ":", "values", "=", "{", "}", "if", "not", "os", ".", "path", ".", "isfile", "(", "config_path", ")", ":", "raise", "IpaUtilsException", "(", "'Config fi...
Parse ini config file and return a dict of values. The provided section overrides any values in default section.
[ "Parse", "ini", "config", "file", "and", "return", "a", "dict", "of", "values", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L224-L256
SUSE-Enceladus/ipa
ipa/ipa_utils.py
get_ssh_client
def get_ssh_client(ip, ssh_private_key_file, ssh_user='root', port=22, timeout=600, wait_period=10): """Attempt to establish and test ssh connection.""" if ip in CLIENT_CACHE: return CLIENT_CACHE[ip] star...
python
def get_ssh_client(ip, ssh_private_key_file, ssh_user='root', port=22, timeout=600, wait_period=10): """Attempt to establish and test ssh connection.""" if ip in CLIENT_CACHE: return CLIENT_CACHE[ip] star...
[ "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", ...
Attempt to establish and test ssh connection.
[ "Attempt", "to", "establish", "and", "test", "ssh", "connection", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L271-L305
SUSE-Enceladus/ipa
ipa/ipa_utils.py
get_yaml_config
def get_yaml_config(config_path): """ Load yaml config file and return dictionary. Todo: * This will need refactoring similar to the test search. """ config_path = os.path.expanduser(config_path) if not os.path.isfile(config_path): raise IpaUtilsException( 'Config fi...
python
def get_yaml_config(config_path): """ Load yaml config file and return dictionary. Todo: * This will need refactoring similar to the test search. """ config_path = os.path.expanduser(config_path) if not os.path.isfile(config_path): raise IpaUtilsException( 'Config fi...
[ "def", "get_yaml_config", "(", "config_path", ")", ":", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "config_path", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "config_path", ")", ":", "raise", "IpaUtilsException", "(", "'Con...
Load yaml config file and return dictionary. Todo: * This will need refactoring similar to the test search.
[ "Load", "yaml", "config", "file", "and", "return", "dictionary", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L408-L423
SUSE-Enceladus/ipa
ipa/ipa_utils.py
parse_sync_points
def parse_sync_points(names, tests): """ Slice list of test names on sync points. If test is test file find full path to file. Returns: A list of test file sets and sync point strings. Examples: ['test_hard_reboot'] [set('test1', 'test2')] [set('test1', 'test2'), 't...
python
def parse_sync_points(names, tests): """ Slice list of test names on sync points. If test is test file find full path to file. Returns: A list of test file sets and sync point strings. Examples: ['test_hard_reboot'] [set('test1', 'test2')] [set('test1', 'test2'), 't...
[ "def", "parse_sync_points", "(", "names", ",", "tests", ")", ":", "test_files", "=", "[", "]", "section", "=", "set", "(", ")", "for", "name", "in", "names", ":", "if", "name", "in", "SYNC_POINTS", ":", "if", "section", ":", "test_files", ".", "append"...
Slice list of test names on sync points. If test is test file find full path to file. Returns: A list of test file sets and sync point strings. Examples: ['test_hard_reboot'] [set('test1', 'test2')] [set('test1', 'test2'), 'test_soft_reboot'] [set('test1', 'test2'),...
[ "Slice", "list", "of", "test", "names", "on", "sync", "points", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L435-L464
SUSE-Enceladus/ipa
ipa/ipa_utils.py
put_file
def put_file(client, source_file, destination_file): """ Copy file to instance using Paramiko client connection. """ try: sftp_client = client.open_sftp() sftp_client.put(source_file, destination_file) except Exception as error: raise IpaUtilsException( 'Error cop...
python
def put_file(client, source_file, destination_file): """ Copy file to instance using Paramiko client connection. """ try: sftp_client = client.open_sftp() sftp_client.put(source_file, destination_file) except Exception as error: raise IpaUtilsException( 'Error cop...
[ "def", "put_file", "(", "client", ",", "source_file", ",", "destination_file", ")", ":", "try", ":", "sftp_client", "=", "client", ".", "open_sftp", "(", ")", "sftp_client", ".", "put", "(", "source_file", ",", "destination_file", ")", "except", "Exception", ...
Copy file to instance using Paramiko client connection.
[ "Copy", "file", "to", "instance", "using", "Paramiko", "client", "connection", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L482-L495
SUSE-Enceladus/ipa
ipa/ipa_utils.py
redirect_output
def redirect_output(fileobj): """Redirect standard out to file.""" old = sys.stdout sys.stdout = fileobj try: yield fileobj finally: sys.stdout = old
python
def redirect_output(fileobj): """Redirect standard out to file.""" old = sys.stdout sys.stdout = fileobj try: yield fileobj finally: sys.stdout = old
[ "def", "redirect_output", "(", "fileobj", ")", ":", "old", "=", "sys", ".", "stdout", "sys", ".", "stdout", "=", "fileobj", "try", ":", "yield", "fileobj", "finally", ":", "sys", ".", "stdout", "=", "old" ]
Redirect standard out to file.
[ "Redirect", "standard", "out", "to", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L499-L506
SUSE-Enceladus/ipa
ipa/ipa_utils.py
ssh_config
def ssh_config(ssh_user, ssh_private_key_file): """Create temporary ssh config 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) ...
python
def ssh_config(ssh_user, ssh_private_key_file): """Create temporary ssh config 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) ...
[ "def", "ssh_config", "(", "ssh_user", ",", "ssh_private_key_file", ")", ":", "try", ":", "ssh_file", "=", "NamedTemporaryFile", "(", "delete", "=", "False", ",", "mode", "=", "'w+'", ")", "ssh_file", ".", "write", "(", "'Host *\\n'", ")", "ssh_file", ".", ...
Create temporary ssh config file.
[ "Create", "temporary", "ssh", "config", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L510-L521
SUSE-Enceladus/ipa
ipa/ipa_utils.py
update_history_log
def update_history_log(history_log, clear=False, description=None, test_log=None): """ Update the history log file with item. If clear flag is provided the log file is deleted. """ if not test_log and not clear: raise IpaUt...
python
def update_history_log(history_log, clear=False, description=None, test_log=None): """ Update the history log file with item. If clear flag is provided the log file is deleted. """ if not test_log and not clear: raise IpaUt...
[ "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 ...
Update the history log file with item. If clear flag is provided the log file is deleted.
[ "Update", "the", "history", "log", "file", "with", "item", ".", "If", "clear", "flag", "is", "provided", "the", "log", "file", "is", "deleted", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_utils.py#L524-L560
shanbay/peeweext
peeweext/validation.py
RegexValidator.validate
def validate(self, value): """Validate string by regex :param value: str :return: """ if not self._compiled_regex.match(value): raise ValidationError( 'value {:s} not match r"{:s}"'.format(value, self._regex))
python
def validate(self, value): """Validate string by regex :param value: str :return: """ if not self._compiled_regex.match(value): raise ValidationError( 'value {:s} not match r"{:s}"'.format(value, self._regex))
[ "def", "validate", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "_compiled_regex", ".", "match", "(", "value", ")", ":", "raise", "ValidationError", "(", "'value {:s} not match r\"{:s}\"'", ".", "format", "(", "value", ",", "self", ".", "...
Validate string by regex :param value: str :return:
[ "Validate", "string", "by", "regex", ":", "param", "value", ":", "str", ":", "return", ":" ]
train
https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/validation.py#L47-L54
tgbugs/pyontutils
ilxutils/ontoutils/create_strict_records_from_ontology.py
Ontology2DataFrame.ontology2df
def ontology2df(self): '''Updates self.g or self.path bc you could only choose 1''' if isinstance(self.path, str) or isinstance(self.path, p): self.path = str(self.path) filetype = p(self.path).suffix if filetype == '.json': self.g = None ...
python
def ontology2df(self): '''Updates self.g or self.path bc you could only choose 1''' if isinstance(self.path, str) or isinstance(self.path, p): self.path = str(self.path) filetype = p(self.path).suffix if filetype == '.json': self.g = None ...
[ "def", "ontology2df", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "path", ",", "str", ")", "or", "isinstance", "(", "self", ".", "path", ",", "p", ")", ":", "self", ".", "path", "=", "str", "(", "self", ".", "path", ")", "filetyp...
Updates self.g or self.path bc you could only choose 1
[ "Updates", "self", ".", "g", "or", "self", ".", "path", "bc", "you", "could", "only", "choose", "1" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ontoutils/create_strict_records_from_ontology.py#L41-L86
tgbugs/pyontutils
ilxutils/ontoutils/create_strict_records_from_ontology.py
CommonPredMap.create_pred2common
def create_pred2common(self): ''' Takes list linked to common name and maps common name to accepted predicate and their respected suffixes to decrease sensitivity. ''' self.pred2common = {} for common_name, ext_preds in self.common2preds.items(): for pred in ext_p...
python
def create_pred2common(self): ''' Takes list linked to common name and maps common name to accepted predicate and their respected suffixes to decrease sensitivity. ''' self.pred2common = {} for common_name, ext_preds in self.common2preds.items(): for pred in ext_p...
[ "def", "create_pred2common", "(", "self", ")", ":", "self", ".", "pred2common", "=", "{", "}", "for", "common_name", ",", "ext_preds", "in", "self", ".", "common2preds", ".", "items", "(", ")", ":", "for", "pred", "in", "ext_preds", ":", "pred", "=", "...
Takes list linked to common name and maps common name to accepted predicate and their respected suffixes to decrease sensitivity.
[ "Takes", "list", "linked", "to", "common", "name", "and", "maps", "common", "name", "to", "accepted", "predicate", "and", "their", "respected", "suffixes", "to", "decrease", "sensitivity", "." ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ontoutils/create_strict_records_from_ontology.py#L177-L185
tgbugs/pyontutils
ilxutils/ontoutils/create_strict_records_from_ontology.py
CommonPredMap.clean_pred
def clean_pred(self, pred, ignore_warning=False): ''' Takes the predicate and returns the suffix, lower case, stripped version ''' original_pred = pred pred = pred.lower().strip() if 'http' in pred: pred = pred.split('/')[-1] elif ':' in pred: if p...
python
def clean_pred(self, pred, ignore_warning=False): ''' Takes the predicate and returns the suffix, lower case, stripped version ''' original_pred = pred pred = pred.lower().strip() if 'http' in pred: pred = pred.split('/')[-1] elif ':' in pred: if p...
[ "def", "clean_pred", "(", "self", ",", "pred", ",", "ignore_warning", "=", "False", ")", ":", "original_pred", "=", "pred", "pred", "=", "pred", ".", "lower", "(", ")", ".", "strip", "(", ")", "if", "'http'", "in", "pred", ":", "pred", "=", "pred", ...
Takes the predicate and returns the suffix, lower case, stripped version
[ "Takes", "the", "predicate", "and", "returns", "the", "suffix", "lower", "case", "stripped", "version" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ontoutils/create_strict_records_from_ontology.py#L187-L200
tgbugs/pyontutils
ilxutils/ontoutils/create_strict_records_from_ontology.py
CommonPredMap.get_common_pred
def get_common_pred(self, pred): ''' Gets version of predicate and sees if we have a translation to a common relation. INPUT: pred = predicate from the triple OUTPUT: Common relationship or None ''' pred = self.clean_pred(pred) comm...
python
def get_common_pred(self, pred): ''' Gets version of predicate and sees if we have a translation to a common relation. INPUT: pred = predicate from the triple OUTPUT: Common relationship or None ''' pred = self.clean_pred(pred) comm...
[ "def", "get_common_pred", "(", "self", ",", "pred", ")", ":", "pred", "=", "self", ".", "clean_pred", "(", "pred", ")", "common_pred", "=", "self", ".", "pred2common", ".", "get", "(", "pred", ")", "return", "common_pred" ]
Gets version of predicate and sees if we have a translation to a common relation. INPUT: pred = predicate from the triple OUTPUT: Common relationship or None
[ "Gets", "version", "of", "predicate", "and", "sees", "if", "we", "have", "a", "translation", "to", "a", "common", "relation", ".", "INPUT", ":", "pred", "=", "predicate", "from", "the", "triple", "OUTPUT", ":", "Common", "relationship", "or", "None" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ontoutils/create_strict_records_from_ontology.py#L202-L211
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_network_interface
def _create_network_interface( self, ip_config_name, nic_name, public_ip, region, resource_group_name, subnet, accelerated_networking=False ): """ Create a network interface in the resource group. Attach NIC to the subnet and public IP provided. """ nic_confi...
python
def _create_network_interface( self, ip_config_name, nic_name, public_ip, region, resource_group_name, subnet, accelerated_networking=False ): """ Create a network interface in the resource group. Attach NIC to the subnet and public IP provided. """ nic_confi...
[ "def", "_create_network_interface", "(", "self", ",", "ip_config_name", ",", "nic_name", ",", "public_ip", ",", "region", ",", "resource_group_name", ",", "subnet", ",", "accelerated_networking", "=", "False", ")", ":", "nic_config", "=", "{", "'location'", ":", ...
Create a network interface in the resource group. Attach NIC to the subnet and public IP provided.
[ "Create", "a", "network", "interface", "in", "the", "resource", "group", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L140-L177
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_public_ip
def _create_public_ip(self, public_ip_name, resource_group_name, region): """ Create dynamic public IP address in the resource group. """ public_ip_config = { 'location': region, 'public_ip_allocation_method': 'Dynamic' } try: public_i...
python
def _create_public_ip(self, public_ip_name, resource_group_name, region): """ Create dynamic public IP address in the resource group. """ public_ip_config = { 'location': region, 'public_ip_allocation_method': 'Dynamic' } try: public_i...
[ "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"...
Create dynamic public IP address in the resource group.
[ "Create", "dynamic", "public", "IP", "address", "in", "the", "resource", "group", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L179-L198
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_resource_group
def _create_resource_group(self, region, resource_group_name): """ Create resource group if it does not exist. """ resource_group_config = {'location': region} try: self.resource.resource_groups.create_or_update( resource_group_name, resource_group_co...
python
def _create_resource_group(self, region, resource_group_name): """ Create resource group if it does not exist. """ resource_group_config = {'location': region} try: self.resource.resource_groups.create_or_update( resource_group_name, resource_group_co...
[ "def", "_create_resource_group", "(", "self", ",", "region", ",", "resource_group_name", ")", ":", "resource_group_config", "=", "{", "'location'", ":", "region", "}", "try", ":", "self", ".", "resource", ".", "resource_groups", ".", "create_or_update", "(", "re...
Create resource group if it does not exist.
[ "Create", "resource", "group", "if", "it", "does", "not", "exist", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L200-L213
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_storage_profile
def _create_storage_profile(self): """ Create the storage profile for the instance. Image reference can be a custom image name or a published urn. """ if self.image_publisher: storage_profile = { 'image_reference': { 'publisher': s...
python
def _create_storage_profile(self): """ Create the storage profile for the instance. Image reference can be a custom image name or a published urn. """ if self.image_publisher: storage_profile = { 'image_reference': { 'publisher': s...
[ "def", "_create_storage_profile", "(", "self", ")", ":", "if", "self", ".", "image_publisher", ":", "storage_profile", "=", "{", "'image_reference'", ":", "{", "'publisher'", ":", "self", ".", "image_publisher", ",", "'offer'", ":", "self", ".", "image_offer", ...
Create the storage profile for the instance. Image reference can be a custom image name or a published urn.
[ "Create", "the", "storage", "profile", "for", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L215-L246
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_subnet
def _create_subnet(self, resource_group_name, subnet_id, vnet_name): """ Create a subnet in the provided vnet and resource group. """ subnet_config = {'address_prefix': '10.0.0.0/29'} try: subnet_setup = self.network.subnets.create_or_update( resource...
python
def _create_subnet(self, resource_group_name, subnet_id, vnet_name): """ Create a subnet in the provided vnet and resource group. """ subnet_config = {'address_prefix': '10.0.0.0/29'} try: subnet_setup = self.network.subnets.create_or_update( resource...
[ "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 a subnet in the provided vnet and resource group.
[ "Create", "a", "subnet", "in", "the", "provided", "vnet", "and", "resource", "group", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L248-L263
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_virtual_network
def _create_virtual_network(self, region, resource_group_name, vnet_name): """ Create a vnet in the given resource group with default address space. """ vnet_config = { 'location': region, 'address_space': { 'address_prefixes': ['10.0.0.0/27'] ...
python
def _create_virtual_network(self, region, resource_group_name, vnet_name): """ Create a vnet in the given resource group with default address space. """ vnet_config = { 'location': region, 'address_space': { 'address_prefixes': ['10.0.0.0/27'] ...
[ "def", "_create_virtual_network", "(", "self", ",", "region", ",", "resource_group_name", ",", "vnet_name", ")", ":", "vnet_config", "=", "{", "'location'", ":", "region", ",", "'address_space'", ":", "{", "'address_prefixes'", ":", "[", "'10.0.0.0/27'", "]", "}...
Create a vnet in the given resource group with default address space.
[ "Create", "a", "vnet", "in", "the", "given", "resource", "group", "with", "default", "address", "space", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L265-L285
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_vm
def _create_vm(self, vm_config): """ Attempt to create or update VM instance based on vm_parameters config. """ try: vm_setup = self.compute.virtual_machines.create_or_update( self.running_instance_id, self.running_instance_id, vm_config ...
python
def _create_vm(self, vm_config): """ Attempt to create or update VM instance based on vm_parameters config. """ try: vm_setup = self.compute.virtual_machines.create_or_update( self.running_instance_id, self.running_instance_id, vm_config ...
[ "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_conf...
Attempt to create or update VM instance based on vm_parameters config.
[ "Attempt", "to", "create", "or", "update", "VM", "instance", "based", "on", "vm_parameters", "config", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L287-L303
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._create_vm_config
def _create_vm_config(self, interface): """ Create the VM config dictionary. Requires an existing network interface object. """ # Split image ID into it's components. self._process_image_id() hardware_profile = { 'vm_size': self.instance_type or AZUR...
python
def _create_vm_config(self, interface): """ Create the VM config dictionary. Requires an existing network interface object. """ # Split image ID into it's components. self._process_image_id() hardware_profile = { 'vm_size': self.instance_type or AZUR...
[ "def", "_create_vm_config", "(", "self", ",", "interface", ")", ":", "# Split image ID into it's components.", "self", ".", "_process_image_id", "(", ")", "hardware_profile", "=", "{", "'vm_size'", ":", "self", ".", "instance_type", "or", "AZURE_DEFAULT_TYPE", "}", ...
Create the VM config dictionary. Requires an existing network interface object.
[ "Create", "the", "VM", "config", "dictionary", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L305-L351
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._get_instance
def _get_instance(self): """ Return the instance matching the running_instance_id. """ try: instance = self.compute.virtual_machines.get( self.running_instance_id, self.running_instance_id, expand='instanceView' ) except Exc...
python
def _get_instance(self): """ Return the instance matching the running_instance_id. """ try: instance = self.compute.virtual_machines.get( self.running_instance_id, self.running_instance_id, expand='instanceView' ) except Exc...
[ "def", "_get_instance", "(", "self", ")", ":", "try", ":", "instance", "=", "self", ".", "compute", ".", "virtual_machines", ".", "get", "(", "self", ".", "running_instance_id", ",", "self", ".", "running_instance_id", ",", "expand", "=", "'instanceView'", "...
Return the instance matching the running_instance_id.
[ "Return", "the", "instance", "matching", "the", "running_instance_id", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L353-L367
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._get_instance_state
def _get_instance_state(self): """ Retrieve state of instance. """ instance = self._get_instance() statuses = instance.instance_view.statuses for status in statuses: if status.code.startswith('PowerState'): return status.display_status
python
def _get_instance_state(self): """ Retrieve state of instance. """ instance = self._get_instance() statuses = instance.instance_view.statuses for status in statuses: if status.code.startswith('PowerState'): return status.display_status
[ "def", "_get_instance_state", "(", "self", ")", ":", "instance", "=", "self", ".", "_get_instance", "(", ")", "statuses", "=", "instance", ".", "instance_view", ".", "statuses", "for", "status", "in", "statuses", ":", "if", "status", ".", "code", ".", "sta...
Retrieve state of instance.
[ "Retrieve", "state", "of", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L369-L378
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._get_management_client
def _get_management_client(self, client_class): """ Return instance of resource management client. """ try: client = get_client_from_auth_file( client_class, auth_path=self.service_account_file ) except ValueError as error: rais...
python
def _get_management_client(self, client_class): """ Return instance of resource management client. """ try: client = get_client_from_auth_file( client_class, auth_path=self.service_account_file ) except ValueError as error: rais...
[ "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", ":", ...
Return instance of resource management client.
[ "Return", "instance", "of", "resource", "management", "client", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L380-L402
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._launch_instance
def _launch_instance(self): """ Create new test instance in a resource group with the same name. """ self.running_instance_id = ipa_utils.generate_instance_name( 'azure-ipa-test' ) self.logger.debug('ID of instance: %s' % self.running_instance_id) self...
python
def _launch_instance(self): """ Create new test instance in a resource group with the same name. """ self.running_instance_id = ipa_utils.generate_instance_name( 'azure-ipa-test' ) self.logger.debug('ID of instance: %s' % self.running_instance_id) self...
[ "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_instan...
Create new test instance in a resource group with the same name.
[ "Create", "new", "test", "instance", "in", "a", "resource", "group", "with", "the", "same", "name", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L417-L473
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._process_image_id
def _process_image_id(self): """ Split image id into component values. Example: SUSE:SLES:12-SP3:2018.01.04 Publisher:Offer:Sku:Version Raises: If image_id is not a valid format. """ try: image_info = self.image_id.strip().split(...
python
def _process_image_id(self): """ Split image id into component values. Example: SUSE:SLES:12-SP3:2018.01.04 Publisher:Offer:Sku:Version Raises: If image_id is not a valid format. """ try: image_info = self.image_id.strip().split(...
[ "def", "_process_image_id", "(", "self", ")", ":", "try", ":", "image_info", "=", "self", ".", "image_id", ".", "strip", "(", ")", ".", "split", "(", "':'", ")", "self", ".", "image_publisher", "=", "image_info", "[", "0", "]", "self", ".", "image_offe...
Split image id into component values. Example: SUSE:SLES:12-SP3:2018.01.04 Publisher:Offer:Sku:Version Raises: If image_id is not a valid format.
[ "Split", "image", "id", "into", "component", "values", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L475-L492
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._set_default_resource_names
def _set_default_resource_names(self): """ Generate names for resources based on the running_instance_id. """ self.ip_config_name = ''.join([ self.running_instance_id, '-ip-config' ]) self.nic_name = ''.join([self.running_instance_id, '-nic']) self.pub...
python
def _set_default_resource_names(self): """ Generate names for resources based on the running_instance_id. """ self.ip_config_name = ''.join([ self.running_instance_id, '-ip-config' ]) self.nic_name = ''.join([self.running_instance_id, '-nic']) self.pub...
[ "def", "_set_default_resource_names", "(", "self", ")", ":", "self", ".", "ip_config_name", "=", "''", ".", "join", "(", "[", "self", ".", "running_instance_id", ",", "'-ip-config'", "]", ")", "self", ".", "nic_name", "=", "''", ".", "join", "(", "[", "s...
Generate names for resources based on the running_instance_id.
[ "Generate", "names", "for", "resources", "based", "on", "the", "running_instance_id", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L494-L502
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._set_image_id
def _set_image_id(self): """ If an existing instance is used get image id from deployment. """ instance = self._get_instance() image_info = instance.storage_profile.image_reference if image_info.publisher: self.image_id = ':'.join([ image_info...
python
def _set_image_id(self): """ If an existing instance is used get image id from deployment. """ instance = self._get_instance() image_info = instance.storage_profile.image_reference if image_info.publisher: self.image_id = ':'.join([ image_info...
[ "def", "_set_image_id", "(", "self", ")", ":", "instance", "=", "self", ".", "_get_instance", "(", ")", "image_info", "=", "instance", ".", "storage_profile", ".", "image_reference", "if", "image_info", ".", "publisher", ":", "self", ".", "image_id", "=", "'...
If an existing instance is used get image id from deployment.
[ "If", "an", "existing", "instance", "is", "used", "get", "image", "id", "from", "deployment", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L504-L517
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._set_instance_ip
def _set_instance_ip(self): """ Get the IP address based on instance ID. If public IP address not found attempt to get private IP. """ try: ip_address = self.network.public_ip_addresses.get( self.running_instance_id, self.public_ip_name )....
python
def _set_instance_ip(self): """ Get the IP address based on instance ID. If public IP address not found attempt to get private IP. """ try: ip_address = self.network.public_ip_addresses.get( self.running_instance_id, self.public_ip_name )....
[ "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", "E...
Get the IP address based on instance ID. If public IP address not found attempt to get private IP.
[ "Get", "the", "IP", "address", "based", "on", "instance", "ID", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L519-L541
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._start_instance
def _start_instance(self): """ Start the instance. """ try: vm_start = self.compute.virtual_machines.start( self.running_instance_id, self.running_instance_id ) except Exception as error: raise AzureCloudException( ...
python
def _start_instance(self): """ Start the instance. """ try: vm_start = self.compute.virtual_machines.start( self.running_instance_id, self.running_instance_id ) except Exception as error: raise AzureCloudException( ...
[ "def", "_start_instance", "(", "self", ")", ":", "try", ":", "vm_start", "=", "self", ".", "compute", ".", "virtual_machines", ".", "start", "(", "self", ".", "running_instance_id", ",", "self", ".", "running_instance_id", ")", "except", "Exception", "as", "...
Start the instance.
[ "Start", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L543-L556
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._stop_instance
def _stop_instance(self): """ Stop the instance. """ try: vm_stop = self.compute.virtual_machines.power_off( self.running_instance_id, self.running_instance_id ) except Exception as error: raise AzureCloudException( ...
python
def _stop_instance(self): """ Stop the instance. """ try: vm_stop = self.compute.virtual_machines.power_off( self.running_instance_id, self.running_instance_id ) except Exception as error: raise AzureCloudException( ...
[ "def", "_stop_instance", "(", "self", ")", ":", "try", ":", "vm_stop", "=", "self", ".", "compute", ".", "virtual_machines", ".", "power_off", "(", "self", ".", "running_instance_id", ",", "self", ".", "running_instance_id", ")", "except", "Exception", "as", ...
Stop the instance.
[ "Stop", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L558-L571
SUSE-Enceladus/ipa
ipa/ipa_azure.py
AzureCloud._terminate_instance
def _terminate_instance(self): """ Terminate the resource group and instance. """ try: self.resource.resource_groups.delete(self.running_instance_id) except Exception as error: raise AzureCloudException( 'Unable to terminate resource group:...
python
def _terminate_instance(self): """ Terminate the resource group and instance. """ try: self.resource.resource_groups.delete(self.running_instance_id) except Exception as error: raise AzureCloudException( 'Unable to terminate resource group:...
[ "def", "_terminate_instance", "(", "self", ")", ":", "try", ":", "self", ".", "resource", ".", "resource_groups", ".", "delete", "(", "self", ".", "running_instance_id", ")", "except", "Exception", "as", "error", ":", "raise", "AzureCloudException", "(", "'Una...
Terminate the resource group and instance.
[ "Terminate", "the", "resource", "group", "and", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_azure.py#L573-L582
tgbugs/pyontutils
ilxutils/ilxutils/scicrunch_client_helper.py
preferred_change
def preferred_change(data): ''' Determines preferred existing id based on curie prefix in the ranking list ''' ranking = [ 'CHEBI', 'NCBITaxon', 'COGPO', 'CAO', 'DICOM', 'UBERON', 'NLX', 'NLXANAT', 'NLXCELL', 'NLXFUNC', 'NLX...
python
def preferred_change(data): ''' Determines preferred existing id based on curie prefix in the ranking list ''' ranking = [ 'CHEBI', 'NCBITaxon', 'COGPO', 'CAO', 'DICOM', 'UBERON', 'NLX', 'NLXANAT', 'NLXCELL', 'NLXFUNC', 'NLX...
[ "def", "preferred_change", "(", "data", ")", ":", "ranking", "=", "[", "'CHEBI'", ",", "'NCBITaxon'", ",", "'COGPO'", ",", "'CAO'", ",", "'DICOM'", ",", "'UBERON'", ",", "'NLX'", ",", "'NLXANAT'", ",", "'NLXCELL'", ",", "'NLXFUNC'", ",", "'NLXINV'", ",", ...
Determines preferred existing id based on curie prefix in the ranking list
[ "Determines", "preferred", "existing", "id", "based", "on", "curie", "prefix", "in", "the", "ranking", "list" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client_helper.py#L16-L68
tgbugs/pyontutils
ilxutils/ilxutils/scicrunch_client_helper.py
merge
def merge(new, old): ''' synonyms and existing_ids are part of an object bug that can create duplicates if in the same batch ''' for k, vals in new.items(): if k == 'synonyms': new_synonyms = vals if old['synonyms']: old_literals = [syn['literal'].lower().strip(...
python
def merge(new, old): ''' synonyms and existing_ids are part of an object bug that can create duplicates if in the same batch ''' for k, vals in new.items(): if k == 'synonyms': new_synonyms = vals if old['synonyms']: old_literals = [syn['literal'].lower().strip(...
[ "def", "merge", "(", "new", ",", "old", ")", ":", "for", "k", ",", "vals", "in", "new", ".", "items", "(", ")", ":", "if", "k", "==", "'synonyms'", ":", "new_synonyms", "=", "vals", "if", "old", "[", "'synonyms'", "]", ":", "old_literals", "=", "...
synonyms and existing_ids are part of an object bug that can create duplicates if in the same batch
[ "synonyms", "and", "existing_ids", "are", "part", "of", "an", "object", "bug", "that", "can", "create", "duplicates", "if", "in", "the", "same", "batch" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client_helper.py#L71-L171
SUSE-Enceladus/ipa
ipa/scripts/cli.py
main
def main(context, no_color): """ Ipa provides a Python API and command line utility for testing images. It can be used to test images in the Public Cloud (AWS, Azure, GCE, etc.). """ if context.obj is None: context.obj = {} context.obj['no_color'] = no_color
python
def main(context, no_color): """ Ipa provides a Python API and command line utility for testing images. It can be used to test images in the Public Cloud (AWS, Azure, GCE, etc.). """ if context.obj is None: context.obj = {} context.obj['no_color'] = no_color
[ "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. It can be used to test images in the Public Cloud (AWS, Azure, GCE, etc.).
[ "Ipa", "provides", "a", "Python", "API", "and", "command", "line", "utility", "for", "testing", "images", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli.py#L73-L81
SUSE-Enceladus/ipa
ipa/scripts/cli.py
results
def results(context, history_log): """Process provided history log and results files.""" if context.obj is None: context.obj = {} context.obj['history_log'] = history_log if context.invoked_subcommand is None: context.invoke(show, item=1)
python
def results(context, history_log): """Process provided history log and results files.""" if context.obj is None: context.obj = {} context.obj['history_log'] = history_log if context.invoked_subcommand is None: context.invoke(show, item=1)
[ "def", "results", "(", "context", ",", "history_log", ")", ":", "if", "context", ".", "obj", "is", "None", ":", "context", ".", "obj", "=", "{", "}", "context", ".", "obj", "[", "'history_log'", "]", "=", "history_log", "if", "context", ".", "invoked_s...
Process provided history log and results files.
[ "Process", "provided", "history", "log", "and", "results", "files", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli.py#L347-L354
SUSE-Enceladus/ipa
ipa/scripts/cli.py
archive
def archive(context, clear_log, items, path, name): """ Archive the history log and all results/log files. After archive is created optionally clear the history log. """ history_log = context.obj['history_log'] no_color = context.obj['no_color'] with open(history_log, 'r') as f: # ...
python
def archive(context, clear_log, items, path, name): """ Archive the history log and all results/log files. After archive is created optionally clear the history log. """ history_log = context.obj['history_log'] no_color = context.obj['no_color'] with open(history_log, 'r') as f: # ...
[ "def", "archive", "(", "context", ",", "clear_log", ",", "items", ",", "path", ",", "name", ")", ":", "history_log", "=", "context", ".", "obj", "[", "'history_log'", "]", "no_color", "=", "context", ".", "obj", "[", "'no_color'", "]", "with", "open", ...
Archive the history log and all results/log files. After archive is created optionally clear the history log.
[ "Archive", "the", "history", "log", "and", "all", "results", "/", "log", "files", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli.py#L379-L429
SUSE-Enceladus/ipa
ipa/scripts/cli.py
delete
def delete(context, item): """ Delete the specified history item from the history log. """ 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) - it...
python
def delete(context, item): """ Delete the specified history item from the history log. """ 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) - it...
[ "def", "delete", "(", "context", ",", "item", ")", ":", "history_log", "=", "context", ".", "obj", "[", "'history_log'", "]", "no_color", "=", "context", ".", "obj", "[", "'no_color'", "]", "try", ":", "with", "open", "(", "history_log", ",", "'r+'", "...
Delete the specified history item from the history log.
[ "Delete", "the", "specified", "history", "item", "from", "the", "history", "log", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli.py#L447-L493
SUSE-Enceladus/ipa
ipa/scripts/cli.py
show
def show(context, log, results_file, verbose, item): """ Print test results info from provided results json file. If no results file is supplied echo results from most recent test in history if it exists. If verbose option selected, echo all test cases. If ...
python
def show(context, log, results_file, verbose, item): """ Print test results info from provided results json file. If no results file is supplied echo results from most recent test in history if it exists. If verbose option selected, echo all test cases. If ...
[ "def", "show", "(", "context", ",", "log", ",", "results_file", ",", "verbose", ",", "item", ")", ":", "history_log", "=", "context", ".", "obj", "[", "'history_log'", "]", "no_color", "=", "context", ".", "obj", "[", "'no_color'", "]", "if", "not", "r...
Print test results info from provided results json file. If no results file is supplied echo results from most recent test in history if it exists. If verbose option selected, echo all test cases. If log option selected echo test log.
[ "Print", "test", "results", "info", "from", "provided", "results", "json", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli.py#L528-L583
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._get_ssh_client
def _get_ssh_client(self): """Return a new or existing SSH client for given ip.""" return ipa_utils.get_ssh_client( self.instance_ip, self.ssh_private_key_file, self.ssh_user, timeout=self.timeout )
python
def _get_ssh_client(self): """Return a new or existing SSH client for given ip.""" return ipa_utils.get_ssh_client( self.instance_ip, self.ssh_private_key_file, self.ssh_user, timeout=self.timeout )
[ "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.
[ "Return", "a", "new", "or", "existing", "SSH", "client", "for", "given", "ip", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L197-L204
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._log_info
def _log_info(self): """Output test run information to top of log file.""" if self.cloud == 'ssh': self.results['info'] = { 'platform': self.cloud, 'distro': self.distro_name, 'image': self.instance_ip, 'timestamp': self.time_st...
python
def _log_info(self): """Output test run information to top of log file.""" if self.cloud == 'ssh': self.results['info'] = { 'platform': self.cloud, 'distro': self.distro_name, 'image': self.instance_ip, 'timestamp': self.time_st...
[ "def", "_log_info", "(", "self", ")", ":", "if", "self", ".", "cloud", "==", "'ssh'", ":", "self", ".", "results", "[", "'info'", "]", "=", "{", "'platform'", ":", "self", ".", "cloud", ",", "'distro'", ":", "self", ".", "distro_name", ",", "'image'"...
Output test run information to top of log file.
[ "Output", "test", "run", "information", "to", "top", "of", "log", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L212-L240
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._write_to_log
def _write_to_log(self, output): """Write the output string to the log file.""" with open(self.log_file, 'a') as log_file: log_file.write('\n') log_file.write(output) log_file.write('\n')
python
def _write_to_log(self, output): """Write the output string to the log file.""" with open(self.log_file, 'a') as log_file: log_file.write('\n') log_file.write(output) log_file.write('\n')
[ "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 the output string to the log file.
[ "Write", "the", "output", "string", "to", "the", "log", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L242-L247
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._merge_results
def _merge_results(self, results): """Combine results of test run with exisiting dict.""" self.results['tests'] += results['tests'] for key, value in results['summary'].items(): self.results['summary'][key] += value
python
def _merge_results(self, results): """Combine results of test run with exisiting dict.""" self.results['tests'] += results['tests'] for key, value in results['summary'].items(): self.results['summary'][key] += value
[ "def", "_merge_results", "(", "self", ",", "results", ")", ":", "self", ".", "results", "[", "'tests'", "]", "+=", "results", "[", "'tests'", "]", "for", "key", ",", "value", "in", "results", "[", "'summary'", "]", ".", "items", "(", ")", ":", "self"...
Combine results of test run with exisiting dict.
[ "Combine", "results", "of", "test", "run", "with", "exisiting", "dict", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L249-L254
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._save_results
def _save_results(self): """Save results dictionary to json file.""" with open(self.results_file, 'w') as results_file: json.dump(self.results, results_file)
python
def _save_results(self): """Save results dictionary to json file.""" with open(self.results_file, 'w') as results_file: json.dump(self.results, results_file)
[ "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.
[ "Save", "results", "dictionary", "to", "json", "file", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L346-L349
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._set_distro
def _set_distro(self): """Determine distro for image and create instance of class.""" if self.distro_name == 'sles': self.distro = SLES() elif self.distro_name == 'opensuse_leap': self.distro = openSUSE_Leap() else: raise IpaCloudException( ...
python
def _set_distro(self): """Determine distro for image and create instance of class.""" if self.distro_name == 'sles': self.distro = SLES() elif self.distro_name == 'opensuse_leap': self.distro = openSUSE_Leap() else: raise IpaCloudException( ...
[ "def", "_set_distro", "(", "self", ")", ":", "if", "self", ".", "distro_name", "==", "'sles'", ":", "self", ".", "distro", "=", "SLES", "(", ")", "elif", "self", ".", "distro_name", "==", "'opensuse_leap'", ":", "self", ".", "distro", "=", "openSUSE_Leap...
Determine distro for image and create instance of class.
[ "Determine", "distro", "for", "image", "and", "create", "instance", "of", "class", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L351-L360
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._set_results_dir
def _set_results_dir(self): """Create results directory if not exists.""" if self.running_instance_id: self.results_dir = os.path.join( self.results_dir, self.cloud, self.image_id, self.running_instance_id ) ...
python
def _set_results_dir(self): """Create results directory if not exists.""" if self.running_instance_id: self.results_dir = os.path.join( self.results_dir, self.cloud, self.image_id, self.running_instance_id ) ...
[ "def", "_set_results_dir", "(", "self", ")", ":", "if", "self", ".", "running_instance_id", ":", "self", ".", "results_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "results_dir", ",", "self", ".", "cloud", ",", "self", ".", "image_id", ...
Create results directory if not exists.
[ "Create", "results", "directory", "if", "not", "exists", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L368-L407
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._collect_vm_info
def _collect_vm_info(self): """ Gather basic info about VM """ 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)
python
def _collect_vm_info(self): """ Gather basic info about VM """ 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)
[ "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",...
Gather basic info about VM
[ "Gather", "basic", "info", "about", "VM" ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L427-L435
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._update_history
def _update_history(self): """Save the current test information to history json.""" ipa_utils.update_history_log( self.history_log, description=self.description, test_log=self.log_file )
python
def _update_history(self): """Save the current test information to history json.""" ipa_utils.update_history_log( self.history_log, description=self.description, test_log=self.log_file )
[ "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.
[ "Save", "the", "current", "test", "information", "to", "history", "json", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L437-L443
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud._wait_on_instance
def _wait_on_instance(self, state, timeout=600, wait_period=10): """Wait until instance is in given state.""" current_state = 'Undefined' start = time.time() end = start + timeout while time.time() < end: current_state = self._get_instance_state() if sta...
python
def _wait_on_instance(self, state, timeout=600, wait_period=10): """Wait until instance is in given state.""" current_state = 'Undefined' start = time.time() end = start + timeout while time.time() < end: current_state = self._get_instance_state() if sta...
[ "def", "_wait_on_instance", "(", "self", ",", "state", ",", "timeout", "=", "600", ",", "wait_period", "=", "10", ")", ":", "current_state", "=", "'Undefined'", "start", "=", "time", ".", "time", "(", ")", "end", "=", "start", "+", "timeout", "while", ...
Wait until instance is in given state.
[ "Wait", "until", "instance", "is", "in", "given", "state", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L445-L463
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.execute_ssh_command
def execute_ssh_command(self, client, command): """Execute the provided command and log output.""" try: out = ipa_utils.execute_ssh_command(client, command) except Exception as error: raise IpaCloudException( 'Command: "{0}", failed execution: {1}.'.format...
python
def execute_ssh_command(self, client, command): """Execute the provided command and log output.""" try: out = ipa_utils.execute_ssh_command(client, command) except Exception as error: raise IpaCloudException( 'Command: "{0}", failed execution: {1}.'.format...
[ "def", "execute_ssh_command", "(", "self", ",", "client", ",", "command", ")", ":", "try", ":", "out", "=", "ipa_utils", ".", "execute_ssh_command", "(", "client", ",", "command", ")", "except", "Exception", "as", "error", ":", "raise", "IpaCloudException", ...
Execute the provided command and log output.
[ "Execute", "the", "provided", "command", "and", "log", "output", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L465-L476
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.extract_archive
def extract_archive(self, client, archive_path, extract_path=None): """Extract the archive files using the client in the current path.""" try: out = ipa_utils.extract_archive(client, archive_path, extract_path) except Exception as error: raise IpaCloudException( ...
python
def extract_archive(self, client, archive_path, extract_path=None): """Extract the archive files using the client in the current path.""" try: out = ipa_utils.extract_archive(client, archive_path, extract_path) except Exception as error: raise IpaCloudException( ...
[ "def", "extract_archive", "(", "self", ",", "client", ",", "archive_path", ",", "extract_path", "=", "None", ")", ":", "try", ":", "out", "=", "ipa_utils", ".", "extract_archive", "(", "client", ",", "archive_path", ",", "extract_path", ")", "except", "Excep...
Extract the archive files using the client in the current path.
[ "Extract", "the", "archive", "files", "using", "the", "client", "in", "the", "current", "path", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L478-L490
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.hard_reboot_instance
def hard_reboot_instance(self): """Stop then start the instance.""" self._stop_instance() self._start_instance() self._set_instance_ip() self.logger.debug('IP of instance: %s' % self.instance_ip) ipa_utils.clear_cache()
python
def hard_reboot_instance(self): """Stop then start the instance.""" self._stop_instance() self._start_instance() self._set_instance_ip() self.logger.debug('IP of instance: %s' % self.instance_ip) ipa_utils.clear_cache()
[ "def", "hard_reboot_instance", "(", "self", ")", ":", "self", ".", "_stop_instance", "(", ")", "self", ".", "_start_instance", "(", ")", "self", ".", "_set_instance_ip", "(", ")", "self", ".", "logger", ".", "debug", "(", "'IP of instance: %s'", "%", "self",...
Stop then start the instance.
[ "Stop", "then", "start", "the", "instance", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L492-L498
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.install_package
def install_package(self, client, package): """ Install package using distro specific install method. """ try: out = self.distro.install_package(client, package) except Exception as error: raise IpaCloudException( 'Failed installing package...
python
def install_package(self, client, package): """ Install package using distro specific install method. """ try: out = self.distro.install_package(client, package) except Exception as error: raise IpaCloudException( 'Failed installing package...
[ "def", "install_package", "(", "self", ",", "client", ",", "package", ")", ":", "try", ":", "out", "=", "self", ".", "distro", ".", "install_package", "(", "client", ",", "package", ")", "except", "Exception", "as", "error", ":", "raise", "IpaCloudExceptio...
Install package using distro specific install method.
[ "Install", "package", "using", "distro", "specific", "install", "method", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L500-L513
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.process_injection_file
def process_injection_file(self, client): """ Load yaml file and process injection configuration. There are 5 injection options: :inject_packages: an rpm path or list of rpm paths which will be copied and installed on the test instance. :inject_archive...
python
def process_injection_file(self, client): """ Load yaml file and process injection configuration. There are 5 injection options: :inject_packages: an rpm path or list of rpm paths which will be copied and installed on the test instance. :inject_archive...
[ "def", "process_injection_file", "(", "self", ",", "client", ")", ":", "configuration", "=", "ipa_utils", ".", "get_yaml_config", "(", "self", ".", "inject", ")", "if", "configuration", ".", "get", "(", "'inject_packages'", ")", ":", "inject_packages", "=", "c...
Load yaml file and process injection configuration. There are 5 injection options: :inject_packages: an rpm path or list of rpm paths which will be copied and installed on the test instance. :inject_archives: an archive or list of archives which will ...
[ "Load", "yaml", "file", "and", "process", "injection", "configuration", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L515-L581
SUSE-Enceladus/ipa
ipa/ipa_cloud.py
IpaCloud.put_file
def put_file(self, client, source_file): """ Put file on instance in default SSH directory. """ try: file_name = os.path.basename(source_file) ipa_utils.put_file(client, source_file, file_name) except Exception as error: raise IpaCloudException...
python
def put_file(self, client, source_file): """ Put file on instance in default SSH directory. """ try: file_name = os.path.basename(source_file) ipa_utils.put_file(client, source_file, file_name) except Exception as error: raise IpaCloudException...
[ "def", "put_file", "(", "self", ",", "client", ",", "source_file", ")", ":", "try", ":", "file_name", "=", "os", ".", "path", ".", "basename", "(", "source_file", ")", "ipa_utils", ".", "put_file", "(", "client", ",", "source_file", ",", "file_name", ")"...
Put file on instance in default SSH directory.
[ "Put", "file", "on", "instance", "in", "default", "SSH", "directory", "." ]
train
https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/ipa_cloud.py#L583-L597
tgbugs/pyontutils
neurondm/neurondm/models/allen_cell_types.py
AllenCellTypes.build_transgenic_lines
def build_transgenic_lines(self): """ init class | "transgenic_line_source_name":"stock_number" a Class add superClass | rdfs:subClassOf ilxtr:transgenicLine add *order* | ilxtr:useObjectProperty ilxtr:<order> add name | rdfs:label "name" add def |...
python
def build_transgenic_lines(self): """ init class | "transgenic_line_source_name":"stock_number" a Class add superClass | rdfs:subClassOf ilxtr:transgenicLine add *order* | ilxtr:useObjectProperty ilxtr:<order> add name | rdfs:label "name" add def |...
[ "def", "build_transgenic_lines", "(", "self", ")", ":", "triples", "=", "[", "]", "for", "cell_line", "in", "self", ".", "neuron_data", ":", "for", "tl", "in", "cell_line", "[", "'donor'", "]", "[", "'transgenic_lines'", "]", ":", "_id", "=", "tl", "[", ...
init class | "transgenic_line_source_name":"stock_number" a Class add superClass | rdfs:subClassOf ilxtr:transgenicLine add *order* | ilxtr:useObjectProperty ilxtr:<order> add name | rdfs:label "name" add def | definition: "description" add transtype | ...
[ "init", "class", "|", "transgenic_line_source_name", ":", "stock_number", "a", "Class", "add", "superClass", "|", "rdfs", ":", "subClassOf", "ilxtr", ":", "transgenicLine", "add", "*", "order", "*", "|", "ilxtr", ":", "useObjectProperty", "ilxtr", ":", "<order",...
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/models/allen_cell_types.py#L257-L294
tgbugs/pyontutils
nifstd/nifstd_tools/ilx_utils.py
decodeIlxResp
def decodeIlxResp(resp): """ We need this until we can get json back directly and this is SUPER nasty""" lines = [_ for _ in resp.text.split('\n') if _] # strip empties if 'successfull' in lines[0]: return [(_.split('"')[1], ilxIdFix(_.split(': ')[-1])) for _ in li...
python
def decodeIlxResp(resp): """ We need this until we can get json back directly and this is SUPER nasty""" lines = [_ for _ in resp.text.split('\n') if _] # strip empties if 'successfull' in lines[0]: return [(_.split('"')[1], ilxIdFix(_.split(': ')[-1])) for _ in li...
[ "def", "decodeIlxResp", "(", "resp", ")", ":", "lines", "=", "[", "_", "for", "_", "in", "resp", ".", "text", ".", "split", "(", "'\\n'", ")", "if", "_", "]", "# strip empties", "if", "'successfull'", "in", "lines", "[", "0", "]", ":", "return", "[...
We need this until we can get json back directly and this is SUPER nasty
[ "We", "need", "this", "until", "we", "can", "get", "json", "back", "directly", "and", "this", "is", "SUPER", "nasty" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/ilx_utils.py#L154-L165
tgbugs/pyontutils
nifstd/nifstd_tools/ilx_utils.py
getSubOrder
def getSubOrder(existing): """ Alpha sort by the full chain of parents. """ 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...
python
def getSubOrder(existing): """ Alpha sort by the full chain of parents. """ 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...
[ "def", "getSubOrder", "(", "existing", ")", ":", "alpha", "=", "list", "(", "zip", "(", "*", "sorted", "(", "(", "(", "k", ",", "v", "[", "'rec'", "]", "[", "'label'", "]", ")", "for", "k", ",", "v", "in", "existing", ".", "items", "(", ")", ...
Alpha sort by the full chain of parents.
[ "Alpha", "sort", "by", "the", "full", "chain", "of", "parents", "." ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/ilx_utils.py#L294-L317
tgbugs/pyontutils
nifstd/nifstd_tools/parcellation/berman.py
clean
def clean(string): ''' Begining of the string can sometimes have odd noise ''' # manual fixes in the source # 24/1.png # 9/1.png # 3/1.png #if ')' in string: # fix in the source data #string = string.split(')')[0] + ')' # remove trailing garbage return (string .replace(...
python
def clean(string): ''' Begining of the string can sometimes have odd noise ''' # manual fixes in the source # 24/1.png # 9/1.png # 3/1.png #if ')' in string: # fix in the source data #string = string.split(')')[0] + ')' # remove trailing garbage return (string .replace(...
[ "def", "clean", "(", "string", ")", ":", "# manual fixes in the source", "# 24/1.png", "# 9/1.png", "# 3/1.png", "#if ')' in string: # fix in the source data", "#string = string.split(')')[0] + ')' # remove trailing garbage", "return", "(", "string", ".", "replace", "(", "'_'",...
Begining of the string can sometimes have odd noise
[ "Begining", "of", "the", "string", "can", "sometimes", "have", "odd", "noise" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/parcellation/berman.py#L35-L51
tgbugs/pyontutils
nifstd/nifstd_tools/parcellation/berman.py
BermanSrc.loadData
def loadData(cls): """ Sigh, this was indeed a poorly conceived approach since it hard blocks when the files are not in the source so you can't easily bootstrap from another source and the cognitive overhead is way, way too high :/ Adding dry_run/bootstrap to __new__ sort of he...
python
def loadData(cls): """ Sigh, this was indeed a poorly conceived approach since it hard blocks when the files are not in the source so you can't easily bootstrap from another source and the cognitive overhead is way, way too high :/ Adding dry_run/bootstrap to __new__ sort of he...
[ "def", "loadData", "(", "cls", ")", ":", "\"\"\" Have to run this out here because resSource is handicapped \"\"\"", "data", "=", "[", "]", "if", "cls", ".", "source_images", ".", "exists", "(", ")", ":", "for", "folder", "in", "cls", ".", "source_images", ".", ...
Sigh, this was indeed a poorly conceived approach since it hard blocks when the files are not in the source so you can't easily bootstrap from another source and the cognitive overhead is way, way too high :/ Adding dry_run/bootstrap to __new__ sort of helps?
[ "Sigh", "this", "was", "indeed", "a", "poorly", "conceived", "approach", "since", "it", "hard", "blocks", "when", "the", "files", "are", "not", "in", "the", "source", "so", "you", "can", "t", "easily", "bootstrap", "from", "another", "source", "and", "the"...
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/parcellation/berman.py#L90-L133
tgbugs/pyontutils
nifstd/nifstd_tools/hbp_cells.py
ilx_conv
def ilx_conv(graph, prefix, ilx_start): """ convert a set of temporary identifiers to ilx and modify the graph in place """ 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}' ...
python
def ilx_conv(graph, prefix, ilx_start): """ convert a set of temporary identifiers to ilx and modify the graph in place """ 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}' ...
[ "def", "ilx_conv", "(", "graph", ",", "prefix", ",", "ilx_start", ")", ":", "to_sub", "=", "set", "(", ")", "for", "subject", "in", "graph", ".", "subjects", "(", "rdflib", ".", "RDF", ".", "type", ",", "rdflib", ".", "OWL", ".", "Class", ")", ":",...
convert a set of temporary identifiers to ilx and modify the graph in place
[ "convert", "a", "set", "of", "temporary", "identifiers", "to", "ilx", "and", "modify", "the", "graph", "in", "place" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/hbp_cells.py#L62-L93
tgbugs/pyontutils
pyontutils/necromancy.py
alreadyHasEntry
def alreadyHasEntry(oldClassString, og): """ Return true if there is already an owl:Class with the old id""" namespace = oldClassString.split(':')[0] if namespace == 'http': target = rdflib.URIRef(oldClassString) print('OLD CLASS ID IS A URL', oldClassString) else: try: ...
python
def alreadyHasEntry(oldClassString, og): """ Return true if there is already an owl:Class with the old id""" namespace = oldClassString.split(':')[0] if namespace == 'http': target = rdflib.URIRef(oldClassString) print('OLD CLASS ID IS A URL', oldClassString) else: try: ...
[ "def", "alreadyHasEntry", "(", "oldClassString", ",", "og", ")", ":", "namespace", "=", "oldClassString", ".", "split", "(", "':'", ")", "[", "0", "]", "if", "namespace", "==", "'http'", ":", "target", "=", "rdflib", ".", "URIRef", "(", "oldClassString", ...
Return true if there is already an owl:Class with the old id
[ "Return", "true", "if", "there", "is", "already", "an", "owl", ":", "Class", "with", "the", "old", "id" ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/necromancy.py#L49-L62
tgbugs/pyontutils
neurondm/neurondm/lang.py
config
def config(remote_base= 'https://raw.githubusercontent.com/SciCrunch/NIF-Ontology/', local_base= None, # devconfig.ontology_local_repo by default branch= devconfig.neurons_branch, core_graph_paths= ['ttl/phenotype-core.ttl', 'ttl/ph...
python
def config(remote_base= 'https://raw.githubusercontent.com/SciCrunch/NIF-Ontology/', local_base= None, # devconfig.ontology_local_repo by default branch= devconfig.neurons_branch, core_graph_paths= ['ttl/phenotype-core.ttl', 'ttl/ph...
[ "def", "config", "(", "remote_base", "=", "'https://raw.githubusercontent.com/SciCrunch/NIF-Ontology/'", ",", "local_base", "=", "None", ",", "# devconfig.ontology_local_repo by default", "branch", "=", "devconfig", ".", "neurons_branch", ",", "core_graph_paths", "=", "[", ...
Wraps graphBase.configGraphIO to provide a set of sane defaults for input ontologies and output files.
[ "Wraps", "graphBase", ".", "configGraphIO", "to", "provide", "a", "set", "of", "sane", "defaults", "for", "input", "ontologies", "and", "output", "files", "." ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/lang.py#L34-L75
tgbugs/pyontutils
pyontutils/ontutils.py
add_version_iri
def add_version_iri(graph, epoch): """ Also remove the previous versionIRI if there was one.""" 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_versi...
python
def add_version_iri(graph, epoch): """ Also remove the previous versionIRI if there was one.""" 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_versi...
[ "def", "add_version_iri", "(", "graph", ",", "epoch", ")", ":", "for", "ont", "in", "graph", ".", "subjects", "(", "rdf", ".", "type", ",", "owl", ".", "Ontology", ")", ":", "for", "versionIRI", "in", "graph", ".", "objects", "(", "ont", ",", "owl", ...
Also remove the previous versionIRI if there was one.
[ "Also", "remove", "the", "previous", "versionIRI", "if", "there", "was", "one", "." ]
train
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/ontutils.py#L323-L329
Sheeprider/BitBucket-api
bitbucket/bitbucket.py
Bitbucket.auth
def auth(self): """ Return credentials for current Bitbucket user. """ if self.oauth: return self.oauth return (self.username, self.password)
python
def auth(self): """ Return credentials for current Bitbucket user. """ if self.oauth: return self.oauth return (self.username, self.password)
[ "def", "auth", "(", "self", ")", ":", "if", "self", ".", "oauth", ":", "return", "self", ".", "oauth", "return", "(", "self", ".", "username", ",", "self", ".", "password", ")" ]
Return credentials for current Bitbucket user.
[ "Return", "credentials", "for", "current", "Bitbucket", "user", "." ]
train
https://github.com/Sheeprider/BitBucket-api/blob/be45515d506d87f14807a676f3c2f20d79674b75/bitbucket/bitbucket.py#L71-L75
Sheeprider/BitBucket-api
bitbucket/bitbucket.py
Bitbucket.authorize
def authorize(self, consumer_key, consumer_secret, callback_url=None, access_token=None, access_token_secret=None): """ Call this with your consumer key, secret and callback URL, to generate a token for verification. """ self.consumer_key = consumer_key ...
python
def authorize(self, consumer_key, consumer_secret, callback_url=None, access_token=None, access_token_secret=None): """ Call this with your consumer key, secret and callback URL, to generate a token for verification. """ self.consumer_key = consumer_key ...
[ "def", "authorize", "(", "self", ",", "consumer_key", ",", "consumer_secret", ",", "callback_url", "=", "None", ",", "access_token", "=", "None", ",", "access_token_secret", "=", "None", ")", ":", "self", ".", "consumer_key", "=", "consumer_key", "self", ".", ...
Call this with your consumer key, secret and callback URL, to generate a token for verification.
[ "Call", "this", "with", "your", "consumer", "key", "secret", "and", "callback", "URL", "to", "generate", "a", "token", "for", "verification", "." ]
train
https://github.com/Sheeprider/BitBucket-api/blob/be45515d506d87f14807a676f3c2f20d79674b75/bitbucket/bitbucket.py#L143-L170
Sheeprider/BitBucket-api
bitbucket/bitbucket.py
Bitbucket.verify
def verify(self, verifier, consumer_key=None, consumer_secret=None, access_token=None, access_token_secret=None): """ After converting the token into verifier, call this to finalize the authorization. """ # Stored values can be supplied to verify self.consu...
python
def verify(self, verifier, consumer_key=None, consumer_secret=None, access_token=None, access_token_secret=None): """ After converting the token into verifier, call this to finalize the authorization. """ # Stored values can be supplied to verify self.consu...
[ "def", "verify", "(", "self", ",", "verifier", ",", "consumer_key", "=", "None", ",", "consumer_secret", "=", "None", ",", "access_token", "=", "None", ",", "access_token_secret", "=", "None", ")", ":", "# Stored values can be supplied to verify", "self", ".", "...
After converting the token into verifier, call this to finalize the authorization.
[ "After", "converting", "the", "token", "into", "verifier", "call", "this", "to", "finalize", "the", "authorization", "." ]
train
https://github.com/Sheeprider/BitBucket-api/blob/be45515d506d87f14807a676f3c2f20d79674b75/bitbucket/bitbucket.py#L172-L198