Skip to content

refactor: split large test and source files into focused modules#5299

Open
skamenan7 wants to merge 4 commits intollamastack:mainfrom
skamenan7:feat/bug-bash-2
Open

refactor: split large test and source files into focused modules#5299
skamenan7 wants to merge 4 commits intollamastack:mainfrom
skamenan7:feat/bug-bash-2

Conversation

@skamenan7
Copy link
Copy Markdown
Contributor

@skamenan7 skamenan7 commented Mar 25, 2026

What does this PR do?

Splits 3 Python files that exceeded 1000 lines into smaller, focused modules. Pure refactoring with no behavior changes. All public names remain importable from the same paths.

Original file Lines Split into
tests/unit/providers/utils/inference/test_openai_mixin.py 1438 4 files by concern
tests/unit/providers/responses/builtin/test_openai_responses.py 3226 7 files by feature group
src/llama_stack/providers/inline/scoring/basic/utils/ifeval_utils.py 3319 5 files by responsibility

test_openai_mixin.py — split by test concern:

  • openai_mixin_helpers.py — shared impl classes (180L)
  • conftest.py — shared fixtures, auto-discovered by pytest (16L)
  • test_openai_mixin_models.py — model listing, registration, availability (580L)
  • test_openai_mixin_provider_data.py — provider data API key, custom model lists (200L)
  • test_openai_mixin_inference.py — inference enforcement, stream options, param passthrough (520L)

test_openai_responses.py — split by feature group:

  • conftest.py — 11 shared fixtures (116L)
  • test_openai_responses_helpers.py — shared async generator (47L)
  • test_openai_responses_core.py — core response creation, instructions, store logic (857L)
  • test_openai_responses_agent.py — failed streams, agent loop, incomplete details (500L)
  • test_openai_responses_tools.py — tool calls, MCP, file search, strict field (670L)
  • test_openai_responses_prompts.py — prompt template variants (579L)
  • test_openai_responses_params.py — param passthrough, service tier, stream options (856L)

ifeval_utils.py — split by responsibility:

  • ifeval_word_list.pyWORD_LIST data literal only, grandfathered as pure data (1552L)
  • ifeval_support.py — language constants, regex patterns, utility functions (296L)
  • ifeval_checkers_core.pyInstruction base class + 15 checker classes (828L)
  • ifeval_checkers_format.py — 15 checker classes (703L)
  • ifeval_utils.py — thin entry point: re-exports INSTRUCTION_DICT and INSTRUCTION_LIST (96L)

The external import in ifeval_scoring_fn.py is unchanged. Shared fixtures previously loaded via a root conftest.py plugin import are now in a directory-level conftest.py and auto-discovered by pytest.

Test Plan

uv run pytest tests/unit/providers/utils/inference/test_openai_mixin_models.py \
  tests/unit/providers/utils/inference/test_openai_mixin_provider_data.py \
  tests/unit/providers/utils/inference/test_openai_mixin_inference.py -v


uv run pytest tests/unit/providers/responses/builtin/ -v


uv run pre-commit run --all-files

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 25, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 26, 2026

This pull request has merge conflicts that must be resolved before it can be merged. @skamenan7 please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 26, 2026
@skamenan7 skamenan7 force-pushed the feat/bug-bash-2 branch 2 times, most recently from 4baf184 to dbba243 Compare March 26, 2026 10:58
@mergify mergify bot removed the needs-rebase label Mar 26, 2026
@skamenan7 skamenan7 marked this pull request as ready for review March 26, 2026 11:24
@skamenan7
Copy link
Copy Markdown
Contributor Author

Hi @leseb , thanks for the PR# 5281 review and merge. this one follows that one for more changes. PTAL.

@skamenan7 skamenan7 force-pushed the feat/bug-bash-2 branch 2 times, most recently from 8806bdf to 01c9ea8 Compare March 26, 2026 12:46
@skamenan7 skamenan7 force-pushed the feat/bug-bash-2 branch 7 times, most recently from b229b9d to 2d415d6 Compare March 26, 2026 15:16
@skamenan7 skamenan7 requested a review from leseb March 26, 2026 15:49
@skamenan7 skamenan7 force-pushed the feat/bug-bash-2 branch 3 times, most recently from 9bd0f3a to 4de2882 Compare March 26, 2026 17:46
@skamenan7 skamenan7 force-pushed the feat/bug-bash-2 branch 2 times, most recently from 5682761 to bad3eed Compare March 26, 2026 19:48
Split 1438-line test_openai_mixin.py into:
- openai_mixin_helpers.py: shared impl classes
- conftest.py: shared fixtures (auto-discovered by pytest)
- test_openai_mixin_models.py: model lifecycle tests (580L)
- test_openai_mixin_provider_data.py: provider data and custom list tests (200L)
- test_openai_mixin_inference.py: inference enforcement and stream options tests (520L)

Removes test_openai_mixin.py from GRANDFATHERED_FILES in check_file_size.py.

Signed-off-by: skamenan7 <skamenan@redhat.com>
… group

Split 3226-line test_openai_responses.py into:
- conftest.py: shared fixtures (116L, auto-discovered)
- test_openai_responses_helpers.py: fake_stream generator (47L)
- test_openai_responses_core.py: core creation, instructions, store logic (857L)
- test_openai_responses_agent.py: failed streams, agent loop incomplete (500L)
- test_openai_responses_tools.py: tool calls, MCP, file search (670L)
- test_openai_responses_prompts.py: prompt template variants (579L)
- test_openai_responses_params.py: param passthrough, service_tier, stream_options (856L)

Removes test_openai_responses.py from GRANDFATHERED_FILES in check_file_size.py.
103 tests pass across all new files.

Signed-off-by: skamenan7 <skamenan@redhat.com>
Split 3319-line ifeval_utils.py into:
- ifeval_word_list.py: WORD_LIST data literal only (1552L, grandfathered as pure data)
- ifeval_support.py: LANGUAGE_CODES, regex constants, utility functions, arg constants (296L)
- ifeval_checkers_core.py: Instruction base + 15 checker classes (828L)
- ifeval_checkers_format.py: 15 checker classes (703L)
- ifeval_utils.py: thin entry point with INSTRUCTION_DICT/LIST registry (96L)

Updates pyproject.toml per-file-ignores to point RUF001 suppression at the new
files containing Unicode characters instead of the now-thin ifeval_utils.py.
External import path preserved: ifeval_scoring_fn.py unchanged.
Also removes stale plugin import of deleted test_openai_responses from root conftest.py.

Signed-off-by: skamenan7 <skamenan@redhat.com>
…ort.py

Upstream PR llamastack#5267 added a docstring to get_langid() in ifeval_utils.py.
Since that function now lives in ifeval_support.py after the split, carry
the docstring over to the correct location.

Signed-off-by: skamenan7 <skamenan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants