Skip to content

Conversation

@zacharya19
Copy link
Contributor

@zacharya19 zacharya19 commented Nov 2, 2019

Make sure you have checked all steps below.

Jira

Description

  • Here are some details about my PR, including screenshots of any UI changes:
    In order to allow multiple teams and users to use the same Airflow instance, I've added a tagging option for DAGs.
    Each dag can have one, a few or none tags, then the user can filter in the homepage specific tags.
    The filtering is saved in a cookie to save the user preferences.
    Before:
    image

After:
image

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    test_home_filter_tags in view tests, to check if the cookie is set properly.

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
    • If you implement backwards incompatible changes, please leave a note in the Updating.md so we can assign it to a appropriate release

@zacharya19 zacharya19 force-pushed the z/DagTags branch 4 times, most recently from 0d817ea to a49807e Compare November 2, 2019 18:07
Copy link
Member

@turbaszek turbaszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of tagging DAGs. I found few nits and also, shouldn't we add more tests?

@zacharya19
Copy link
Contributor Author

zacharya19 commented Nov 2, 2019

@nuclearpinguin Since most of this change is UI related except checking the cookie part (and come to think of it - I should separate the filter part to another function and write a small test for it, will do), not sure which tests I should add.
Any thoughts?

@zacharya19 zacharya19 force-pushed the z/DagTags branch 2 times, most recently from cef89e3 to 23eeb44 Compare November 2, 2019 20:52
@OmerJog
Copy link
Contributor

OmerJog commented Nov 3, 2019

@zacharya19 There is an error with the test you added

ERROR: test_home_filter_tags (tests.www.test_views.TestAirflowBaseViews)
----------------------------------------------------------------------
   Traceback (most recent call last):
    tests/www/test_views.py line 329 in setUp
      super().setUp()
    tests/www/test_views.py line 70 in setUp
      self.login()
    tests/www/test_views.py line 73 in login
      role_admin = self.appbuilder.sm.find_role('Admin')
    /usr/local/lib/python3.6/site-packages/flask_appbuilder/security/sqla/manager.py line 201 in find_role
      return self.get_session.query(self.role_model).filter_by(name=name).first()
    /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py line 3240 in first
      ret = list(self[0:1])
    /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py line 3018 in __getitem__
      return list(res)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py line 3342 in __iter__
      return self._execute_and_instances(context)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py line 3367 in _execute_and_instances
      result = conn.execute(querycontext.statement, self._params)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py line 988 in execute
      return meth(self, multiparams, params)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py line 287 in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py line 1107 in _execute_clauseelement
      distilled_params,
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py line 1253 in _execute_context
      e, statement, parameters, cursor, context
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py line 1473 in _handle_dbapi_exception
      util.raise_from_cause(sqlalchemy_exception, exc_info)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py line 398 in raise_from_cause
      reraise(type(exception), exception, tb=exc_tb, cause=cause)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py line 152 in reraise
      raise value.with_traceback(tb)
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py line 1249 in _execute_context
      cursor, statement, parameters, context
    /usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py line 580 in do_execute
      cursor.execute(statement, parameters)
   InternalError: (psycopg2.InternalError) current transaction is aborted, commands ignored until end of transaction block
   
   [SQL: SELECT ab_role.id AS ab_role_id, ab_role.name AS ab_role_name 
   FROM ab_role 
   WHERE ab_role.name = %(name_1)s 
    LIMIT %(param_1)s]
   [parameters: {'name_1': 'Admin', 'param_1': 1}]
   (Background on this error at: http://sqlalche.me/e/2j85)

@zacharya19
Copy link
Contributor Author

@OmerJog I don't get those errors locally, weird, checking this.

@zacharya19 zacharya19 force-pushed the z/DagTags branch 2 times, most recently from f679e2b to 886935d Compare November 3, 2019 19:12
Copy link
Member

@feluelle feluelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zacharya19 This seems to be related to https://issues.apache.org/jira/browse/AIRFLOW-4026. WDYT? Should we display these tags as labels next to the dag_id ?

@zacharya19
Copy link
Contributor Author

@feluelle Yes, look like it's also related to this task.
How do I link this PR to two issues? [AIRFLOW-3959] [AIRFLOW-4026] add UI filter with DAGs tags?

I can add display the tags next to the dag_id, but what will happen if a dag has a lot of labels?
I guess it's an edge case that will not really happen, I will add it.

@zacharya19 zacharya19 changed the title [AIRFLOW-3959] add UI filter with DAGs tags [AIRFLOW-3959] [AIRFLOW-4026] add UI filter with DAGs tags? Nov 6, 2019
@feluelle
Copy link
Member

feluelle commented Nov 6, 2019

How do I link this PR to two issues? [AIRFLOW-3959] [AIRFLOW-4026] add UI filter with DAGs tags?

Since you also added consistency for tags (in the db) I would mention that or remove the UI part of it. Like: [AIRFLOW-3959][AIRFLOW-4026] Add filter by DAG tags

I can add display the tags next to the dag_id, but what will happen if a dag has a lot of labels?
I guess it's an edge case that will not really happen, I will add it.

It could happen and I think it should be handled. I suggest to just wrap the line?

@feluelle
Copy link
Member

feluelle commented Nov 6, 2019

Note that we also need to update the commit message to include both tickets so that both Jira tickets get linked to this PR. But it can also be done by the committer who merges it if the PR is already ready to be merged. But in your case I see you need to do some fixes first ;)

