Skip to content

Refactor: move model provisioning policies to streamwise/model_provisioner/#312

Open
James-QiuHaoran wants to merge 3 commits into
mainfrom
hqiu/refactor-model-provisioner
Open

Refactor: move model provisioning policies to streamwise/model_provisioner/#312
James-QiuHaoran wants to merge 3 commits into
mainfrom
hqiu/refactor-model-provisioner

Conversation

@James-QiuHaoran
Copy link
Copy Markdown
Collaborator

Move the 6 policy/allocator files (greedy, milp, naive_baseline, hexgen, helix, policies) from simulator/ into streamwise/model_provisioner/ so they can be reused by both the simulator evaluation framework and the StreamWise serving system.

Changes

  • Create streamwise/model_provisioner/ package with __init__.py that adds simulator/ to sys.path for foundation module access
  • Create simulator/__init__.py that adds streamwise/ to sys.path so model_provisioner is importable from simulator code
  • Update all imports across simulator files and 20 test files
  • Switch data_loading.py to use Path instead of str for data_dir params (accepts both str | Path)
  • Fix mypy issue in wrapper/run_httpserver.py (bytearray assignment)
  • Add .venv to .flake8 exclude and .gitignore

Testing

  • 453 simulator tests pass (30 pre-existing ProcessPoolExecutor failures unchanged from main)
  • flake8 clean
  • mypy: 115 errors (all pre-existing unused-ignore in wrapper/ files; main has 116)

…ioner/

Move the 6 policy/allocator files (greedy, milp, naive_baseline, hexgen,
helix, policies) from simulator/ into streamwise/model_provisioner/ so
they can be reused by both the simulator evaluation framework and the
StreamWise serving system.

- Create streamwise/model_provisioner/ package with __init__.py that
  adds simulator/ to sys.path for foundation module access
- Create simulator/__init__.py that adds streamwise/ to sys.path so
  model_provisioner is importable from simulator code
- Update all imports across simulator files and 20 test files
- Switch data_loading.py to use Path instead of str for data_dir params
- Fix mypy issue in wrapper/run_httpserver.py (bytearray assignment)
- Add .venv to .flake8 exclude and .gitignore

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 16, 2026

Test Results

1 145 tests  +1   1 145 ✅ +1   14m 54s ⏱️ ±0s
   13 suites ±0       0 💤 ±0 
   13 files   ±0       0 ❌ ±0 

Results for commit 28e322e. ± Comparison against base commit c20eb25.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@kdh0102 kdh0102 left a comment

Choose a reason for hiding this comment

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

Overall, looks good to me.
I still encounter some path issues in the jupyter notebooks, and I handled the cases by adding another block:

import pathlib
import sys

streamwise_path = pathlib.Path().resolve().parent / "streamwise"
if str(streamwise_path) not in sys.path:
    sys.path.insert(0, str(streamwise_path))

If you don't think this fix needs to be handled in this PR, it looks good for me to merge.

Support both local dev (../../simulator) and Docker (../simulator) paths
when resolving the simulator directory for foundation module imports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the 6 model provisioning policy/allocator files (policies, greedy, milp, naive_baseline, hexgen, helix) out of simulator/ and into a new streamwise/model_provisioner/ package so the same code can be reused by both the simulator evaluation framework and the StreamWise serving system. Cross-package imports are enabled via sys.path injection in two new __init__.py files. Tests are updated to extend temp_sys_path and use the new dotted module paths.

Changes:

  • Create streamwise/model_provisioner/ package containing the moved allocator/policy modules with intra-package relative imports.
  • Add simulator/__init__.py and streamwise/model_provisioner/__init__.py that mutate sys.path to bridge the two packages.
  • Update all simulator-source and ~20 test-file imports; switch data_loading.py defaults to a Path-resolved absolute data dir; small mypy fix in wrapper/run_httpserver.py; ignore .venv in .flake8/.gitignore.

Reviewed changes

