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

{CI} Add check __init__.py file in all extensions #5620

Merged
merged 5 commits into from
Dec 9, 2022

Conversation

wangzelin007
Copy link
Member

@wangzelin007 wangzelin007 commented Dec 9, 2022

Check if the vendored_sdks directory contains __init__.py in all extensions.
Will exclude empty vendored_sdks dir, for example:
azure-cli-extensions\src\containerapp-preview\azext_containerapp_preview\vendored_sdks is a empty dir that didn't contain any files.

Test screenshot:
image
image

@ghost ghost requested a review from yonzhan December 9, 2022 04:48
@ghost ghost added the Auto-Assign Auto assign by bot label Dec 9, 2022
@ghost ghost assigned zhoxing-ms Dec 9, 2022
@ghost ghost added the ContainerApp label Dec 9, 2022
@ghost ghost requested review from zhoxing-ms and jsntcy December 9, 2022 04:49
@ghost ghost added the CI label Dec 9, 2022
@ghost ghost requested a review from jiasli December 9, 2022 04:49
@ghost ghost requested a review from kairu-ms December 9, 2022 04:49
@ghost ghost assigned wangzelin007 Dec 9, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 9, 2022

Add check for init.py file

@yonzhan yonzhan added this to the Dec 2022 (2023-01-10) milestone Dec 9, 2022
@wangzelin007 wangzelin007 requested a review from bebound December 9, 2022 06:16
@wangzelin007 wangzelin007 marked this pull request as ready for review December 9, 2022 06:25
scripts/ci/test_init.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zhoxing-ms zhoxing-ms left a comment

Choose a reason for hiding this comment

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

Just a small comment, no other questions

@jiasli
Copy link
Member

jiasli commented Dec 9, 2022

I think an alternative solution is to use find_namespace_packages to build a namespace package, but this is not an easy job.

if os.path.isdir(src_d_full):
for d in os.listdir(src_d_full):
if d.startswith('azext_'):
# root_dir: azure-cli-extensions\src\ext_name\azext_ext_name
Copy link
Member

Choose a reason for hiding this comment

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

Nice comment! It makes the code very easy to understand! 👍

@wangzelin007
Copy link
Member Author

wangzelin007 commented Dec 9, 2022

I think an alternative solution is to use find_namespace_packages to build a namespace package, but this is not an easy job.

This is a very good suggestion, it solves the problem fundamentally, but we need to modify the setup.py files of all extensions

Test screenshot:
image
image

What worries me the most are some of the effects it might have:

  1. With namespace packages, all entries in the path must be scanned before the package is created.
  2. Implicit package directories go against the Zen of Python.
  3. Implicit package directories pose awkward backwards compatibility challenges.

""" Check if the vendored_sdks directory contains __init__.py in all extensions """
ref = []
# SRC_PATH: azure-cli-extensions\src
for src_d in os.listdir(SRC_PATH):
Copy link
Member

Choose a reason for hiding this comment

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

Is it better to only check the extension that the PR is working on?

Copy link
Member Author

Choose a reason for hiding this comment

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

os.walk is very fast, it takes less than six seconds to check all the files, and the incremental check takes more time and effort.

@wangzelin007 wangzelin007 merged commit 0928b47 into Azure:main Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants