Repository navigation
[DRAFT] [Storyline example] Turbine Report - Shareholder Reporting Dynamic Dag - #53352
shubhamraj-git wants to merge 1 commit into
Conversation
8aaecf6 to
22430ff
Compare
22430ff to
6987847
Compare
jscheffl
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Example must be w/o other provider dependency. Might be extended by an example in Amazon provider. But import must be removed here :-(
There was a problem hiding this comment.
Yaa makes sense, will remove it. Having it might create dependency.
| # Config for the stakeholder dags | ||
| CONFIG: list[dict[str, Any]] = [ | ||
| { | ||
| "name": "stakeholder_a", |
There was a problem hiding this comment.
Could we invent just two names instead of "a" and "b"? Maybe just artificial names like "miller" or "smith"?
| "type": "s3", | ||
| "bucket": "example-bucket", | ||
| "key": "stakeholder_data.csv", |
There was a problem hiding this comment.
Could we use local file and drop the CSV besides the dag in the examples folder?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
As we might take code snippets in the documentation, probably we shoudl have the doc_md inline?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
This is done to overcome the issue of late binding in python.
|
|
||
| import os | ||
|
|
||
| import pandas as pd |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Typing is cool! But do we need to define -> None on the dag level? Is this common best practice? Not sure.
There was a problem hiding this comment.
No, let me remove it.
|
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. |
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.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.