Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ momento-wire-types = "^0.106.0"
grpcio = "^1.46.0"
# note if you bump this presigned url test need be updated
pyjwt = "^2.4.0"
# Need a lower bound of 4 to be compatible with python 3.7 flake8
importlib-metadata = { version = ">=4", python = "<3.8" }

[tool.poetry.group.test.dependencies]
pytest = "^7.1.3"
Expand Down Expand Up @@ -111,11 +109,6 @@ module = [
]
disallow_any_expr = false

[[tool.mypy.overrides]]
# this file has mypy incompatibilities between py37 and later versions
module = "momento.internal._utilities._momento_version"
ignore_errors = true

[[tool.mypy.overrides]]
# reading an enum in a protobuf generated class
module = "momento.internal._utilities._permissions"
Expand Down
1 change: 0 additions & 1 deletion src/momento/internal/_utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
_validate_topic_name,
_validate_ttl,
)
from ._momento_version import momento_version
from ._python_runtime_version import PYTHON_RUNTIME_VERSION
from ._time import _timedelta_to_ms
37 changes: 0 additions & 37 deletions src/momento/internal/_utilities/_momento_version.py

This file was deleted.

21 changes: 8 additions & 13 deletions src/momento/internal/aio/_scs_grpc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from momento.config.auth_configuration import AuthConfiguration
from momento.config.transport.transport_strategy import StaticGrpcConfiguration
from momento.errors.exceptions import ConnectionException
from momento.internal._utilities import PYTHON_RUNTIME_VERSION, ClientType, momento_version
from momento.internal._utilities import PYTHON_RUNTIME_VERSION, ClientType
from momento.internal._utilities._channel_credentials import (
channel_credentials_from_root_certs_or_default,
)
Expand All @@ -38,8 +38,6 @@
class _ControlGrpcManager:
"""Internal gRPC control manager."""

version = momento_version