Copilot reviewed 35 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
streamwise/model_provisioner/init.py New package init; injects simulator/ into sys.path to satisfy foundation imports.
streamwise/model_provisioner/policies.py Moved policy definitions; uses absolute imports from simulator/.
streamwise/model_provisioner/greedy.py Moved; switched to relative imports for sibling policies module.
streamwise/model_provisioner/milp.py Moved; relative import of .policies.
streamwise/model_provisioner/naive_baseline.py Moved; relative imports of .policies.
streamwise/model_provisioner/hexgen.py Moved; relative imports of .greedy/.policies.
streamwise/model_provisioner/helix.py Moved; relative imports of .milp/.policies.
simulator/init.py New package init; injects streamwise/ into sys.path.
simulator/auto_model_allocator.py Update lazy imports to model_provisioner.*.
simulator/actions.py, multirequests.py, provisioning.py, model_allocator.py Update policy imports to model_provisioner.policies.
simulator/data_loading.py Default data_dir switched to absolute Path of simulator/data/; accepts str | Path.
wrapper/run_httpserver.py Rename payload_bytes rebinding to payload_buffer to satisfy mypy.
tests/simulator/test_*.py (16 files) Add "streamwise" to temp_sys_path and update imports to model_provisioner.*.
.flake8, .gitignore Exclude .venv.

Comment thread simulator/__init__.py
Comment on lines +11 to +15
_STREAMWISE_DIR = os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "streamwise")
)
if _STREAMWISE_DIR not in sys.path:
sys.path.insert(0, _STREAMWISE_DIR)
Comment on lines +10 to +20
# Add simulator/ to sys.path so policy files can import foundation modules.
# Supports both local dev layout (../../simulator) and Docker layout (../simulator).
_HERE = os.path.dirname(os.path.abspath(__file__))
_CANDIDATES = [
os.path.normpath(os.path.join(_HERE, "..", "..", "simulator")),
os.path.normpath(os.path.join(_HERE, "..", "simulator")),
]
for _path in _CANDIDATES:
if os.path.isdir(_path) and _path not in sys.path:
sys.path.insert(0, _path)
break
Comment thread simulator/data_loading.py Outdated
Agent-Logs-Url: https://github.com/Azure/realtimevideogen/sessions/d53596b3-c563-4deb-af27-7226e9dac364

