Audio Dataset
This commit is contained in:
audio_toolset
modules
utils
@ -92,12 +92,21 @@ class Config(ConfigParser, ABC):
|
||||
@property
|
||||
def model_class(self):
|
||||
try:
|
||||
return locate_and_import_class(self.model.type)
|
||||
return locate_and_import_class(self.model.type, folder_path='models')
|
||||
except AttributeError as e:
|
||||
raise AttributeError(f'The model alias you provided ("{self.get("model", "type")}") ' +
|
||||
f'was not found!\n' +
|
||||
f'{e}')
|
||||
|
||||
@property
|
||||
def data_class(self):
|
||||
try:
|
||||
return locate_and_import_class(self.data.class_name, folder_path='datasets')
|
||||
except AttributeError as e:
|
||||
raise AttributeError(f'The dataset alias you provided ("{self.get("data", "class_name")}") ' +
|
||||
f'was not found!\n' +
|
||||
f'{e}')
|
||||
|
||||
# --------------------------------------------------
|
||||
# TODO: Do this programmatically; This did not work:
|
||||
# Initialize Default Sections as Property
|
||||
|
@ -41,10 +41,10 @@ def check_path(file_path):
|
||||
assert str(file_path).endswith('.pik')
|
||||
|
||||
|
||||
def locate_and_import_class(class_name, models_location: Union[str, PurePath] = 'models', forceload=False):
|
||||
def locate_and_import_class(class_name, folder_path: Union[str, PurePath] = ''):
|
||||
"""Locate an object by name or dotted path, importing as necessary."""
|
||||
models_location = Path(models_location)
|
||||
module_paths = [x for x in models_location.rglob('*.py') if x.is_file() and '__init__' not in x.name]
|
||||
folder_path = Path(folder_path)
|
||||
module_paths = [x for x in folder_path.rglob('*.py') if x.is_file() and '__init__' not in x.name]
|
||||
for module_path in module_paths:
|
||||
mod = importlib.import_module('.'.join([x.replace('.py', '') for x in module_path.parts]))
|
||||
try:
|
||||
|
Reference in New Issue
Block a user