parent
							
								
									ff29a6b816
								
							
						
					
					
						commit
						415a5cf644
					
				| @ -1,11 +0,0 @@ | ||||
| [flake8] | ||||
| max-line-length = 127 | ||||
| extend-ignore = E203 | ||||
| per-file-ignores = | ||||
|     # Most of this is just long strings | ||||
|     ./swarms/prompts/**.py: E501 W293 W291 | ||||
|     ./swarms/__init__.py: F401 | ||||
| exclude = | ||||
|     ./playground | ||||
|     ./tests | ||||
|     ./scripts | ||||
| @ -0,0 +1,37 @@ | ||||
| name: "Init Environment" | ||||
| description: "Initialize environment for tests" | ||||
| runs: | ||||
|   using: "composite" | ||||
|   steps: | ||||
|       - name: Checkout actions | ||||
|         uses: actions/checkout@v3 | ||||
| 
 | ||||
|       - name: Set up Python ${{ matrix.python-version }} | ||||
|         uses: actions/setup-python@v4 | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
| 
 | ||||
|       - name: Install and configure Poetry | ||||
|         uses: snok/install-poetry@v1 | ||||
|         with: | ||||
|           virtualenvs-create: true | ||||
|           virtualenvs-in-project: true | ||||
|           installer-parallel: true | ||||
| 
 | ||||
|       - name: Load cached venv | ||||
|         id: cached-poetry-dependencies | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: .venv | ||||
|           key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||||
| 
 | ||||
|       - name: Install dependencies | ||||
|         if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||||
|         run: poetry install --no-interaction --no-root --with test --with dev --all-extras | ||||
|         shell: bash | ||||
| 
 | ||||
|       - name: Activate venv  | ||||
|         run: | | ||||
|           source .venv/bin/activate | ||||
|           echo PATH=$PATH >> $GITHUB_ENV | ||||
|         shell: bash | ||||
| @ -1,52 +1,14 @@ | ||||
| --- | ||||
| documentation: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: ["docs/**", "*.md"] | ||||
| tests: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "tests/**" | ||||
| agents: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/agents/**" | ||||
| artifacts: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/artifacts/**" | ||||
| chunkers: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/chunkers/**" | ||||
| cli: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/cli/**" | ||||
| loaders: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/loaders/**" | ||||
| memory: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/memory/**" | ||||
| models: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/models/**" | ||||
| prompts: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/prompts/**" | ||||
| structs: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/structs/**" | ||||
| telemetry: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/telemetry/**" | ||||
| tokenizers: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/tokenizers/**" | ||||
| tools: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/tools/**" | ||||
| utils: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/utils/**" | ||||
| workers: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "swarms/workers/**" | ||||
| rust: | ||||
|   - changed-files: | ||||
|       - any-glob-to-any-file: "**/*.rs" | ||||
| # this is a config file for the github action labeler | ||||
| 
 | ||||
| # Add 'label1' to any changes within 'example' folder or any subfolders | ||||
| example_change: | ||||
|   - example/** | ||||
| 
 | ||||
| # Add 'label2' to any file changes within 'example2' folder | ||||
| example2_change: example2/* | ||||
| 
 | ||||
| # Add label3 to any change to .txt files within the entire repository. | ||||
| # Quotation marks are required for the leading asterisk | ||||
| text_files: | ||||
|   - '**/*.txt' | ||||
|  | ||||
| @ -1,44 +0,0 @@ | ||||
| --- | ||||
| name: "Setup" | ||||
| description: Setup the environment for the project | ||||
| inputs: | ||||
|   python-version: | ||||
|     description: "Python version to use" | ||||
|     required: false | ||||
|     default: "3.10" | ||||
| runs: | ||||
|   using: "composite" | ||||
|   steps: | ||||
|     - name: Free up disk space | ||||
|       run: | | ||||
|         sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL | ||||
|         sudo docker image prune --all --force | ||||
|       shell: bash | ||||
|     - name: Set up Python ${{ inputs.python-version }} | ||||
|       uses: actions/setup-python@v4 | ||||
|       with: | ||||
|         python-version: ${{ inputs.python-version }} | ||||
|     - name: Install and configure Poetry | ||||
|       uses: snok/install-poetry@v1 | ||||
|       with: | ||||
|         installer-parallel: true | ||||
|     - name: Cache Poetry cache | ||||
|       uses: actions/cache@v4 | ||||
|       with: | ||||
|         path: ~/.cache/pypoetry | ||||
|         key: poetry-cache | ||||
|           -${{ runner.os }} | ||||
|           -${{ steps.setup_python.outputs.python-version }} | ||||
|           -${{ env.POETRY_VERSION }} | ||||
|     - name: Cache Packages | ||||
|       uses: actions/cache@v4 | ||||
|       with: | ||||
|         path: ~/.local | ||||
|         key: poetry-local | ||||
|           -${{ runner.os }} | ||||
|           -${{ steps.setup_python.outputs.python-version }} | ||||
|           -${{ hashFiles('**/poetry.lock')}} | ||||
|           -${{ hashFiles('.github/workflows/*.yml') }} | ||||
|     - name: Install dependencies | ||||
|       run: POETRY_VIRTUALENVS_CREATE=false poetry install | ||||
|       shell: bash | ||||
| @ -0,0 +1,15 @@ | ||||
| name: "PR Labeler" | ||||
| 
 | ||||
| on: | ||||
|   pull_request_target: | ||||
|     types: ["opened", "reopened", "ready_for_review"] | ||||
| 
 | ||||
| jobs: | ||||
|   triage: | ||||
|     permissions: | ||||
|       contents: read | ||||
|       pull-requests: write | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/labeler@v5 | ||||
|     if: ${{ github.event.pull_request.draft == false }} | ||||
| @ -0,0 +1,30 @@ | ||||
| name: Pull Request Checks | ||||
| 
 | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
| 
 | ||||
| jobs: | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|     steps: | ||||
|       - name: Checkout code | ||||
|         uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: Set up Python | ||||
|         uses: actions/setup-python@v5 | ||||
|         with: | ||||
|           python-version: 3.x | ||||
| 
 | ||||
|       - name: Install dependencies | ||||
|         run: | | ||||
|           pip install -r requirements.txt | ||||
|           pip install swarms | ||||
|           pip install pytest  | ||||
| 
 | ||||
|       - name: Run tests and checks | ||||
|         run: | | ||||
|           pytest | ||||
|           pylint swarms | ||||
| @ -0,0 +1,23 @@ | ||||
| name: Pylint | ||||
| 
 | ||||
| on: [push] | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         python-version: ["3.8", "3.9", "3.10"] | ||||
|     steps: | ||||
|     - uses: actions/checkout@v4 | ||||
|     - name: Set up Python ${{ matrix.python-version }} | ||||
|       uses: actions/setup-python@v5 | ||||
|       with: | ||||
|         python-version: ${{ matrix.python-version }} | ||||
|     - name: Install dependencies | ||||
|       run: | | ||||
|         python -m pip install --upgrade pip | ||||
|         pip install pylint | ||||
|     - name: Analysing the code with pylint | ||||
|       run: | | ||||
|         pylint $(git ls-files '*.py') | ||||
| @ -0,0 +1,39 @@ | ||||
| # This workflow will install Python dependencies, run tests and lint with a single version of Python | ||||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||||
| 
 | ||||
| name: Python application | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: [ "master" ] | ||||
|   pull_request: | ||||
|     branches: [ "master" ] | ||||
| 
 | ||||
| permissions: | ||||
|   contents: read | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/checkout@v4 | ||||
|     - name: Set up Python 3.10 | ||||
|       uses: actions/setup-python@v5 | ||||
|       with: | ||||
|         python-version: "3.10" | ||||
|     - name: Install dependencies | ||||
|       run: | | ||||
|         python -m pip install --upgrade pip | ||||
|         pip install flake8 pytest swarms | ||||
|         if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||||
|     - name: Lint with flake8 | ||||
|       run: | | ||||
|         # stop the build if there are Python syntax errors or undefined names | ||||
|         flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||||
|         # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||||
|         flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||||
|     - name: Test with pytest | ||||
|       run: | | ||||
|         pytest | ||||
| @ -0,0 +1,41 @@ | ||||
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||||
| 
 | ||||
| name: Python package | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: [ "master" ] | ||||
|   pull_request: | ||||
|     branches: [ "master" ] | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         python-version: ["3.7", "3.9", "3.10", "3.11"] | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/checkout@v4 | ||||
|     - name: Set up Python ${{ matrix.python-version }} | ||||
|       uses: actions/setup-python@v5 | ||||
|       with: | ||||
|         python-version: ${{ matrix.python-version }} | ||||
|     - name: Install dependencies | ||||
|       run: | | ||||
|         python -m pip install --upgrade pip | ||||
|         python -m pip install --upgrade swarms | ||||
|         python -m pip install flake8 pytest swarms | ||||
|         if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||||
|     - name: Lint with flake8 | ||||
|       run: | | ||||
|         # stop the build if there are Python syntax errors or undefined names | ||||
|         flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||||
|         # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||||
|         flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||||
|     - name: Test with pytest | ||||
|       run: | | ||||
|         pytest | ||||
| @ -1,49 +1,27 @@ | ||||
| --- | ||||
| # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. | ||||
| # | ||||
| # You can adjust the behavior by modifying this file. | ||||
| # For more information, see: | ||||
| # https://github.com/actions/stale | ||||
| name: Mark stale issues and pull requests | ||||
| 
 | ||||
| on: | ||||
|   schedule: | ||||
|     # Scheduled to run at 1.30 UTC everyday | ||||
|     - cron: "30 1 * * *" | ||||
|   - cron: '26 12 * * *' | ||||
| 
 | ||||
| jobs: | ||||
|   stale: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
|     permissions: | ||||
|       issues: write | ||||
|       pull-requests: write | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/stale@v9 | ||||
|       with: | ||||
|         repo-token: ${{ secrets.GITHUB_TOKEN }} | ||||
|           days-before-issue-stale: 14 | ||||
|           days-before-issue-close: 14 | ||||
|           stale-issue-label: "status:stale" | ||||
|           close-issue-reason: not_planned | ||||
|           any-of-labels: "status:awaiting user response,status:more data needed" | ||||
|           stale-issue-message: > | ||||
|             Marking this issue as stale since it has been open for 14 days with no activity.  This issue | ||||
|             will be closed if no further activity occurs. | ||||
| 
 | ||||
|           close-issue-message: > | ||||
|             This issue was closed because it has been inactive for 28 days. Please post a new issue if | ||||
|             you need further assistance. Thanks! | ||||
| 
 | ||||
|           days-before-pr-stale: 14 | ||||
|           days-before-pr-close: 14 | ||||
|           stale-pr-label: "status:stale" | ||||
|           stale-pr-message: > | ||||
|             Marking this pull request as stale since it has been open for 14 days with no activity. This | ||||
|             PR will be closed if no further activity occurs. | ||||
| 
 | ||||
|           close-pr-message: > | ||||
|             This pull request was closed because it has been inactive for 28 days.  Please open a new | ||||
|             pull request if you need furtherassistance. Thanks! | ||||
| 
 | ||||
|           # Label that can be assigned to issues to exclude them from being marked as stale | ||||
|           exempt-issue-labels: "override-stale" | ||||
|           # Label that can be assigned to PRs to exclude them from being marked as stale | ||||
|           exempt-pr-labels: "override-stale" | ||||
|         stale-issue-message: 'Stale issue message' | ||||
|         stale-pr-message: 'Stale pull request message' | ||||
|         stale-issue-label: 'no-issue-activity' | ||||
|         stale-pr-label: 'no-pr-activity' | ||||
| @ -0,0 +1,49 @@ | ||||
| # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. | ||||
| # | ||||
| # You can adjust the behavior by modifying this file. | ||||
| # For more information, see: | ||||
| # https://github.com/actions/stale | ||||
| name: Mark stale issues and pull requests | ||||
| 
 | ||||
