Skip to content
Open
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
158 changes: 158 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ let
# This is needed for the libsqlite3-sys crate to find the correct sqlite3.
export PKG_CONFIG_PATH="${pkgs.sqlite.dev}/lib/pkgconfig''${PKG_CONFIG_PATH:+:''${PKG_CONFIG_PATH}}"
'';
# Fixes: libstdc++.so.6: cannot open shared object file: No such file or directory
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];
Comment thread
jerbaroo marked this conversation as resolved.
};
};
in
Expand Down
10 changes: 10 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ nix-test-integration *TEST_ARGS: nix-build

timeout --signal term --kill-after {{pytest_timeout_kill_seconds}} {{pytest_timeout_seconds}} pytest --color=yes {{TEST_ARGS}}

# Benchmark query cost and render a graph.
[group('bench')]
bench-chunks-select:
#!/usr/bin/env bash
set -euo pipefail
cargo bench --bench chunks_select

source "./libs/opsqueue_python/.setup_local_venv.sh"
python opsqueue/benches/plot_chunks_select.py

# Run all linters, fast and slow
[group('lint')]
lint: (lint-light "--all-files") lint-heavy
Expand Down
12 changes: 8 additions & 4 deletions libs/opsqueue_python/.setup_local_venv.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
relative_dir_path="$(dirname "${BASH_SOURCE[0]}")"
absolute_dir_path="$(cd "$relative_dir_path" && pwd)"

python_version_hash=$(python --version --version | sha1sum | cut -c1-40)
venv_path="$absolute_dir_path/.venv-$python_version_hash"

# Then, we (create iff necessary) and activate an (empty!) virtual env
# so Maturin doesn't complain when running `maturin develop`.
if [ ! -d ".venv-$python_version_hash" ]; then
if [ ! -d "$venv_path" ]; then
echo "Creating an empty Python virtualenv to be able to run 'maturin develop', for Python version '$(python --version --version)' (hash $python_version_hash)..."
python -m venv ".venv-$python_version_hash"
python -m venv "$venv_path"
echo "Done!"
fi

source ".venv-$python_version_hash/bin/activate"
source "$venv_path/bin/activate"

# Ensure `pytest` is available in the venv;
# If we were to use `pytest` from Nix, it would not see the locally built python package!
uv pip install -r pyproject.toml --all-extras --quiet
uv pip install -r "$absolute_dir_path/pyproject.toml" --all-extras --quiet
1 change: 1 addition & 0 deletions libs/opsqueue_python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test = [
"pytest-xdist==3.8.0",
"multiprocess==0.70.19",
"pytest-timeout==2.4.0",
"matplotlib>=3.11.1",
]

[tool.pytest.ini_options]
Expand Down
7 changes: 7 additions & 0 deletions opsqueue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ workspace-hack.workspace = true
workspace = true

[dev-dependencies]
criterion.workspace = true
insta.workspace = true
assert_matches.workspace = true

[[bench]]
name = "chunks_select"
harness = false
required-features = ["server-logic"]

[features]
# Dependencies only in use by the server-logic:
Expand Down
Loading
Loading