generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 92
Feat: Download Worksheet Results #1547
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
anilsoni7
wants to merge
9
commits into
data-dot-all:main
Choose a base branch
from
syncron-oss:query_result_download
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8af5e16
Initial query download feature changes
01d681d
download feature implementation from frontend
6c8cd54
fixing download query result issues
caf497b
fix linting problems
be85bdd
refactor changes for result doenload feature
f7cb94b
fix: test_create_query_download_url Testcase
87f7cc7
fix: add unauthorized testcases for query result download
f5b104c
Merge branch 'main' into query_result_download
5c2be05
fixing CI/CD checks
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
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
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
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,69 @@ | ||
| import logging | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| from botocore.exceptions import ClientError | ||
|
|
||
| from dataall.base.aws.sts import SessionHelper | ||
| from dataall.base.db.exceptions import AWSResourceNotFound | ||
|
|
||
| if TYPE_CHECKING: | ||
| from dataall.core.environment.db.environment_models import Environment | ||
|
|
||
| try: | ||
| from mypy_boto3_s3 import S3Client as S3ClientType | ||
| except ImportError: | ||
| S3ClientType = None | ||
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class S3Client: | ||
| def __init__(self, env: 'Environment'): | ||
| self._client = SessionHelper.remote_session(env.AwsAccountId, env.region).client('s3', region_name=env.region) | ||
| self._env = env | ||
|
|
||
| @property | ||
| def client(self) -> 'S3ClientType': | ||
| return self._client | ||
|
|
||
dlpzx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def get_presigned_url(self, bucket, key, expire_minutes: int = 15): | ||
| expire_seconds = expire_minutes * 60 | ||
| try: | ||
| presigned_url = self.client.generate_presigned_url( | ||
| 'get_object', | ||
| Params=dict( | ||
| Bucket=bucket, | ||
| Key=key, | ||
| ), | ||
| ExpiresIn=expire_seconds, | ||
| ) | ||
| return presigned_url | ||
| except ClientError as e: | ||
| log.error(f'Failed to get presigned URL due to: {e}') | ||
| raise e | ||
|
|
||
| def object_exists(self, bucket, key) -> bool: | ||
| try: | ||
| self.client.head_object(Bucket=bucket, Key=key) | ||
| return True | ||
| except ClientError as e: | ||
| if e.response['Error']['Code'] == '404': | ||
| log.info(f'Object {key} not found in bucket {bucket}') | ||
| return False | ||
| log.error(f'Failed to check object existence due to: {e}') | ||
| raise AWSResourceNotFound('s3_object_exists', f'Object {key} not found in bucket {bucket}') | ||
|
|
||
| def put_object(self, bucket, key, body): | ||
| try: | ||
| self.client.put_object(Bucket=bucket, Key=key, Body=body) | ||
| except ClientError as e: | ||
| log.error(f'Failed to put object due to: {e}') | ||
| raise e | ||
|
|
||
| def get_object(self, bucket, key) -> str: | ||
| try: | ||
| response = self.client.get_object(Bucket=bucket, Key=key) | ||
| return response['Body'].read().decode('utf-8') | ||
| except ClientError as e: | ||
| log.error(f'Failed to get object due to: {e}') | ||
| raise e | ||
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
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
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.