-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Add Amazon Provider Neptune Analytics #64274
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
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
bb435c8
neptune analytics initial
a85224d
Added NeptuneCreateGraphOperator and supporting files/classes
5a96713
Added private endpoint operators
7cf5b6c
fixed assignment error
c70a3f6
Fixed type error
3f2a0a3
fixed another return type error
e37fbd6
Fixed assignment error in delete endpoint operator
0c35600
Added NeptuneDeleteGraphOperator and NeptuneStartImportTaskOperator
0e55791
Fixed prek findings
69f8fd8
Added NeptuneCancelImportTaskOperator
e0e6a44
Added system tests and fixed errors found during system testing
ellisms b879497
Added additional links for import job and vpce
ellisms d1ca1bf
Updated system and unit tests, and operator fixes
ellisms 7685064
Added Neptune Analytics docs
ellisms 1983d76
added console links to NeptuneCreateGraphWithImportOperator
ellisms 7dfac96
Fixed missing operator_extra_links assignment
ellisms 9ab4b3f
Update providers/amazon/tests/unit/amazon/aws/triggers/test_neptune_a…
ellisms 947c123
Update providers/amazon/src/airflow/providers/amazon/aws/operators/ne…
ellisms 972526c
Fixed issues found in CI
ellisms d44d026
Fixed broken test and CI failures
ellisms 4207545
Fixed url typo in provider file
ellisms fa0a643
Requested PR changes
890bf7d
Added Neptune Analytics exceptions and addressed PR comments
e29b4f0
Fixed mypy errors
e54af79
provider update
155d462
Updated system test exception handling based on prek findings
f8c0890
Fixed calling lower() on None
d517ecd
Added custom import waiter and addressed PR suggestions
ellisms d6cb794
Addressed mypy finding
ellisms 663ebad
Fixed deferrable issues found in testing
ellisms 3b8b22c
Fixed function signature error
ellisms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,148 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| .. Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
|
|
||
| ======================== | ||
| Amazon Neptune Analytics | ||
| ======================== | ||
|
|
||
| `Amazon Neptune Analytics <https://docs.aws.amazon.com/neptune-analytics/latest/userguide/what-is-neptune-analytics.html>`__ is a memory-optimized graph database engine for analytics. With Neptune Analytics, you can get insights and find trends by processing large amounts of graph data in seconds. | ||
|
|
||
| Prerequisite Tasks | ||
| ------------------ | ||
|
|
||
| .. include:: ../_partials/prerequisite_tasks.rst | ||
|
|
||
| Generic Parameters | ||
| ------------------ | ||
|
|
||
| .. include:: ../_partials/generic_parameters.rst | ||
|
|
||
| Operators | ||
| --------- | ||
|
|
||
| .. _howto/operator:NeptuneCreateGraphOperator: | ||
|
|
||
| Create a new Neptune Graph | ||
| ========================== | ||
|
|
||
| To create a new Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreateGraphOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_graph] | ||
| :end-before: [END howto_operator_neptune_analytics_create_graph] | ||
|
|
||
|
|
||
| .. _howto/operator:NeptuneDeleteGraphOperator: | ||
|
|
||
| Delete a Neptune Graph | ||
| ====================== | ||
|
|
||
| To delete an existing Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneDeleteGraphOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_delete_graph] | ||
| :end-before: [END howto_operator_neptune_analytics_delete_graph] | ||
|
|
||
| .. _howto/operator:NeptuneCreatePrivateGraphEndpointOperator: | ||
|
|
||
| Create a Neptune Graph private endpoint | ||
| ======================================= | ||
|
|
||
| To create a VPC Endpoint for connecting to an existing Neptune Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreatePrivateGraphEndpointOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_private_endpoint] | ||
| :end-before: [END howto_operator_neptune_analytics_create_private_endpoint] | ||
|
|
||
| .. _howto/operator:NeptuneDeletePrivateGraphEndpointOperator: | ||
|
|
||
| Delete a Neptune Graph private endpoint | ||
| ======================================= | ||
|
|
||
| To delete a VPC Endpoint attached to an existing Neptune Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneDeletePrivateGraphEndpointOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_delete_private_endpoint] | ||
| :end-before: [END howto_operator_neptune_analytics_delete_private_endpoint] | ||
|
|
||
| .. _howto/operator:NeptuneCreateGraphWithImportOperator: | ||
|
|
||
| Create a Neptune Graph with a data import task | ||
| ============================================== | ||
|
|
||
| To create a Neptune Analytics Graph and immediately import data, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCreateGraphWithImportOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_create_graph_with_import] | ||
| :end-before: [END howto_operator_neptune_analytics_create_graph_with_import] | ||
|
|
||
| .. _howto/operator:NeptuneStartImportTaskOperator: | ||
|
|
||
| Import data into an existing Neptune Graph | ||
| ========================================== | ||
|
|
||
| To import data into an existing Neptune Analytics Graph, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneStartImportTaskOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_start_import_task] | ||
| :end-before: [END howto_operator_neptune_analytics_start_import_task] | ||
|
|
||
| .. _howto/operator:NeptuneCancelImportTaskOperator: | ||
|
|
||
| Cancel a running import task | ||
| ============================ | ||
|
|
||
| To cancel an existing import task, you can use | ||
| :class:`~airflow.providers.amazon.aws.operators.neptune_analytics.NeptuneCancelImportTaskOperator`. | ||
| This operator can be run in deferrable mode by passing ``deferrable=True`` as a parameter. This requires | ||
| the aiobotocore module to be installed. | ||
|
|
||
| .. exampleinclude:: /../../amazon/tests/system/amazon/aws/example_neptune_analytics.py | ||
| :language: python | ||
| :dedent: 4 | ||
| :start-after: [START howto_operator_neptune_analytics_cancel_import_task] | ||
| :end-before: [END howto_operator_neptune_analytics_cancel_import_task] | ||
This file contains hidden or 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 hidden or 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
42 changes: 42 additions & 0 deletions
42
providers/amazon/src/airflow/providers/amazon/aws/hooks/neptune_analytics.py
This file contains hidden or 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,42 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook | ||
|
|
||
|
|
||
| class NeptuneAnalyticsHook(AwsBaseHook): | ||
| """ | ||
| Interact with Amazon Neptune Analytics. | ||
|
|
||
| Additional arguments (such as ``aws_conn_id``) may be specified and | ||
| are passed down to the underlying AwsBaseHook. | ||
|
|
||
| .. seealso:: | ||
| - :class:`~airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook` | ||
| """ | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| kwargs["client_type"] = "neptune-graph" | ||
|
eladkal marked this conversation as resolved.
|
||
| super().__init__(*args, **kwargs) | ||
|
|
||
| def _get_graph_endpoint_id(self, graph_id: str, vpc_id: str): | ||
| """Return the vpc endpoint id for this graph.""" | ||
| result = self.conn.get_private_graph_endpoint(graphIdentifier=graph_id, vpcId=vpc_id) | ||
| return result.get("vpcEndpointId") | ||
This file contains hidden or 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
42 changes: 42 additions & 0 deletions
42
providers/amazon/src/airflow/providers/amazon/aws/links/neptune_analytics.py
This file contains hidden or 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,42 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| from __future__ import annotations | ||
|
|
||
| from airflow.providers.amazon.aws.links.base_aws import BASE_AWS_CONSOLE_LINK, BaseAwsLink | ||
|
|
||
|
|
||
| class NeptuneGraphLink(BaseAwsLink): | ||
| """Helper class for constructing an Amazon Neptune Analytics Graph Link.""" | ||
|
|
||
| name = "Neptune Graph" | ||
| key = "_neptune_graph" | ||
| format_str = ( | ||
| BASE_AWS_CONSOLE_LINK | ||
| + "/neptune/home?region={region_name}#analytics-graph-details:id={graph_id}" | ||
| + ";tab=connectivity" | ||
| ) | ||
|
|
||
|
|
||
| class NeptuneImportTaskLink(BaseAwsLink): | ||
| """Helper class for constructing an Amazon Neptune Analytics import task link.""" | ||
|
|
||
| name = "Neptune Import Task" | ||
| key = "_import_task" | ||
| format_str = ( | ||
| BASE_AWS_CONSOLE_LINK | ||
| + "/neptune/home?region={region_name}#analytics-import-task-details:id={import_task_id}" | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.