-
Notifications
You must be signed in to change notification settings - Fork 0
#10 Conversion to UV build system, Python 3.13, Mise, Devcont #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| .git/ | ||
| .venv/ | ||
| dist/ | ||
| __pycache__/ | ||
| *.pyc | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .coverage | ||
| htmlcov/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: pip | ||
| - package-ecosystem: uv | ||
| directory: "/" | ||
| schedule: | ||
| interval: weekly | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.13 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,70 +3,50 @@ | |
| This is a flask application that will integrates with [Redux](https://github.com/ReduxISU/Redux) to provide qiskit based solvers | ||
| for problems. | ||
|
|
||
| **Python 3.10–3.13 is required.** | ||
| **Python 3.13 is required.** Dependencies and the environment are managed with | ||
| [uv](https://docs.astral.sh/uv/). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so why are we forcing python 3.13? It is what we ship in the docker container, true.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not necessarily forcing 3.13, but i can convert it to 3.12. But yes, everything is shipping with all of the dependencies. One of the nice things about UV is that you don't have to have python installed, UV installs whatever version of python you need to run the project.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Making it 3.13 isn't the point. The point it that I used to be able to say that it was tested with two versions (3.12 and 3.13) and that's not true any more. By removing the matrix tests, it's forced down to a single version. Ultimately, we're going to -ship- one version in the docker to ghcr, but I can't say anything about compatibility with other python versions unless they are tested.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood, I’ll add the matrix tests back in this evening |
||
|
|
||
| ## Getting Started | ||
| To run this, create a python virtual environment and "enter" it | ||
|
|
||
| ``` | ||
| cd the-location-of-this-README.md | ||
| python3 -m venv .venv | ||
| ``` | ||
| Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then sync the | ||
| environment (uv installs Python 3.13 automatically if it isn't already present): | ||
|
|
||
| For Windows: | ||
|
|
||
| ``` | ||
| .venv\scripts\Activate.bat | ||
| ``` | ||
|
|
||
| For anything else: | ||
|
|
||
| ``` | ||
| . .venv/bin/activate | ||
| cd the-location-of-this-README.md | ||
| uv sync | ||
| ``` | ||
|
|
||
| Then install the requirements: | ||
| This creates `.venv/`, installs all runtime + dev dependencies, and installs the | ||
| `quantumsolver` package itself. | ||
|
|
||
| ``` | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| For development (adds pytest, pylint, pip-audit): | ||
| Run the development server. Redux expects the solver on port **27100**: | ||
|
|
||
| ``` | ||
| pip install -r requirements-dev.txt | ||
| uv run flask --app quantumsolver.app run --port 27100 | ||
| ``` | ||
|
|
||
| Tell it which app we want: | ||
|
|
||
| For Windows: | ||
| Or run it under gunicorn (the production WSGI server), binding TCP only: | ||
|
|
||
| ``` | ||
| set FLASK_APP=quantumsolver.py | ||
| uv run gunicorn --bind '[::]:27100' quantumsolver.app:app | ||
| ``` | ||
|
|
||
| For anything else: | ||
| ``` | ||
| export FLASK_APP=quantumsolver.py | ||
| ``` | ||
| > The committed `gunicorn.conf.py` additionally binds a unix socket at | ||
| > `/run/quantumsolver/gunicorn.sock` for nginx. That path is provisioned by systemd in | ||
| > production (see `deploy/`), so pass `--config gunicorn.conf.py` locally only if you first | ||
| > create it: `sudo mkdir -p /run/quantumsolver && sudo chown "$USER" /run/quantumsolver`. | ||
|
|
||
| Now, run it! | ||
| ## Running the Tests | ||
|
|
||
| ``` | ||
| $ flask run | ||
| * Serving Flask app 'quantumsolver.py' | ||
| * Debug mode: off | ||
| WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. | ||
| * Running on http://127.0.0.1:5000 | ||
| Press CTRL+C to quit | ||
| uv run pytest -v | ||
| ``` | ||
|
|
||
| ## Running the Tests | ||
|
|
||
| With the virtual environment active: | ||
| Lint (ruff) and format check (black): | ||
|
|
||
| ``` | ||
| pytest -v | ||
| uv run ruff check . | ||
| uv run black --check . | ||
| ``` | ||
|
|
||
| ## API Endpoints | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Qiskit-based quantum solvers for Redux, served as a Flask app.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| """quantum solver flask app initialization""" | ||
|
|
||
| from flask import Flask | ||
|
|
||
| app = Flask(__name__) | ||
|
|
||
| # Imported for its side effect of registering routes on `app`. | ||
| from quantumsolver import routes # noqa: E402, F401 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| from qiskit import QuantumCircuit, qasm2 | ||
| from qiskit_aer import AerSimulator | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we lose by doing this is the matrix build (testing both 3.12 and 3.13). I'm not sure I'm ok with losing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can convert it to 3.12, and keep this.