Co-authored-by: James-QiuHaoran <22564180+James-QiuHaoran@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented May 17, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /home/REDACTED/.local/bin/pytest pytest --ignore=tests/simulator --ignore=tests/streamwise --ignore=tests/streamwise_app -vv (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions
Copy link
Copy Markdown

Lint Results

Check Status
Python
Shell
YAML
JSON
Markdown
Bicep

@github-actions
Copy link
Copy Markdown

Mypy Type Checking

✅ No issues found

Metric Count
📂 Files 296
❌ Errors 0
⚠️ Warnings 0
📝 Notes 0
Full mypy output
Success: no issues found in 296 source files

@github-actions
Copy link
Copy Markdown

Diff Coverage

Diff: origin/main...HEAD, staged and unstaged changes

  • simulator/init.py (0.0%): Missing lines 7-8,11,14-15
  • simulator/actions.py (100%)
  • simulator/auto_model_allocator.py (100%)
  • simulator/data_loading.py (100%)
  • simulator/model_allocator.py (100%)
  • simulator/multirequests.py (100%)
  • simulator/provisioning.py (100%)
  • streamwise/model_provisioner/init.py (100%)
  • streamwise/model_provisioner/greedy.py (100%)
  • streamwise/model_provisioner/helix.py (100%)
  • streamwise/model_provisioner/hexgen.py (100%)
  • streamwise/model_provisioner/milp.py (100%)
  • streamwise/model_provisioner/naive_baseline.py (100%)
  • tests/simulator/test_auto_model_allocator.py (100%)
  • tests/simulator/test_data_loading.py (100%)
  • tests/simulator/test_evaluator.py (100%)
  • tests/simulator/test_greedy.py (100%)
  • tests/simulator/test_helix.py (100%)
  • tests/simulator/test_hexgen.py (100%)
  • tests/simulator/test_milp.py (100%)
  • tests/simulator/test_models.py (100%)
  • tests/simulator/test_multirequests_derive.py (100%)
  • tests/simulator/test_simulator.py (100%)
  • tests/simulator/test_simulator_actions.py (100%)
  • tests/simulator/test_simulator_baseline.py (100%)
  • tests/simulator/test_simulator_energy.py (100%)
  • tests/simulator/test_simulator_multirequests.py (100%)
  • tests/simulator/test_simulator_plotutils.py (100%)
  • tests/simulator/test_simulator_policies.py (100%)
  • tests/simulator/test_simulator_provisioning.py (100%)
  • tests/simulator/test_simulator_types.py (100%)
  • tests/simulator/test_simulator_utils.py (100%)
  • tests/simulator/test_workflows.py (100%)
  • wrapper/run_httpserver.py (0.0%): Missing lines 1269-1270

Summary

  • Total: 105 lines
  • Missing: 7 lines
  • Coverage: 93%

simulator/init.py

Lines 3-16

   3 on top of the model_provisioner allocation policies.
   4 
   5 The allocation policy implementations live in ``streamwise/model_provisioner/``.
   6 """
!  7 import os
!  8 import sys
   9 
  10 # Make model_provisioner importable for simulator modules.
! 11 _STREAMWISE_DIR = os.path.normpath(
  12     os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "streamwise")
  13 )
! 14 if _STREAMWISE_DIR not in sys.path:
! 15     sys.path.insert(0, _STREAMWISE_DIR)

wrapper/run_httpserver.py

Lines 1265-1274

  1265     last_ping_time = time.time()
  1266 
  1267     try:
  1268         payload_bytes = await asyncio.to_thread(pickle.dumps, gen_task)
! 1269         payload_buffer = bytearray(payload_bytes)
! 1270         payload_tensor = torch.frombuffer(payload_buffer, dtype=torch.uint8).to("cuda")
  1271         payload_size = torch.tensor([payload_tensor.numel()], dtype=torch.int64, device="cuda")
  1272 
  1273         if payload_size.item() > MAX_PAYLOAD_BYTES:
  1274             logging.error(f"[{rank}] Payload too large: {payload_size.item()} bytes.")

@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Complexity Health
. 80% 0
apps 67% 0
apps.streamanimate 89% 0
apps.streamcast 91% 0
apps.streamchat 87% 0
apps.streamdub 64% 0
apps.streamedit 79% 0
apps.streamlecture 94% 0
apps.streammovie 89% 0
apps.streampersona 64% 0
apps.streamshort 71% 0
simulator 90% 0
streamwise 68% 0
streamwise.model_provisioner 83% 0
tests 99% 0
tests.simulator 100% 0
tests.streamwise 100% 0
tests.streamwise_app 99% 0
wrapper 67% 0
wrapper.4kagent 94% 0
wrapper.bagel 37% 0
wrapper.cogview 45% 0
wrapper.fantasytalking 55% 0
wrapper.flux 74% 0
wrapper.flux2 100% 0
wrapper.flux2klein 99% 0
wrapper.fluxkontext 100% 0
wrapper.fluxkrea 99% 0
wrapper.fluxupscaler 68% 0
wrapper.hidream 88% 0
wrapper.hunyuanavatar 74% 0
wrapper.hunyuanframepack 52% 0
wrapper.hunyuanframepackf1 59% 0
wrapper.hunyuanframepackvae 63% 0
wrapper.hunyuanimage 84% 0
wrapper.imageresize 100% 0
wrapper.januspro 91% 0
wrapper.kokoro 87% 0
wrapper.llamagen 65% 0
wrapper.mock 86% 0
wrapper.podcasttranscript 45% 0
wrapper.qwenimage 89% 0
wrapper.qwenimageedit 88% 0
wrapper.realesrgan 77% 0
wrapper.slidetranscript 59% 0
wrapper.vibevoice 31% 0
wrapper.vibevoice.schedule 50% 0
wrapper.wan 34% 0
wrapper.wan22 75% 0
wrapper.xtts 75% 0
wrapper.yolo 69% 0
Summary 78% (26766 / 34151) 0

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.

4 participants