| on: | ||||
|   schedule: | ||||
|   # Scheduled to run at 1.30 UTC everyday | ||||
|   - cron: '30 1 * * *' | ||||
| 
 | ||||
| jobs: | ||||
|   stale: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
|     permissions: | ||||
|       issues: write | ||||
|       pull-requests: write | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/stale@v9 | ||||
|       with: | ||||
|         repo-token: ${{ secrets.GITHUB_TOKEN }} | ||||
|         days-before-issue-stale: 14 | ||||
|         days-before-issue-close: 14 | ||||
|         stale-issue-label: "status:stale" | ||||
|         close-issue-reason: not_planned | ||||
|         any-of-labels: "status:awaiting user response,status:more data needed" | ||||
|         stale-issue-message: > | ||||
|           Marking this issue as stale since it has been open for 14 days with no activity. | ||||
|           This issue will be closed if no further activity occurs. | ||||
|         close-issue-message: > | ||||
|           This issue was closed because it has been inactive for 28 days. | ||||
|           Please post a new issue if you need further assistance. Thanks! | ||||
|         days-before-pr-stale: 14 | ||||
|         days-before-pr-close: 14 | ||||
|         stale-pr-label: "status:stale" | ||||
|         stale-pr-message: > | ||||
|           Marking this pull request as stale since it has been open for 14 days with no activity. | ||||
|           This PR will be closed if no further activity occurs. | ||||
|         close-pr-message: > | ||||
|           This pull request was closed because it has been inactive for 28 days. | ||||
|           Please open a new pull request if you need further assistance. Thanks! | ||||
|         # Label that can be assigned to issues to exclude them from being marked as stale | ||||
|         exempt-issue-labels: 'override-stale' | ||||
|         # Label that can be assigned to PRs to exclude them from being marked as stale | ||||
|         exempt-pr-labels: "override-stale" | ||||
|          | ||||
| @ -1,16 +1,110 @@ | ||||
| --- | ||||
| name: build | ||||
| on: [push, pull_request] | ||||
| name: test | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: [master] | ||||
|   pull_request: | ||||
|   workflow_dispatch: | ||||
| 
 | ||||
| env: | ||||
|   POETRY_VERSION: "1.4.2" | ||||
| 
 | ||||
| jobs: | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         python-version: | ||||
|           - "3.8" | ||||
|           - "3.9" | ||||
|           - "3.10" | ||||
|           - "3.11" | ||||
|         test_type: | ||||
|           - "core" | ||||
|           - "extended" | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Set up Python ${{ matrix.python-version }} | ||||
|         uses: "snok/install-poetry@v1" | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           poetry-version: "1.4.2" | ||||
|           cache-key: ${{ matrix.test_type }} | ||||
|           install-command:  | ||||
|               if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|                 echo "Running core tests, installing dependencies with poetry..." | ||||
|                 poetry install | ||||
|               else | ||||
|                 echo "Running extended tests, installing dependencies with poetry..." | ||||
|                 poetry install -E extended_testing | ||||
|               fi | ||||
|       - name: Run ${{matrix.test_type}} tests | ||||
|         run: | | ||||
|           if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|             make test | ||||
|           else | ||||
|             make extended_tests | ||||
|           fi | ||||
|         shell: bash | ||||
|     name: Python ${{ matrix.python-version }} ${{ matrix.test_type }} | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Set up Python ${{ matrix.python-version }} | ||||
|         uses: "./.github/actions/poetry_setup" | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           poetry-version: "1.4.2" | ||||
|           cache-key: ${{ matrix.test_type }} | ||||
|           install-command: | | ||||
|               if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|                 echo "Running core tests, installing dependencies with poetry..." | ||||
|                 poetry install | ||||
|               else | ||||
|                 echo "Running extended tests, installing dependencies with poetry..." | ||||
|                 poetry install -E extended_testing | ||||
|               fi | ||||
|       - name: Run ${{matrix.test_type}} tests | ||||
|         run: | | ||||
|           if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|             make test | ||||
|           else | ||||
|             make extended_tests | ||||
|           fi | ||||
|         shell: bash | ||||
|   build: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       matrix: | ||||
|         python-version: | ||||
|           - "3.8" | ||||
|           - "3.9" | ||||
|           - "3.10" | ||||
|           - "3.11" | ||||
|         test_type: | ||||
|           - "core" | ||||
|           - "extended" | ||||
|     name: Python ${{ matrix.python-version }} ${{ matrix.test_type }} | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - uses: ./.github/library/setup | ||||
|       - name: Install dependencies | ||||
|       - name: Set up Python ${{ matrix.python-version }} | ||||
|         uses: "./.github/actions/poetry_setup" | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           poetry-version: "1.4.2" | ||||
|           cache-key: ${{ matrix.test_type }} | ||||
|           install-command: | | ||||
|               if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|                 echo "Running core tests, installing dependencies with poetry..." | ||||
|                 poetry install | ||||
|               else | ||||
|                 echo "Running extended tests, installing dependencies with poetry..." | ||||
|                 poetry install -E extended_testing | ||||
|               fi | ||||
|       - name: Run ${{matrix.test_type}} tests | ||||
|         run: | | ||||
|           pip install pytest | ||||
|       - name: Run Python unit tests | ||||
|         run: pytest | ||||
|       - name: Verify that the Docker image for the action builds | ||||
|         run: docker build . --file Dockerfile | ||||
|           if [ "${{ matrix.test_type }}" == "core" ]; then | ||||
|             make test | ||||
|           else | ||||
|             make extended_tests | ||||
|           fi | ||||
|         shell: bash | ||||
| @ -0,0 +1,27 @@ | ||||
| name: Unit Tests | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
| 
 | ||||
| jobs: | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|     steps: | ||||
|       - name: Checkout code | ||||
|         uses: actions/checkout@v4 | ||||
| 
 | ||||
|       - name: Set up Python | ||||
|         uses: actions/setup-python@v5 | ||||
|         with: | ||||
|           python-version: "3.10" | ||||
| 
 | ||||
|       - name: Install dependencies | ||||
|         run: | | ||||
|           pip install -r requirements.txt | ||||
|           pip install pytest | ||||
| 
 | ||||
|       - name: Run unit tests | ||||
|         run: pytest | ||||
| @ -0,0 +1,36 @@ | ||||
| name: build | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: [ main ] | ||||
|   pull_request: | ||||
|     branches: [ main ] | ||||
| 
 | ||||
| jobs: | ||||
| 
 | ||||
|   build: | ||||
| 
 | ||||
|     runs-on: ubuntu-latest | ||||
| 
 | ||||
|     steps: | ||||
|     - uses: actions/checkout@v4 | ||||
| 
 | ||||
|     - name: Setup Python | ||||
|       uses: actions/setup-python@v5 | ||||
|       with: | ||||
|         python-version: '3.9' | ||||
| 
 | ||||
|     - name: Install dependencies | ||||
|       run: | | ||||
|         pip install -r requirements.txt | ||||
|         pip install pytest | ||||
|         pip install swarms | ||||
| 
 | ||||
|     - name: Run Python unit tests | ||||
|       run: pytest | ||||
| 
 | ||||
|     - name: Verify that the Docker image for the action builds | ||||
|       run: docker build . --file Dockerfile | ||||
| 
 | ||||
|     - name: Verify integration test results | ||||
|       run: pytest | ||||
| @ -1,11 +1,13 @@ | ||||
| --- | ||||
| version: 2 | ||||
| 
 | ||||
| build: | ||||
|   os: ubuntu-22.04 | ||||
|   tools: | ||||
|     python: "3.11" | ||||
| 
 | ||||
| mkdocs: | ||||
|   configuration: mkdocs.yml | ||||
| 
 | ||||
