airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Added Feature: search dags by task id with suggestions

Open pruoff opened this issue 1 year ago • 7 comments

This PR closes: #37106

Previously the DAG search bar could be used to search by DAG id and owner.

Changes in /home UI from user's perspective:

  • DAG search with prefix "task: <task_id>" filters all DAGs by case-insensitive pattern-matching of the provided task_id.
  • suggestions of task_ids are automatically shown when typing. Since the same task_id can be present in many dags, an italic " in <dag_id>" is shown following the task_id suggestion.
  • actively limit the DAG search scope by prefixing "dag:" for dag_id search and "owner:" for owner search.
  • autocompleted suggestions are prefixed by their type e.g. "owner: airflow"

Screenshot 2024-02-11 at 14 25 41

pruoff avatar Feb 15 '24 07:02 pruoff

@pruoff can you rebase and resolve conflicts?

eladkal avatar Apr 01 '24 07:04 eladkal

I checked and I have no auto-complete and suggestions when I type as described in the PR descriptions. Tested with Firefox and Chromium. Did I mis-undertstand the PR that suggestions are not there? Or are the suggestions browser specific?

Also when not prefixing dag: in the search the text entered always filters for the DAG ID. Search for tasks and owner though is working. But dag: prefix smells un-needed if this is the default. Or shall the default be to make a global search?

jscheffl avatar Apr 01 '24 16:04 jscheffl

@jscheffl

I checked and I have no auto-complete and suggestions when I type as described in the PR descriptions. Tested with Firefox and Chromium. Did I mis-undertstand the PR that suggestions are not there? Or are the suggestions browser specific?

A bug was introduced when rebasing, which caused the autocomplete to fail - see the FIX commit. The feature works for me now in both Firefox and Chromium.

Also when not prefixing dag: in the search the text entered always filters for the DAG ID. Search for tasks and owner though is working. But dag: prefix smells un-needed if this is the default. Or shall the default be to make a global search?

The default is to search by both dag id and owner. The dag: prefix resolves confusion in case a dag id and owner are named the same.

pruoff avatar Apr 07 '24 08:04 pruoff

Thanks for the fix, I can confirm it works now as advertised.

I approve from my side. I just kindly request to also alter the documentation a bit. Else the risk is high that nobody will be able to find and discover this cool freature - especially searching for tasks. Can you add / adjust documentation in docs/apache-airflow/ui.rst

Thanks a lot! I now also extended the UI docs.

pruoff avatar Apr 08 '24 06:04 pruoff

@bbovenzi or @eladkal Can yo umake a 2nd pass review, then I thing we should merge this.

jscheffl avatar Apr 19 '24 21:04 jscheffl

Let's rebase.

Quite some effort this time. Included the display_dag_name logic

pruoff avatar Apr 25 '24 10:04 pruoff

Do we want to include searching by task_display_name in this PR or in a follow up?

Searching by task_display_name is already included and the PR does not change this.

pruoff avatar Apr 26 '24 15:04 pruoff

@ashb thanks for the review. I share your concern about resource consumption issues when loading all dags from the DB.

I tried to query the JSON via many ways. One would be: session.query(SerializedDagModel).filter(SerializedDagModel.__table__.columns.data['dag_id'].astext == dag_id) yet I always end up in NotImplementedError: Operator 'getitem' is not supported on this expression.

Can somebody support me here with a minimal working code snippet? In the repo, I cannot find any comparable code that queries the serialized dags in the DB.

pruoff avatar May 25 '24 05:05 pruoff

Here it finally is! I invested many hours in finding the correct methods. Asking for help did not create any responses neither here nor on Slack. There’s only one single occurrence of func.json_extract in the code that I found more or less by accident.

Tested with MySQL, Postgres, and sqlite; sqlite supports func.json_extract but nothing like func.json_keys so I kept the original code for that backend.

pruoff avatar Jul 30 '24 04:07 pruoff

Looking better! I think we should add an info tooltip telling users the new keywords search.

bbovenzi avatar Jul 30 '24 18:07 bbovenzi

(@pruoff And sorry for not noticing the original ping! My GH notifications are a mess)

ashb avatar Aug 01 '24 10:08 ashb