Skip to content

Commit c857011

Browse files
2 parents 44b020c + 7a59011 commit c857011

File tree

80 files changed

+287
-6512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+287
-6512
lines changed

.github/workflows/on-pull-request-mvi.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/on-pull-request.yml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@ on:
66

77
jobs:
88
test:
9-
runs-on: ubuntu-20.04
109
strategy:
1110
matrix:
12-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
11+
# TODO: one of the examples dependencies does not support 3.11
12+
os: [ubuntu-24.04]
13+
python-version: ["3.9", "3.10", "3.11"]
1314
new-python-protobuf: ["true"]
1415
include:
16+
# 3.7 and 3.8 are no longer available on ubuntu-24.04
17+
# We run on 20.04 which was the last version where this worked.
18+
# If support for 20.04 becomes an issue, we can install 3.7 and 3.8
19+
# with pyenv or manually.
20+
- python-version: "3.7"
21+
new-python-protobuf: "true"
22+
os: ubuntu-20.04
1523
- python-version: "3.7"
1624
new-python-protobuf: "false"
25+
os: ubuntu-20.04
26+
- python-version: "3.8"
27+
new-python-protobuf: "true"
28+
os: ubuntu-20.04
29+
runs-on: ${{ matrix.os }}
1730

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

2335
steps:
2436
- uses: actions/checkout@v3
@@ -33,12 +45,11 @@ jobs:
3345
with:
3446
python-version: ${{ matrix.python-version }}
3547

36-
- name: Bootstrap poetry
37-
run: |
38-
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
39-
40-
- name: Configure poetry
41-
run: poetry config virtualenvs.in-project true
48+
- name: Install and configure Poetry
49+
uses: snok/install-poetry@v1
50+
with:
51+
version: 1.3.1
52+
virtualenvs-in-project: true
4253

4354
- name: Install dependencies
4455
run: poetry install
@@ -60,18 +71,14 @@ jobs:
6071
run: poetry run ruff format --check --diff src tests
6172

6273
- name: Run tests
63-
run: poetry run pytest -p no:sugar -q --ignore=tests/momento/vector_index_client
74+
run: poetry run pytest -p no:sugar -q
6475

6576
test-examples:
66-
runs-on: ubuntu-20.04
77+
runs-on: ubuntu-24.04
6778
strategy:
6879
matrix:
6980
# TODO: one of the examples dependencies does not support 3.11
7081
include:
71-
- python-version: "3.7"
72-
package: prepy310
73-
- python-version: "3.8"
74-
package: prepy310
7582
- python-version: "3.9"
7683
package: prepy310
7784
- python-version: "3.10"
@@ -89,10 +96,18 @@ jobs:
8996
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
9097
steps:
9198
- uses: actions/checkout@v3
99+
100+
- name: Install and configure Poetry
101+
uses: snok/install-poetry@v1
102+
with:
103+
version: 1.3.1
104+
virtualenvs-in-project: true
105+
92106
- name: Python SDK sample
93107
uses: actions/setup-python@v4
94108
with:
95109
python-version: ${{ matrix.python-version }}
110+
cache: poetry
96111

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

109-
- name: Bootstrap poetry
110-
run: |
111-
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
112-
113-
- name: Configure poetry
114-
run: poetry config virtualenvs.in-project true
115-
116124
- name: Install dependencies
117125
working-directory: ./examples
118126
run: poetry install

.github/workflows/on-push-to-main-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
build:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-24.04
1010

1111
steps:
1212
- name: Setup repo

.github/workflows/on-push-to-release-branch.yml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
release:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-24.04
1010
outputs:
1111
version: ${{ steps.release.outputs.release }}
1212
steps:
@@ -30,18 +30,33 @@ jobs:
3030
run: echo "::set-output name=release::${{ steps.semrel.outputs.version }}"
3131

3232
test:
33-
runs-on: ubuntu-20.04
3433
strategy:
3534
matrix:
36-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
35+
os: [ubuntu-20.04]
36+
python-version: ["3.9", "3.10", "3.11"]
3737
new-python-protobuf: ["true"]
3838
include:
39+
# 3.7 and 3.8 are no longer available on ubuntu-24.04
40+
# We run on 20.04 which was the last version where this worked.
41+
# If support for 20.04 becomes an issue, we can install 3.7 and 3.8
42+
# with pyenv or manually.
3943
- python-version: "3.7"
44+
new-python-protobuf: "true"
45+
os: ubuntu-20.04
46+
- python-version: "3.7"
47+
new-python-protobuf: "false"
48+
os: ubuntu-20.04
49+
- python-version: "3.8"
50+
new-python-protobuf: "true"
51+
os: ubuntu-20.04
52+
- python-version: "3.8"
4053
new-python-protobuf: "false"
54+
os: ubuntu-20.04
55+
runs-on: ${{ matrix.os }}
56+
4157
env:
4258
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
4359
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
44-
TEST_VECTOR_INDEX_NAME: python-integration-test-vector-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
4560

4661
steps:
4762
- uses: actions/checkout@v3
@@ -51,12 +66,11 @@ jobs:
5166
with:
5267
python-version: ${{ matrix.python-version }}
5368

54-
- name: Bootstrap poetry
55-
run: |
56-
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
57-
58-
- name: Configure poetry
59-
run: poetry config virtualenvs.in-project true
69+
- name: Install and configure Poetry
70+
uses: snok/install-poetry@v1
71+
with:
72+
version: 1.3.1
73+
virtualenvs-in-project: true
6074

6175
- name: Install dependencies
6276
run: poetry install
@@ -78,24 +92,26 @@ jobs:
7892
run: poetry run ruff format --diff src tests
7993

