-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working DAG; expanded validation task
- Loading branch information
1 parent
d73aecc
commit 601946a
Showing
9 changed files
with
847 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// .devcontainer/devcontainer.json | ||
{ | ||
"name": "Airflow Container", | ||
"dockerComposeFile": "docker-compose.yaml", | ||
"service": "airflow", | ||
"workspaceFolder": "/home/airflow", | ||
"extensions": [ | ||
"ms-python.python" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import json | ||
Check failure on line 1 in airflow/dags/dcatus_pipeline.py GitHub Actions / Python LintRuff (F401)
|
||
import pendulum | ||
import requests | ||
|
||
from pathlib import Path | ||
from airflow import Dataset | ||
from airflow.decorators import dag, task | ||
from datetime import datetime, timedelta | ||
from includes.validate.dcat_us import validate_json_schema | ||
from includes.utils.json_util import open_json | ||
|
||
SRC = Dataset( | ||
"https://raw.githubusercontent.com/GSA/catalog.data.gov/main/tests/harvest-sources/data.json" | ||
) | ||
now = pendulum.now() | ||
|
||
|
||
def make_path(fileName): | ||
return Path(__file__).parents[1] / "data" / "schemas" / fileName | ||
|
||
|
||
@dag( | ||
"dcatus_pipeline", | ||
start_date=datetime(year=2023, month=2, day=5), | ||
catchup=False, | ||
tags=["etl"], | ||
schedule_interval=timedelta(minutes=2), | ||
) | ||
def dcatus_pipeline(): | ||
@task(task_id="extract_dcatus") | ||
def extract(src: Dataset) -> list: | ||
resp = requests.get(url=src.uri) | ||
data = resp.json() | ||
print(data) | ||
return data["dataset"] | ||
|
||
@task(task_id="validate_dcatus") | ||
def validate(dataset: Dataset) -> Dataset: | ||
file_path = make_path("dataset.json") | ||
print("file path ::: {file_path}") | ||
dataset_schema = open_json(file_path) | ||
[success, error] = validate_json_schema(dataset, dataset_schema) | ||
print(f"success: {success}, error: {error}") | ||
return True if success else False | ||
|
||
dataset = extract(SRC) | ||
validated = validate.expand(dataset=dataset) | ||
Check failure on line 47 in airflow/dags/dcatus_pipeline.py GitHub Actions / Python LintRuff (F841)
|
||
|
||
|
||
dcatus_pipeline() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
601946a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report