Skip to content

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

scmacdon
Copy link
Contributor

@scmacdon scmacdon commented Jun 5, 2025

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.

@scmacdon scmacdon self-assigned this Jun 5, 2025
@scmacdon scmacdon added Python This issue relates to the AWS SDK for Python (boto3) Basics A basic code example showing the core actions for a particular service. labels Jun 5, 2025
@scmacdon scmacdon added the Follow After Scouts, more languages are added to examples as Follows. label Jun 6, 2025
@scmacdon scmacdon requested a review from beqqrry-aws June 6, 2025 19:59
@scmacdon scmacdon added the On Call Review needed This work needs an on-call review label Jun 10, 2025
Copy link
Contributor

@rlhagerm rlhagerm left a 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:
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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']}")
Copy link
Contributor

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.

Copy link
Contributor Author

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")
Copy link
Contributor

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.

Copy link
Contributor Author

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}")
Copy link
Contributor

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.

Copy link
Contributor Author

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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([
Copy link
Contributor

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.

Copy link
Contributor Author

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")
Copy link
Contributor

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.

Copy link
Contributor Author

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

@rlhagerm rlhagerm removed the On Call Review needed This work needs an on-call review label Jun 12, 2025
@scmacdon
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Basics A basic code example showing the core actions for a particular service. Follow After Scouts, more languages are added to examples as Follows. Python This issue relates to the AWS SDK for Python (boto3)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants