Skip to content

Allow user to specify custom S3 endpoint #67

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.109
0.8.110
13 changes: 7 additions & 6 deletions ml_logger/ml_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# ML_Logger defaults
ROOT = os.environ.get("ML_LOGGER_ROOT", CWD) or CWD
S3_ROOT = os.environ.get("ML_LOGGER_S3_ROOT", None)
S3_ENDPOINT = os.environ.get("ML_LOGGER_S3_ENDPOINT", None)
LOGGER_USER = os.environ.get("ML_LOGGER_USER", USER)
ACCESS_TOKEN = os.environ.get("ML_LOGGER_ACCESS_TOKEN", None)

Expand Down Expand Up @@ -939,7 +940,7 @@ def glob_s3(self, query="*", wd=None, max_keys=1000, **KWargs):
query_prefix = '/'.join(query_prefix)
truncate = len(work_prefix) + 1 if work_prefix else 0

s3_client = boto3.client('s3')
s3_client = boto3.client('s3', endpoint_url=S3_ENDPOINT)
# list_objects_v2 supports pagination. -- Ge
response = s3_client.list_objects(Bucket=bucket, Prefix=s3_prefix,
MaxKeys=max_keys, **KWargs)
Expand Down Expand Up @@ -1416,8 +1417,8 @@ def download_dir(self, source_path, to, unpack='tar'):
@staticmethod
def remove_s3(bucket, *keys):
import boto3
client = boto3.client('s3')
return client.delete_object(Bucket=bucket, Key=pJoin(*keys))
s3_client = boto3.client('s3', endpoint_url=S3_ENDPOINT)
return s3_client.delete_object(Bucket=bucket, Key=pJoin(*keys))

@staticmethod
def remove_gs(*keys, path=None):
Expand Down Expand Up @@ -1487,7 +1488,7 @@ def upload_s3(source_path, *keys, path=None):

# todo: consider adding exception handling -- good or bad?
# Upload the file
s3_client = boto3.client('s3')
s3_client = boto3.client('s3', endpoint_url=S3_ENDPOINT)
# from botocore.exceptions import ClientError
# try:
response = s3_client.upload_file(source_path, bucket, object_name)
Expand All @@ -1506,8 +1507,8 @@ def download_s3(*keys, path=None, to):
bucket, *object_name = path.split('/')
object_name = '/'.join(object_name)

s3 = boto3.client('s3')
return s3.download_file(bucket, object_name, to)
s3_client = boto3.client('s3', endpoint_url=S3_ENDPOINT)
return s3_client.download_file(bucket, object_name, to)

def save_images(self, stack, key, n_rows=None, n_cols=None, cmap=None, normalize=None,
value_range=(0, 1), background=1, dtype=np.uint8):
Expand Down