Skip to content
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
fe1f715
test
hannahwestra25 Dec 5, 2025
2fef545
remove extra uv
hannahwestra25 Dec 5, 2025
a4d95f4
use sync
hannahwestra25 Dec 5, 2025
87afed9
remove pip
hannahwestra25 Dec 5, 2025
147c563
pre-commit
hannahwestra25 Dec 5, 2025
512ad08
clean
hannahwestra25 Dec 5, 2025
4c5a7c5
add missing install
hannahwestra25 Dec 5, 2025
7d3e352
updat toc
hannahwestra25 Dec 5, 2025
1725917
change to pip install
hannahwestra25 Dec 10, 2025
1660e3e
use sync
hannahwestra25 Dec 10, 2025
5d41c42
use extra
hannahwestra25 Dec 10, 2025
d2a393c
explicit dev
hannahwestra25 Dec 10, 2025
2e76518
test all
hannahwestra25 Dec 10, 2025
aa4b4c0
list
hannahwestra25 Dec 10, 2025
1bc4e72
only dev
hannahwestra25 Dec 10, 2025
a0da5e3
update cmd
hannahwestra25 Dec 10, 2025
1fe92f1
addopts
hannahwestra25 Dec 10, 2025
d8bbf8a
Merge branch 'main' of https://github.com/Azure/PyRIT into integratio…
hannahwestra25 Dec 10, 2025
ae4e46d
dependency groups
hannahwestra25 Dec 10, 2025
3348933
explicit python path
hannahwestra25 Dec 10, 2025
351f04c
explicit python path
hannahwestra25 Dec 10, 2025
b5eada3
update git pipeline
hannahwestra25 Dec 10, 2025
96ab48d
update var
hannahwestra25 Dec 10, 2025
3b6bb27
add uv env
hannahwestra25 Dec 10, 2025
a5911ff
add cache dir
hannahwestra25 Dec 10, 2025
f92a591
syntax
hannahwestra25 Dec 10, 2025
b0e0480
remove re-assignment
hannahwestra25 Dec 10, 2025
f994ce8
uncomment
hannahwestra25 Dec 11, 2025
842a02f
fix missing env var
hannahwestra25 Dec 11, 2025
1020b9a
custom uv cache dir
hannahwestra25 Dec 11, 2025
4d31886
simple example
hannahwestra25 Dec 11, 2025
a3070a0
Merge branch 'main' of https://github.com/Azure/PyRIT into integratio…
hannahwestra25 Dec 11, 2025
e69ce68
lost changes
hannahwestra25 Dec 11, 2025
81510da
remove lock
hannahwestra25 Dec 11, 2025
d6d658a
convert
hannahwestra25 Dec 11, 2025
bf24f8a
always all install
hannahwestra25 Dec 11, 2025
9dc6249
update all
hannahwestra25 Dec 11, 2025
21e9209
always use all
hannahwestra25 Dec 11, 2025
fab6135
fix toc
hannahwestra25 Dec 11, 2025
fefe0ab
update build book
hannahwestra25 Dec 11, 2025
9ea167c
use extra command
hannahwestra25 Dec 11, 2025
5470f7c
update book yml
hannahwestra25 Dec 11, 2025
2876953
install uv in build book
hannahwestra25 Dec 11, 2025
e4ce7d4
run jb
hannahwestra25 Dec 11, 2025
e9bc2aa
Merge branch 'main' of https://github.com/Azure/PyRIT into integratio…
hannahwestra25 Dec 12, 2025
ed35048
update integration tests and component gov
hannahwestra25 Dec 12, 2025
f81edc9
remove unnecessary --extra
hannahwestra25 Dec 12, 2025
bcc18f7
test
hannahwestra25 Dec 12, 2025
30a2116
remove upgrade
hannahwestra25 Dec 12, 2025
5b870d4
ls
hannahwestra25 Dec 12, 2025
8df0878
copy all tests
hannahwestra25 Dec 12, 2025
67c0140
add mock prompt target to integration test mocks
hannahwestra25 Dec 12, 2025
2fb1cfe
fix path
hannahwestra25 Dec 12, 2025
c69a6ea
Merge branch 'main' of https://github.com/Azure/PyRIT into integratio…
hannahwestra25 Dec 17, 2025
3aa0c59
update docker and tests
hannahwestra25 Dec 17, 2025
d8592aa
remove references to old conda file
hannahwestra25 Dec 17, 2025
9458029
remove conda references
hannahwestra25 Dec 17, 2025
934a7f9
remove cache code
hannahwestra25 Dec 17, 2025
c303952
update link
hannahwestra25 Dec 17, 2025
b3e1e87
add log
hannahwestra25 Dec 17, 2025
b076347
double install feedgen
hannahwestra25 Dec 18, 2025
ce3f59c
remove extra install
hannahwestra25 Dec 18, 2025
752f419
conditionally remove file
hannahwestra25 Dec 18, 2025
4e88385
try with all
hannahwestra25 Dec 18, 2025
980c19e
add uv run
hannahwestra25 Dec 18, 2025
0293e10
address some comments
hannahwestra25 Dec 19, 2025
7dc8786
update docs and use local workspace
hannahwestra25 Dec 19, 2025
d598feb
revert path and address md comments
hannahwestra25 Dec 19, 2025
9b0765f
fix headers
hannahwestra25 Dec 19, 2025
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
41 changes: 29 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
FROM mcr.microsoft.com/devcontainers/anaconda:3
# Use a Python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim

# Makes installation faster
ENV UV_COMPILE_BYTECODE=1
ENV UV_SYSTEM_PYTHON=1
ENV UV_LINK_MODE=copy
Comment thread
hannahwestra25 marked this conversation as resolved.
Outdated

SHELL ["/bin/bash", "-c"]

USER root

# Install required system packages + ODBC prerequisites
RUN apt-get update && apt-get install -y \
sudo \
unixodbc \
unixodbc-dev \
libgl1-mesa-glx \
git \
curl \
xdg-utils \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -41,25 +49,34 @@ RUN apt-get update \
libpulse0 \
&& rm -rf /var/lib/apt/lists/*

# Create conda env and install pyodbc into it
RUN conda create -n pyrit-dev python=3.11 -y && \
conda install -n pyrit-dev -c conda-forge pyodbc -y && \
chown -R vscode:vscode /opt/conda/envs/pyrit-dev
ARG USERNAME=vscode
# Create the user and grant passwordless sudo
RUN groupadd $USERNAME \
Comment thread
hannahwestra25 marked this conversation as resolved.
&& useradd -g $USERNAME -m $USERNAME \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Create venv using uv
RUN uv venv /opt/venv --python 3.11 \
Comment thread
hannahwestra25 marked this conversation as resolved.
&& chown -R vscode:vscode /opt/venv \
&& ls -la /opt/venv/bin/activate
ENV PATH="/opt/venv/bin:$PATH"

# Pre-create common user caches and fix permissions
RUN mkdir -p /home/vscode/.cache/pre-commit \
&& mkdir -p /home/vscode/.vscode-server \
&& mkdir -p /home/vscode/.cache/pip \
&& mkdir -p /home/vscode/.cache/conda \
&& mkdir -p /home/vscode/.cache/uv \
&& mkdir -p /home/vscode/.cache/venv \
&& mkdir -p /home/vscode/.cache/pylance \
&& chown -R vscode:vscode /home/vscode/.cache /home/vscode/.vscode-server \
&& chmod -R 777 /home/vscode/.cache/conda /home/vscode/.cache/pip /home/vscode/.cache/pylance /opt/conda/pkgs/cache/ \
&& chmod -R 777 /home/vscode/.cache/pip /home/vscode/.cache/pylance /home/vscode/.cache/venv /home/vscode/.cache/uv\
&& chmod -R 755 /home/vscode/.vscode-server

USER vscode
RUN /opt/conda/bin/conda init bash && \
echo "conda activate pyrit-dev" >> /home/vscode/.bashrc
RUN echo "source /opt/conda/etc/profile.d/conda.sh && conda activate pyrit-dev" >> /home/vscode/.bash_profile
# Create bash configuration files and activate the venv in bash sessions
RUN touch /home/vscode/.bashrc /home/vscode/.bash_profile \
&& echo "[ -f /opt/venv/bin/activate ] && source /opt/venv/bin/activate" >> /home/vscode/.bashrc \
&& echo "[ -f /opt/venv/bin/activate ] && source /opt/venv/bin/activate" >> /home/vscode/.bash_profile

# Configure Git for better performance with bind mounts
RUN git config --global core.preloadindex true \
Expand All @@ -68,5 +85,5 @@ RUN git config --global core.preloadindex true \
&& git config --global status.showUntrackedFiles all \
&& git config --global core.fsmonitor true

# Set pip’s cache directory so it can be mounted
ENV PIP_CACHE_DIR="/home/vscode/.cache/pip"
# Set uv’s cache directory so it can be mounted
ENV UV_CACHE_DIR="/home/vscode/.cache/uv"
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"containerEnv": {
"PYTHONPATH": "/workspace"
},
"containerUser": "vscode",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/opt/conda/envs/pyrit-dev/bin/python",
"python.defaultInterpreterPath": "/opt/venv/bin/python",
"python.analysis.extraPaths": [
"/workspace"
],
Expand All @@ -31,7 +32,7 @@
"pyrit/**"
],
"python.analysis.exclude": [
"/opt/conda/envs/**",
"/opt/venv/**",
"**/.venv/**",
"**/site-packages/**",
"**/doc/**",
Expand Down
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ if [ -f "$HASH_FILE" ]; then
chmod 666 "$HASH_FILE"
fi

source /opt/conda/etc/profile.d/conda.sh
conda activate pyrit-dev

# Compute current hash
CURRENT_HASH=$(sha256sum /workspace/pyproject.toml | awk '{print $1}')

Expand All @@ -49,8 +46,8 @@ if [ ! -f "$HASH_FILE" ] || [ "$(cat $HASH_FILE)" != "$CURRENT_HASH" ]; then
echo "📦 pyproject.toml has changed, installing environment..."

# Install dependencies
conda install ipykernel -y
pip install -e '.[dev,all]'
uv sync --extra dev --extra all
uv add ipykernel

# Save the new hash
echo "$CURRENT_HASH" > "$HASH_FILE"
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ services:
memory: "16G"
volumes:
- ..:/workspace:delegated
- pyrit-env:/opt/conda/envs/pyrit-dev:cached
- pyrit-env:/opt/venv:cached
- pip-cache:/home/vscode/.cache/pip:cached
- uv-cache:/home/vscode/.cache/uv:cached
- precommit-cache:/home/vscode/.cache/pre-commit:cached
- conda-cache:/home/vscode/.cache/conda:cached
- mypy-cache:/workspace/.mypy_cache:cached
- pylance-cache:/home/vscode/.cache/pylance:cached
network_mode: "host"
Expand All @@ -25,7 +25,7 @@ services:
volumes:
pyrit-env:
pip-cache:
uv-cache:
precommit-cache:
conda-cache:
mypy-cache:
pylance-cache:
88 changes: 34 additions & 54 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,12 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read

env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: ${{ env.PRE_COMMIT_PYTHON_VERSION }}
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pip-${{ env.PRE_COMMIT_PYTHON_VERSION }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ env.PRE_COMMIT_PYTHON_VERSION }}-
${{ runner.os }}-pip-

- name: Cache pre-commit environments
uses: actions/cache@v3
Expand All @@ -53,11 +41,18 @@ jobs:
restore-keys: |
pre-commit-${{ runner.os }}-

- name: Upgrade pip and setuptools
run: python -m pip install --upgrade pip setuptools packaging
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# Install a specific version of uv.
version: "0.9.17"
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Install dev extras
run: pip install --no-cache-dir .[dev,all]
run: uv sync --extra dev --extra all

- name: disk space
run: df -all -h
Expand All @@ -68,21 +63,19 @@ jobs:
RUN_LONG_PRECOMMIT: true
run: |
git fetch origin main
pre-commit run --from-ref origin/main --to-ref HEAD
uv run pre-commit run --from-ref origin/main --to-ref HEAD

- name: Run pre-commit fully (on main)
if: github.ref == 'refs/heads/main'
env:
RUN_LONG_PRECOMMIT: true
run: |
pre-commit run --all-files
uv run pre-commit run --all-files

pre-commit-windows:
runs-on: windows-latest
permissions:
contents: read
env:
PIP_CACHE_DIR: ${{ github.workspace }}\.cache\pip
defaults:
run:
shell: pwsh
Expand All @@ -93,15 +86,6 @@ jobs:
with:
python-version: ${{ env.PRE_COMMIT_PYTHON_VERSION }}

- name: Cache pip packages
uses: actions/cache@v3
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pip-${{ env.PRE_COMMIT_PYTHON_VERSION }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ env.PRE_COMMIT_PYTHON_VERSION }}-
${{ runner.os }}-pip-

- name: Cache pre-commit environments
uses: actions/cache@v3
with:
Expand All @@ -110,11 +94,18 @@ jobs:
restore-keys: |
pre-commit-${{ runner.os }}-

- name: Upgrade pip and setuptools
run: python -m pip install --upgrade pip setuptools packaging
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# Install a specific version of uv.
version: "0.9.17"
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Install dev extras
run: pip install --no-cache-dir '.[dev,all]'
run: uv sync --extra dev --extra all

- name: disk space
run: df -all -h
Expand All @@ -125,14 +116,14 @@ jobs:
RUN_LONG_PRECOMMIT: true
run: |
git fetch origin main
pre-commit run --from-ref origin/main --to-ref HEAD
uv run pre-commit run --from-ref origin/main --to-ref HEAD

- name: Run pre-commit fully (on main)
if: github.ref == 'refs/heads/main'
env:
RUN_LONG_PRECOMMIT: true
run: |
pre-commit run --all-files
uv run pre-commit run --all-files

# Main job runs only if pre-commit succeeded
main-job:
Expand All @@ -144,8 +135,6 @@ jobs:
package_name: ["pyrit"]
package_extras: ["dev", "dev_all"]
runs-on: ${{ matrix.os }}
env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
# EnricoMi/publish-unit-test-result-action@v2 requires the following permissions
permissions:
contents: read
Expand All @@ -160,36 +149,27 @@ jobs:
with:
python-version: ${{ matrix.python }}

# Cache pip packages
# GitHub automatically handles cache eviction after 7 days of inactivity (or 10GB)
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows
- name: Cache pip packages
uses: actions/cache@v3
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ matrix.package_extras }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python }}-${{ matrix.package_extras }}-
${{ runner.os }}-pip-${{ matrix.python }}-
${{ runner.os }}-pip-

- name: Install setuptools and pip
run: python -m pip install --upgrade pip setuptools packaging
# Install a specific version of uv.
version: "0.9.17"
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

# Install PyRIT with optional extras
- name: Install PyRIT with pip
- name: Install PyRIT with uv
# If the matrix extras is 'dev_all', then we install '.[dev,all]'
# otherwise just install the literal extras from the matrix
shell: bash
run: |
if [ "${{ matrix.package_extras }}" = "dev_all" ]; then
extras="dev,all"
uv sync --extra dev --extra all
else
extras="${{ matrix.package_extras }}"
uv sync --extra dev
fi

pip install --no-cache-dir ".[${extras}]"

- name: Run unit tests with code coverage
run: make unit-test-cov-xml

Expand Down
24 changes: 13 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,25 @@ jobs:
steps:
- uses: actions/checkout@v4

# Cache pip packages for faster installs
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

# Install dependencies
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install PyRIT with pip
run: pip install .[dev]
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
# Install a specific version of uv.
version: "0.9.17"
enable-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/uv.lock

- name: Install PyRIT with uv
run: uv sync --extra dev --extra all

# Build the book
- name: Build the book
run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all pre-commit mypy test test-cov-html test-cov-xml

CMD:=python -m
CMD:=uv run -m
PYMODULE:=pyrit
TESTS:=tests
UNIT_TESTS:=tests/unit
Expand All @@ -17,8 +17,8 @@ mypy:
$(CMD) mypy $(PYMODULE) $(UNIT_TESTS)

docs-build:
jb build -W -v ./doc
python ./build_scripts/generate_rss.py
uv run jb build -W -v ./doc
uv run ./build_scripts/generate_rss.py

# Because of import time, "auto" seemed to actually go slower than just using 4 processes
unit-test:
Expand Down
4 changes: 2 additions & 2 deletions doc/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ chapters:
- file: cookbooks/3_copyright_violations
- file: cookbooks/4_testing_bias
- file: cookbooks/5_psychosocial_harms
- file: setup/1a_install_conda
- file: setup/1a_install_uv
sections:
- file: setup/1b_install_docker
- file: setup/jupyter_setup
- file: setup/populating_secrets
- file: setup/use_azure_sql_db
- file: contributing/README
sections:
- file: contributing/1a_install_conda
- file: contributing/1a_install_uv
- file: contributing/1b_install_devcontainers
- file: contributing/2_git
- file: contributing/3_incorporating_research
Expand Down
Loading
Loading