def __init__(self, configuration: Configuration, credential_provider: CredentialProvider):
self._secure_channel = grpc.aio.secure_channel(
target=credential_provider.control_endpoint,
Expand All @@ -62,8 +60,6 @@ def async_stub(self) -> control_client.ScsControlStub:
class _DataGrpcManager:
"""Internal gRPC data manager."""

version = momento_version

def __init__(self, configuration: Configuration, credential_provider: CredentialProvider):
self._logger = logs.logger
self._secure_channel = grpc.aio.secure_channel(
Expand Down Expand Up @@ -139,8 +135,6 @@ def async_stub(self) -> cache_client.ScsStub:
class _PubsubGrpcManager:
"""Internal gRPC pubsub manager."""

version = momento_version

def __init__(self, configuration: TopicConfiguration, credential_provider: CredentialProvider):
# NOTE: This is hard-coded for now but we may want to expose it via TopicConfiguration in the future, as we do with some of the other clients.
grpc_config = StaticGrpcConfiguration(deadline=timedelta(milliseconds=1100))
Expand All @@ -162,8 +156,6 @@ def async_stub(self) -> pubsub_client.PubsubStub:
class _PubsubGrpcStreamManager:
"""Internal gRPC pubsub stream manager."""

version = momento_version

def __init__(self, configuration: TopicConfiguration, credential_provider: CredentialProvider):
# NOTE: This is hard-coded for now but we may want to expose it via TopicConfiguration in the future, as we do with some of the other clients.
grpc_config = StaticGrpcConfiguration(deadline=timedelta(milliseconds=1100))
Expand All @@ -185,8 +177,6 @@ def async_stub(self) -> pubsub_client.PubsubStub:
class _TokenGrpcManager:
"""Internal gRPC token manager."""

version = momento_version

def __init__(self, configuration: AuthConfiguration, credential_provider: CredentialProvider):
self._secure_channel = grpc.aio.secure_channel(
target=credential_provider.token_endpoint,
Expand All @@ -209,9 +199,11 @@ def async_stub(self) -> token_client.TokenStub:
def _interceptors(
auth_token: str, client_type: ClientType, retry_strategy: Optional[RetryStrategy] = None
) -> list[grpc.aio.ClientInterceptor]:
from momento import __version__ as momento_version

headers = [
Header("authorization", auth_token),
Header("agent", f"python:{client_type.value}:{_ControlGrpcManager.version}"),
Header("agent", f"python:{client_type.value}:{momento_version}"),
Header("runtime-version", f"python {PYTHON_RUNTIME_VERSION}"),
]
return list(
Expand All @@ -226,9 +218,12 @@ def _interceptors(


def _stream_interceptors(auth_token: str, client_type: ClientType) -> list[grpc.aio.UnaryStreamClientInterceptor]:
# This is a workaround to avoid circular imports.
from momento import __version__ as momento_version

headers = [
Header("authorization", auth_token),
Header("agent", f"python:{client_type.value}:{_PubsubGrpcStreamManager.version}"),
Header("agent", f"python:{client_type.value}:{momento_version}"),
Header("runtime-version", f"python {PYTHON_RUNTIME_VERSION}"),
]
return [AddHeaderStreamingClientInterceptor(headers)]
21 changes: 8 additions & 13 deletions src/momento/internal/synchronous/_scs_grpc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from momento.config.auth_configuration import AuthConfiguration
from momento.config.transport.transport_strategy import StaticGrpcConfiguration
from momento.errors.exceptions import ConnectionException
from momento.internal._utilities import PYTHON_RUNTIME_VERSION, ClientType, momento_version
from momento.internal._utilities import PYTHON_RUNTIME_VERSION, ClientType
from momento.internal._utilities._channel_credentials import (
channel_credentials_from_root_certs_or_default,
)
Expand All @@ -37,8 +37,6 @@
class _ControlGrpcManager:
"""Internal gRPC control mananger."""

version = momento_version

def __init__(self, configuration: Configuration, credential_provider: CredentialProvider):
self._secure_channel = grpc.secure_channel(
target=credential_provider.control_endpoint,
Expand All @@ -63,8 +61,6 @@ def stub(self) -> control_client.ScsControlStub:
class _DataGrpcManager:
"""Internal gRPC data mananger."""

version = momento_version

def __init__(self, configuration: Configuration, credential_provider: CredentialProvider):
self._logger = logs.logger
self._secure_channel = grpc.secure_channel(
Expand Down Expand Up @@ -156,8 +152,6 @@ def stub(self) -> cache_client.ScsStub:
class _PubsubGrpcManager:
"""Internal gRPC pubsub manager."""

version = momento_version

def __init__(self, configuration: TopicConfiguration, credential_provider: CredentialProvider):
# NOTE: This is hard-coded for now but we may want to expose it via TopicConfiguration in the future, as we do with some of the other clients.
grpc_config = StaticGrpcConfiguration(deadline=timedelta(milliseconds=1100))
Expand All @@ -182,8 +176,6 @@ def stub(self) -> pubsub_client.PubsubStub:
class _PubsubGrpcStreamManager:
"""Internal gRPC pubsub stream manager."""

version = momento_version

def __init__(self, configuration: TopicConfiguration, credential_provider: CredentialProvider):
# NOTE: This is hard-coded for now but we may want to expose it via TopicConfiguration in the future, as we do with some of the other clients.
grpc_config = StaticGrpcConfiguration(deadline=timedelta(milliseconds=1100))
Expand All @@ -208,8 +200,6 @@ def stub(self) -> pubsub_client.PubsubStub:
class _TokenGrpcManager:
"""Internal gRPC token manager."""

version = momento_version

def __init__(self, configuration: AuthConfiguration, credential_provider: CredentialProvider):
self._secure_channel = grpc.secure_channel(
target=credential_provider.token_endpoint,
Expand All @@ -234,9 +224,11 @@ def stub(self) -> token_client.TokenStub:
def _interceptors(
auth_token: str, client_type: ClientType, retry_strategy: Optional[RetryStrategy] = None
) -> list[grpc.UnaryUnaryClientInterceptor]:
from momento import __version__ as momento_version

headers = [
Header("authorization", auth_token),
Header("agent", f"python:{client_type.value}:{_ControlGrpcManager.version}"),
Header("agent", f"python:{client_type.value}:{momento_version}"),
Header("runtime-version", f"python {PYTHON_RUNTIME_VERSION}"),
]
return list(
Expand All @@ -247,9 +239,12 @@ def _interceptors(


def _stream_interceptors(auth_token: str, client_type: ClientType) -> list[grpc.UnaryStreamClientInterceptor]:
# This is here to avoid circular imports
from momento import __version__ as momento_version

headers = [
Header("authorization", auth_token),
Header("agent", f"python:{client_type.value}:{_PubsubGrpcStreamManager.version}"),
Header("agent", f"python:{client_type.value}:{momento_version}"),
Header("runtime-version", f"python {PYTHON_RUNTIME_VERSION}"),
]
return [AddHeaderStreamingClientInterceptor(headers)]
2 changes: 1 addition & 1 deletion tests/momento/internal/_utilities/test_momento_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from momento.internal._utilities import momento_version
from momento import __version__ as momento_version


def test_momento_version() -> None:
Expand Down