Skip to content

Refactor import boundaries and API signatures for consistency across pyfuse modules#2

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/apply-coding-best-practices
Closed

Refactor import boundaries and API signatures for consistency across pyfuse modules#2
Copilot wants to merge 2 commits into
mainfrom
copilot/apply-coding-best-practices

Conversation

Copilot AI commented Apr 13, 2026

Copy link
Copy Markdown

This PR applies two cross-cutting code quality rules across the affected runtime modules: avoid inline imports except where needed to break cycles, and align argument naming/order for shared call paths.

  • Import hygiene (inline imports removed where unnecessary)

    • Moved avoidable function-scoped imports to module scope in:
      • pyfuse/__main__.py
      • pyfuse/worker/worker.py
      • pyfuse/worker/remote.py
    • Kept lazy import only where it is required to avoid an import cycle (Graph inside submit_remote).
  • Optional-backend import behavior preserved

    • Reworked backend modules to keep optional dependency ergonomics while reducing inline imports:
      • pyfuse/worker/backends/redis.py
      • pyfuse/worker/backends/rabbitmq.py
    • Added guarded module-level imports (try/except ImportError) and retained clear dependency error paths at backend initialization.
  • Argument coherence across modules

    • Standardized remote submission override naming:
      • submit_remote(..., _backend=...)submit_remote(..., backend=...)
    • Updated traced-call wiring to match (graph/tracing.py).
    • Aligned parameter ordering in serve(...) with worker construction conventions (import_to_package before auto_install).
# Before
await submit_remote(func, wrapper, *args, _backend=backend, **kwargs)

# After
await submit_remote(func, wrapper, *args, backend=backend, **kwargs)

Copilot AI and others added 2 commits April 13, 2026 18:17
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