Skip to content

fix(util-genai): keep multimodal tests Python 3.8-compatible - #253

Merged
sipercai merged 2 commits into
mainfrom
fix/multimodal-retirement-worker-py38-tests
Jul 29, 2026
Merged

fix(util-genai): keep multimodal tests Python 3.8-compatible#253
sipercai merged 2 commits into
mainfrom
fix/multimodal-retirement-worker-py38-tests

Conversation

@sipercai

@sipercai sipercai commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Description

Keep the synchronized multimodal tests runnable for downstream Python 3.8
consumers without changing LoongSuite runtime behavior or its declared
requires-python >=3.9 support floor.

This replaces parenthesized multi-context with statements with nested context
managers and replaces runtime-evaluated built-in generic annotations with
typing.Tuple / typing.Dict in the affected tests. No production source files
are changed.

Fixes # (N/A)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Python 3.8 compileall across util/opentelemetry-util-genai/src and tests
  • Python 3.8 full multimodal test directory: 135 passed, 1 credential-dependent test skipped
  • tox -e py39-test-util-genai: 330 passed, 1 credential-dependent test skipped
  • tox -e py312-test-util-genai: 330 passed, 1 credential-dependent test skipped
  • tox -e lint-util-genai: pylint 10.00/10
  • tox -e typecheck: 0 errors, 0 warnings
  • Fresh-cache tox -e precommit

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Validation Evidence

Spec and Scope

  • Linked issue/spec: N/A
  • Approved scope: retain only downstream Python 3.8 test compatibility; do not change uploader retirement behavior
  • Changed surface: util-genai tests and CHANGELOG-loongsuite.md
  • Runtime source: unchanged from origin/main

Local Checks

Check Command Result Notes
Static readiness python3 "$PIPELINE_SKILL_DIR/scripts/check_loongsuite_pr_readiness.py" --repo . pass Expected warning: no instrumentation plugin directory changed
Precommit PRE_COMMIT_HOME="$(mktemp -d)" tox -e precommit pass Fresh hook cache; clean worktree afterward
Python 3.8 syntax python3.8 -m compileall -q util/opentelemetry-util-genai/src util/opentelemetry-util-genai/tests pass Covers all util-genai source and test files
Python 3.8 focused tests PYTHONPATH="$PWD/util/opentelemetry-util-genai/src" python3.8 -m pytest -q util/opentelemetry-util-genai/tests/_multimodal_upload pass 135 passed, 1 credential-dependent test skipped
Python 3.9 tests tox -e py39-test-util-genai pass 330 passed, 1 credential-dependent test skipped
Python 3.12 tests tox -e py312-test-util-genai pass 330 passed, 1 credential-dependent test skipped
Lint tox -e lint-util-genai pass pylint 10.00/10
Typecheck tox -e typecheck pass 0 errors, 0 warnings
Independent diff review scoped branch review pass Zero actionable findings
Privacy scan branch-diff path, identity, credential, internal-URL, and private-artifact scan pass No matches

Fix Verification

  • On the synchronized baseline, Python 3.8 cannot parse the parenthesized
    multi-context with statements and evaluates tuple[...] / dict[...]
    annotations during test collection.
  • On this branch, Python 3.8 compileall passes and the complete multimodal test
    directory collects and runs successfully.
  • Python 3.9 and Python 3.12 full util-genai suites remain green.

Business Isolation

Scenario Status Evidence
prepare/start fault N/A Test-only syntax and annotation changes
response mapping/stop fault N/A No runtime callback changed
fail callback fault N/A No runtime callback changed
stream chunk/final callback fault N/A No streaming code changed
early close/cancellation/GeneratorExit N/A No generator lifecycle changed
cross-task or cross-Context stream N/A No Context handling changed
clean sibling after fault N/A No runtime state changed

Real E2E Matrix

Scenario Status Command or Demo Evidence
non-streaming N/A Test-only change No model/provider path changed
streaming N/A Test-only change No stream path changed
concurrency N/A Test-only change No runtime concurrency changed
agent/tool/ReAct N/A Test-only change No agent/tool path changed
tool-heavy N/A Test-only change No tool path changed
error path N/A Test-only change No runtime error path changed

Telemetry and Weaver

Check Status Command or Artifact Notes
Span tree / span kinds N/A Test-only change No telemetry output changed
Content capture modes N/A Test-only change No content-capture behavior changed
Concurrency isolation N/A Test-only change No trace or Context state changed
Weaver live-check N/A Test-only change No Weaver-checkable telemetry delta

CI

  • Current published head: LoongSuite package tests, util-genai lint, precommit,
    changelog, and license checks passed.
  • Superseded failure: typecheck failed on the retirement-worker implementation
    that this update removes; local typecheck passes on the narrowed head.
  • Follow-up needed: rerun GitHub checks after pushing this update, then
    synchronize the compatibility commit into the downstream Python 3.8 branch.

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

Replaces per-pair daemon thread creation with a single lazily-started FIFO retirement worker for multimodal uploader cleanup. This prevents unbounded thread growth during rapid runtime configuration changes. Also fixes Python 3.8 test compatibility by replacing parenthesized context managers and lowercase generic types with their typing module equivalents.

Overall: LGTM. The approach is clean, the double-check locking pattern is correct, fork safety is well-handled, and the regression tests comprehensively cover the new behavior (single-worker reuse, FIFO ordering, fail-open on shutdown failure, fork reset, atexit sentinel).

Findings

  • [Info] multimodal_upload_hook.py:51-54 — The globals().get("_retired_pair_at_fork_registered", False) pattern is slightly unusual for a module-level guard. A plain _retired_pair_at_fork_registered = False at module level would be equivalent and more readable. The current form works correctly but may confuse readers into thinking there is a circular dependency being avoided. Non-blocking.
  • [Info] multimodal_upload_hook.py:155-160_reset_retired_pair_worker_after_fork intentionally does not reset _retired_pair_at_fork_registered, which is correct since os.register_at_fork handlers are inherited by the child process. A brief inline comment explaining this design choice would help future maintainers.

Suggestions

  • Consider adding a one-line comment above the _retired_pair_at_fork_registered module variable explaining that it survives fork resets because the register_at_fork handler is inherited by child processes.

Automated review by github-manager-bot

@sipercai sipercai changed the title fix(util-genai): serialize retired uploader cleanup fix(util-genai): keep multimodal tests Python 3.8-compatible Jul 28, 2026

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

LGTM — This PR correctly fixes Python 3.8 compatibility issues in the multimodal test files by replacing Python 3.9+ type hints (tuple[str, int]Tuple[str, int]) and Python 3.10+ parenthesized context managers with nested with statements.

The changes are minimal, focused, and do not affect production code. They ensure downstream consumers on Python 3.8 can run the tests without issues.


Automated review by github-manager-bot

@ralf0131 ralf0131 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Clean mechanical fix — replaces Python 3.9+ built-in generics (tuple[], dict[]) with typing.Tuple/typing.Dict and parenthesized multi-context with with nested context managers in test files only. No production code changes.


Automated review by github-manager-bot

@sipercai
sipercai merged commit 6df095f into main Jul 29, 2026
211 checks passed
@sipercai
sipercai deleted the fix/multimodal-retirement-worker-py38-tests branch July 29, 2026 01:38
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.

3 participants