Closed necat1 closed 3 months ago
Also something like this before self.store = client.Table(table_name)?
I'm not sure best way to code this
# Check if the table exists
existing_tables = self.client.meta.client.list_tables()["TableNames"]
if table_name not in existing_tables:
# Create the table if it does not exist
self.client.create_table............
Also regarding this part, why are you passing on attribute error? I would think we want to know if any issues with initialization?
try:
client.meta.client.update_time_to_live(
TableName=self.table_name,
TimeToLiveSpecification={
"Enabled": True,
"AttributeName": "expiration",
},
)
except AttributeError:
pass
Also regarding this part, why are you passing on attribute error? I would think we want to know if any issues with initialization?
try: client.meta.client.update_time_to_live( TableName=self.table_name, TimeToLiveSpecification={ "Enabled": True, "AttributeName": "expiration", }, ) except AttributeError: pass
When TTL index is already added to table dynamodb client raises an error next time its called, and i don't know a way to explixitly check if index is added, although i can do some research.
Also something like this before self.store = client.Table(table_name)?
I'm not sure best way to code this
# Check if the table exists existing_tables = self.client.meta.client.list_tables()["TableNames"] if table_name not in existing_tables: # Create the table if it does not exist self.client.create_table............
I will look into this, i think boto3 supports this.
Thanks for the continued efforts. I think it would be best to not have URL parameter SESSION_DYNAMODB_URL if possible because none of the other backends use it, and it can be used directly in the boto client. Having the table one is good though.
Thanks for comprehensive review. boto3 doesn't have default connections. The alternative here is to have hardcoded URL when user doesn't provide client.
Thanks for the continued efforts. I think it would be best to not have URL parameter SESSION_DYNAMODB_URL if possible because none of the other backends use it, and it can be used directly in the boto client. Having the table one is good though.
Thanks for comprehensive review. boto3 doesn't have default connections. The alternative here is to have hardcoded URL when user doesn't provide client.
Or maybe just use default value from defaults without parametrizing SessionInterface?
Thanks for the continued efforts. I think it would be best to not have URL parameter SESSION_DYNAMODB_URL if possible because none of the other backends use it, and it can be used directly in the boto client. Having the table one is good though.
Thanks for comprehensive review. boto3 doesn't have default connections. The alternative here is to have hardcoded URL when user doesn't provide client.
I mean instead you should pass the instance like SESSION_DYNAMODB = boto3.resource( "dynamodb", endpoint_url="http://localhost:8000", etc)
Also the CI tests are working, maybe add
name: Run unittests
on: [push, pull_request]
jobs:
unittests:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo
ports:
- 27017:27017
dynamodb:
image: amazon/dynamodb-local
ports:
- 8000:8000
steps:
...
Thanks for the continued efforts. I think it would be best to not have URL parameter SESSION_DYNAMODB_URL if possible because none of the other backends use it, and it can be used directly in the boto client. Having the table one is good though.
Thanks for comprehensive review. boto3 doesn't have default connections. The alternative here is to have hardcoded URL when user doesn't provide client.
I mean instead you should pass the instance like SESSION_DYNAMODB = boto3.resource( "dynamodb", endpoint_url="http://localhost:8000", etc)
Yeah long story short, I think it's fine to just have the port 800 hardcoded into the default client and remove url: str = Defaults.SESSION_DYNAMODB_URL. This will make it the same as all of the other backends.
Also lets compare to cachelib backend, which will be very similar: https://github.com/pallets-eco/cachelib/blob/main/src/cachelib/dynamodb.py
Great suggestions! I will have time to work on this on weekend.
@necat1 I noticed the use BillingMode="PAY_PER_REQUEST", instead of throughput in cachelib, should we do that?
They also use table.wait_until_exists() and table.load(). Not sure if we need those.
https://github.com/pallets-eco/cachelib/blob/main/src/cachelib/dynamodb.py
I'm thinking we don't need either
BillingMode="PAY_PER_REQUEST"
or
read_capacity: int = Defaults.SESSION_DYNAMODB_READ,
write_capacity: int = Defaults.SESSION_DYNAMODB_WRITE,
The user could switch using AWS Management Console, AWS CLI, or programatically
dynamodb.update_table(
TableName=table_name,
BillingMode='PAY_PER_REQUEST'
)
This would simplify things a fair bit for us
Thanks for the continued efforts. I think it would be best to not have URL parameter SESSION_DYNAMODB_URL if possible because none of the other backends use it, and it can be used directly in the boto client. Having the table one is good though.