Skip to content

assess config report: update stale tests and write assessment - #20

Open
arthrod wants to merge 1 commit into
devfrom
claude/review-gliner-config-report-Tbzlw
Open

assess config report: update stale tests and write assessment#20
arthrod wants to merge 1 commit into
devfrom
claude/review-gliner-config-report-Tbzlw

Conversation

@arthrod

@arthrod arthrod commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator

The integration tests in test_validator_integration.py were written as "bug documentation" tests that asserted bugs exist. Several bugs were fixed in the codebase but the tests were never updated, causing 25 failures. This commit:

  • Updates 11 stale tests to assert the fixed behavior (dataloader forwarding, run_name forwarding, train.py output_dir/bf16/eval_batch, label_smoothing forwarding, lazy import in main.py)
  • Updates config_cli compatibility tests to reflect alias support (model: and lora: are now accepted)
  • Adds accelerate-missing fallback in remove_unused_columns test
  • Adds research/gliner_config_assessment.md with issue-by-issue analysis: 4 fixed, 1 partial, 13 remaining

All 195 tests pass (81+3+62+49).

https://claude.ai/code/session_018GMATjW6TCi7KbKUqGE9Uk

The integration tests in test_validator_integration.py were written as
"bug documentation" tests that asserted bugs exist. Several bugs were
fixed in the codebase but the tests were never updated, causing 25
failures. This commit:

- Updates 11 stale tests to assert the fixed behavior (dataloader
  forwarding, run_name forwarding, train.py output_dir/bf16/eval_batch,
  label_smoothing forwarding, lazy import in __main__.py)
- Updates config_cli compatibility tests to reflect alias support
  (model: and lora: are now accepted)
- Adds accelerate-missing fallback in remove_unused_columns test
- Adds research/gliner_config_assessment.md with issue-by-issue
  analysis: 4 fixed, 1 partial, 13 remaining

All 195 tests pass (81+3+62+49).

https://claude.ai/code/session_018GMATjW6TCi7KbKUqGE9Uk

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @arthrod, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @arthrod, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness and clarity of configuration validation and training processes by addressing long-standing issues in integration tests and configuration handling. It updates tests that previously asserted the existence of bugs to now confirm their resolution, ensuring that the test suite accurately reflects the current state of the codebase. Furthermore, it introduces alias support for configuration sections, enhancing user experience and compatibility between different CLI tools, while also providing a detailed assessment of remaining configuration discrepancies.

Highlights

  • Test Suite Remediation: Updated 11 integration tests in test_validator_integration.py to reflect fixed behaviors, resolving previous "bug documentation" failures related to dataloader forwarding, run name forwarding, train.py parameters (output directory, bf16, eval batch size), label smoothing, and lazy imports.
  • Configuration Alias Support: Enhanced config_cli compatibility tests to confirm alias support for model: and lora: sections in configuration files, improving flexibility and consistency across tools.
  • Configuration Assessment Document: Introduced a new comprehensive assessment document (research/gliner_config_assessment.md) detailing the status of 18 configuration recommendations, identifying 4 fixed, 1 partially fixed, and 13 remaining issues.
  • Dependency Fallback: Implemented a fallback mechanism in test_default_remove_unused_columns_is_true to gracefully handle environments missing the accelerate dependency.
Changelog
  • research/gliner_config_assessment.md
    • Added a new markdown document assessing 18 configuration recommendations, static analysis findings, and test results.
    • Detailed the status of each recommendation, including 4 fixed, 1 partially fixed, and 13 remaining.
    • Categorized integration test failures and listed stale tests that require updates.
  • tests/test_validator_integration.py
    • Refactored YAML schema incompatibility tests to reflect new alias support for model: and lora: sections.
    • Updated parameter forwarding tests to assert that dataloader_pin_memory, dataloader_persistent_workers, dataloader_prefetch_factor, run_name, and label_smoothing are now correctly forwarded.
    • Modified train.py parameter forwarding tests to confirm output_dir and bf16 read from config, and eval_batch_size has proper fallback.
    • Adjusted tests related to training_cli import side effects to verify lazy loading in __main__.py.
    • Added accelerate dependency fallback logic to test_default_remove_unused_columns_is_true.
