-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagster-airlift] airflow operator switcher
- Loading branch information
Showing
10 changed files
with
300 additions
and
33 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
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
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
68 changes: 68 additions & 0 deletions
68
...lift/dagster_airlift_tests/integration_tests/airflow_op_switcheroo/dags/switcheroo_dag.py
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,68 @@ | ||
import logging | ||
import os | ||
from datetime import datetime | ||
|
||
from airflow import DAG | ||
from airflow.operators.python import PythonOperator | ||
from dagster_airlift.in_airflow import mark_as_dagster_migrating | ||
from dagster_airlift.migration_state import ( | ||
AirflowMigrationState, | ||
DagMigrationState, | ||
TaskMigrationState, | ||
) | ||
|
||
logging.basicConfig() | ||
logging.getLogger().setLevel(logging.INFO) | ||
requests_log = logging.getLogger("requests.packages.urllib3") | ||
requests_log.setLevel(logging.INFO) | ||
requests_log.propagate = True | ||
|
||
|
||
def write_to_file_in_airflow_home() -> None: | ||
airflow_home = os.environ["AIRFLOW_HOME"] | ||
with open(os.path.join(airflow_home, "airflow_home_file.txt"), "w") as f: | ||
f.write("Hello") | ||
|
||
|
||
def write_to_other_file_in_airflow_home() -> None: | ||
airflow_home = os.environ["AIRFLOW_HOME"] | ||
with open(os.path.join(airflow_home, "other_airflow_home_file.txt"), "w") as f: | ||
f.write("Hello") | ||
|
||
|
||
default_args = { | ||
"owner": "airflow", | ||
"depends_on_past": False, | ||
"start_date": datetime(2023, 1, 1), | ||
"retries": 1, | ||
} | ||
|
||
dag = DAG( | ||
"the_dag", default_args=default_args, schedule_interval=None, is_paused_upon_creation=False | ||
) | ||
op_to_migrate = PythonOperator( | ||
task_id="some_task", python_callable=write_to_file_in_airflow_home, dag=dag | ||
) | ||
op_doesnt_migrate = PythonOperator( | ||
task_id="other_task", python_callable=write_to_other_file_in_airflow_home, dag=dag | ||
) | ||
# Add a dependency between the two tasks | ||
op_doesnt_migrate.set_upstream(op_to_migrate) | ||
|
||
# # set up the debugger | ||
# print("Waiting for debugger to attach...") | ||
# debugpy.listen(("localhost", 7778)) | ||
# debugpy.wait_for_client() | ||
mark_as_dagster_migrating( | ||
global_vars=globals(), | ||
migration_state=AirflowMigrationState( | ||
dags={ | ||
"the_dag": DagMigrationState( | ||
tasks={ | ||
"some_task": TaskMigrationState(migrated=True), | ||
"other_task": TaskMigrationState(migrated=True), | ||
} | ||
) | ||
} | ||
), | ||
) |
9 changes: 9 additions & 0 deletions
9
...ter-airlift/dagster_airlift_tests/integration_tests/airflow_op_switcheroo/dagster_defs.py
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,9 @@ | ||
from dagster import Definitions, asset | ||
|
||
|
||
@asset | ||
def the_dag__some_task(): | ||
return "asset_value" | ||
|
||
|
||
defs = Definitions(assets=[the_dag__some_task]) |
Oops, something went wrong.