Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option for run id in the ui trigger screen #21851

Merged
merged 11 commits into from Mar 16, 2022

Conversation

talnagar
Copy link
Contributor

@talnagar talnagar commented Feb 27, 2022

Added an option for custom run_id in the trigger dag screen.
this option was already supported in the API.
This commit includes:

  • changes to the static template of the trigger screen
  • extraction of the run_id in the views.py
  • changes to models/dagrun.py - filter dag runs by run_id if exists or execution date
  • unittest for: triggering dagrun with and without run_id, handling duplicate run_id

closes: #21336

Before:
image

After:
image

@boring-cyborg boring-cyborg bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Feb 27, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 27, 2022

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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits 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 Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment 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 for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    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

@ashb
Copy link
Member

ashb commented Feb 28, 2022

Thanks for the PR!

When making UI changes it is helpful to the reviewers if you include before and after screenshots in the PR description

airflow/www/views.py Outdated Show resolved Hide resolved
airflow/www/views.py Outdated Show resolved Hide resolved
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@talnagar
Copy link
Contributor Author

talnagar commented Mar 1, 2022

thanks for the feedback, I added the screen shots to the PR.
I tried to use the same css classes I saw on other templates but wasn't sure if there is some tests that I need to do for different screen types/resolutions?

change label writing to be consistent with the rest of the forrm

Co-authored-by: Brent Bovenzi <brent.bovenzi@gmail.com>
@bbovenzi
Copy link
Contributor

bbovenzi commented Mar 3, 2022

Can we handle duplicate runIds more elegantly?

Screen Shot 2022-03-03 at 12 19 34 PM

@talnagar
Copy link
Contributor Author

talnagar commented Mar 6, 2022

@bbovenzi I am trying to reproduce this error and write a unittest for it.
When I trigger tasks with duplicates in my local env I see the issue is handled and an error msg is shown:
image

can you please write how did you produce this error?

@bbovenzi
Copy link
Contributor

bbovenzi commented Mar 7, 2022

can you please write how did you produce this error?

Actually I'm not sure. I just tried again and the correct error was thrown.

@talnagar
Copy link
Contributor Author

talnagar commented Mar 8, 2022

@bbovenzi @uranusjr I just committed updates to the code:

  • moved dag filtration to model now using sqlalchemy.
  • added a unittest for checking handling of duplicate run_id.
    I would appreciate your feedback.

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

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

UI-wise this looks good to me.

@github-actions
Copy link

github-actions bot commented Mar 8, 2022

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Mar 8, 2022
@potiuk potiuk closed this Mar 9, 2022
@potiuk potiuk reopened this Mar 9, 2022
@uranusjr
Copy link
Member

Logic looks good to me, but can you change the code to not use DagRun.find(), and leave the function unchanged? I don’t think this new logic is general enough that we should risk breaking backward compatibility. (Eventually I feel DagRun.find() should probably be removed entirely, but before that we would do better to avoid using it in new code.)

@talnagar
Copy link
Contributor Author

talnagar commented Mar 10, 2022

@uranusjr not sure I understand what you mean. add a separate function in models/dagrun.py to look for duplicate run ids instead of using the existing find?
I see there is a function for finding duplicates DagRun.find_duplicate():

def find_duplicate(

maybe I should switch to using it instead of DagRun.find()

@talnagar talnagar changed the title added an option for run id in the ui trigger screen add an option for run id in the ui trigger screen Mar 10, 2022
@talnagar talnagar closed this Mar 10, 2022
@talnagar talnagar reopened this Mar 10, 2022
@uranusjr
Copy link
Member

Oh, I was thinking we don’t need to add a function and could just use SQLAlchemy directly in trigger. But find_duplicate is actually better, nice find! I did not even know it exists.

airflow/www/views.py Outdated Show resolved Hide resolved
use existing run_id in error msg in case of duplication

Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
@potiuk potiuk merged commit 14a2d9d into apache:main Mar 16, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 16, 2022

Awesome work, congrats on your first merged pull request!

@curlup
Copy link
Contributor

curlup commented Apr 6, 2022

which version is this included in? and does anyone knows if we can easily backport? thanks!

@ashb
Copy link
Member

ashb commented Apr 6, 2022

This is not yet included in any release, it will be in 2.3.0 which we aim to get out in a week or two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge type:new-feature Changelog: New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override the dag run_id from within the ui
8 participants