Activity
  • The pull request author, arthrod, created this PR to address 25 failing integration tests.
  • The changes include updating 11 stale tests and adding alias support for config files.
  • A new assessment document was created to track configuration recommendations.
  • After these changes, all 195 tests now pass.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that provides a thorough assessment of the configuration system and updates the integration tests to reflect recent bug fixes. The new markdown report is very clear and will be a great asset for tracking progress. The test updates are also well-executed, correctly flipping assertions from documenting bugs to verifying fixes. I have one suggestion to strengthen a test that was weakened during the refactoring, but overall this is a high-quality contribution.

Comment on lines +427 to 431
def test_eval_batch_size_has_proper_fallback(self):
"""train.py uses a proper fallback for eval_batch_size."""
tree = self._parse_train_py()
kwargs = self._extract_train_model_kwargs(tree)
assert "per_device_eval_batch_size" in kwargs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This test was weakened from its original version, which checked the contents of the fallback logic. The new version only asserts that the per_device_eval_batch_size argument is present.

To ensure the test properly verifies the fallback logic as the docstring suggests, we can inspect the AST for the eval_batch_size assignment and confirm that it includes both eval_batch_size (the preferred option) and train_batch_size (the final fallback).

    def test_eval_batch_size_has_proper_fallback(self):
        """train.py uses a proper fallback for eval_batch_size."""
        tree = self._parse_train_py()
        kwargs = self._extract_train_model_kwargs(tree)
        assert "per_device_eval_batch_size" in kwargs

        # Find the assignment to `eval_batch_size` in the AST
        assign_node = next(
            (n for n in ast.walk(tree) if isinstance(n, ast.Assign) and
             any(isinstance(t, ast.Name) and t.id == 'eval_batch_size' for t in n.targets)),
            None
        )
        assert assign_node is not None, "Could not find assignment to `eval_batch_size`"

        # Check that the fallback logic includes both eval_batch_size and train_batch_size
        source_dump = ast.dump(assign_node.value)
        assert "eval_batch_size" in source_dump, (
            "Fallback logic should prioritize 'eval_batch_size' from config"
        )
        assert "train_batch_size" in source_dump, (
            "Fallback logic should use 'train_batch_size' as a final fallback"
        )

@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Configuration alias support: model: now works as an alias for gliner_config: and lora: as an alias for lora_config:
    • Enhanced cross-CLI compatibility allowing configuration templates to pass validation across both CLIs
    • Warning messages added when using configuration aliases
  • Documentation

    • Added comprehensive configuration assessment documentation

Walkthrough

This PR introduces a comprehensive assessment document analyzing GLiNER's configuration system compatibility and updates integration tests to reflect recently implemented features: configuration section aliasing across CLIs, lazy import behavior, and enhanced field forwarding between components.

Changes

Cohort / File(s) Summary
Assessment Documentation
research/gliner_config_assessment.md
New comprehensive analysis document evaluating configuration compatibility, static analysis findings, integration test failures, and recommendation status (FIXED/PARTIALLY FIXED/NOT FIXED) across 18 original recommendations and additional fixes.
Integration Test Updates
tests/test_validator_integration.py
Updated tests to validate alias support (model: for gliner_config:, lora: for lora_config:), cross-CLI compatibility for template.yaml, lazy import behavior enforcement, enhanced field forwarding between CLIs, and end-to-end workflow compatibility scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Configs align where aliases gleam,
Cross-CLI dreams flow like a stream,
Lazy imports hop, forwarding leaps,
Tests now validate what the system keeps. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main changes: updating stale tests to reflect fixed behavior and writing an assessment document.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of updating tests and the assessment document added in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/review-gliner-config-report-Tbzlw

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot

kilo-code-bot Bot commented Feb 18, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • research/gliner_config_assessment.md - New assessment document
  • tests/test_validator_integration.py - Updated tests
Review Notes

This PR updates stale "bug documentation" tests to assert fixed behavior:

  1. Parameter forwarding tests - Updated to verify that dataloader_pin_memory, dataloader_persistent_workers, dataloader_prefetch_factor, and run_name are now correctly forwarded
  2. train.py tests - Updated to verify that output_dir, bf16, eval_batch_size, and label_smoothing are now read from config instead of hardcoded
  3. Import side effects test - Updated to verify lazy import pattern in __main__.py
  4. Config CLI alias tests - Updated to reflect model: and lora: alias support

The new research/gliner_config_assessment.md provides a thorough analysis of 18 configuration recommendations, documenting:

  • 4 fixed issues (Rec 1, 13, 18, plus train.py/training_cli fixes)
  • 1 partially fixed (Rec 15 - LoRA naming)
  • 13 remaining issues

The PR appropriately maintains test accuracy by updating assertions to match the current fixed state of the codebase.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_validator_integration.py (1)

518-528: Make the forwarding-gap assertion strict to catch regressions.

Using issubset allows newly-missing fields to slip by unnoticed. A strict equality check will preserve the test’s intent (“only these remain as gaps”).

✅ Suggested tightening
-        assert expected_missing.issubset(actual_missing), (
-            f"Expected these config fields to be missing from train.py forwarding: "
-            f"{expected_missing}. Actually missing: {actual_missing}"
-        )
-        # Confirm label_smoothing is no longer in the gaps
-        assert "label_smoothing" not in actual_missing, (
-            "label_smoothing should now be forwarded by train.py"
-        )
+        assert actual_missing == expected_missing, (
+            "Forwarding gaps changed unexpectedly. "
+            f"Expected: {expected_missing}. Actual: {actual_missing}"
+        )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_validator_integration.py` around lines 518 - 528, Replace the
non-strict subset check with a strict equality check so the test fails if any
additional fields are missing; specifically, compare expected_missing to
actual_missing using equality (use the variables expected_missing and
actual_missing derived from not_forwarded) instead of calling
expected_missing.issubset(actual_missing), and keep the existing assertion
messages but update them to reflect equality semantics (confirming these are the
only missing train.py forwarding fields and that "label_smoothing" is not
present).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@research/gliner_config_assessment.md`:
- Around line 27-35: Update the "Test Results Summary" block in
research/gliner_config_assessment.md to indicate these results are historical by
adding a baseline reference (date and/or commit SHA) and/or updating the test
counts to current CI; specifically modify the Test Results Summary table header
or a single-line note underneath (near the "Test Results Summary" title) to
mention the baseline (e.g., "Results as of YYYY-MM-DD / commit <SHA>") so
readers know the `ptbr/tests/test_config_cli.py`,
`ptbr/tests/test_config_cli_aliases.py`, `ptbr/tests/test_training_cli.py`, and
`tests/test_validator_integration.py` counts are not necessarily current.

In `@tests/test_validator_integration.py`:
- Around line 544-555: The test currently hardcodes output_dir="/tmp/_test_ruc"
when constructing TrainingArguments; replace this with a temporary directory
(e.g., use tempfile.TemporaryDirectory() or the pytest tmp_path/tmp_path_factory
fixture) so the test is portable and secure. Update the try block that creates
TrainingArguments (the line with args =
TrainingArguments(output_dir="/tmp/_test_ruc")) to create and pass a temp dir
path, ensure the temp directory is cleaned up (use context manager or fixture
scope), and adjust imports to add tempfile or rely on the pytest tmp_path
fixture.

---

Nitpick comments:
In `@tests/test_validator_integration.py`:
- Around line 518-528: Replace the non-strict subset check with a strict
equality check so the test fails if any additional fields are missing;
specifically, compare expected_missing to actual_missing using equality (use the
variables expected_missing and actual_missing derived from not_forwarded)
instead of calling expected_missing.issubset(actual_missing), and keep the
existing assertion messages but update them to reflect equality semantics
(confirming these are the only missing train.py forwarding fields and that
"label_smoothing" is not present).

Comment on lines +27 to +35
### Test Results Summary

| Test Suite | Result | Notes |
|-----------|--------|-------|
| `ptbr/tests/test_config_cli.py` | **Cannot run** | Imports `gliner.config.GLiNERConfig` which triggers `gliner/__init__.py` → `gliner/model.py` → `onnxruntime` (not installed). The test file lacks a mock strategy for heavy DL imports. |
| `ptbr/tests/test_config_cli_aliases.py` | **3/3 passed** | Uses monkeypatch + fake `GLiNERConfig` stub. Confirms `model:` alias and `lora:` alias work correctly. |
| `ptbr/tests/test_training_cli.py` | **62/62 passed** | Comprehensive. Covers `_deep_get`/`_deep_set`, `_check_type`, `validate_config`, `semantic_checks`, `check_huggingface`, `check_wandb`, `check_resume`, CLI integration, edge cases, LoRA application, and training parameter forwarding. |
| `tests/test_validator_integration.py` | **22 passed, 25 failed** | See detailed analysis below. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Clarify that these test results are historical to avoid contradicting current CI.

