Skip to content

chore(ci): use get_package_shards.py in import-profiler for dynamic sharding - #18079

Open
hebaalazzeh wants to merge 6 commits into
mainfrom
fix/import-profiler-dynamic-sharding
Open

chore(ci): use get_package_shards.py in import-profiler for dynamic sharding#18079
hebaalazzeh wants to merge 6 commits into
mainfrom
fix/import-profiler-dynamic-sharding

Conversation

@hebaalazzeh

Copy link
Copy Markdown
Contributor

Summary

Updates the import-profiler workflow to use ci/get_package_shards.py for dynamic sharding matrix generation, bringing it in line with the sharding pattern used in lint.yml and unittest.yml.

Changes

  • initialize Job: Added an initialization job running ci/get_package_shards.py with MAX_SHARDS: 8 to dynamically calculate shard distribution based on modified packages.
  • Dynamic Shards: Replaced static 8-shard matrix ([0..7]) with dynamic shard matrix evaluation. If few or no packages changed, only the necessary number of shards are spawned instead of always spinning up 8 runners.
  • Code Cleanliness: Removed manual git diff parsing and modulo arithmetic from the workflow step, passing PACKAGE_LIST directly to ci/run_conditional_tests.sh.
  • Workflow Status Check: Updated all-import-profiles to depend on [initialize, import-profile] and verify both job outcomes.

Fix module resolution for packages like google-cloud-testutils whose top-level Python package (test_utils) was being filtered out by ignored_prefixes in find_module_from_package.
@hebaalazzeh hebaalazzeh self-assigned this Aug 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the import profiler script to add the absolute path of the package directory to sys.path and bypasses the ignore filter for the google-cloud-testutils package. It also adds a corresponding unit test. The review feedback correctly points out that the new unit test mocks filesystem functions globally instead of locally, violating the repository style guide (Rule 19), and recommends explicitly asserting the expected call sequence of mocked helpers (Rule 20).

Comment thread scripts/import_profiler/test_profiler.py
@hebaalazzeh hebaalazzeh changed the title fix(profiler): use get_package_shards.py for dynamic sharding fix(ci): use get_package_shards.py in import-profiler for dynamic sharding Aug 11, 2026
@hebaalazzeh
hebaalazzeh marked this pull request as ready for review August 11, 2026 21:46
@hebaalazzeh
hebaalazzeh requested a review from a team as a code owner August 11, 2026 21:46
@daniel-sanche daniel-sanche changed the title fix(ci): use get_package_shards.py in import-profiler for dynamic sharding chore(ci): use get_package_shards.py in import-profiler for dynamic sharding Aug 11, 2026
@hebaalazzeh hebaalazzeh added the unit_test:all_packages debug label used to trigger unit tests against all packages in a PR label Aug 11, 2026

@daniel-sanche daniel-sanche left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@hebaalazzeh
hebaalazzeh enabled auto-merge (squash) August 11, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unit_test:all_packages debug label used to trigger unit tests against all packages in a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants