Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open access: addition of logging for queries #43

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dags/open_access/open_access.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import open_access.constants as constants
import pendulum
import logging
from airflow.decorators import dag, task
from common.models.open_access.open_access import OAOpenAccess
from common.operators.sqlalchemy_operator import sqlalchemy_task
Expand All @@ -13,6 +14,7 @@
)
from sqlalchemy.sql import func

logger = logging.getLogger(__name__)

@dag(
start_date=pendulum.today("UTC").add(days=-1),
Expand All @@ -24,18 +26,21 @@ def oa_dag():
def fetch_closed_access_count(query_object, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_comments(parameters=parameters)

@task(executor_config=kubernetes_executor_config)
def fetch_bronze_open_access_count(query_object, closed_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_comments(parameters=parameters, previous=closed_access)

@task(executor_config=kubernetes_executor_config)
def fetch_gold_open_access_count(query_object, bronze_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_parsed_records(
parameters=parameters,
count_function=get_golden_access_count,
Expand All @@ -46,6 +51,7 @@ def fetch_gold_open_access_count(query_object, bronze_access, **kwargs):
def fetch_green_open_access_count(query_object, gold_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_parsed_records(
parameters=parameters,
count_function=get_green_access_count,
Expand Down
Loading