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

[AIRFLOW-5369] Add interactivity to pre-commits #5976

Merged

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Sep 1, 2019

Make sure you have checked all steps below.

Jira

This commit adds full interactivity to pre-commits. Whenever you run pre-commit
and it detects that the image should be rebuild, an interactive question will
pop up instead of failing the build and asking to rebuild with REBUILD=yes

This is much nicer from the user perspective. You can choose whether to:
1) Rebuild the image (which will take some time)
2) Not rebuild the image (this will use the old image with hope it's OK)
3) Quit.

Answer to that question is carried across all images needed to rebuild.
There is the special "build" pre-commit hook that takes care about that.

Note that this interactive question cannot be asked if you run only
single pre-commit hook with Dockerfile because it can run multiple processes
and you can start building in parallel. This is not desired so instead we fail
such builds.

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    No tests for bash scripts (maybe we should add them eventually!)

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

Code Quality

  • Passes flake8

@potiuk
Copy link
Member Author

potiuk commented Sep 1, 2019

This one is really useful if you have pre-commit installed and use it.

It integrates well with breeze not only wit pre-commits - it will now let you answer y/n/q when pre-commit detects that the files need rebuilding.

If you answer "no" it will run all tests in pre-commit using the old, previously built images (which in vast majority of cases will be ok). This is really useful for offline cases (now you can run all pre-commits in offline mode easily and when we also merge #5972 it will be really fast and no necessary rebuilds when you switch between branches and you will be able to use full power of consistent pre-commits without waiting too long for occasional image rebuilds.

@potiuk
Copy link
Member Author

potiuk commented Sep 2, 2019

This one is more difficult/longer to review but I think it might help a lot with adoption and regular use of pre-commit. I myself started using --no-verify far too often, but after we merge #5972 and this one, it should be really smooth to use pre-commit daily (@mik-laj @nuclearpinguin can confirm that pre-commits are really great for daily routine I think).

@dimberman
Copy link
Contributor

@potiuk Is there any way to break this into smaller PRs? There's just... a lot going on here...

@potiuk
Copy link
Member Author

potiuk commented Sep 3, 2019

@dimberman . You are totally right! It started from interactivity but I added a number of other small fixes along the way and now it's too big /complex/has a lot of unrelated changes.

I will break it.

@potiuk potiuk force-pushed the add-interactivity-to-pre-commits branch 2 times, most recently from ab839e4 to 783e1f7 Compare September 8, 2019 11:40
@potiuk
Copy link
Member Author

potiuk commented Sep 8, 2019

Hey @dimberman - I moved out the dumb-init change, and I tried to split it even further, but it seem what's left is totally related. I needed to make a bit more consistent behaviour when I ask interactively whether to rebuild the images. Now we have a really nice behaviour that there are no more failures when you have out-of-date images but it is all interactive.

BTW. I am seriously thinking about adding unit tests for the bash scripts already ;).

@potiuk
Copy link
Member Author

potiuk commented Sep 8, 2019

@mik-laj -> that also addresses your recent questions about rebuilding the images when you run pre-commit manually. I thought this change is already merged, but it was not.

@potiuk potiuk force-pushed the add-interactivity-to-pre-commits branch from 783e1f7 to f8d04be Compare September 9, 2019 03:33
@potiuk potiuk changed the title [AIRFLOW-5369] Add interactivity to pre-commits [AIRFLOW-5369] [DO NOT MERGE YET] Add interactivity to pre-commits Sep 9, 2019
@codecov-io
Copy link

codecov-io commented Sep 9, 2019

Codecov Report

Merging #5976 into master will decrease coverage by 0.13%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #5976      +/-   ##
=========================================
- Coverage   80.03%   79.9%   -0.14%     
=========================================
  Files         607     607              
  Lines       35019   35019              