8094
- name: Run tests
81-
run: poetry run pytest -p no:sugar -q --ignore=tests/momento/vector_index_client
95+
run: poetry run pytest -p no:sugar -q
8296

8397
publish:
84-
runs-on: ubuntu-20.04
98+
runs-on: ubuntu-24.04
8599
needs: [release, test]
86100

87101
steps:
88102
- uses: actions/checkout@v3
89103

104+
- name: Install and configure Poetry
105+
uses: snok/install-poetry@v1
106+
with:
107+
version: 1.3.1
108+
virtualenvs-in-project: true
109+
90110
- name: Setup Python 3.10
91111
uses: actions/setup-python@v4
92112
with:
93113
python-version: "3.10"
94114

95-
- name: Bootstrap poetry
96-
run: |
97-
curl -sL https://install.python-poetry.org | python - -y --version 1.3.1
98-
99115
- name: Bump version
100116
run: poetry version ${{ needs.release.outputs.version }}
101117

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ lint:
2727
do-gen-sync:
2828
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_control_client.py src/momento/internal/synchronous/_scs_control_client.py
2929
@poetry run python src/momento/internal/codegen.py src/momento/internal/aio/_scs_data_client.py src/momento/internal/synchronous/_scs_data_client.py
30-
@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
31-
@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
3230
@poetry run python src/momento/internal/codegen.py src/momento/cache_client_async.py src/momento/cache_client.py
33-
@poetry run python src/momento/internal/codegen.py src/momento/vector_index_client_async.py src/momento/vector_index_client.py
3431
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/shared_behaviors_async.py tests/momento/cache_client/shared_behaviors.py
3532
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_init_async.py tests/momento/cache_client/test_init.py
3633
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_control_async.py tests/momento/cache_client/test_control.py
@@ -40,8 +37,6 @@ do-gen-sync:
4037
@poetry run python src/momento/internal/codegen.py tests/momento/cache_client/test_set_async.py tests/momento/cache_client/test_set.py
4138
@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
4239
@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
43-
@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
44-
@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
4540

4641
.PHONY: gen-sync
4742
## Generate synchronous code and tests from asynchronous code.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To get started with Momento you will need a Momento Auth Token. You can get one
1616
* Website: [https://www.gomomento.com/](https://www.gomomento.com/)
1717
* Momento Documentation: [https://docs.momentohq.com/](https://docs.momentohq.com/)
1818
* Getting Started: [https://docs.momentohq.com/getting-started](https://docs.momentohq.com/getting-started)
19-
* Python SDK Documentation: [https://docs.momentohq.com/develop/sdks/python](https://docs.momentohq.com/develop/sdks/python)
19+
* Python SDK Documentation: [https://docs.momentohq.com/sdks/python](https://docs.momentohq.com/sdks/python)
2020
* Discuss: [Momento Discord](https://discord.gg/3HkAKjUZGq)
2121

2222
## Packages

examples/README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example
4848
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example_async
4949
```
5050

51-
To run the python version 3.10+ vector index examples:
52-
53-
```bash
54-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.vector_index
55-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.vector_index_async
56-
```
57-
5851
To run the examples with SDK debug logging enabled:
5952

6053
```bash
@@ -69,13 +62,6 @@ MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example
6962
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example_async
7063
```
7164

72-
To run the python version <3.10 vector index examples:
73-
74-
```bash
75-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.vector_index
76-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.vector_index_async
77-
```
78-
7965
To run the examples with SDK debug logging enabled:
8066

8167
```bash
@@ -119,12 +105,6 @@ DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example
119105
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example_async
120106
```
121107

122-
To run the vector index example:
123-
124-
```bash
125-
MOMENTO_API_KEY=<YOUR_API_KEY> python -m vector_index.example
126-
```
127-
128108
## Running the load generator example
129109

130110
This repo includes a very basic load generator, to allow you to experiment

examples/lambda/README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The primary use is to provide a base for testing Momento in an AWS lambda enviro
1919
- Node version 14 or higher is required (for deploying the Cloudformation stack containing the Lambda)
2020
- 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.
2121

22-
## Deploying the Momento Python Lambda
22+
## Deploying the Momento Python Lambda with Docker and AWS CDK
2323

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

4343
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.
4444

45-
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.
45+
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.
46+
47+
## Deploying the Momento Python Lambda as a Zip File on AWS Lambda with the AWS Management Console
48+
49+
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.
50+
51+
Follow these steps to create the zip and deploy it to AWS Lambda using the AWS Management Console:
52+
53+
1. Run `make dist` in the `zip` directory to package the lambda for upload as `dist.zip`.
54+
55+
> :bulb: **Tip**: Check out the Makefile for important build steps to package for AWS Lambda.
56+
57+
2. Create a new Lambda function by selecting "Author from scratch".
58+
3. Set the function name to `momento-lambda-demo`.
59+
4. Choose the runtime as `Python 3.8` (you can adjust this as desired).
60+
5. Select the architecture as `x86_64`.
61+
6. Click on "Create function" to create the Lambda function.
62+
7. In the "Code" tab, choose "Upload from the zip" as the code source.
63+
8. Under "Runtime settings", set the Handler to index.handler.
64+
9. Switch to the "Configuration" tab.
65+
10. Set the environment variable `MOMENTO_API_KEY` to your API key.
66+
11. Finally, go to the "Test" tab to test your Lambda function.

examples/lambda/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ WORKDIR /var/task
44

55
# Copy the lambda and the requirements file
66
COPY lambda/index.py .
7-
COPY lambda/aws_requirements.txt .
7+
COPY lambda/requirements.txt .
88

99
# Install Python dependencies
10-
RUN pip install -r aws_requirements.txt -t .
10+
RUN pip install -r requirements.txt -t .
1111

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

0 commit comments

Comments
 (0)