Skip to content

Commit 2c8738f

Browse files
authored
chore: update workflows, examples, tests, readmes for api keys v2 (#514)
* chore: update workflows, examples, tests, readmes for api keys v2 * chore: update examples readme for new env vars * ci: momento-local tests continuing to use v1 key for setup * chore: address dependency review warning * ci: momento local setup requires all the env vars * chore: bump min supported python version in examples to address dep review * chore: another bump for another dep review warning * add comment about timeout in topics examples, run topic_publish in CI
1 parent d34001b commit 2c8738f

33 files changed

Lines changed: 1197 additions & 250 deletions

.github/workflows/momento-local-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
runs-on: ${{ matrix.os }}
1414

1515
env:
16-
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
16+
MOMENTO_API_KEY: ${{ secrets.ALPHA_API_KEY_V2 }}
17+
MOMENTO_ENDPOINT: "cell-alpha-dev.preprod.a.momentohq.com"
18+
V1_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
1719
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
1820

1921
steps:

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
pull_request:
55
branches: [main]
66

7+
env:
8+
V1_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
9+
MOMENTO_API_KEY: ${{ secrets.ALPHA_API_KEY_V2 }}
10+
MOMENTO_ENDPOINT: "cell-alpha-dev.preprod.a.momentohq.com"
11+
712
jobs:
813
test:
914
strategy:
@@ -15,7 +20,6 @@ jobs:
1520
runs-on: ${{ matrix.os }}
1621

1722
env:
18-
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
1923
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
2024

2125
steps:
@@ -78,10 +82,6 @@ jobs:
7882
# the cache for one job in another job.
7983
max-parallel: 1
8084

81-
env:
82-
# TODO: remove token stored as secret in favor of using a
83-
# momento-local instance that can be spun up for testing
84-
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
8585
steps:
8686
- uses: actions/checkout@v3
8787

@@ -139,6 +139,7 @@ jobs:
139139
poetry run python -m ${{ matrix.package }}.quickstart
140140
poetry run python -m ${{ matrix.package }}.example
141141
poetry run python -m ${{ matrix.package }}.example_async
142+
poetry run python -m ${{ matrix.package }}.topic_publish
142143
143144
- name: Run docs samples for python >= 3.10
144145
id: docs-ex-validation

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ poetry run isort .
169169

170170
## Tests :zap:
171171

172-
Integration tests require an api key for testing. Set the env var `TEST_API_KEY` to
172+
Integration tests require an api key for testing. Set the env vars `MOMENTO_API_KEY` and `MOMENTO_ENDPOINT` to
173173
provide it. The env `TEST_CACHE_NAME` is also required, but for now any string value works.
174174

175175
Example of running tests against all python versions:
176176

177177
```
178-
TEST_API_KEY=<api key> TEST_CACHE_NAME=<cache name> poetry run pytest
178+
MOMENTO_API_KEY=<api key> MOMENTO_ENDPOINT=<endpoint> TEST_CACHE_NAME=<cache name> poetry run pytest
179179
```
180180

181181
### For M1 Users
@@ -188,7 +188,7 @@ a github issue with us to let us know. And in the meantime you can work around
188188
issue by installing Rosetta 2 and re-running with:
189189

190190
```
191-
arch -x86_64 TEST_API_KEY=<api key> TEST_CACHE_NAME=<cache name> poetry run pytest
191+
arch -x86_64 MOMENTO_API_KEY=<api key> MOMENTO_ENDPOINT=<endpoint> TEST_CACHE_NAME=<cache name> poetry run pytest
192192
```
193193

194194
### Developing new test cases?

examples/README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _Read this in other languages_: [日本語](README.ja.md)
99

1010
- [Python 3.7 or above is required](https://www.python.org/downloads/)
1111
- To get started with Momento you will need a Momento API key. You can get one from the [Momento Console](https://console.gomomento.com).
12+
- A Momento service endpoint is required. You can find a [list of them here](https://docs.momentohq.com/platform/regions)
1213
- Developer libraries (gcc/python dev headers) installed on machine you intend to run on
1314

1415
**Amazon Linux**
@@ -44,29 +45,29 @@ poetry install
4445
To run the python version 3.10+ examples:
4546

4647
```bash
47-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example
48-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example_async
48+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m py310.example
49+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m py310.example_async
4950
```
5051

5152
To run the examples with SDK debug logging enabled:
5253

5354
```bash
54-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example
55-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m py310.example_async
55+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m py310.example
56+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m py310.example_async
5657
```
5758

5859
To run the python version <3.10 examples:
5960

6061
```bash
61-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example
62-
MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example_async
62+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m prepy310.example
63+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m prepy310.example_async
6364
```
6465

6566
To run the examples with SDK debug logging enabled:
6667

6768
```bash
68-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example
69-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> poetry run python -m prepy310.example_async
69+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m prepy310.example
70+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m prepy310.example_async
7071
```
7172

7273
## Running the Example Using pip
@@ -80,29 +81,29 @@ pip install -r requirements.txt
8081
To run the python version 3.10+ examples:
8182

8283
```bash
83-
MOMENTO_API_KEY=<YOUR_API_KEY> python -m py310.example
84-
MOMENTO_API_KEY=<YOUR_API_KEY> python -m py310.example_async
84+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m py310.example
85+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m py310.example_async
8586
```
8687

8788
To run the examples with SDK debug logging enabled:
8889

8990
```bash
90-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m py310.example
91-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m py310.example_async
91+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m py310.example
92+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m py310.example_async
9293
```
9394

9495
To run the python version <3.10 examples:
9596

9697
```bash
97-
MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example
98-
MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example_async
98+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m prepy310.example
99+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m prepy310.example_async
99100
```
100101

101102
To run the examples with SDK debug logging enabled:
102103

103104
```bash
104-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example
105-
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> python -m prepy310.example_async
105+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m prepy310.example
106+
DEBUG=true MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> python -m prepy310.example_async
106107
```
107108

108109
## Running the load generator example
@@ -135,7 +136,7 @@ To run the load generator:
135136

136137
```bash
137138
# Run example load generator
138-
MOMENTO_API_KEY=<YOUR AUTH TOKEN> poetry run python -m py310.example_load_gen
139+
MOMENTO_API_KEY=<YOUR_API_KEY> MOMENTO_ENDPOINT=<YOUR_ENDPOINT> poetry run python -m py310.example_load_gen
139140
```
140141

141142
You can check out the example code in [example_load_gen.py](py310/example_load_gen.py). The configurable

examples/observability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
example_observability_setup_tracing()
1010

11-
_AUTH_PROVIDER = CredentialProvider.from_environment_variable("MOMENTO_API_KEY")
11+
_AUTH_PROVIDER = CredentialProvider.from_environment_variables_v2()
1212
_ITEM_DEFAULT_TTL_SECONDS = timedelta(seconds=60)
1313
_CACHE_NAME = "test-cache"
1414
_KEY = "test-key"

0 commit comments

Comments
 (0)