@zacharya19 zacharya19 force-pushed the z/DagTags branch 2 times, most recently from fde98f6 to cc18ee3 Compare November 8, 2019 14:41
@zacharya19 zacharya19 changed the title [AIRFLOW-3959] [AIRFLOW-4026] add UI filter with DAGs tags? [AIRFLOW-3959] [AIRFLOW-4026] Add filter by DAG tags Nov 8, 2019
@zacharya19 zacharya19 force-pushed the z/DagTags branch 7 times, most recently from fc32758 to d26ecd4 Compare November 9, 2019 15:14
@kaxil
Copy link
Member

kaxil commented Mar 13, 2020

Do you have any reason this great feature is limited to RBAC enabled airflow in 1.10.9? I just want to use this feature, but we don't use RBAC in our airflow.

Hi @taxpon , as mentioned in http://airflow.apache.org/blog/airflow-1.10.8-1.10.9/#use-airflow-rbac-ui We are deprecating the old Flask-based UI and will be completely removed in the next major release. We backport all the security updates to the old UI but all the new features are only applied to RBAC UI. We had already removed the old flask-based from the Master for a long time now.

@JeffryMAC
Copy link

@zacharya19 is there a way to control over the colours of the tags?

@xuejunteo
Copy link

Is there a way to auto generate permissions based on tags?

e.g.
I want to automatically grant access to user based on his role to a specific list of tags

currently only the can dag read on <dag name> and can dag write on <dag name> is auto populated when there is a new dag

it would be good if i can do something like can dag read on tag <tag name> and can dag write on tag <tag name>

thanks in advance!

@zacharya19
Copy link
Contributor Author

@JeffryMAC The colors right now are hardcoded, what will be the motivation of controlling the color? if you want, it will be possible to add a config param to change the color, like we do in the menu bar color for example.

@xuejunteo That actually sounds like a great feature, I suggest you open a github issue and hopefully someone will pick it up (I'll try to get to it if I've time :)).

leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 15, 2021
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 17, 2021
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 23, 2021
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Nov 25, 2021
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Mar 9, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jun 3, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jun 6, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jul 8, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Aug 26, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 3, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
aglipska pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 7, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Dec 7, 2022
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
leahecole pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Jan 27, 2023
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this pull request Sep 11, 2024
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to kosteev/composer-airflow-test-copybara that referenced this pull request Sep 12, 2024
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 16, 2024
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Nov 6, 2024
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Apr 30, 2025
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request May 21, 2025
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Sep 15, 2025
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 14, 2025
We miss add some dag tag in
apache/airflow#6489
This patch to add dag tag for all others

GitOrigin-RevId: 941a070578bc7d9410715b89658548167352cc4d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:serialization area:webserver Webserver related Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.