diff --git a/.github/workflows/black_format.yml b/.github/workflows/black_format.yml index e381ee8a..7e5bcce7 100644 --- a/.github/workflows/black_format.yml +++ b/.github/workflows/black_format.yml @@ -13,22 +13,12 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main with: python-version: "3.11" - - - name: Install poetry - run: pip install poetry - - - name: Set Poetry config - run: | - poetry config virtualenvs.in-project false - poetry config virtualenvs.path ~/.virtualenvs - - - name: Install dependencies using Poetry - run: | - poetry install -E dev + poetry-version: "1.7.1" + install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands - name: Run Black run: poetry run black --check . -l 140 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fd91587..fac169d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,21 +8,17 @@ on: jobs: check_main: runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v2 + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main with: - python-version: '3.10.10' # Use the version of Python you need - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e . + python-version: "3.11" + poetry-version: "1.7.1" + install-args: "--all-extras" - name: Run main.py with input run: | - echo -e "\n\n\nn" | python main.py + echo -e "\n\n\nn" | poetry run python main.py diff --git a/.github/workflows/poetry-publish-nightly.yml b/.github/workflows/poetry-publish-nightly.yml index be482256..357c04a9 100644 --- a/.github/workflows/poetry-publish-nightly.yml +++ b/.github/workflows/poetry-publish-nightly.yml @@ -29,14 +29,13 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v2 + + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main with: - python-version: 3.11 - - name: Install poetry - run: | - curl -sSL https://install.python-poetry.org | python3 - - echo "$HOME/.local/bin" >> $GITHUB_PATH + python-version: "3.11" + poetry-version: "1.7.1" + - name: Set release version run: | # Extract the version number from pyproject.toml using awk @@ -49,12 +48,14 @@ jobs: sed -i "s/__version__ = '.*'/__version__ = '${NIGHTLY_VERSION}'/g" memgpt/__init__.py cat pyproject.toml cat memgpt/__init__.py + - name: Configure poetry - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_NIGHTLY_TOKEN }} + env: + PYPI_NIGHTLY_TOKEN: ${{ secrets.PYPI_NIGHTLY_TOKEN }} + run: poetry config pypi-token.pypi "$PYPI_NIGHTLY_TOKEN" + - name: Build the Python package run: poetry build + - name: Publish the package to PyPI - run: poetry publish - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_NIGHTLY_TOKEN }} + run: poetry publish \ No newline at end of file diff --git a/.github/workflows/poetry-publish.yml b/.github/workflows/poetry-publish.yml index f16b1af0..6e3d9ecb 100644 --- a/.github/workflows/poetry-publish.yml +++ b/.github/workflows/poetry-publish.yml @@ -11,20 +11,21 @@ jobs: steps: - name: Check out the repository uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v2 + + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main with: - python-version: 3.11 - - name: Install poetry - run: | - curl -sSL https://install.python-poetry.org | python3 - - echo "$HOME/.local/bin" >> $GITHUB_PATH + python-version: "3.11" + poetry-version: "1.7.1" + - name: Configure poetry + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry config pypi-token.pypi "$PYPI_TOKEN" + - name: Build the Python package run: poetry build + - name: Publish the package to PyPI - run: poetry publish - env: - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish \ No newline at end of file diff --git a/.github/workflows/rdme-openapi.yml b/.github/workflows/rdme-openapi.yml index e5755eae..a8c942da 100644 --- a/.github/workflows/rdme-openapi.yml +++ b/.github/workflows/rdme-openapi.yml @@ -17,27 +17,12 @@ jobs: - name: Check out repo 📚 uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main with: python-version: "3.11" - - - name: Install poetry - run: pip install poetry - - - name: Set Poetry config - run: | - poetry config virtualenvs.in-project false - poetry config virtualenvs.path ~/.virtualenvs - - - name: Install dependencies using Poetry - run: | - poetry install --all-extras - - - name: Set Poetry config - run: | - poetry config virtualenvs.in-project false - poetry config virtualenvs.path ~/.virtualenvs + poetry-version: "1.7.1" + install-args: "--all-extras" - name: Generate openapi.json file run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bd4e95a..8b6284fb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,15 +12,8 @@ on: jobs: test: - runs-on: ubuntu-latest - - env: - PGVECTOR_TEST_DB_URL: postgresql+pg8000://memgpt:memgpt@localhost:8888/memgpt - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - timeout-minutes: 15 - steps: - name: Checkout uses: actions/checkout@v4 @@ -33,26 +26,18 @@ jobs: with: python-version: "3.11" poetry-version: "1.7.1" - - - name: Set Poetry config - run: | - poetry config virtualenvs.in-project false - poetry config virtualenvs.path ~/.virtualenvs - - - name: Install dependencies using Poetry - run: | - poetry install --all-extras + install-args: "--all-extras" - name: Run tests with pytest env: PGVECTOR_TEST_DB_URL: postgresql+pg8000://memgpt:memgpt@localhost:8888/memgpt OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - PGVECTOR_TEST_DB_URL=postgresql+pg8000://memgpt:memgpt@localhost:8888/memgpt OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} poetry run pytest -s -vv -k "not test_storage" tests + poetry run pytest -s -vv -k "not test_storage" tests - name: Run storage tests env: PGVECTOR_TEST_DB_URL: postgresql+pg8000://memgpt:memgpt@localhost:8888/memgpt OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - PGVECTOR_TEST_DB_URL=postgresql+pg8000://memgpt:memgpt@localhost:8888/memgpt OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} poetry run pytest -s -vv tests/test_storage.py + poetry run pytest -s -vv tests/test_storage.py diff --git a/tests/test_cli.py b/tests/test_cli.py index 19e3dc5a..37e03dce 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -21,7 +21,7 @@ def test_save_load(): else: client = MemGPT(quickstart="memgpt_hosted") - child = pexpect.spawn("memgpt run --agent test_save_load --first --strip-ui") + child = pexpect.spawn("poetry run memgpt run --agent test_save_load --first --strip-ui") child.expect("Enter your message:", timeout=TIMEOUT) child.sendline() @@ -37,7 +37,7 @@ def test_save_load(): assert child.isalive() is False, "CLI should have terminated." assert child.exitstatus == 0, "CLI did not exit cleanly." - child = pexpect.spawn("memgpt run --agent test_save_load --first --strip-ui") + child = pexpect.spawn("poetry run memgpt run --agent test_save_load --first --strip-ui") child.expect("Using existing agent test_save_load", timeout=TIMEOUT) child.expect("Enter your message:", timeout=TIMEOUT) child.sendline("/exit")