From dee24b0b1ab0f76e9edd95089af1d8526f6dd4ba Mon Sep 17 00:00:00 2001 From: Alex Remedios Date: Wed, 25 Oct 2023 10:04:09 +0100 Subject: [PATCH] fix tests (#2) --- .devcontainer/Dockerfile | 4 ++-- .devcontainer/devcontainer.json | 16 ++++++++-------- .github/workflows/pytest.yml | 9 +++------ .github/workflows/test-publish-to-pypi.yml | 6 +++--- README.md | 11 +---------- src/nbwrite/config.py | 2 +- tests/test_cli.py | 2 +- 7 files changed, 19 insertions(+), 31 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 39dbbd8..80229f8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,6 +6,6 @@ ARG NODE_VERSION="lts/*" RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi USER vscode RUN pip3 --disable-pip-version-check --no-cache-dir install -U \ - 'poetry==1.1.13' \ - 'pip==22.1.2' + 'poetry==1.6.1' \ + 'pip==23.2.1' RUN npm install -g @devcontainers/cli@v0.30.0 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4e4ddb6..165b591 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,14 +10,14 @@ } }, "mounts": [ - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached", - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached", - "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind,consistency=cached", + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached", + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached", + // "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind,consistency=cached", // Add the paths below if you know you use them on your local machine and want them to be available in your container. - // - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshrc,target=/home/vscode/.zshrc,type=bind,consistency=cached", - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached", - "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshenv,target=/home/vscode/.zshenv,type=bind,consistency=cached", + // // + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshrc,target=/home/vscode/.zshrc,type=bind,consistency=cached", + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached", + // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.zshenv,target=/home/vscode/.zshenv,type=bind,consistency=cached", // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.kube/config,target=/home/vscode/.kube/config,type=bind,consistency=cached", // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.kc,target=/home/vscode/.kc,type=bind,consistency=cached", // "source=${localEnv:HOME}${localEnv:USERPROFILE}/.azure/msal_http_cache.bin,target=/home/vscode/.azure/msal_http_cache.bin,type=bind,consistency=cached", @@ -42,6 +42,6 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers-contrib/features/starship:1": {}, }, - "postCreateCommand": "poetry install", + "postCreateCommand": "poetry install --all-extras", "remoteUser": "vscode" } diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 133d961..de8317f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -12,7 +12,6 @@ jobs: - run: npm install -g @devcontainers/cli@v0.30.0 - run: devcontainer up --workspace-folder=. - run: devcontainer exec --workspace-folder=. poetry run pre-commit run --verbose --all-files - - run: devcontainer exec --workspace-folder=. poetry run pytest --cov-report=xml --cov=src - uses: codecov/codecov-action@v1 with: file: coverage.xml @@ -25,8 +24,8 @@ jobs: - macos-latest python-version: - "3.8" - # - "3.9" - # - "3.10" + - "3.9" + - "3.10" - "3.11" runs-on: ${{ matrix.os }} steps: @@ -35,10 +34,8 @@ jobs: with: python-version: ${{ matrix.python-version }} - run: pip install poetry - - run: poetry install + - run: poetry install --all-extras - run: poetry run pytest --cov-report=xml --cov=src - uses: codecov/codecov-action@v1 with: file: coverage.xml - -# TODO README and workflows for e2e test, package release, devcon build \ No newline at end of file diff --git a/.github/workflows/test-publish-to-pypi.yml b/.github/workflows/test-publish-to-pypi.yml index e8f43f6..447ae29 100644 --- a/.github/workflows/test-publish-to-pypi.yml +++ b/.github/workflows/test-publish-to-pypi.yml @@ -3,6 +3,7 @@ on: push: branches: - main + pull_request: jobs: build-n-publish: runs-on: ubuntu-22.04 @@ -15,14 +16,13 @@ jobs: build_version="$(poetry version -s).dev$(date +%s)" poetry version $build_version - run: poetry build - - run: pip install 'pytest==7.1' - run: pip install dist/*gz --force-reinstall - run: pip install nbmake nbformat nbclient # necessary for running smoke test - - run: nbwrite tests/resources/nbwrite-in/example.yaml + - run: nbwrite tests/resources/nbwrite-in/minimal.yaml env: OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}' - run: pip install dist/*whl --force-reinstall - - run: nbwrite tests/resources/nbwrite-in/example.yaml + - run: nbwrite tests/resources/nbwrite-in/minimal.yaml env: OPENAI_API_KEY: '${{ secrets.OPENAI_API_KEY }}' - run: pip install twine==4.0.1 diff --git a/README.md b/README.md index fc659ad..d6140b9 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,7 @@ export OPENAI_API_KEY='sk-xxxx' e.g. nbwrite/example1.yaml: ```yaml task: | - Create a hello world notebook 'x.ipynb', use nbmake's NotebookRun class to test it from a Python application -steps: - - Create a hello world notebook using nbformat - - Use nbmake's NotebookRun class to execute it from a Python application - - Check the output notebook printed what we were expecting -packages: - - nbmake + Plot the iris dataset using pandas generation: count: 2 ``` @@ -136,6 +130,3 @@ using Phoenix. ``` 1. In another termianl, run nbwrite with the following var set: `export NBWRITE_PHOENIX_TRACE=1` 1. Check the phoenix traces in the dashboard (default http://127.0.0.1:6060/) - - -## TODO make phoenix optional, fix empty packages bug diff --git a/src/nbwrite/config.py b/src/nbwrite/config.py index 87917b6..228531d 100644 --- a/src/nbwrite/config.py +++ b/src/nbwrite/config.py @@ -11,7 +11,7 @@ class GenerationConfig(BaseModel): - count: int = 2 + count: int = 1 system_prompt: str = DEFAULT_SYSTEM_PROMPT llm_kwargs: Dict[str, Any] = DEFAULT_LLM_KWARGS retriever_kwargs: Dict[str, Any] = DEFAULT_RETRIEVER_KWARGS diff --git a/tests/test_cli.py b/tests/test_cli.py index 3d404a0..55394c8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -85,4 +85,4 @@ def test_cli_minimal(tmpdir: local): logger.warn(f"Checking outputs in {outdir}") outputs = list(Path(outdir).glob("*.ipynb")) - assert len(outputs) == 2 + assert len(outputs) == 1