我的 Great Expectations 项目有这个文件夹结构:
great_expectations/
dataset/
__init__.py
oracle_dataset.py
datasource/
__init__.py
oracle_datasource.py
great_expectations.yml
datasource/__init__.py
:
from .oracle_datasource import OracleDatasource
dataset/__init__.py
:
from .oracle_dataset import OracleDataset
great_expectations.yml
:
datasources:
db_name:
credentials: ${db_name}
data_asset_type:
class_name: OracleDataset
module_name: .dataset
class_name: OracleDatasource
module_name: .datasource
除了 python 相对导入让我非常困惑之外,我还不确定在运行 great_expectations 命令时使用哪个参考目录。当我尝试时:great_expectations suite new
我收到错误消息:ValueError: no package specified for '.datasource' (required for relative module names)
我认为上面的 .yml 仍然是在尝试了下面的所有内容之后要走的路。我猜对于需要在init或其他地方处理的相对导入有一些我不理解的东西。
编辑:我也试过:
datasources:
db_name:
credentials: ${db_name}
data_asset_type:
class_name: OracleDataset
module_name: great_expectations.dataset
class_name: OracleDatasource
module_name: great_expectations.datasource
The module: 'great_expectations.datasource' does not contain the class: 'OracleDatasource'.
我认为此消息意味着它正在查找 great_expectations 库,我通过尝试包含在库中的类名来确认这一点。
和这个:
datasources:
db_name:
credentials: ${db_name}
data_asset_type:
class_name: OracleDataset
module_name: dataset
class_name: OracleDatasource
module_name: datasource
No module named "datasource" could be found in the repository. Please make sure that the file, corresponding to this package and module, exists and that dynamic loading of code modules, templates, and assets is supported in your execution environment. This error is unrecoverable.
我认为这意味着它正在图书馆之外寻找但找不到文件。
和这个:
datasources:
db_name:
credentials: ${db_name}
data_asset_type:
class_name: OracleDataset
module_name: dataset.oracle_dataset
class_name: OracleDatasource
module_name: datasource.oracle_datasource
No module named "datasource.oracle_datasource" could be found in the repository. Please make sure that the file, corresponding to this package and module, exists and that dynamic loading of code modules, templates, and assets is supported in your execution environment. This error is unrecoverable.
我认为这意味着它正在图书馆之外寻找但找不到文件。