How to use tool_names method in prospector

Best Python code snippet using prospector_python

search_util.py

Source:search_util.py Github

copy

Full Screen

1import logging2from galaxy import eggs3eggs.require('SQLAlchemy')4from sqlalchemy import and_, false, true5log = logging.getLogger( __name__ )6def in_tool_dict( tool_dict, exact_matches_checked, tool_id=None, tool_name=None, tool_version=None ):7 found = False8 if tool_id and not tool_name and not tool_version:9 tool_dict_tool_id = tool_dict[ 'id' ].lower()10 found = ( tool_id == tool_dict_tool_id ) or \11 ( not exact_matches_checked and tool_dict_tool_id.find( tool_id ) >= 0 )12 elif tool_name and not tool_id and not tool_version:13 tool_dict_tool_name = tool_dict[ 'name' ].lower()14 found = ( tool_name == tool_dict_tool_name ) or \15 ( not exact_matches_checked and tool_dict_tool_name.find( tool_name ) >= 0 )16 elif tool_version and not tool_id and not tool_name:17 tool_dict_tool_version = tool_dict[ 'version' ].lower()18 found = ( tool_version == tool_dict_tool_version ) or \19 ( not exact_matches_checked and tool_dict_tool_version.find( tool_version ) >= 0 )20 elif tool_id and tool_name and not tool_version:21 tool_dict_tool_id = tool_dict[ 'id' ].lower()22 tool_dict_tool_name = tool_dict[ 'name' ].lower()23 found = ( tool_id == tool_dict_tool_id and tool_name == tool_dict_tool_name ) or \24 ( not exact_matches_checked and tool_dict_tool_id.find( tool_id ) >= 0 and tool_dict_tool_name.find( tool_name ) >= 0 )25 elif tool_id and tool_version and not tool_name:26 tool_dict_tool_id = tool_dict[ 'id' ].lower()27 tool_dict_tool_version = tool_dict[ 'version' ].lower()28 found = ( tool_id == tool_dict_tool_id and tool_version == tool_dict_tool_version ) or \29 ( not exact_matches_checked and tool_dict_tool_id.find( tool_id ) >= 0 and tool_dict_tool_version.find( tool_version ) >= 0 )30 elif tool_version and tool_name and not tool_id:31 tool_dict_tool_version = tool_dict[ 'version' ].lower()32 tool_dict_tool_name = tool_dict[ 'name' ].lower()33 found = ( tool_version == tool_dict_tool_version and tool_name == tool_dict_tool_name ) or \34 ( not exact_matches_checked and tool_dict_tool_version.find( tool_version ) >= 0 and tool_dict_tool_name.find( tool_name ) >= 0 )35 elif tool_version and tool_name and tool_id:36 tool_dict_tool_version = tool_dict[ 'version' ].lower()37 tool_dict_tool_name = tool_dict[ 'name' ].lower()38 tool_dict_tool_id = tool_dict[ 'id' ].lower()39 found = ( tool_version == tool_dict_tool_version and40 tool_name == tool_dict_tool_name and41 tool_id == tool_dict_tool_id ) or \42 ( not exact_matches_checked and43 tool_dict_tool_version.find( tool_version ) >= 0 and44 tool_dict_tool_name.find( tool_name ) >= 0 and45 tool_dict_tool_id.find( tool_id ) >= 0 )46 return found47def in_workflow_dict( workflow_dict, exact_matches_checked, workflow_name ):48 workflow_dict_workflow_name = workflow_dict[ 'name' ].lower()49 return ( workflow_name == workflow_dict_workflow_name ) or \50 ( not exact_matches_checked and workflow_dict_workflow_name.find( workflow_name ) >= 0 )51def make_same_length( list1, list2 ):52 # If either list is 1 item, we'll append to it until its length is the same as the other.53 if len( list1 ) == 1:54 for i in range( 1, len( list2 ) ):55 list1.append( list1[ 0 ] )56 elif len( list2 ) == 1:57 for i in range( 1, len( list1 ) ):58 list2.append( list2[ 0 ] )59 return list1, list260def search_ids_names( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_names ):61 for i, tool_id in enumerate( tool_ids ):62 tool_name = tool_names[ i ]63 if in_tool_dict( tool_dict, exact_matches_checked, tool_id=tool_id, tool_name=tool_name ):64 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )65 return match_tuples66def search_ids_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_versions ):67 for i, tool_id in enumerate( tool_ids ):68 tool_version = tool_versions[ i ]69 if in_tool_dict( tool_dict, exact_matches_checked, tool_id=tool_id, tool_version=tool_version ):70 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )71 return match_tuples72def search_names_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_names, tool_versions ):73 for i, tool_name in enumerate( tool_names ):74 tool_version = tool_versions[ i ]75 if in_tool_dict( tool_dict, exact_matches_checked, tool_name=tool_name, tool_version=tool_version ):76 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )77 return match_tuples78def search_repository_metadata( app, exact_matches_checked, tool_ids='', tool_names='', tool_versions='',79 workflow_names='', all_workflows=False ):80 sa_session = app.model.context.current81 match_tuples = []82 ok = True83 if tool_ids or tool_names or tool_versions:84 for repository_metadata in sa_session.query( app.model.RepositoryMetadata ) \85 .filter( app.model.RepositoryMetadata.table.c.includes_tools == true() ) \86 .join( app.model.Repository ) \87 .filter( and_( app.model.Repository.table.c.deleted == false(),88 app.model.Repository.table.c.deprecated == false() ) ):89 metadata = repository_metadata.metadata90 if metadata:91 tools = metadata.get( 'tools', [] )92 for tool_dict in tools:93 if tool_ids and not tool_names and not tool_versions:94 for tool_id in tool_ids:95 if in_tool_dict( tool_dict, exact_matches_checked, tool_id=tool_id ):96 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )97 elif tool_names and not tool_ids and not tool_versions:98 for tool_name in tool_names:99 if in_tool_dict( tool_dict, exact_matches_checked, tool_name=tool_name ):100 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )101 elif tool_versions and not tool_ids and not tool_names:102 for tool_version in tool_versions:103 if in_tool_dict( tool_dict, exact_matches_checked, tool_version=tool_version ):104 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )105 elif tool_ids and tool_names and not tool_versions:106 if len( tool_ids ) == len( tool_names ):107 match_tuples = search_ids_names( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_names )108 elif len( tool_ids ) == 1 or len( tool_names ) == 1:109 tool_ids, tool_names = make_same_length( tool_ids, tool_names )110 match_tuples = search_ids_names( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_names )111 else:112 ok = False113 elif tool_ids and tool_versions and not tool_names:114 if len( tool_ids ) == len( tool_versions ):115 match_tuples = search_ids_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_versions )116 elif len( tool_ids ) == 1 or len( tool_versions ) == 1:117 tool_ids, tool_versions = make_same_length( tool_ids, tool_versions )118 match_tuples = search_ids_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_versions )119 else:120 ok = False121 elif tool_versions and tool_names and not tool_ids:122 if len( tool_versions ) == len( tool_names ):123 match_tuples = search_names_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_names, tool_versions )124 elif len( tool_versions ) == 1 or len( tool_names ) == 1:125 tool_versions, tool_names = make_same_length( tool_versions, tool_names )126 match_tuples = search_names_versions( tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_names, tool_versions )127 else:128 ok = False129 elif tool_versions and tool_names and tool_ids:130 if len( tool_versions ) == len( tool_names ) and len( tool_names ) == len( tool_ids ):131 for i, tool_version in enumerate( tool_versions ):132 tool_name = tool_names[ i ]133 tool_id = tool_ids[ i ]134 if in_tool_dict( tool_dict, exact_matches_checked, tool_id=tool_id, tool_name=tool_name, tool_version=tool_version ):135 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )136 else:137 ok = False138 elif workflow_names or all_workflows:139 for repository_metadata in sa_session.query( app.model.RepositoryMetadata ) \140 .filter( app.model.RepositoryMetadata.table.c.includes_workflows == true() ) \141 .join( app.model.Repository ) \142 .filter( and_( app.model.Repository.table.c.deleted == false(),143 app.model.Repository.table.c.deprecated == false() ) ):144 metadata = repository_metadata.metadata145 if metadata:146 # metadata[ 'workflows' ] is a list of tuples where each contained tuple is147 # [ <relative path to the .ga file in the repository>, <exported workflow dict> ]148 if workflow_names:149 workflow_tups = metadata.get( 'workflows', [] )150 workflows = [ workflow_tup[1] for workflow_tup in workflow_tups ]151 for workflow_dict in workflows:152 for workflow_name in workflow_names:153 if in_workflow_dict( workflow_dict, exact_matches_checked, workflow_name ):154 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )155 elif all_workflows:156 match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) )...

