Skip to content

Commit 62cedd1

Browse files
committed
chore: update workflows, examples, tests, readmes for api keys v2
1 parent d34001b commit 62cedd1

32 files changed

Lines changed: 1027 additions & 89 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ 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 }}
1717
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
1818

1919
steps:

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616

1717
env:
18-
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
18+
MOMENTO_API_KEY: ${{ secrets.ALPHA_API_KEY_V2 }}
19+
MOMENTO_ENDPOINT: "cell-alpha-dev.preprod.a.momentohq.com"
20+
V1_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
1921
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
2022

2123
steps:
@@ -79,9 +81,9 @@ jobs:
7981
max-parallel: 1
8082

8183
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 }}
84+
V1_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
85+
MOMENTO_API_KEY: ${{ secrets.ALPHA_API_KEY_V2 }}
86+
MOMENTO_ENDPOINT: "cell-alpha-dev.preprod.a.momentohq.com"
8587
steps:
8688
- uses: actions/checkout@v3
8789

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/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"

examples/poetry.lock

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prepy310/example.py

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

77
from example_utils.example_logging import initialize_logging
88

9-
_AUTH_PROVIDER = CredentialProvider.from_environment_variable("MOMENTO_API_KEY")
9+
_AUTH_PROVIDER = CredentialProvider.from_environment_variables_v2()
1010
_CACHE_NAME = "cache"
1111
_ITEM_DEFAULT_TTL_SECONDS = timedelta(seconds=60)
1212
_KEY = "MyKey"

examples/prepy310/example_async.py

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

88
from example_utils.example_logging import initialize_logging
99

10-
_AUTH_PROVIDER = CredentialProvider.from_environment_variable("MOMENTO_API_KEY")
10+
_AUTH_PROVIDER = CredentialProvider.from_environment_variables_v2()
1111
_CACHE_NAME = "cache"
1212
_ITEM_DEFAULT_TTL_SECONDS = timedelta(seconds=60)
1313
_KEY = "MyKey"

examples/prepy310/quickstart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
cache_name = "default-cache"
88
with CacheClient.create(
99
configuration=Configurations.Laptop.v1(),
10-
credential_provider=CredentialProvider.from_environment_variable("MOMENTO_API_KEY"),
10+
credential_provider=CredentialProvider.from_environment_variables_v2(),
1111
default_ttl=timedelta(seconds=60),
1212
) as cache_client:
1313
create_cache_response = cache_client.create_cache(cache_name)

examples/prepy310/readme.py

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

66
cache_client = CacheClient(
77
configuration=Configurations.Laptop.v1(),
8-
credential_provider=CredentialProvider.from_environment_variable("MOMENTO_API_KEY"),
8+
credential_provider=CredentialProvider.from_environment_variables_v2(),
99
default_ttl=timedelta(seconds=60),
1010
)
1111
cache_client.create_cache("cache")

examples/prepy310/topic_publish.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from example_utils.example_logging import initialize_logging
1414

15-
_AUTH_PROVIDER = CredentialProvider.from_environment_variable("MOMENTO_API_KEY")
15+
_AUTH_PROVIDER = CredentialProvider.from_environment_variables_v2()
1616
_CACHE_NAME = "cache"
1717
_logger = logging.getLogger("topic-publish-example")
1818

@@ -28,7 +28,9 @@ def main() -> None:
2828
initialize_logging()
2929
setup_cache()
3030
_logger.info("hello")
31-
with TopicClient(TopicConfigurations.Default.v1(), _AUTH_PROVIDER) as client:
31+
with TopicClient(
32+
TopicConfigurations.Default.v1().with_client_timeout(timedelta(seconds=10)), _AUTH_PROVIDER
33+
) as client:
3234
response = client.publish("cache", "my_topic", "my_value")
3335
if isinstance(response, TopicPublish.Error):
3436
print("error: ", response.message)

0 commit comments

Comments
 (0)