Skip to content

Commit c61947d

Browse files
committed
Merge branch '0.12.7_minio_proxy' into add_minio_proxy_server
2 parents 7764467 + 58aed20 commit c61947d

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

datajoint/s3.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
from io import BytesIO
55
import minio # https://docs.minio.io/docs/python-client-api-reference
6+
import urllib3
67
import warnings
78
import uuid
89
import logging
@@ -16,9 +17,29 @@ class Folder:
1617
"""
1718
A Folder instance manipulates a flat folder of objects within an S3-compatible object store
1819
"""
19-
def __init__(self, endpoint, bucket, access_key, secret_key, *, secure=False, **_):
20-
self.client = minio.Minio(endpoint, access_key=access_key, secret_key=secret_key,
21-
secure=secure)
20+
def __init__(self, endpoint, bucket, access_key, secret_key, *, secure=False, proxy_server=None, **_):
21+
if proxy_server:
22+
# from https://docs.min.io/docs/python-client-api-reference
23+
http_client = urllib3.ProxyManager(
24+
proxy_server,
25+
timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
26+
cert_reqs="CERT_REQUIRED",
27+
retries=urllib3.Retry(
28+
total=5,
29+
backoff_factor=0.2,
30+
status_forcelist=[500, 502, 503, 504],
31+
)
32+
)
33+
else:
34+
http_client = None
35+
36+
self.client = minio.Minio(
37+
endpoint,
38+
access_key=access_key,
39+
secret_key=secret_key,
40+
secure=secure,
41+
http_client=http_client,
42+
)
2243
self.bucket = bucket
2344
if not self.client.bucket_exists(bucket):
2445
raise errors.BucketInaccessible('Inaccessible s3 bucket %s' % bucket)

datajoint/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_store_spec(self, store):
137137
spec['subfolding'] = spec.get('subfolding', DEFAULT_SUBFOLDING)
138138
spec_keys = { # REQUIRED in uppercase and allowed in lowercase
139139
'file': ('PROTOCOL', 'LOCATION', 'subfolding', 'stage'),
140-
's3': ('PROTOCOL', 'ENDPOINT', 'BUCKET', 'ACCESS_KEY', 'SECRET_KEY', 'LOCATION', 'secure', 'subfolding', 'stage')}
140+
's3': ('PROTOCOL', 'ENDPOINT', 'BUCKET', 'ACCESS_KEY', 'SECRET_KEY', 'LOCATION', 'secure', 'subfolding', 'stage', 'proxy_server')}
141141

142142
try:
143143
spec_keys = spec_keys[spec.get('protocol', '').lower()]

0 commit comments

Comments
 (0)