https://github.com/sodadata/prefect-soda-core
https://github.com/sodadata/prefect-soda-core
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sodadata/prefect-soda-core
- Owner: sodadata
- License: apache-2.0
- Created: 2022-08-09T08:48:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T11:08:54.000Z (over 2 years ago)
- Last Synced: 2025-08-10T13:47:12.287Z (11 months ago)
- Language: Python
- Size: 1.22 MB
- Stars: 16
- Watchers: 11
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# prefect-soda-core
## Welcome!
Prefect 2.0 collection for Soda Core
## Getting Started
### Python setup
Requires an installation of Python 3.7+.
We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the [Prefect documentation](https://orion-docs.prefect.io/).
### Installation
`prefect-soda-core` is based on `soda-core`.
As `soda-core` requires you to specify the right option for your database, so does `prefect-soda-core`.
I.e. to use `prefect-soda-core` with Snowflake, run the following:
```bash
pip install prefect-soda-core[snowflake]
```
You can find the list of supported options in `setup.py`.
**Please note that since this integration is built on top of Soda CLI, it is not possible to run data quality checks using Spark.**
### Write and run a flow
```python
from prefect import flow
from prefect.context import get_run_context
from prefect_soda_core.soda_configuration import SodaConfiguration
from prefect_soda_core.sodacl_check import SodaCLCheck
from prefect_soda_core.tasks import soda_scan_execute
@flow
def run_soda_scan():
soda_configuration_block = SodaConfiguration(
configuration_yaml_path="/path/to/config.yaml"
)
soda_check_block = SodaCLCheck(
sodacl_yaml_path="/path/to/checks.yaml"
)
# Using the flow_run_name as the name of the file to store the scan results
flow_run_name = get_run_context().flow_run.name
scan_results_file_path = f"{flow_run_name}.json"
return soda_scan_execute(
data_source_name="my_datasource",
configuration=soda_configuration_block,
checks=soda_check_block,
variables={"var": "value"},
scan_results_file=scan_results_file_path,
verbose=True,
return_scan_result_file_content=False,
shell_env={"SNOWFLAKE_PASSWORD": "********"}
)
run_soda_scan()
```
## Resources
If you encounter any bugs while using `prefect-soda-core`, feel free to open an issue in the [prefect-soda-core](https://github.com/sodadata/prefect-soda-core) repository.
If you have any questions or issues while using `prefect-soda-core`, you can find help in either the [Prefect Discourse forum](https://discourse.prefect.io/) or the [Prefect Slack community](https://prefect.io/slack).
## Development
If you'd like to install a version of `prefect-soda-core` for development, clone the repository and perform an editable install with `pip`:
```bash
git clone https://github.com/sodadata/prefect-soda-core.git
cd prefect-soda-core/
pip install -e ".[dev]"
# Install linting pre-commit hooks
pre-commit install
```