Full Screen

Full Screen

mpi.py

Source:mpi.py Github

copy

Full Screen

1# Copyright 2013-2019 The Meson development team2# Licensed under the Apache License, Version 2.0 (the "License");3# you may not use this file except in compliance with the License.4# You may obtain a copy of the License at5# http://www.apache.org/licenses/LICENSE-2.06# Unless required by applicable law or agreed to in writing, software7# distributed under the License is distributed on an "AS IS" BASIS,8# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.9# See the License for the specific language governing permissions and10# limitations under the License.11import functools12import typing as T13import os14import re15from .base import (DependencyMethods, PkgConfigDependency, factory_methods,16 ConfigToolDependency, detect_compiler, ExternalDependency)17from ..environment import detect_cpu_family18if T.TYPE_CHECKING:19 from .base import DependencyType20 from ..compilers import Compiler21 from ..environment import Environment, MachineChoice22@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})23def mpi_factory(env: 'Environment', for_machine: 'MachineChoice',24 kwargs: T.Dict[str, T.Any], methods: T.List[DependencyMethods]) -> T.List['DependencyType']:25 language = kwargs.get('language', 'c')26 if language not in {'c', 'cpp', 'fortran'}:27 # OpenMPI doesn't work without any other languages28 return []29 candidates = []30 compiler = detect_compiler('mpi', env, for_machine, language)31 compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'}32 # Only OpenMPI has pkg-config, and it doesn't work with the intel compilers33 if DependencyMethods.PKGCONFIG in methods and not compiler_is_intel:34 pkg_name = None35 if language == 'c':36 pkg_name = 'ompi-c'37 elif language == 'cpp':38 pkg_name = 'ompi-cxx'39 elif language == 'fortran':40 pkg_name = 'ompi-fort'41 candidates.append(functools.partial(42 PkgConfigDependency, pkg_name, env, kwargs, language=language))43 if DependencyMethods.CONFIG_TOOL in methods:44 nwargs = kwargs.copy()45 if compiler_is_intel:46 if env.machines[for_machine].is_windows():47 nwargs['version_arg'] = '-v'48 nwargs['returncode_value'] = 349 if language == 'c':50 tool_names = [os.environ.get('I_MPI_CC'), 'mpiicc']51 elif language == 'cpp':52 tool_names = [os.environ.get('I_MPI_CXX'), 'mpiicpc']53 elif language == 'fortran':54 tool_names = [os.environ.get('I_MPI_F90'), 'mpiifort']55 cls = IntelMPIConfigToolDependency # type: T.Type[ConfigToolDependency]56 else: # OpenMPI, which doesn't work with intel57 #58 # We try the environment variables for the tools first, but then59 # fall back to the hardcoded names60 if language == 'c':61 tool_names = [os.environ.get('MPICC'), 'mpicc']62 elif language == 'cpp':63 tool_names = [os.environ.get('MPICXX'), 'mpic++', 'mpicxx', 'mpiCC']64 elif language == 'fortran':65 tool_names = [os.environ.get(e) for e in ['MPIFC', 'MPIF90', 'MPIF77']]66 tool_names.extend(['mpifort', 'mpif90', 'mpif77'])67 cls = OpenMPIConfigToolDependency68 tool_names = [t for t in tool_names if t] # remove empty environment variables69 assert tool_names70 nwargs['tools'] = tool_names71 candidates.append(functools.partial(72 cls, tool_names[0], env, nwargs, language=language))73 if DependencyMethods.SYSTEM in methods:74 candidates.append(functools.partial(75 MSMPIDependency, 'msmpi', env, kwargs, language=language))76 return candidates77class _MPIConfigToolDependency(ConfigToolDependency):78 def _filter_compile_args(self, args: T.Sequence[str]) -> T.List[str]:79 """80 MPI wrappers return a bunch of garbage args.81 Drop -O2 and everything that is not needed.82 """83 result = []84 multi_args = ('-I', )85 if self.language == 'fortran':86 fc = self.env.coredata.compilers[self.for_machine]['fortran']87 multi_args += fc.get_module_incdir_args()88 include_next = False89 for f in args:90 if f.startswith(('-D', '-f') + multi_args) or f == '-pthread' \91 or (f.startswith('-W') and f != '-Wall' and not f.startswith('-Werror')):92 result.append(f)93 if f in multi_args:94 # Path is a separate argument.95 include_next = True96 elif include_next:97 include_next = False98 result.append(f)99 return result100 def _filter_link_args(self, args: T.Sequence[str]) -> T.List[str]:101 """102 MPI wrappers return a bunch of garbage args.103 Drop -O2 and everything that is not needed.104 """105 result = []106 include_next = False107 for f in args:108 if self._is_link_arg(f):109 result.append(f)110 if f in ('-L', '-Xlinker'):111 include_next = True112 elif include_next:113 include_next = False114 result.append(f)115 return result116 def _is_link_arg(self, f: str) -> bool:117 if self.clib_compiler.id == 'intel-cl':118 return f == '/link' or f.startswith('/LIBPATH') or f.endswith('.lib') # always .lib whether static or dynamic119 else:120 return (f.startswith(('-L', '-l', '-Xlinker')) or121 f == '-pthread' or122 (f.startswith('-W') and f != '-Wall' and not f.startswith('-Werror')))123class IntelMPIConfigToolDependency(_MPIConfigToolDependency):124 """Wrapper around Intel's mpiicc and friends."""125 version_arg = '-v' # --version is not the same as -v126 def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],127 language: T.Optional[str] = None):128 super().__init__(name, env, kwargs, language=language)129 if not self.is_found:130 return131 args = self.get_config_value(['-show'], 'link and compile args')132 self.compile_args = self._filter_compile_args(args)133 self.link_args = self._filter_link_args(args)134 def _sanitize_version(self, out: str) -> str:135 v = re.search(r'(\d{4}) Update (\d)', out)136 if v:137 return '{}.{}'.format(v.group(1), v.group(2))138 return out139class OpenMPIConfigToolDependency(_MPIConfigToolDependency):140 """Wrapper around OpenMPI mpicc and friends."""141 version_arg = '--showme:version'142 def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],143 language: T.Optional[str] = None):144 super().__init__(name, env, kwargs, language=language)145 if not self.is_found:146 return147 c_args = self.get_config_value(['--showme:compile'], 'compile_args')148 self.compile_args = self._filter_compile_args(c_args)149 l_args = self.get_config_value(['--showme:link'], 'link_args')150 self.link_args = self._filter_link_args(l_args)151 def _sanitize_version(self, out: str) -> str:152 v = re.search(r'\d+.\d+.\d+', out)153 if v:154 return v.group(0)155 return out156class MSMPIDependency(ExternalDependency):157 """The Microsoft MPI."""158 def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any],159 language: T.Optional[str] = None):160 super().__init__(name, env, kwargs, language=language)161 # MSMPI only supports the C API162 if language not in {'c', 'fortran', None}:163 self.is_found = False164 return165 # MSMPI is only for windows, obviously166 if not self.env.machines[self.for_machine].is_windows():167 return168 incdir = os.environ.get('MSMPI_INC')169 arch = detect_cpu_family(self.env.coredata.compilers.host)170 libdir = None171 if arch == 'x86':172 libdir = os.environ.get('MSMPI_LIB32')173 post = 'x86'174 elif arch == 'x86_64':175 libdir = os.environ.get('MSMPI_LIB64')176 post = 'x64'177 if libdir is None or incdir is None:178 self.is_found = False179 return180 self.is_found = True181 self.link_args = ['-l' + os.path.join(libdir, 'msmpi')]182 self.compile_args = ['-I' + incdir, '-I' + os.path.join(incdir, post)]183 if self.language == 'fortran':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run prospector automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful