kacpermuda commented on code in PR #65788:
URL: https://github.com/apache/airflow/pull/65788#discussion_r3160544469


##########
providers/openlineage/src/airflow/providers/openlineage/api/datasets.py:
##########
@@ -0,0 +1,155 @@
+# 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.
+"""Public helpers for emitting OpenLineage events carrying dataset lineage."""
+
+from __future__ import annotations
+
+import logging
+from datetime import datetime, timezone
+from typing import TYPE_CHECKING
+
+from openlineage.client.event_v2 import Dataset, Job, Run, RunEvent, RunState
+
+from airflow.providers.openlineage.api.core import emit, is_openlineage_active
+from airflow.providers.openlineage.plugins.adapter import _PRODUCER, 
OpenLineageAdapter
+from airflow.providers.openlineage.plugins.macros import (
+    _get_dag_run_clear_number,
+    _get_dag_run_conf,
+    _get_logical_date,
+    lineage_job_name,
+    lineage_job_namespace,
+    lineage_run_id,
+)
+from airflow.providers.openlineage.utils.utils import (
+    build_task_event_job_facets,
+    build_task_event_run_facets,
+    get_dag_run_dag_and_task_from_ti,
+    get_task_instance_from_context,
+)
+from airflow.utils.state import TaskInstanceState
+
+if TYPE_CHECKING:
+    from openlineage.client.event_v2 import InputDataset, OutputDataset
+    from openlineage.client.facet_v2 import JobFacet, RunFacet
+
+    from airflow.models.taskinstance import TaskInstance
+    from airflow.sdk.execution_time.task_runner import RuntimeTaskInstance
+
+log = logging.getLogger(__name__)
+
+__all__ = ["emit_dataset_lineage"]
+
+
+def emit_dataset_lineage(

Review Comment:
   Will look through the exceptions we raise, but I think they're mostly 
related to user input (f.e. missing ti and no ti in context, meaning the 
function is not run within airflow task, not really easy to do). But imo we 
have two options:
   1. raise exceptions, let the users handle them
   2. wrap everything in giant try/except, introduce `raise_on_error: bool = 
False`, log a warning on error and move on, so we make it easier for users to 
handle errors, without wrapping each execution in giant try/except.
   
   I can go with option 2, since it's easy on our side.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to