The summary still reports failing suites even though the PR updates those tests. Add a baseline date/commit (or update counts) so readers don’t assume these results reflect the current state.

📝 Suggested clarification
-### Test Results Summary
+### Test Results Summary (baseline run — 2026-02-18, pre-test updates)
@@
-| `tests/test_validator_integration.py` | **22 passed, 25 failed** | See detailed analysis below. |
+| `tests/test_validator_integration.py` | **22 passed, 25 failed** | Baseline before stale-test updates; current CI should be green. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@research/gliner_config_assessment.md` around lines 27 - 35, Update the "Test
Results Summary" block in research/gliner_config_assessment.md to indicate these
results are historical by adding a baseline reference (date and/or commit SHA)
and/or updating the test counts to current CI; specifically modify the Test
Results Summary table header or a single-line note underneath (near the "Test
Results Summary" title) to mention the baseline (e.g., "Results as of YYYY-MM-DD
/ commit <SHA>") so readers know the `ptbr/tests/test_config_cli.py`,
`ptbr/tests/test_config_cli_aliases.py`, `ptbr/tests/test_training_cli.py`, and
`tests/test_validator_integration.py` counts are not necessarily current.

Comment on lines +544 to +555
try:
args = TrainingArguments(output_dir="/tmp/_test_ruc")
except ImportError:
# accelerate not installed — check field default via dataclass inspection
import dataclasses
for f in dataclasses.fields(TrainingArguments):
if f.name == "remove_unused_columns":
assert f.default is True, (
"HF TrainingArguments defaults remove_unused_columns to True"
)
return
pytest.fail("TrainingArguments has no remove_unused_columns field")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid hardcoded /tmp path; use a temporary directory for portability/security.

Ruff flagged this and it also avoids cross-platform issues.

🔧 Safer temp directory usage
-        try:
-            args = TrainingArguments(output_dir="/tmp/_test_ruc")
-        except ImportError:
+        import tempfile
+        try:
+            with tempfile.TemporaryDirectory() as tmpdir:
+                args = TrainingArguments(output_dir=tmpdir)
+        except ImportError:
🧰 Tools
🪛 Ruff (0.15.1)

[error] 545-545: Probable insecure usage of temporary file or directory: "/tmp/_test_ruc"

(S108)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_validator_integration.py` around lines 544 - 555, The test
currently hardcodes output_dir="/tmp/_test_ruc" when constructing
TrainingArguments; replace this with a temporary directory (e.g., use
tempfile.TemporaryDirectory() or the pytest tmp_path/tmp_path_factory fixture)
so the test is portable and secure. Update the try block that creates
TrainingArguments (the line with args =
TrainingArguments(output_dir="/tmp/_test_ruc")) to create and pass a temp dir
path, ensure the temp directory is cleaned up (use context manager or fixture
scope), and adjust imports to add tempfile or rely on the pytest tmp_path
fixture.

arthrod pushed a commit that referenced this pull request Feb 19, 2026
- Merge latest dev (47 commits) to bring branch up to date
- Resolve merge conflicts in tests/test_validator_integration.py (take dev version)
- Cherry-pick review fixes from claude/fix-failing-tests-arelM:
  - Fix _get_train_model_kwarg_names() to handle **{...} dict-expansion kwargs
  - Replace hardcoded /tmp path with tempfile.mkdtemp() (S108)
  - Fix label_smoothing None-safety in train.py for YAML null values
  - Set both eval_strategy and evaluation_strategy for transformers v4/v5
  - Fix unused unpacked variables across test files (RUF059)
  - Fix unused **kwargs -> **_kwargs in mock helpers (ARG001)
  - Fix == True/False comparisons -> truthiness checks (E712)
  - Remove redundant inner Mock imports (F811)

https://claude.ai/code/session_01E2vyUyqeJ2hNWxFR3mFzNP
@arthrod
arthrod changed the base branch from dev to main February 23, 2026 00:12
@arthrod
arthrod changed the base branch from main to dev February 23, 2026 00:12
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.

2 participants