-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[dagster-airlift] mark dags as migrating #23370
Conversation
examples/experimental/dagster-airlift/dagster_airlift/within_airflow.py
Outdated
Show resolved
Hide resolved
...erimental/dagster-airlift/dagster_airlift_tests/airflow_migrating_project/dags/simple_dag.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor changes
4ff80f5
to
de7ca4a
Compare
466fff1
to
e1e11e2
Compare
de7ca4a
to
a57a8c1
Compare
e1e11e2
to
ac1ddf1
Compare
a57a8c1
to
7c7c8b4
Compare
ac1ddf1
to
277a9ae
Compare
1c2343a
to
e745d9a
Compare
277a9ae
to
a69dca9
Compare
e745d9a
to
15efcd4
Compare
a69dca9
to
f212aea
Compare
15efcd4
to
1ad114f
Compare
f212aea
to
c0b5cea
Compare
1ad114f
to
a70502a
Compare
c0b5cea
to
0a4a7bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make the change now or one of us can do it in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q mgmt. I think we should pass globals in explicitly
5ccfbeb
to
90fb17a
Compare
4fc7a51
to
cb04863
Compare
cb04863
to
2b11d64
Compare
|
2b11d64
to
5279253
Compare
*, | ||
global_vars: Dict[str, Any], | ||
migration_state: AirflowMigrationState, | ||
logger: logging.Logger = logging.getLogger("dagster_airlift"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be None
and then default to logging.getLogger("dagster_airlift")
in function the body given the way that Python does mutable parameters
Should only ever be the last line in a dag file. | ||
|
||
Args: | ||
global_vars (Dict[str, Any]): The global variables in the current context. In most cases, retrieved with `globals()` (no import required). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a pointer to https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html#loading-dags to show how we are just doing what airflow does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Please heed final comments.
5279253
to
1fccf5a
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Function that allows users to mark airflow dags as "migrating", and injects a tag into the dag with information about the migration. When placing the tag in the dag, there are two options: 1. Construct a new dag using essentially a shallow copy of the old dag, and then inject this into global scope. 2. Inject a tag into the existing dag object you find in global scope using the mutability of airflow dag's data structures. I prefer (2) in this approach, because the surface area is way lower than (1), and it should be relatively resistant to changes in airflow's API other than this one tiny surface area ([which hasn't changed since 1.10, when tags were first introduced)](https://airflow.apache.org/docs/apache-airflow/1.10.10/_modules/airflow/models/dag.html#DAG). Unless we can figure out a reliable way to create an arbitrary copy constructor for dags across any airflow version, we're likely to run into brittleness with trying to reconstruct a dag from the pure object, I think. In general, taking advantage of airflow's mutability when we can seems like a good approach to injecting migration state. Another point of discussion; what to do when there are no dags in scope which the state migration object has reference to. For now I throw an exception, but wondering if this is too harsh. Finally, there's the question of how these tags show up in airflow's UI. It's pretty ugly to see this json blob appear in the airflow UI after setting the tag, but there doesn't seem to be any other data structures we can use for this (except maybe params? But I feel more hesitant hooking into that since it's significantly more complex implementation wise). So might be the best we can do for now.
Function that allows users to mark airflow dags as "migrating", and injects a tag into the dag with information about the migration.
When placing the tag in the dag, there are two options:
I prefer (2) in this approach, because the surface area is way lower than (1), and it should be relatively resistant to changes in airflow's API other than this one tiny surface area (which hasn't changed since 1.10, when tags were first introduced). Unless we can figure out a reliable way to create an arbitrary copy constructor for dags across any airflow version, we're likely to run into brittleness with trying to reconstruct a dag from the pure object, I think. In general, taking advantage of airflow's mutability when we can seems like a good approach to injecting migration state.
Another point of discussion; what to do when there are no dags in scope which the state migration object has reference to. For now I throw an exception, but wondering if this is too harsh.
Finally, there's the question of how these tags show up in airflow's UI. It's pretty ugly to see this json blob appear in the airflow UI after setting the tag, but there doesn't seem to be any other data structures we can use for this (except maybe params? But I feel more hesitant hooking into that since it's significantly more complex implementation wise). So might be the best we can do for now.