forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openlineage: execute extraction and message sending in separate proce…
…ss (apache#40078) Signed-off-by: Maciej Obuchowski <[email protected]>
- Loading branch information
1 parent
7df04b8
commit fe1a87b
Showing
11 changed files
with
391 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
from __future__ import annotations | ||
|
||
import datetime | ||
import time | ||
|
||
from openlineage.client.generated.base import Dataset | ||
|
||
from airflow.models.dag import DAG | ||
from airflow.models.operator import BaseOperator | ||
from airflow.providers.openlineage.extractors import OperatorLineage | ||
|
||
|
||
class OpenLineageExecutionOperator(BaseOperator): | ||
def __init__(self, *, stall_amount=0, **kwargs) -> None: | ||
super().__init__(**kwargs) | ||
self.stall_amount = stall_amount | ||
|
||
def execute(self, context): | ||
self.log.error("STALL AMOUNT %s", self.stall_amount) | ||
time.sleep(1) | ||
|
||
def get_openlineage_facets_on_start(self): | ||
return OperatorLineage(inputs=[Dataset(namespace="test", name="on-start")]) | ||
|
||
def get_openlineage_facets_on_complete(self, task_instance): | ||
self.log.error("STALL AMOUNT %s", self.stall_amount) | ||
time.sleep(self.stall_amount) | ||
return OperatorLineage(inputs=[Dataset(namespace="test", name="on-complete")]) | ||
|
||
|
||
with DAG( | ||
dag_id="test_openlineage_execution", | ||
default_args={"owner": "airflow", "retries": 3, "start_date": datetime.datetime(2022, 1, 1)}, | ||
schedule="0 0 * * *", | ||
dagrun_timeout=datetime.timedelta(minutes=60), | ||
): | ||
no_stall = OpenLineageExecutionOperator(task_id="execute_no_stall") | ||
|
||
short_stall = OpenLineageExecutionOperator(task_id="execute_short_stall", stall_amount=5) | ||
|
||
mid_stall = OpenLineageExecutionOperator(task_id="execute_mid_stall", stall_amount=15) | ||
|
||
long_stall = OpenLineageExecutionOperator(task_id="execute_long_stall", stall_amount=30) |
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
Oops, something went wrong.