How to use module_path method in avocado

Best Python code snippet using avocado_python

access.py

Source:access.py Github

copy

Full Screen

1"""Accessors for Gromacs datasets.2"""3from os.path import dirname, join4from glob import glob5from .. import Bunch6def load_benzene():7 """Load the Gromacs benzene dataset.8 Returns9 -------10 data : Bunch11 Dictionary-like object, the interesting attributes are:12 - 'data' : the data files by alchemical leg13 - 'DESCR': the full description of the dataset14 """15 module_path = dirname(__file__)16 data = {'Coulomb': sorted(glob(join(module_path, 'benzene', 'Coulomb', '*', 'dhdl.xvg.bz2'))),17 'VDW': sorted(glob(join(module_path, 'benzene', 'VDW', '*', 'dhdl.xvg.bz2')))}18 with open(join(module_path, 'benzene', 'descr.rst')) as rst_file:19 fdescr = rst_file.read()20 return Bunch(data=data,21 DESCR=fdescr)22def load_ABFE():23 """Load the Gromacs ABFE dataset.24 Returns25 -------26 data : Bunch27 Dictionary-like object, the interesting attributes are:28 - 'data' : the data files by alchemical leg29 - 'DESCR': the full description of the dataset30 """31 module_path = dirname(__file__)32 data = {'complex': sorted(glob(join(module_path, 'ABFE', 'complex', 'dhdl_*.xvg'))),33 'ligand': sorted(glob(join(module_path, 'ABFE', 'ligand', 'dhdl_*.xvg')))}34 with open(join(module_path, 'ABFE', 'descr.rst')) as rst_file:35 fdescr = rst_file.read()36 return Bunch(data=data,37 DESCR=fdescr)38def load_expanded_ensemble_case_1():39 """Load the Gromacs Host CB7 Guest C3 expanded ensemble dataset, case 1 (single simulation visits all states).40 Returns41 -------42 data : Bunch43 Dictionary-like object, the interesting attributes are:44 - 'data' : the data files by alchemical leg45 - 'DESCR': the full description of the dataset46 """47 module_path = dirname(__file__)48 data = {'AllStates': glob(join(module_path, 'expanded_ensemble', 'case_1', 'CB7_Guest3_dhdl.xvg.gz'))}49 with open(join(module_path, 'expanded_ensemble', 'case_1', 'descr.rst')) as rst_file:50 fdescr = rst_file.read()51 return Bunch(data=data,52 DESCR=fdescr)53def load_expanded_ensemble_case_2():54 """Load the Gromacs Host CB7 Guest C3 expanded ensemble dataset, case 2 (two simulations visit all states independently).55 Returns56 -------57 data : Bunch58 Dictionary-like object, the interesting attributes are:59 - 'data' : the data files by alchemical leg60 - 'DESCR': the full description of the dataset61 """62 module_path = dirname(__file__)63 data = {'AllStates': sorted(glob(join(module_path, 'expanded_ensemble', 'case_2', '*.xvg.gz')))}64 with open(join(module_path, 'expanded_ensemble', 'case_2', 'descr.rst')) as rst_file:65 fdescr = rst_file.read()66 return Bunch(data=data,67 DESCR=fdescr)68def load_expanded_ensemble_case_3():69 """Load the Gromacs Host CB7 Guest C3 REX dataset, case 3.70 Returns71 -------72 data : Bunch73 Dictionary-like object, the interesting attributes are:74 - 'data' : the data files by alchemical leg75 - 'DESCR': the full description of the dataset76 """77 module_path = dirname(__file__)78 data = {'AllStates': sorted(glob(join(module_path, 'expanded_ensemble', 'case_3', '*.xvg.gz')))}79 with open(join(module_path, 'expanded_ensemble', 'case_3', 'descr.rst')) as rst_file:80 fdescr = rst_file.read()81 return Bunch(data=data,82 DESCR=fdescr)83def load_water_particle_without_energy():84 """Load the Gromacs water particle without energy dataset.85 Returns86 -------87 data : Bunch88 Dictionary-like object, the interesting attributes are:89 - 'data' : the data files by alchemical leg90 - 'DESCR': the full description of the dataset91 """92 module_path = dirname(__file__)93 data = {'AllStates': sorted(glob(join(module_path, 'water_particle', 'without_energy', '*.xvg.bz2')))}94 with open(join(module_path, 'water_particle', 'descr.rst')) as rst_file:95 fdescr = rst_file.read()96 return Bunch(data=data,97 DESCR=fdescr)98def load_water_particle_with_potential_energy():99 """Load the Gromacs water particle with potential energy dataset.100 Returns101 -------102 data : Bunch103 Dictionary-like object, the interesting attributes are:104 - 'data' : the data files by alchemical leg105 - 'DESCR': the full description of the dataset106 """107 module_path = dirname(__file__)108 data = {'AllStates': sorted(glob(join(module_path, 'water_particle', 'with_potential_energy', '*.xvg.bz2')))}109 with open(join(module_path, 'water_particle', 'descr.rst')) as rst_file:110 fdescr = rst_file.read()111 return Bunch(data=data,112 DESCR=fdescr)113def load_water_particle_with_total_energy():114 """Load the Gromacs water particle with total energy dataset.115 Returns116 -------117 data : Bunch118 Dictionary-like object, the interesting attributes are:119 - 'data' : the data files by alchemical leg120 - 'DESCR': the full description of the dataset121 """122 module_path = dirname(__file__)123 data = {'AllStates': sorted(glob(join(module_path, 'water_particle', 'with_total_energy', '*.xvg.bz2')))}124 with open(join(module_path, 'water_particle', 'descr.rst')) as rst_file:125 fdescr = rst_file.read()126 return Bunch(data=data,...

Full Screen

Full Screen

common.py

Source:common.py Github

copy

Full Screen

...16 if print_traceback:17 eprint(traceback.format_exc())18 if need_exit:19 exit(1)20def list_modules_by_module_path(module_path):21 ret = []22 module = pydoc.importfile(module_path)23 # code below inspired by the pydoc source24 modpkgs_names = set()25 if hasattr(module, '__path__'):26 for importer, modname, ispkg in pkgutil.iter_modules(module.__path__):27 modpkgs_names.add(modname)28 for key, value in inspect.getmembers(module, inspect.ismodule):29 if value.__name__.startswith(module.__name__ + '.') and key not in modpkgs_names:30 ret.append({"name": value.__name__, "module_path": module_path})31 return ret32def list_classes_by_module_path(module_path):33 ret = []34 module = pydoc.importfile(module_path)35 for member in inspect.getmembers(module, inspect.isclass):36 if member[1].__module__ == module.__name__:37 ret.append( {"name": member[1].__name__, "qualname": member[1].__qualname__, "module_path": module_path} )38 return ret39def list_functions_by_module_path(module_path):40 ret = []41 module = pydoc.importfile(module_path)42 try:43 all = module.__all__44 except AttributeError:45 all = None46 for member in inspect.getmembers(module, inspect.isroutine):47 if (all is not None or inspect.isbuiltin(member[1]) or inspect.getmodule(member[1]) is module):48 ret.append( {"name": member[0], "module_path": module_path} )49 return ret50def list_data_by_module_path(module_path):51 ret = []52 module = pydoc.importfile(module_path)53 reserved_names = ["__builtins__", "__cached__", "__doc__", "__file__", "__loader__", "__name__", "__package__", "__spec__"]54 for member in inspect.getmembers(module, pydoc.isdata):55 if member[0] not in reserved_names:56 ret.append( {"name": member[0], "type_name": type(member[1]).__name__, "module_path": module_path} )57 return ret58class Dipper:59 def __init__(self, args):60 self.args = args61 conf_file = "{}/.config/dipperpy.yaml".format(str(Path.home()))62 self.conf_file_object = {"main": {"print_traceback": True}}63 try:64 with open(conf_file, "r") as f:...

Full Screen

Full Screen

table_finder.py

Source:table_finder.py Github

copy

Full Screen

1import importlib2import inspect3import pkgutil4import sys5from abc import ABC6from os import path7from typing import Iterator, Optional, Set8from bq_schema.bigquery_table import BigqueryTable9def find_tables(module_path: str, ignore_abstract: bool) -> Set[BigqueryTable]:10 tables = {}11 for table in _tables_iterator(module_path, ignore_abstract):12 tables[(table.project, table.dataset, table.name)] = table13 return set(tables.values())14def _tables_iterator(15 root_path: str, ignore_abstract: bool, current_path: Optional[str] = None16) -> Iterator[BigqueryTable]:17 """18 Recursively find all defined bigquery tables.19 """20 if current_path is None:21 module_path = root_path22 else:23 module_path = current_path[current_path.find(root_path) :]24 sys_path = sys.path[0].replace(path.sep, ".")25 module_path_to_iterate = module_path26 module_path = module_path.replace(path.sep, ".")27 for (_, module_name, is_pkg) in pkgutil.iter_modules([module_path_to_iterate]):28 module_path = module_path.replace(sys_path, "")29 module_path = module_path[1:] if module_path.startswith(".") else module_path30 module = importlib.import_module(f"{module_path}.{module_name}")31 if is_pkg and module.__file__:32 sub_path = module.__file__.replace(f"{path.sep}__init__.py", "")33 yield from _tables_iterator(root_path, ignore_abstract, sub_path)34 for attribute_name in dir(module):35 if attribute_name.startswith("__"):36 continue37 attribute = getattr(module, attribute_name)38 if (39 inspect.isclass(attribute)40 and issubclass(attribute, BigqueryTable)41 and attribute != BigqueryTable42 and not (43 ignore_abstract44 and attribute45 in ABC.__subclasses__() # only direct descendants are in ABC's subclass list46 # , any concrete implementations shouldn't be here47 )48 ):...

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 avocado 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