forked from nasa-gcn/python-dynamodb-autoincrement
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't require upstream patches for boto3
The AWS Python SDK, [boto3], has [resource] objects that provide high-level interfaces to AWS services. The [DynamoDB resource] greatly simplifies marshalling and unmarshalling data. We rely on the resource method for [TransactWriteItems] among others that are absent from boto3. We opened PR boto/boto3#4010 to add that method. The resource methods are synthesized at runtime from a data file. Fortunately, boto3 has a [Loader] mechanism that allows the user to add extra data files, and the [loader search path] is configurable. In order to not depend upon our upstream PR for boto3, we distribute the extra data files and fix up the loader search path by putting it in a [.pth file] which Python executes automatically during startup. FIXME: The .pth file method does not currently work when we are doing editable installs. It _should_ work with editable installs if we factor the data files and the .pth file to a separate package that we add as a dependency. [boto3]: https://github.com/boto/boto3 [resource]: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html [DynamoDB resource]: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#resources [TransactWriteItems]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html [Loader]: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/loaders.html [loader search path]: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/loaders.html#the-search-path [.pth file]: https://docs.python.org/3/library/site.html
- Loading branch information
Showing
7 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import boto3_missing; boto3_missing.install() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright © 2023 United States Government as represented by the | ||
# Administrator of the National Aeronautics and Space Administration. | ||
# All Rights Reserved. | ||
"""Add missing boto3 SDK data. | ||
See | ||
https://botocore.amazonaws.com/v1/documentation/api/latest/reference/loaders.html, | ||
https://github.com/boto/boto3/pull/4010 | ||
""" | ||
|
||
from os import environ, pathsep | ||
|
||
from . import data | ||
|
||
|
||
def install(): | ||
new_path = [*data.__path__] | ||
if orig_path := environ.get("AWS_DATA_PATH"): | ||
new_path.extend(orig_path.split(pathsep)) | ||
environ["AWS_DATA_PATH"] = pathsep.join(new_path) |
23 changes: 23 additions & 0 deletions
23
boto3_missing/data/dynamodb/2012-08-10/resources-1.sdk-extras.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"merge": { | ||
"service": { | ||
"actions": { | ||
"GetItem": { | ||
"request": { "operation": "GetItem" } | ||
}, | ||
"PutItem": { | ||
"request": { "operation": "PutItem" } | ||
}, | ||
"Query": { | ||
"request": { "operation": "Query" } | ||
}, | ||
"Scan": { | ||
"request": { "operation": "Scan" } | ||
}, | ||
"TransactWriteItems": { | ||
"request": { "operation": "TransactWriteItems" } | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters