From 42908843d64ba22541cbc82619d7e0d7365b9af3 Mon Sep 17 00:00:00 2001 From: Edoardo Baldi Date: Wed, 1 Oct 2025 14:55:48 +0200 Subject: [PATCH 1/2] WIP: Migrate to ipytestsuite package --- Dockerfile | 2 ++ binder/environment.yml | 6 +---- binder/postBuild | 3 +++ docker/environment.yml | 5 +--- magic_example.ipynb | 54 ++++++++++++++++++++++++++++++++++++------ pyproject.toml | 17 ++++++++----- 6 files changed, 65 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index ed72ac0e..39c56e1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,8 @@ RUN mamba env update -n base -f /tmp/environment.yml && \ echo "Installing CUDA-enabled PyTorch" && \ pip install --no-cache-dir --force-reinstall torch torchvision; \ fi && \ + # Install ipytestsuite from TestPyPI (temporary, will use PyPI once published) + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "ipytestsuite[ai]" && \ # Clean up all package caches to reduce image size mamba clean --all -f -y && \ # Remove pip cache diff --git a/binder/environment.yml b/binder/environment.yml index 0293e453..d5b3f0d2 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -4,7 +4,7 @@ channels: - conda-forge - pytorch dependencies: - - python=3.10 + - python=3.12 - pip - pip: - numpy @@ -22,10 +22,6 @@ dependencies: - scikit-learn - attrs - multiprocess - - openai - - tenacity - - markdown2 - - python-dotenv - pillow - opencv-python - torch diff --git a/binder/postBuild b/binder/postBuild index 8f6dd066..26d20a78 100755 --- a/binder/postBuild +++ b/binder/postBuild @@ -3,3 +3,6 @@ set -ex mkdir -p ${HOME}/.ipython/profile_default cp binder/ipython_config.py ${HOME}/.ipython/profile_default/ + +# Install ipytestsuite from TestPyPI (temporary, will use PyPI once published) +pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "ipytestsuite[ai]" diff --git a/docker/environment.yml b/docker/environment.yml index 6fa594e4..fcf7038c 100644 --- a/docker/environment.yml +++ b/docker/environment.yml @@ -3,6 +3,7 @@ name: base channels: - conda-forge dependencies: + - python=3.12 - pip - pip: - numpy @@ -20,10 +21,6 @@ dependencies: - scikit-learn - attrs - multiprocess - - openai - - tenacity - - markdown2 - - python-dotenv - pillow - opencv-python - albumentations diff --git a/magic_example.ipynb b/magic_example.ipynb index 07b759cc..9f38c7ba 100644 --- a/magic_example.ipynb +++ b/magic_example.ipynb @@ -2,24 +2,64 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
OpenAI client configured successfully.
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
🔄 IPytest extension (re)loaded (with AI support).
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "%reload_ext tutorial.tests.testsuite" + "%reload_ext ipytestsuite" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "36143cb14d384b5598bab2994c67954e", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "VBox(children=(Output(outputs=({'output_type': 'display_data', 'data': {'text/plain': 'HTML(value=\\'
int:\n", @@ -89,7 +129,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.10" + "version": "3.12.11" }, "vscode": { "interpreter": { diff --git a/pyproject.toml b/pyproject.toml index a40c781a..c592f16c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "python-tutorial" version = "v2025.05" description = "Jupyter-based Python programming tutorial" -requires-python = ">=3.10" +requires-python = ">=3.12" [project.optional-dependencies] dev = [ @@ -21,16 +21,13 @@ dev = [ "scikit-learn", "attrs", "multiprocess", - "openai", - "tenacity", - "markdown2", - "python-dotenv", "pillow", "opencv-python", "albumentations", "grad-cam", "plotly", - "torch==2.7.0", # pinned to last stable version as of 2025-05-14 + "torch>=2.0.0", # PyTorch 2.x series + "ipytestsuite[ai]>=0.1.0", ] # pytest @@ -93,3 +90,11 @@ indent-style = "space" # Setuptools: suppress package discovery [tool.setuptools] packages = [] + +[[tool.uv.index]] +name = "testpypi" +url = "https://test.pypi.org/simple/" +explicit = true + +[tool.uv.sources] +ipytestsuite = { index = "testpypi" } From 3431c6c8cf7124f3016a4daf6fffae5baf20ce6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:01:24 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- magic_example.ipynb | 48 ++++----------------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/magic_example.ipynb b/magic_example.ipynb index 9f38c7ba..4061a90d 100644 --- a/magic_example.ipynb +++ b/magic_example.ipynb @@ -2,62 +2,22 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/html": [ - "
OpenAI client configured successfully.
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
🔄 IPytest extension (re)loaded (with AI support).
" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "%reload_ext ipytestsuite" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "36143cb14d384b5598bab2994c67954e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "VBox(children=(Output(outputs=({'output_type': 'display_data', 'data': {'text/plain': 'HTML(value=\\'