Skip to content

Commit 049ae7b

Browse files
committed
rolled in review comments
1 parent a8c9e2d commit 049ae7b

26 files changed

+92
-63
lines changed

python/example_code/neptune/HelloNeptune.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

python/example_code/neptune/analytics/CreateNeptuneGraphExample.py renamed to python/example_code/neptune/analytics/create_neptune_graph_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
"""
2222

2323
GRAPH_NAME = "sample-analytics-graph"
24-
REGION = "us-east-1"
2524

2625
def main():
2726
"""
2827
Main entry point: create NeptuneGraph client and call graph creation.
2928
"""
3029
# Hypothetical client - boto3 currently doesn't have NeptuneGraph client, so replace with actual client if available
31-
neptune_graph_client = boto3.client("neptune", region_name=REGION)
30+
neptune_graph_client = boto3.client("neptune")
3231

3332
execute_create_graph(neptune_graph_client, GRAPH_NAME)
3433

python/example_code/neptune/analytics/NeptuneAnalyticsQueryExample.py renamed to python/example_code/neptune/analytics/neptune_analytics_query_example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222

2323
NEPTUNE_ANALYTICS_ENDPOINT = "https://<your-neptune-analytics-endpoint>:8182"
2424
GRAPH_ID = "<your-graph-id>"
25-
REGION = "us-east-1"
2625

2726
def main():
2827
# Build the boto3 client for neptune-graph with endpoint override
2928
client = boto3.client(
3029
"neptune-graph",
31-
region_name=REGION,
3230
endpoint_url=NEPTUNE_ANALYTICS_ENDPOINT
3331
)
3432

python/example_code/neptune/database/NeptuneGremlinExplainAndProfileExample.py renamed to python/example_code/neptune/database/neptune_gremlin_explain_and_profile_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def main():
3232

3333
neptune_client = boto3.client(
3434
"neptunedata",
35-
region_name="us-east-1",
3635
endpoint_url=NEPTUNE_ENDPOINT,
3736
config=config
3837
)

python/example_code/neptune/database/NeptuneGremlinQueryExample.py renamed to python/example_code/neptune/database/neptune_gremlin_query_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def main():
3030

3131
neptune_client = boto3.client(
3232
"neptunedata",
33-
region_name="us-east-1",
3433
endpoint_url=NEPTUNE_ENDPOINT,
3534
config=config
3635
)

python/example_code/neptune/database/OpenCypherExplainExample.py renamed to python/example_code/neptune/database/open_cypher_explain_example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def main():
3131

3232
neptune_client = boto3.client(
3333
"neptunedata",
34-
region_name="us-east-1",
3534
endpoint_url=NEPTUNE_ENDPOINT,
3635
config=config
3736
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# snippet-start:[neptune.python.hello.main]
5+
import boto3
6+
from botocore.exceptions import ClientError
7+
8+
9+
def describe_db_clusters(neptune_client):
10+
"""
11+
Describes the Amazon Neptune DB clusters using a paginator to handle multiple pages.
12+
Raises ClientError with 'ResourceNotFoundException' if no clusters are found.
13+
"""
14+
paginator = neptune_client.get_paginator("describe_db_clusters")
15+
clusters_found = False
16+
17+
for page in paginator.paginate():
18+
for cluster in page.get("DBClusters", []):
19+
clusters_found = True
20+
print(f"Cluster Identifier: {cluster['DBClusterIdentifier']}")
21+
print(f"Status: {cluster['Status']}")
22+
23+
if not clusters_found:
24+
raise ClientError(
25+
{
26+
"Error": {
27+
"Code": "ResourceNotFoundException",
28+
"Message": "No Neptune DB clusters found."
29+
}
30+
},
31+
operation_name="DescribeDBClusters"
32+
)
33+
34+
def main():
35+
"""
36+
Main entry point: creates the Neptune client and calls the describe operation.
37+
"""
38+
neptune_client = boto3.client("neptune")
39+
try:
40+
describe_db_clusters(neptune_client)
41+
except ClientError as e:
42+
error_code = e.response["Error"]["Code"]
43+
if error_code == "ResourceNotFoundException":
44+
print(f"Resource not found: {e.response['Error']['Message']}")
45+
else:
46+
print(f"Unexpected ClientError: {e.response['Error']['Message']}")
47+
except Exception as e:
48+
print(f"Unexpected error: {str(e)}")
49+
50+
if __name__ == "__main__":
51+
main()
52+
53+
# snippet-end:[neptune.python.hello.main]

python/example_code/neptune/NeptuneScenario.py renamed to python/example_code/neptune/neptune_scenario.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# snippet-start:[neptune.python.delete.cluster.main]
1515
from botocore.exceptions import ClientError
1616

17-
1817
def delete_db_cluster(neptune_client, cluster_id: str):
1918
"""
2019
Deletes a Neptune DB cluster and throws exceptions to the caller.

python/example_code/neptune/tests/analytics_tests/test_create_graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from unittest.mock import MagicMock
33
from botocore.exceptions import ClientError, BotoCoreError
4-
from analytics.CreateNeptuneGraphExample import execute_create_graph # Adjust import based on your file structure
4+
from analytics.create_neptune_graph_example import execute_create_graph # Adjust import based on your file structure
55

66

77
def test_execute_create_graph(capfd):

0 commit comments

Comments
 (0)