Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
2 parents 44b020c + 7a59011 commit c857011
Show file tree
Hide file tree
Showing 80 changed files with 287 additions and 6,512 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/on-pull-request-mvi.yml

This file was deleted.

52 changes: 30 additions & 22 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
# TODO: one of the examples dependencies does not support 3.11
os: [ubuntu-24.04]
python-version: ["3.9", "3.10", "3.11"]
new-python-protobuf: ["true"]
include:
# 3.7 and 3.8 are no longer available on ubuntu-24.04
# We run on 20.04 which was the last version where this worked.
# If support for 20.04 becomes an issue, we can install 3.7 and 3.8
# with pyenv or manually.
- python-version: "3.7"
new-python-protobuf: "true"
os: ubuntu-20.04
- python-version: "3.7"
new-python-protobuf: "false"
os: ubuntu-20.04
- python-version: "3.8"
new-python-protobuf: "true"
os: ubuntu-20.04
runs-on: ${{ matrix.os }}

env:
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
TEST_VECTOR_INDEX_NAME: python-integration-test-vector-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}

steps:
- uses: actions/checkout@v3
Expand All @@ -33,12 +45,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true

- name: Install dependencies
run: poetry install
Expand All @@ -60,18 +71,14 @@ jobs:
run: poetry run ruff format --check --diff src tests

- name: Run tests
run: poetry run pytest -p no:sugar -q --ignore=tests/momento/vector_index_client
run: poetry run pytest -p no:sugar -q

test-examples:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
# TODO: one of the examples dependencies does not support 3.11
include:
- python-version: "3.7"
package: prepy310
- python-version: "3.8"
package: prepy310
- python-version: "3.9"
package: prepy310
- python-version: "3.10"
Expand All @@ -89,10 +96,18 @@ jobs:
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v3

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true

- name: Python SDK sample
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Verify README generation
uses: momentohq/standards-and-practices/github-actions/oss-readme-template@gh-actions-v2
Expand All @@ -106,13 +121,6 @@ jobs:
template_file: ./README.template.md
output_file: ./README.md

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Install dependencies
working-directory: ./examples
run: poetry install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-to-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- name: Setup repo
Expand Down
48 changes: 32 additions & 16 deletions .github/workflows/on-push-to-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
release:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.release.outputs.release }}
steps:
Expand All @@ -30,18 +30,33 @@ jobs:
run: echo "::set-output name=release::${{ steps.semrel.outputs.version }}"

test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-20.04]
python-version: ["3.9", "3.10", "3.11"]
new-python-protobuf: ["true"]
include:
# 3.7 and 3.8 are no longer available on ubuntu-24.04
# We run on 20.04 which was the last version where this worked.
# If support for 20.04 becomes an issue, we can install 3.7 and 3.8
# with pyenv or manually.
- python-version: "3.7"
new-python-protobuf: "true"
os: ubuntu-20.04
- python-version: "3.7"
new-python-protobuf: "false"
os: ubuntu-20.04
- python-version: "3.8"
new-python-protobuf: "true"
os: ubuntu-20.04
- python-version: "3.8"
new-python-protobuf: "false"
os: ubuntu-20.04
runs-on: ${{ matrix.os }}

env:
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
TEST_VECTOR_INDEX_NAME: python-integration-test-vector-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}

steps:
- uses: actions/checkout@v3
Expand All @@ -51,12 +66,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true

- name: Install dependencies
run: poetry install
Expand All @@ -78,24 +92,26 @@ jobs:
run: poetry run ruff format --diff src tests

- name: Run tests
run: poetry run pytest -p no:sugar -q --ignore=tests/momento/vector_index_client
run: poetry run pytest -p no:sugar -q

publish:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: [release, test]

steps:
- uses: actions/checkout@v3

- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
- name: Bump version
run: poetry version ${{ needs.release.outputs.version }}

Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ lint:
do-gen-sync:
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_control_client.py src/momento/internal/synchronous/_scs_control_client.py
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_data_client.py src/momento/internal/synchronous/_scs_data_client.py
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_vector_index_control_client.py src/momento/internal/synchronous/_vector_index_control_client.py
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_vector_index_data_client.py src/momento/internal/synchronous/_vector_index_data_client.py
@poetry run python src/momento/internal/codegen.py src/momento/cache_client_async.py src/momento/cache_client.py
@poetry run python src/momento/internal/codegen.py src/momento/vector_index_client_async.py src/momento/vector_index_client.py
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/shared_behaviors_async.py tests/momento/cache_client/shared_behaviors.py
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_init_async.py tests/momento/cache_client/test_init.py
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_control_async.py tests/momento/cache_client/test_control.py
Expand All @@ -40,8 +37,6 @@ do-gen-sync:
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_set_async.py tests/momento/cache_client/test_set.py
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_sorted_set_async.py tests/momento/cache_client/test_sorted_set.py
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_sorted_set_simple_async.py tests/momento/cache_client/test_sorted_set_simple.py
@poetry run python src/momento/internal/codegen.py tests/momento/vector_index_client/test_control_async.py tests/momento/vector_index_client/test_control.py
@poetry run python src/momento/internal/codegen.py tests/momento/vector_index_client/test_data_async.py tests/momento/vector_index_client/test_data.py