| python: | ||||
|    install: | ||||
|    - requirements: requirements.txt | ||||
|  | ||||
| @ -1,6 +0,0 @@ | ||||
| --- | ||||
| formatter: | ||||
|   type: basic | ||||
|   include_document_start: true | ||||
|   max_line_length: 100 | ||||
|   pad_line_comments: 2 | ||||
| @ -1,14 +0,0 @@ | ||||
| --- | ||||
| extends: default | ||||
| 
 | ||||
| rules: | ||||
|   line-length: | ||||
|     max: 127 | ||||
|   truthy: | ||||
|     # GitHub Actions | ||||
|     check-keys: false | ||||
| 
 | ||||
| ignore: | ||||
|   # GH Actions | ||||
|   - lib | ||||
|   - .venv | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -1,2 +0,0 @@ | ||||
| [pytest] | ||||
| testpaths = tests | ||||
| @ -1,10 +0,0 @@ | ||||
| exclude = ["./playground", "./tests", "./scripts"] | ||||
| line-length = 127 | ||||
| 
 | ||||
| [lint] | ||||
| ignore = ["E203"] | ||||
| select = ["E", "F", "W"] | ||||
| 
 | ||||
| [lint.per-file-ignores] | ||||
| "./swarms/prompts/**.py" = ["E501", "W291", "W293"] | ||||
| "./swarms/__init__.py" = ["F401"] | ||||
| @ -0,0 +1,73 @@ | ||||
| # JSON | ||||
| 
 | ||||
| # Contents of test_json.py, which must be placed in the `tests/` directory. | ||||
| 
 | ||||
| import json | ||||
| 
 | ||||
| import pytest | ||||
| 
 | ||||
| from swarms.tokenizers import JSON | ||||
| 
 | ||||
| 
 | ||||
| # Fixture for reusable JSON schema file paths | ||||
| @pytest.fixture | ||||
| def valid_schema_path(tmp_path): | ||||
|     d = tmp_path / "sub" | ||||
|     d.mkdir() | ||||
|     p = d / "schema.json" | ||||
|     p.write_text( | ||||
|         '{"type": "object", "properties": {"name": {"type":' | ||||
|         ' "string"}}}' | ||||
|     ) | ||||
|     return str(p) | ||||
| 
 | ||||
| 
 | ||||
| @pytest.fixture | ||||
| def invalid_schema_path(tmp_path): | ||||
|     d = tmp_path / "sub" | ||||
|     d.mkdir() | ||||
|     p = d / "invalid_schema.json" | ||||
|     p.write_text("this is not a valid JSON") | ||||
|     return str(p) | ||||
| 
 | ||||
| 
 | ||||
| # This test class must be subclassed as JSON class is abstract | ||||
| class TestableJSON(JSON): | ||||
|     def validate(self, data): | ||||
|         # Here must be a real validation implementation for testing | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| # Basic tests | ||||
| def test_initialize_json(valid_schema_path): | ||||
|     json_obj = TestableJSON(valid_schema_path) | ||||
|     assert json_obj.schema_path == valid_schema_path | ||||
|     assert "name" in json_obj.schema["properties"] | ||||
| 
 | ||||
| 
 | ||||
| def test_load_schema_failure(invalid_schema_path): | ||||
|     with pytest.raises(json.JSONDecodeError): | ||||
|         TestableJSON(invalid_schema_path) | ||||
| 
 | ||||
| 
 | ||||
| # Mocking tests | ||||
| def test_validate_calls_method(monkeypatch): | ||||
|     # Mock the validate method to check that it is being called | ||||
|     pass | ||||
| 
 | ||||
| 
 | ||||
| # Exception tests | ||||
| def test_initialize_with_nonexistent_schema(): | ||||
|     with pytest.raises(FileNotFoundError): | ||||
|         TestableJSON("nonexistent_path.json") | ||||
| 
 | ||||
| 
 | ||||
| # Tests on different Python versions if applicable | ||||
| # ... | ||||
| 
 | ||||
| 
 | ||||
| # Grouping tests marked as slow if they perform I/O operations | ||||
| @pytest.mark.slow | ||||
| def test_loading_large_schema(): | ||||
|     # Test with a large json file | ||||
|     pass | ||||
					Loading…
					
					
				
		Reference in new issue