-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made the change for all data integrations
- Loading branch information
Showing
10 changed files
with
111 additions
and
8 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
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,13 @@ | ||
from aqueduct.utils.integration_validation import validate_integration_is_connected | ||
|
||
|
||
def validate_is_connected(): | ||
"""This decorator, when used on an Integration class method, ensures that the integration is | ||
connected before allowing the method to be called.""" | ||
|
||
def decorator(method): | ||
def wrapper(self, *args, **kwargs): | ||
validate_integration_is_connected(self.name(), self._metadata.exec_state) | ||
return method(*args, **kwargs) | ||
return wrapper | ||
return decorator |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Optional | ||
|
||
from aqueduct.error import IntegrationFailedToConnect, IntegrationConnectionInProgress | ||
|
||
from aqueduct.constants.enums import ExecutionStatus | ||
from aqueduct.models.execution_state import ExecutionState | ||
|
||
|
||
def validate_integration_is_connected(name: str, exec_state: Optional[ExecutionState]) -> None: | ||
"""Method used to determine if this integration was successfully connected to or not. | ||
If not successfully connected (or pending), we will raise an Exception. | ||
""" | ||
# TODO(ENG-2813): Remove the assumption that a missing `exec_state` means success. | ||
if exec_state is None or exec_state.status == ExecutionStatus.SUCCEEDED: | ||
return | ||
|
||
if exec_state.status == ExecutionStatus.FAILED: | ||
raise IntegrationFailedToConnect( | ||
"Cannot use integration %s because it has not been successfully connected to:" | ||
"%s\n%s\n\n Please see the /integrations page on the UI for more details." % ( | ||
name, exec_state.error.tip, exec_state.error.context, | ||
) | ||
) | ||
else: | ||
raise IntegrationConnectionInProgress( | ||
"Cannot use integration %s because it is still in the process of connecting." | ||
"Please see the /integrations page oen the UI for more details." | ||
% name | ||
) | ||
|