You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ntr (via GitHub)" <gi...@apache.org> on 2025/02/15 01:25:28 UTC

[PR] Set task/dag labels for Dataproc Batch [airflow]

ntr opened a new pull request, #46781:
URL: https://github.com/apache/airflow/pull/46781

   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **Set task/dag labels for Dataproc Batch**
   Setting labels `airflow-dag` and `airflow-task` using sanitized dag and task id. This should help the users to keep track of historical execution of dataproc serverless batches.
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1970640332


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   But then it will be different dag, so labelling it with sanitised dag_id makes perfect sense IMHO



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "michalmodras (via GitHub)" <gi...@apache.org>.
michalmodras commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2663825918

   This looks good to me - @VladaZakharova let's have someone in the team review as well. 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1970413279


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Didnt meant to replace dag_id.
   My intention was to add another label



##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Didnt mean to replace dag_id.
   My intention was to add another label



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2665385369

   Looks good to me!
   Verified, on UI in Dataproc everything works as expected both in deff and non-deff modes :)
   
   @potiuk Can you please approve and merge, if it looks good to you? 
   
   Thanks :)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2691464642

   anything remaining @eladkal :)? 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1970066522


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   But users can also change dag_id.
   
   Some patterns of dag authoring migrated to use dag_display_name and hide the option to set dag_id directly.
   Unless there is a strong reason to avoid I would rather we allow to set it, provide to users the needed knowledge and let them to make thier choices.
   
   Regardless if my suggestion is not accepted we should at least explain in a user facing doc why we don't track the display name.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #46781:
URL: https://github.com/apache/airflow/pull/46781


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2663933455

   Needs rebase :)


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1967295095


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Good point. 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "ntr (via GitHub)" <gi...@apache.org>.
ntr commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2701675962

   @eladkal can you please take a look again? I cannot merge this PR without your approval. Thanks.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "ntr (via GitHub)" <gi...@apache.org>.
ntr commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1972356638


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Updated with another tag (label).



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "ntr (via GitHub)" <gi...@apache.org>.
ntr commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1965960449


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Google cloud labels have their own validation so I wanted to have an explicit code that sanitizes the values. Othewise, if someone changes dag_display_name value workloads will start to fail with validation error.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1970066522


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   But users can also change dag_id.
   
   Some patterns of dag authoring migrated to use dag_display_name and hide the option to set dag_id directly.
   Unless there is a strong reason to avoid I would rather we allow to set it, provide to users the needed knowledge and let them to make thier choices.
   
   Regardless if my suggestion is not accepted we should at least explain in a user facing doc why we don't track the display name.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "ntr (via GitHub)" <gi...@apache.org>.
ntr commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2672269474

   Thanks, updated.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1965148569


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   Is there a reason not to label with `dag_display_name` ?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2708915769

   Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "ntr (via GitHub)" <gi...@apache.org>.
ntr commented on code in PR #46781:
URL: https://github.com/apache/airflow/pull/46781#discussion_r1970377030


##########
providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:
##########
@@ -2708,6 +2710,25 @@ def _inject_openlineage_properties_into_dataproc_batch(self, context: Context) -
                 exc_info=e,
             )
 
+    def __update_batch_labels(self):
+        dag_id = re.sub(r"[.\s]", "_", self.dag_id.lower())
+        task_id = re.sub(r"[.\s]", "_", self.task_id.lower())

Review Comment:
   I am not sure if `dag_display_name` is a better choice for identifying dags - I do not see any enforcement for it to be unique.  (Updated PR description).
   
   We can just add one more label with display name and make it clear that it is not id, but to be honest I do not see use-case for that. What do you think? 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Set task/dag labels for Dataproc Batch [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #46781:
URL: https://github.com/apache/airflow/pull/46781#issuecomment-2660610091

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org