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

Fix Breeze2 autocomplete #22695

Merged
merged 1 commit into from
Apr 3, 2022
Merged

Fix Breeze2 autocomplete #22695

merged 1 commit into from
Apr 3, 2022

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Apr 1, 2022

Breeze2 autocomplete did not work because we were using some old
way of adding it (via click-complete). Since then click has
native (and very well working) autocomplete support without any
external dependencies needed. It cannnot automatically generate
the completions but it is not needed either, because we can
store generated completion scripts in our repo.

We also move some imports to local and catch rich_click import
error to minimize dependencies needed to get autocomplete
working. Setup-autocomplete install (and upgrade if needed
click in case it needs to be used by autocomplete script.

Fixes: #21164


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@potiuk
Copy link
Member Author

potiuk commented Apr 1, 2022

Hey @edithturn - I finally got to the "autocomplete" on Breeze2. It turned out that "click-complete" is not needed as a dependency :). This is some old package and click has good autocomplete support out-of-the-box. I fixed setup-autocomplete and it seems autocomplete now works like ... Breeze.

@potiuk
Copy link
Member Author

potiuk commented Apr 1, 2022

Another step for bash Breeze removal

@edithturn
Copy link
Contributor

wow @potiuk that is great 👏🏼 , some files are still being .sh right?

@potiuk
Copy link
Member Author

potiuk commented Apr 2, 2022

wow @potiuk that is great 👏🏼 , some files are still being .sh right?

Some files will have to remain .sh :)

@Bowrna
Copy link
Contributor

Bowrna commented Apr 2, 2022

Cool @potiuk :)

@potiuk potiuk force-pushed the fix-breeze2-complete branch 2 times, most recently from db8377e to 254db8e Compare April 3, 2022 09:34
@potiuk
Copy link
Member Author

potiuk commented Apr 3, 2022

I performed a few more tests and updated the autocomplete setup so that it works in all the circumstances (I hope). I refactored imports slightly so that in case indeed user does not use virtualenv with Breeze installed, click is the only requirement that is needed for the autocomplete to work.

@potiuk potiuk force-pushed the fix-breeze2-complete branch from 254db8e to db8377e Compare April 3, 2022 09:39
Breeze2 autocomplete did not work because we were using some old
way of adding it (via click-complete). Since then click has
native (and very well working) autocomplete support without any
external dependencies needed. It cannnot automatically generate
the completions but it is not needed either, because we can
store generated completion scripts in our repo.

We also move some imports to local and catch rich_click import
error to minimize dependencies needed to get autocomplete
working. Setup-autocomplete install (and upgrade if needed
click in case it needs to be used by autocomplete script.

Fixes: apache#21164
@potiuk potiuk force-pushed the fix-breeze2-complete branch from db8377e to 393d199 Compare April 3, 2022 09:41
@potiuk
Copy link
Member Author

potiuk commented Apr 3, 2022

I am very close to enable Breeze2 for everyone (@Bowrna @edithturn @eladkal ) - this one is one of the prerequiste, and I have another one coming tha reviews and de-duplicates/syncs all changes and make it "prod-ready" - Plase take a look at this one and I'd love to merge it soon. The third PR will move the old breeze to legacy and replace the current ./breeze with the new one :).

I cannot wait to get the new Breeze2 in the hands of our contributors. It's sooo much nicer than the old one

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Apr 3, 2022
@github-actions
Copy link

github-actions bot commented Apr 3, 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.

@potiuk potiuk merged commit 4fb929a into apache:main Apr 3, 2022
@potiuk potiuk deleted the fix-breeze2-complete branch April 3, 2022 18:52
@@ -102,6 +99,9 @@ def check_package_installed(package_name: str) -> bool:


def get_filesystem_type(filepath):
# We import it locally so that click autocomplete works
import psutil
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain this part to me @potiuk? Why do we have to import locally for autocomplete to work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because when autocomplete loads list of methods, it imports breeze.py and it has to import it fully to determine list of available options (quite similarly like Airflow parsing dag files to determine the structure of DAG.

Therefore we should make sure that very little number of packages need to be imported. There are two reasons:

  • in the environment where autocomplete is executed, psutil might be simply not installed (And import will fail)
  • importing packages takes time - we want to make autocomplete as fast as possible so that it returns list of available options immediately

This is the same thing as the one described by @blag here: #22613 (comment) and why we need to do the same in Airflow when we convert to click + click-rich.

It's also fundamentally the same case as the one described here in Airflow docs for DAG top-level code: https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html?highlight=best%20practices#top-level-python-code

@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Apr 14, 2022
@potiuk potiuk restored the fix-breeze2-complete branch April 26, 2022 20:52
@potiuk potiuk deleted the fix-breeze2-complete branch July 29, 2022 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Breeze2 autocomplete requires click-complete to be installed
5 participants