Skip to content

[DRAFT] [Storyline example] Turbine Report - Shareholder Reporting Dynamic Dag - #53352

Closed
shubhamraj-git wants to merge 1 commit into
apache:mainfrom
shubhamraj-git:issue-52478
Closed

shubhamraj-git wants to merge 1 commit into
apache:mainfrom
shubhamraj-git:issue-52478

Conversation

@shubhamraj-git

Copy link
Copy Markdown
Contributor

closes: #52481


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@jscheffl jscheffl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good starting point!

Are there any pieces in the documentation that can replace existing Dags or can this example directly be sourced or linked in any documentation as it is?

I assume it is draft and a Classic-Dag is following as well after the taskflow one? (I assume makes sense to create if the rest is sorted to prevent double work anyway :-D

import json
from typing import Any

from airflow.providers.amazon.aws.hooks.s3 import S3Hook

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example must be w/o other provider dependency. Might be extended by an example in Amazon provider. But import must be removed here :-(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaa makes sense, will remove it. Having it might create dependency.

# Config for the stakeholder dags
CONFIG: list[dict[str, Any]] = [
{
"name": "stakeholder_a",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we invent just two names instead of "a" and "b"? Maybe just artificial names like "miller" or "smith"?

Comment on lines +39 to +41
"type": "s3",
"bucket": "example-bucket",
"key": "stakeholder_data.csv",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use local file and drop the CSV besides the dag in the examples folder?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name of the dag should be according to the use case, not what technically is produced.

doc_md=DOC_MD_DAG,
)
def stakeholder_subdag() -> None:
@task(doc_md=LOAD_DATA_DOC_MD)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we might take code snippets in the documentation, probably we shoudl have the doc_md inline?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also a good idea... actually I considered one dag where we loop to generate different tasks based on config... but a dag per config is also fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can do that, snippets would easier to get.

for config in CONFIG:
dynamic_dag_id: str = f"use_case_{config['name']}_report"

def make_subdag(dag_config: dict[str, Any], dag_id: str) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you add a function to generate the Dag? Is this a best practice? Not sure, whenever I did it I just started here with the @dag inside the loop and generated it. But no strong opinionn

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done to overcome the issue of late binding in python.


import os

import pandas as pd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is pandas in default Airflow dependencies? Or would we need to wrap this into a virtualenv to ensure it is loadable in a default setup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes we need to figure this out, since with dags having use cases we might need some more dependency.

),
doc_md=DOC_MD_DAG,
)
def stakeholder_subdag() -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing is cool! But do we need to define -> None on the dag level? Is this common best practice? Not sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, let me remove it.

@github-actions

github-actions Bot commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Sep 4, 2025
@shubhamraj-git
shubhamraj-git deleted the issue-52478 branch September 7, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New example along storyline: Turbine report

2 participants