Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
frozen: true

- name: Run type checks
run: pixi run --as-is -e dev ty check src tests
run: pixi run --as-is -e dev type-check

test:
name: Unit Tests - Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -79,7 +79,9 @@ jobs:
frozen: true

- name: Run tests
run: pixi run --as-is -e ${{ steps.pixi.outputs.env }} pytest --cov=src/hextools --cov-report=xml --cov-report=term
# The GUI tests run in their own job: in one process with the rest, Qt objects
# they leave behind crash later tests when garbage-collected.
run: pixi run --as-is -e ${{ steps.pixi.outputs.env }} pytest --ignore=tests/gui --cov=src/hextools --cov-report=xml --cov-report=term

gui-test:
name: GUI Tests
Expand Down
6 changes: 3 additions & 3 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ test it, and how to make it available in the GUI.

```bash
pixi install -e dev
pixi run -e py313 tests # pytest with coverage
pixi run -e py313 lint # pre-commit hooks (ruff, ...)
pixi run -e py313 type-check # ty
pixi run tests # pytest with coverage
pixi run lint # pre-commit hooks (ruff, ...)
pixi run type-check # ty
pixi run start-mock # try your code in a mock IPython session
pixi run hex-gui-mock # try it in the GUI
```
Expand Down
11 changes: 5 additions & 6 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ pixi install # solves and installs the default environment

| Environment | Use it for |
| -------------- | -------------------------------------------------------------------------- |
| `terminal` | The IPython command-line session on the beamline (`pixi run start`). |
| `gui` | The HEX Data Acquisition GUI against real hardware (`pixi run hex-gui`). |
| `terminal` | The IPython command-line session (`pixi run start`) and the HEX Data Acquisition GUI (`pixi run hex-gui`) on the beamline. |
| `qs` | The Bluesky Queue Server backend and HTTP server. |
| `dev` | Development tools, plus the terminal and GUI with simulated devices (`pixi run start-mock`, `pixi run hex-gui-mock`). |

Pixi picks the environment that defines a task automatically, so in most cases
Pixi picks a default environment for each task, so in most cases
`pixi run <task>` is all you need. Pass `-e <environment>` to choose one
explicitly.

Expand Down Expand Up @@ -59,7 +58,7 @@ pixi run qs-server # HTTP server on localhost:60610
pixi run qserver-gui # upstream bluesky-widgets queue monitor

