import on call (#2382)

This commit is contained in:
Pere Miquel Brull 2022-01-24 21:29:03 +01:00 committed by GitHub
parent 71e78ab460
commit 6a8fc9e0fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,9 +18,7 @@ from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import List, Optional, Tuple from typing import List, Optional, Tuple
import boto3
import click import click
from boto3.exceptions import S3UploadFailedError
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
@ -61,6 +59,16 @@ def upload_backup(endpoint: str, bucket: str, key: str, file: Path) -> None:
:param file: file to upload :param file: file to upload
""" """
try:
import boto3
from boto3.exceptions import S3UploadFailedError
except ModuleNotFoundError as err:
logger.error(
"Trying to import boto3 to run the backup upload."
+ " Please install openmetadata-ingestion[backup]."
)
raise err
s3_key = Path(key) / file.name s3_key = Path(key) / file.name
click.secho( click.secho(
f"Uploading {file} to {endpoint}/{bucket}/{str(s3_key)}...", f"Uploading {file} to {endpoint}/{bucket}/{str(s3_key)}...",