Skip to content

test(backends): unit tests for julia_worker.py - #275

Draft
kvnloo wants to merge 1 commit into
devfrom
chatgpt/n27-z0int-juliaworker
Draft

kvnloo wants to merge 1 commit into
devfrom
chatgpt/n27-z0int-juliaworker

Conversation

@kvnloo

@kvnloo kvnloo commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Issue

Refs #255

Changed files

  • tests/test_julia_worker.py (new): isolated pytest fake packages and subprocess JSONL harness; 11 protocol tests.
  • No production, fixture-directory, configuration, dependency, lockfile, or CI changes.

Acceptance checklist — tests implemented, not executed

  • test_status_before_load — status before load; configured CLI flags, defaults, PID, and unloaded state.
  • test_predict_round_trip — request ID, state/questions passthrough, default loader kwargs, latency/load timings, device.
  • test_warm_then_predict_loads_once — warm/status/predict sequence and one resident model load.
  • test_invalid_json_does_not_kill_worker — malformed JSON error, ignored blank line, continued status response.
  • test_shutdown_stops_processing — early clean exit without extra stdout.
  • test_request_error_is_reported_per_line — missing questions KeyError, bounded traceback, successful following request.
  • test_missing_answers_become_empty_dict — empty model response normalizes to empty answers.
  • test_stdout_carries_only_protocol_lines — parseable JSON on stdout; fake-library chatter on stderr.
  • test_autocast_off_replaces_torch_autocast — off vs auto class names across independent processes.
  • test_warm_on_start_failure_is_recorded — model-load exception saved in status, subsequent predict error, worker survives.
  • test_missing_model_dir_exits_2 — missing required argument and invalid --autocast value exit 2 with usage errors.
  • Tests import only Python stdlib + pytest and never import the worker in-process; fake julia and torch live under tmp_path, injected via subprocess PYTHONPATH.
  • No real Julia, torch, HOME, network, sleeps, or additional dependencies in subprocess environment; 30-second subprocess timeouts.
  • Only the issue-allowed new test file changed.
  • Maintainer/CI to run tests and verify outcomes.

tests NOT RUN - ChatGPT cannot execute code (written via GitHub connector; no pass counts or CI claims).

Exact test commands

pip install -e '.[test]' && python -m pytest -q tests/test_julia_worker.py

Notes

The worker source on dev already matches the specified status, warm, shutdown, predict, and load-error contracts. No production bug fix was justified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:verify Tests, mutation, evidence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant