-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Python Add the Amazon Neptune Python follow #7473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you've made the high-level fixes and it matches the specification, I can do a full review.
@@ -18,6 +26,14 @@ neptune_Hello: | |||
neptune: {DescribeDBClustersPaginator} | |||
neptune_ExecuteQuery: | |||
languages: | |||
Python: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This metadata tag is not listed in the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a new section in the spec to include the code submitted from the SME. Its clear now in the spec..
@@ -31,6 +47,14 @@ neptune_ExecuteQuery: | |||
neptune: {ExecuteQuery} | |||
neptune_CreateGraph: | |||
languages: | |||
Python: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata key not listed in specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment. SME contributed code that is outside the main scenario is now listed in spec.
@@ -44,6 +68,14 @@ neptune_CreateGraph: | |||
neptune: {CreateGraph} | |||
neptune_ExecuteOpenCypherExplainQuery: | |||
languages: | |||
Python: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key not listed in specification. Same for many of these in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - SME code now in spec.
@@ -0,0 +1,31 @@ | |||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python files should not be named with uppercase names. They should match the patterns in the rest of the library. Same for all files in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the names of Python files.
response = neptune_client.describe_db_clusters() | ||
for cluster in response.get("DBClusters", []): | ||
print(f"Cluster Identifier: {cluster['DBClusterIdentifier']}") | ||
print(f"Status: {cluster['Status']}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specification requires handling a ResourceNotFoundException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hello example been updated
""" | ||
Main entry point: creates the Neptune client and calls the describe operation. | ||
""" | ||
neptune_client = boto3.client("neptune", region_name="us-east-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not hard-code regions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
neptune_client.delete_db_cluster(**request) | ||
print(f" Deleting DB Cluster: {cluster_id}") | ||
except Exception as e: | ||
print(f" Failed to delete DB Cluster '{cluster_id}': {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specification requires handling a ResourceNotFoundException. Same for all actions in this PR, they should follow the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - all code now adhere to spec in terms of exceptions
hours, mins = divmod(mins, 60) | ||
return f"{hours:02}:{mins:02}:{secs:02}" | ||
|
||
def wait_until_instance_deleted( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is not needed, it should use the built-in boto3 waiters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been updated to use a waiter
@pytest.mark.integration | ||
def test_neptune_run_scenario(monkeypatch): | ||
# Patch input() to simulate all required inputs | ||
input_sequence = iter([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to press c to move on in python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@pytest.fixture(scope="module") | ||
def neptune_client(): | ||
"""Create a real Neptune boto3 client for integration testing.""" | ||
client = boto3.client("neptune", region_name="us-east-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow the current testing patterns in the library until we decide as a team to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modelled tests after the Keyspace. Confirmed we follow pattern too
The Hello and Scenario examples run as excepted. The tests have been refactored to follow other Python tests such as Keyspace. The Spec was updated to include SME contributed code examples. |
This pull request adds the Amazon Neptune Python follow
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.