.PHONY: gen-sync
## Generate synchronous code and tests from asynchronous code.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To get started with Momento you will need a Momento Auth Token. You can get one
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
* Python SDK Documentation: [https://docs.momentohq.com/develop/sdks/python](https://docs.momentohq.com/develop/sdks/python)
* Python SDK Documentation: [https://docs.momentohq.com/sdks/python](https://docs.momentohq.com/sdks/python)
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)

## Packages
Expand Down
20 changes: 0 additions & 20 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example_async
```

To run the python version 3.10+ vector index examples:

```bash
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.vector_index
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.vector_index_async
```

To run the examples with SDK debug logging enabled:

```bash
Expand All @@ -69,13 +62,6 @@ MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example_async
```

To run the python version <3.10 vector index examples:

```bash
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.vector_index
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.vector_index_async
```

To run the examples with SDK debug logging enabled:

```bash
Expand Down Expand Up @@ -119,12 +105,6 @@ DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example_async
```

To run the vector index example:

```bash
MOMENTO_API_KEY=<YOUR_API_KEY> python -m vector_index.example
```

## Running the load generator example

This repo includes a very basic load generator, to allow you to experiment
Expand Down
25 changes: 23 additions & 2 deletions examples/lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The primary use is to provide a base for testing Momento in an AWS lambda enviro
- Node version 14 or higher is required (for deploying the Cloudformation stack containing the Lambda)
- To get started with Momento you will need a Momento Auth Token. You can get one from the [Momento Console](https://console.gomomento.com). Check out the [getting started](https://docs.momentohq.com/getting-started) guide for more information on obtaining an auth token.

## Deploying the Momento Python Lambda
## Deploying the Momento Python Lambda with Docker and AWS CDK

The source code for the CDK application lives in the `infrastructure` directory.
To build and deploy it you will first need to install the dependencies:
Expand All @@ -42,4 +42,25 @@ npm run cdk deploy

The lambda does not set up a way to access itself externally, so to run it, you will have to go to `MomentoDockerLambda` in AWS Lambda and run a test.

The lambda is set up to make set and get calls for the key 'key' in the cache 'cache'. You can play around with the code by changing the `docker/lambda/index.py` file. Remember to update `docker/lambda/aws_requirements.txt` file if you add additional Python dependencies.
The lambda is set up to make set and get calls for the key 'key' in the cache 'cache'. You can play around with the code by changing the `docker/lambda/index.py` file. Remember to update `docker/lambda/aws_requirements.txt` file if you add additional Python dependencies.

## Deploying the Momento Python Lambda as a Zip File on AWS Lambda with the AWS Management Console

Alternatively, we can deploy the Momento Python Lambda as a Zip File on AWS Lambda. We can do this using the `zip` directory in this example.

Follow these steps to create the zip and deploy it to AWS Lambda using the AWS Management Console:

1. Run `make dist` in the `zip` directory to package the lambda for upload as `dist.zip`.

> :bulb: **Tip**: Check out the Makefile for important build steps to package for AWS Lambda.
2. Create a new Lambda function by selecting "Author from scratch".
3. Set the function name to `momento-lambda-demo`.
4. Choose the runtime as `Python 3.8` (you can adjust this as desired).
5. Select the architecture as `x86_64`.
6. Click on "Create function" to create the Lambda function.
7. In the "Code" tab, choose "Upload from the zip" as the code source.
8. Under "Runtime settings", set the Handler to index.handler.
9. Switch to the "Configuration" tab.
10. Set the environment variable `MOMENTO_API_KEY` to your API key.
11. Finally, go to the "Test" tab to test your Lambda function.
4 changes: 2 additions & 2 deletions examples/lambda/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ WORKDIR /var/task

# Copy the lambda and the requirements file
COPY lambda/index.py .
COPY lambda/aws_requirements.txt .
COPY lambda/requirements.txt .

# Install Python dependencies
RUN pip install -r aws_requirements.txt -t .
RUN pip install -r requirements.txt -t .

# Set the CMD to your lambda (could also be done as a parameter override outside of the Dockerfile)
CMD ["index.handler"]
Expand Down
Loading

0 comments on commit c857011

Please sign in to comment.