Issue Description
Set base package requirements only imports needed for the default reader and storage class (local / pandas).
For the optional imports, dask and object store libs, add a check in the class loading calls and warn if a class load fails due to missing dependency.
|
def get_df_reader(config, *args, **kwargs): |
|
config = clean_config(config) |
|
|
|
cls = load_class(config["engine"]["path"], OasisReader) |
|
|
|
storage = config["engine"]["options"].pop("storage", None) or LocalStorage("/") |
|
return cls( |
|
config["filepath"], storage, *args, **kwargs, **config["engine"]["options"] |
|
) |
|
def get_storage_from_config(config: StorageConfig): |
|
cls = load_class(config["storage_class"], BaseStorage) |
|
return cls(**config["options"]) |
|
|
|
|
|
def get_storage_from_config_path(config_path: Optional[str], fallback_path: str): |
|
""" |
|
Loads the config from the supplied path. If no config path is provided or the path |
|
doesn't exist a local file store object will be created with the root set to the |
|
fallback path. |
|
|
|
:param config_path: The path to the config file to load |
|
:param fallback_path: The path for the local file store should the config path not exist |
|
""" |
|
if config_path and os.path.exists(config_path): |
|
with open(config_path) as f: |
|
config: StorageConfig = json.load(f) |
|
model_storage = get_storage_from_config(config) |
|
elif fallback_path: |
|
model_storage = LocalStorage( |
|
root_dir=fallback_path, |
|
) |
|
else: |
|
raise ConfigError( |
|
"The given config path does not exist and no fallback path was given to create the local storage from" |
|
) |
|
|
|
return model_storage |
Issue Description
Set base package requirements only imports needed for the default reader and storage class (local / pandas).
For the optional imports,
daskand object store libs, add a check in the class loading calls and warn if a class load fails due to missing dependency.OasisDataManager/oasis_data_manager/df_reader/config.py
Lines 68 to 76 in 26fd1d9
OasisDataManager/oasis_data_manager/filestore/config.py
Lines 82 to 109 in 26fd1d9