litellm/.circleci/config.yml
Krrish Dholakia 713d998680 aider: Added print working directory command before running pytest in CircleCI config.
# Aider chat conversation:

USER: what directory is pytest in?

ASSISTANT: The `pytest` command is typically installed in the `bin` directory of your Python environment. If you're using a virtual environment, it would be in the `bin` directory of that environment.

However, the location of the `pytest` command doesn't affect how
^C KeyboardInterrupt

USER: i mean the pytest command in the config.yml

ASSISTANT: The pytest command in the `.circleci/config.yml` file is being run in the `~/project` directory. This is specified by the `working_directory` key in the `local_testing` job.

When the `python -m pytest -vv test_logging.py --junitxml=test-results/junit.xml` command is run, it's being run in the `~/project` directory.

If `test_logging.py` is not in the `~/project` directory, you would need to provide the relative path to it from `~/project`. For example, if it's in a `tests` directory under `~/project`, you would use `tests/test_logging.py`.

USER: can you print the pwd before running the pytest?  # Run pytest and generate JUnit XML report
      - run:
          name: Run tests
          command: |
            python -m pytest -vv tests/test_logging.py --junitxml=test-results/junit.xml
          no_output_timeout: 30m

ASSISTANT: Sure, you can add a command to print the current working directory (pwd) before running the pytest command. Here's how you can do it:

```yaml
.circleci/config.yml
<<<<<<< HEAD
      # Run pytest and generate JUnit XML report
      - run:
          name: Run tests
          command: |
            python -m pytest -vv tests/test_logging.py --junitxml=test-results/junit.xml
          no_output_timeout: 30m
=======
      # Run pytest and generate JUnit XML report
      - run:
          name: Run tests
          command: |
            pwd
            python -m pytest -vv tests/test_logging.py --junitxml=test-results/junit.xml
          no_output_timeout: 30m
>>>>>>> updated
```

This change will print the current working directory before running the pytest command.
2023-10-07 18:14:35 -07:00

116 lines
3.6 KiB
YAML

version: 2.1
jobs:
local_testing:
docker:
- image: circleci/python:3.8
working_directory: ~/project
steps:
- checkout
- run:
name: Check if litellm dir was updated or if pyproject.toml was modified
command: |
if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep -E 'pyproject\.toml|litellm/')" ]; then
echo "litellm updated"
else
echo "No changes to litellm or pyproject.toml. Skipping tests."
circleci step halt
fi
- restore_cache:
keys:
- v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
- run:
name: Install Dependencies
command: |
python -m pip install --upgrade pip
python -m pip install -r .circleci/requirements.txt
pip install infisical
pip install pytest
pip install pytest-asyncio
pip install mypy
pip install -q google-generativeai
pip install openai[datalib]
pip install -Uq chromadb==0.3.29
pip install "boto3>=1.28.57"
pip install appdirs
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum ".circleci/requirements.txt" }}
- run:
name: Linting Testing
command: |
cd litellm
python -m pip install types-requests types-setuptools types-redis
if ! python -m mypy . --ignore-missing-imports; then
echo "mypy detected errors"
exit 1
fi
cd ..
# Run pytest and generate JUnit XML report
- run:
name: Run tests
command: |
pwd
python -m pytest -vv tests/test_logging.py --junitxml=test-results/junit.xml
no_output_timeout: 30m
# Store test results
- store_test_results:
path: test-results
publish_to_pypi:
docker:
- image: cimg/python:3.8
working_directory: ~/project
environment:
TWINE_USERNAME: __token__
steps:
- checkout
- run:
name: Checkout code
command: git checkout $CIRCLE_SHA1
# Check if setup.py is modified and publish to PyPI
- run:
name: PyPI publish
command: |
echo "Install TOML package."
python -m pip install toml
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['name'])")
if ! pip show -v $PACKAGE_NAME | grep -q "Version: ${VERSION}"; then
echo "pyproject.toml modified"
echo -e "[pypi]\nusername = ishaan-jaff\npassword = madeBerri@992" > ~/.pypirc
python -m pip install --upgrade pip
pip install build
pip install wheel
pip install --upgrade twine setuptools
rm -rf build dist
echo "Building package"
python -m build
echo "Twine upload to dist"
echo "Contents of dist directory:"
ls dist/
twine upload --verbose dist/*
else
echo "Version ${VERSION} of package is already published on PyPI. Skipping PyPI publish."
circleci step halt
fi
workflows:
version: 2
build_and_test:
jobs:
- local_testing
- publish_to_pypi:
requires:
- local_testing