Skip to content

Resolve CI Ruff failures in app and space server entrypoints#53

Merged
quantumdynamics927-dotcom merged 2 commits intomainfrom
copilot/ci-cd-pipeline-tests-failing
Apr 5, 2026
Merged

Resolve CI Ruff failures in app and space server entrypoints#53
quantumdynamics927-dotcom merged 2 commits intomainfrom
copilot/ci-cd-pipeline-tests-failing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

The CI/CD pipeline was failing across Python 3.10–3.13 before tests ran because Ruff flagged import, undefined-name, and exception-chaining issues in the web entrypoints. This change tightens those files so the matrix can progress past lint consistently.

  • app.py

    • Restore missing json and QuantumCircuit imports used by QRNG, noisy simulation, and benchmark output paths
    • Update the Bell-pair UI handler to match the current bell_pair(engine) API and render the returned circuit correctly
  • space_server.py

    • Normalize top-level and local import ordering to satisfy Ruff import rules
    • Remove the unused StaticFiles import
    • Chain HTTPException re-raises with from e in API handlers to preserve exception context
  • Behavioral alignment

    • Keep the existing endpoint/UI behavior intact while making the entrypoints consistent with the current module interfaces and lint policy
def create_bell_pair():
    try:
        result = bell_pair(engine)
        return result.circuit.draw(output="text")
    except Exception as e:
        return f"Error: {str(e)}"

Copilot AI and others added 2 commits April 5, 2026 03:48
Agent-Logs-Url: https://github.com/quantumdynamics927-dotcom/QPyth/sessions/45126d95-0912-4638-845a-b82c5cbc0392

Co-authored-by: quantumdynamics927-dotcom <247722560+quantumdynamics927-dotcom@users.noreply.github.com>
Agent-Logs-Url: https://github.com/quantumdynamics927-dotcom/QPyth/sessions/45126d95-0912-4638-845a-b82c5cbc0392

Co-authored-by: quantumdynamics927-dotcom <247722560+quantumdynamics927-dotcom@users.noreply.github.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
q-pyth Ready Ready Preview, Comment Apr 5, 2026 3:50am

@quantumdynamics927-dotcom quantumdynamics927-dotcom marked this pull request as ready for review April 5, 2026 03:50
Copilot AI review requested due to automatic review settings April 5, 2026 03:50
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 addresses Ruff lint failures in the project’s web entrypoints so CI can proceed to the test phase, and aligns the Gradio Bell-pair handler with the current bell_pair(engine) API.

Changes:

  • Fix/normalize imports in app.py and space_server.py (missing imports + Ruff-friendly ordering).
  • Update the Gradio Bell-pair UI handler to call bell_pair(engine) and render the returned circuit.
  • Improve FastAPI error re-raises by chaining HTTPException(... ) from e to preserve traceback context.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
space_server.py Import ordering cleanup and exception chaining in API endpoints to satisfy Ruff and preserve error context.
app.py Restore needed imports and update the Bell-pair UI handler to use the current bell_pair(engine) interface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread space_server.py
# QRNG Phi-Scaled - FIXED
from quantumpytho.modules.qrng_sacred import qrng_phi_sequence

result = qrng_phi_sequence(request.count)
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

qrng_phi_sequence is being called with request.count as the first positional argument, but its signature is qrng_phi_sequence(engine, num_qubits=..., length=...). This will raise a TypeError at runtime and breaks the phi-scaled QRNG path. Pass engine explicitly and map request.count to the length parameter (and optionally expose num_qubits if needed).

Suggested change
result = qrng_phi_sequence(request.count)
result = qrng_phi_sequence(engine, length=request.count)

Copilot uses AI. Check for mistakes.
Comment thread app.py
circuit = bell_pair()
return circuit.draw(output='text')
result = bell_pair(engine)
return result.circuit.draw(output="text")
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

result.circuit.draw(output="text") returns a Qiskit drawing object (e.g., TextDrawing), not a plain string. Gradio Textbox outputs are simplest/most reliable when they receive a string; consider converting the drawing to str(...) (or calling .__str__()) before returning so the UI consistently renders the diagram.

Suggested change
return result.circuit.draw(output="text")
return str(result.circuit.draw(output="text"))

Copilot uses AI. Check for mistakes.
@quantumdynamics927-dotcom quantumdynamics927-dotcom merged commit 7ce1f61 into main Apr 5, 2026
16 checks passed
@quantumdynamics927-dotcom quantumdynamics927-dotcom deleted the copilot/ci-cd-pipeline-tests-failing branch April 5, 2026 03:56
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