=========================================
- Hits        28029   27983      -46     
- Misses       6990    7036      +46
Impacted Files Coverage Δ
airflow/executors/sequential_executor.py 47.61% <0%> (-52.39%) ⬇️
airflow/utils/log/colored_log.py 81.81% <0%> (-11.37%) ⬇️
airflow/utils/sqlalchemy.py 86.44% <0%> (-6.78%) ⬇️
airflow/executors/__init__.py 63.26% <0%> (-4.09%) ⬇️
airflow/utils/dag_processing.py 56.44% <0%> (-2.36%) ⬇️
airflow/jobs/scheduler_job.py 73.08% <0%> (-1.21%) ⬇️
airflow/models/taskinstance.py 93.22% <0%> (-0.51%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa8e18a...46a22e7. Read the comment docs.

@potiuk potiuk force-pushed the add-interactivity-to-pre-commits branch 7 times, most recently from 959f47e to 5be9342 Compare September 11, 2019 00:46
@potiuk potiuk changed the title [AIRFLOW-5369] [DO NOT MERGE YET] Add interactivity to pre-commits [AIRFLOW-5369] Add interactivity to pre-commits Sep 11, 2019
@potiuk
Copy link
Member Author

potiuk commented Sep 11, 2019

Hey @dimberman -> it's still big but it adds really nice feature to pre-commits now. It's fully interactive now and when you need to rebuild an image, it will ask you - so that you can make decision. Just tested it and it is really nice to work with it.

@potiuk
Copy link
Member Author

potiuk commented Sep 11, 2019

It would be great to get this merged before the workshop in Guadalahara :)

@potiuk
Copy link
Member Author

potiuk commented Sep 15, 2019

Hey @dimberman :)?

@potiuk
Copy link
Member Author

potiuk commented Sep 16, 2019

🙏

@mik-laj
Copy link
Member

mik-laj commented Sep 17, 2019

@potiuk Can you do rebase?

This commit adds full interactivity to pre-commits. Whenever you run pre-commit
and it detects that the image should be rebuild, an interactive question will
pop up instead of failing the build and asking to rebuild with REBUILD=yes

This is much nicer from the user perspective. You can choose whether to:
1) Rebuild the image (which will take some time)
2) Not rebuild the image (this will use the old image with hope it's OK)
3) Quit.

Answer to that question is carried across all images needed to rebuild.
There is the special "build" pre-commit hook that takes care about that.

Note that this interactive question cannot be asked if you run only
single pre-commit hook with Dockerfile because it can run multiple processes
and you can start building in parallel. This is not desired so instead we fail
such builds.
@potiuk potiuk force-pushed the add-interactivity-to-pre-commits branch from 5be9342 to 46a22e7 Compare September 17, 2019 14:27
@potiuk potiuk merged commit 857788e into apache:master Sep 18, 2019
potiuk added a commit that referenced this pull request Sep 18, 2019
This commit adds full interactivity to pre-commits. Whenever you run pre-commit
and it detects that the image should be rebuild, an interactive question will
pop up instead of failing the build and asking to rebuild with REBUILD=yes

This is much nicer from the user perspective. You can choose whether to:
1) Rebuild the image (which will take some time)
2) Not rebuild the image (this will use the old image with hope it's OK)
3) Quit.

Answer to that question is carried across all images needed to rebuild.
There is the special "build" pre-commit hook that takes care about that.

Note that this interactive question cannot be asked if you run only
single pre-commit hook with Dockerfile because it can run multiple processes
and you can start building in parallel. This is not desired so instead we fail
such builds.

(cherry picked from commit 857788e)
@potiuk potiuk deleted the add-interactivity-to-pre-commits branch September 19, 2019 22:43
ashb pushed a commit that referenced this pull request Sep 24, 2019
This commit adds full interactivity to pre-commits. Whenever you run pre-commit
and it detects that the image should be rebuild, an interactive question will
pop up instead of failing the build and asking to rebuild with REBUILD=yes

This is much nicer from the user perspective. You can choose whether to:
1) Rebuild the image (which will take some time)
2) Not rebuild the image (this will use the old image with hope it's OK)
3) Quit.

Answer to that question is carried across all images needed to rebuild.
There is the special "build" pre-commit hook that takes care about that.

Note that this interactive question cannot be asked if you run only
single pre-commit hook with Dockerfile because it can run multiple processes
and you can start building in parallel. This is not desired so instead we fail
such builds.

(cherry picked from commit 857788e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants