python - 如何满怀期待地使用Kedro?

标签 python airflow kedro great-expectations

我正在使用 Kedro 创建用于 ETL 目的的管道,并且正在使用 Great-Expectations 完成特定于列的验证。 Kedro 文档 here 中列出了一个 hooks.py 文件。该钩子(Hook)是按照 Kedro-docs 上提到的说明注册的。

这是我当前的工作流程: 工作流程:

  1. 使用 kedro new 创建了 kedro 项目,项目名称 ecom_analytics
  2. 将数据集存储在名为 dataset_raw.csvdataset_validate.csvdata/01_raw 文件夹中
  3. 使用 great_expectations init 初始化 Great_expectations 项目
  4. 使用 great_expectations datasource new 创建新数据源。我添加的名称是 main_datasource
  5. 使用 great_expectations suite new 创建新的期望。使用数据助手将这种期望称为 data.raw
  6. 使用great_expectations suite edit data.raw编辑了great_expectations套件
  7. data/01_raw 中为数据集创建了目录条目
  8. 添加了 kedro 文档中给出的远大期望 hooks.py' 并在 settings.py` 文件上注册了钩子(Hook)
  9. 尝试过kedro viz --autoreload。这适用于查看可视化
  10. 使用kedro run时出现错误
│ /opt/conda/lib/python3.9/site-packages/great_expectations/data_context/data_context/abstract_dat │
│ a_context.py:758 in get_batch                                                                    │
│                                                                                                  │
│    755 │   │   else:                                                                             │
│    756 │   │   │   data_asset_type = arg3                                                        │
│    757 │   │   batch_parameters = kwargs.get("batch_parameters")                                 │
│ ❱  758 │   │   return self._get_batch_v2(                                                        │
│    759 │   │   │   batch_kwargs=batch_kwargs,                                                    │
│    760 │   │   │   expectation_suite_name=expectation_suite_name,                                │
│    761 │   │   │   data_asset_type=data_asset_type,                                              │
│                                                                                                  │
│ /opt/conda/lib/python3.9/site-packages/great_expectations/data_context/data_context/abstract_dat │
│ a_context.py:867 in _get_batch_v2                                                                │
│                                                                                                  │
│    864 │   │   │   expectation_suite = self.get_expectation_suite(expectation_suite_name)        │
│    865 │   │                                                                                     │
│    866 │   │   datasource = self.get_datasource(batch_kwargs.get("datasource"))  # type: ignore  │
│ ❱  867 │   │   batch = datasource.get_batch(  # type: ignore[union-attr]                         │
│    868 │   │   │   batch_kwargs=batch_kwargs, batch_parameters=batch_parameters                  │
│    869 │   │   )                                                                                 │
│    870 │   │   if data_asset_type is None:                                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Datasource' object has no attribute 'get_batch'

请使用以下项目的最新开发分支来查看问题:https://github.com/DhavalThkkar/ecom-analytics

这非常难以处理。我已加载要在 data/01_raw 文件夹内检查验证的数据集。如果有人可以帮助我提供此存储库的端到端示例,我将不胜感激

最佳答案

您可以在此处查看一个最小示例:https://github.com/erwinpaillacan/kedro-great-expectations-example

基本上,您需要定义:

  • 内存数据集,已在示例中定义
  • 明确您的期望
  • 定义与您的期望相关的检查点。
  • 映射器数据集:检查点conf/base/parameters/great_expectations_hook.yml

关于python - 如何满怀期待地使用Kedro?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74865372/

相关文章:

python - 无法使用Python连接到MSSQL Server数据库

python - 在嵌套字典中查找键的所有键和键

python - celery-django 找不到设置

airflow - 无需Web服务器即可重新启动apag Airflow

google-cloud-platform - DataBricks + Kedro Vs GCP + Kubeflow Vs 服务器 + Kedro + Airflow

python - 为什么我的 Kedro 日志文件一直为空?我错过了什么步骤吗?

python - 为什么我的埃拉托色尼筛法这么慢?

airflow - Apache Airflow : Executor reports task instance finished (failed) although the task says its queued

python - 如何在 Kedro 0.18 中以编程方式注册 kedro 数据目录?

python - 从 Airflow 中的 BigQueryOperator 获取结果