# Development
pixi run -e py313 tests
pixi run -e py313 lint
pixi run -e py313 type-check
pixi run tests
pixi run lint
pixi run type-check
```
596 changes: 134 additions & 462 deletions pixi.lock

Large diffs are not rendered by default.

69 changes: 39 additions & 30 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ matplotlib = ">=3.10.9,<4"
qtpy = ">=2.4.3,<3"
pyside6 = ">=6.9.0,<7"
nexpy = ">=2.0.3,<3"
pexpect = ">=4.9.0,<5"

# Install the `gui` extra (bluesky-widgets, ntnda-qt-viewer, ...) in this env.
[feature.terminal.pypi-dependencies]
hextools = { path = ".", editable = true, extras = ["gui"] }
ntnda-qt-viewer = { git = "https://github.com/jwlodek/ntnda-qt-viewer", rev = "main" }

[feature.terminal.tasks.hex-gui]
cmd = "python -m hextools.gui"
default-environment = "terminal"

[feature.terminal.tasks.qserver-gui]
cmd = "queue-monitor --http-server-uri https://xf27id1-hex-qs1.nsls2.bnl.gov:443"
default-environment = "terminal"

[feature.terminal.tasks.start]
cmd = "unset SESSION_MANAGER PYTHONPATH PYTHONUSERBASE && MPLBACKEND=qtagg ipython -i src/hextools/profiles/{{ profile }}.py"
Expand All @@ -54,6 +68,7 @@ args = [
{ arg = "profile", default = "collection" },
]
env = { HEXTOOLS_RUNNING_IN_CI = "{% if mock == 'true' %}YES{% endif %}" }
default-environment = "terminal"

[feature.py311.dependencies]
python = "3.11.*"
Expand Down Expand Up @@ -87,28 +102,20 @@ greenlet = ">=3.5.6,<4"
# Runs the profile in mock mode; mock mode needs dev-only packages (uvicorn via
# tiled-server). Sets its own env because task env does not propagate through
# `depends-on`.
[feature.mock.tasks.start-mock]
[feature.dev.tasks.start-mock]
cmd = "unset SESSION_MANAGER PYTHONPATH PYTHONUSERBASE && MPLBACKEND=qtagg ipython -i src/hextools/profiles/{{ profile }}.py"
args = [{ arg = "profile", default = "collection" }]
env = { HEXTOOLS_RUNNING_IN_CI = "YES", BEAMLINE_ACRONYM = "HEX" }
default-environment = "dev"

[feature.gui.dependencies]
pyside6 = ">=6.9.0,<7"
qtpy = ">=2.4.3,<3"
pexpect = ">=4.9.0,<5"

# Install the `gui` extra (bluesky-widgets, ntnda-qt-viewer, ...) in this env.
[feature.gui.pypi-dependencies]
hextools = { path = ".", editable = true, extras = ["gui"] }
ntnda-qt-viewer = { git = "https://github.com/jwlodek/ntnda-qt-viewer", rev = "main" }

[feature.dev.tasks.hex-gui-mock]
cmd = "python -m hextools.gui --mock"
default-environment = "dev"

[feature.gui.tasks]
qserver-gui = "queue-monitor --http-server-uri https://xf27id1-hex-qs1.nsls2.bnl.gov:443"
hex-gui = "python -m hextools.gui"

[feature.mock.tasks]
hex-gui-mock = "python -m hextools.gui --mock"
# ty doesn't pick up pixi's environment from CONDA_PREFIX on its own.
[feature.dev.tasks.type-check]
cmd = "ty check --python $CONDA_PREFIX src tests"
default-environment = "dev"

[feature.exporter.tasks]
auto-exporter = "python -m hextools.exporters.auto_exporter"
Expand Down Expand Up @@ -136,33 +143,35 @@ args = [
# Base environments
default = { solve-group = "default" }
# Everything needed to develop, test, and run the terminal and GUI in mock mode.
dev = { features = ["profile", "terminal", "gui", "dev", "mock"], solve-group = "profile" }
dev = { features = ["profile", "terminal", "dev"], solve-group = "profile" }
docs = { features = ["docs"], solve-group = "default" }

# Profile environments
# Profile environments (`terminal` also runs the GUI)
terminal = {features = ["profile", "terminal"], solve-group = "profile"}
qs = { features = ["profile", "qs"], solve-group = "profile" }

# Tiled webhook server that runs metadata exporters
exporter = { features = ["exporter"], solve-group = "default" }

# Python version specific environments for CI
py311 = { features = ["dev", "py311"], solve-group = "py311" }
py312 = { features = ["dev", "py312"], solve-group = "py312" }
py313 = { features = ["dev", "py313"], solve-group = "py313" }
py311 = { features = ["dev", "terminal", "py311"], solve-group = "py311" }
py312 = { features = ["dev", "terminal", "py312"], solve-group = "py312" }
py313 = { features = ["dev", "terminal", "py313"], solve-group = "py313" }

[environments.gui]
features = ["profile", "gui"]
solve-group = "profile"
[feature.dev.tasks.tests]
cmd = "pytest --cov=src/hextools --cov-report=term"
default-environment = "dev"

[feature.py313.tasks]
tests = "pytest --cov=src/hextools --cov-report=term"
# Run the tests, then serve the html coverage report whether or not they passed.
# VS Code's terminal opens file:// links in the editor, but http:// in the browser.
coverage = """
[feature.dev.tasks.coverage]
cmd = """
pytest --cov=src/hextools --cov-report=term --cov-report=html; \
echo "Coverage report: http://localhost:8765/index.html (Ctrl-C to stop)" \
&& python -m http.server 8765 --bind 127.0.0.1 --directory $PIXI_PROJECT_ROOT/htmlcov
"""
lint = "pre-commit run --all-files"
type-check = "ty check src tests"
default-environment = "dev"

[feature.dev.tasks.lint]
cmd = "pre-commit run --all-files"
default-environment = "dev"
Loading
Loading