-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from US-GHG-Center/merge-veda-data-airflow
feat: support for scheduled ingest triggers
- Loading branch information
Showing
9 changed files
with
103 additions
and
19 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,34 @@ | ||
""" | ||
Builds a DAG for each collection (indicated by a .json file) in the <BUCKET>/collections/ folder. | ||
These DAGs are used to discover and ingest items for each collection. | ||
""" | ||
from airflow.models.variable import Variable | ||
|
||
|
||
from veda_data_pipeline.veda_discover_pipeline import get_discover_dag | ||
|
||
|
||
def generate_dags(): | ||
import boto3 | ||
import json | ||
|
||
mwaa_stac_conf = Variable.get("MWAA_STACK_CONF", deserialize_json=True) | ||
bucket = mwaa_stac_conf["EVENT_BUCKET"] | ||
|
||
client = boto3.client("s3") | ||
response = client.list_objects_v2(Bucket=bucket, Prefix="collections/") | ||
|
||
for file_ in response["Contents"]: | ||
key = file_["Key"] | ||
if key.endswith("/"): | ||
continue | ||
result = client.get_object(Bucket=bucket, Key=key) | ||
collection = result["Body"].read().decode() | ||
collection = json.loads(collection) | ||
if collection.get("schedule"): | ||
get_discover_dag( | ||
id=f"discover-{collection['collection']}", event=collection | ||
) | ||
|
||
|
||
generate_dags() |
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
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
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
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
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
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
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
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