-
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.
- Loading branch information
1 parent
62b0f50
commit 91b3d6c
Showing
2 changed files
with
38 additions
and
3 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
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,35 @@ | ||
import requests | ||
from airflow.decorators import task | ||
from rikolti.metadata_mapper.lambda_function import map_page | ||
from rikolti.metadata_mapper.lambda_shepherd import get_mapping_status | ||
|
||
@task() | ||
def get_collection_metadata_task(params=None): | ||
if not params or not params.get('collection_id'): | ||
raise ValueError("Collection ID not found in params") | ||
collection_id = params.get('collection_id') | ||
|
||
resp = requests.get( | ||
"https://registry.cdlib.org/api/v1/" | ||
f"rikolticollection/{collection_id}/?format=json" | ||
) | ||
resp.raise_for_status() | ||
|
||
return resp.json() | ||
|
||
|
||
# max_active_tis_per_dag - setting on the task to restrict how many | ||
# instances can be running at the same time, *across all DAG runs* | ||
@task() | ||
def map_page_task(page: str, collection: dict): | ||
collection_id = collection.get('id') | ||
if not collection_id: | ||
return False | ||
mapped_page = map_page(collection_id, page, collection) | ||
return mapped_page | ||
|
||
|
||
@task() | ||
def get_mapping_status_task(collection: dict, mapped_pages: list): | ||
mapping_status = get_mapping_status(collection, mapped_pages) | ||
return mapping_status |