Skip to content

Commit

Permalink
initialization in first use
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs committed Sep 25, 2019
1 parent 192ab65 commit c1df10b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 23 deletions.
15 changes: 14 additions & 1 deletion python/pyarrow/_s3.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ def finalize_s3():
check_status(CFinalizeS3())


cdef bint _initialized = False


cdef _ensure_initialized():
global _initialized
if not _initialized:
initialize_s3()
_initialized = True


cdef class S3FileSystem(FileSystem):
"""S3-backed FileSystem implementation
Expand Down Expand Up @@ -79,9 +89,12 @@ cdef class S3FileSystem(FileSystem):
scheme='https', endpoint_override=None,
bint background_writes=True):
cdef:
CS3Options options = CS3Options.Defaults()
CS3Options options
shared_ptr[CS3FileSystem] wrapped

_ensure_initialized()

options = CS3Options.Defaults()
if access_key is not None or secret_key is not None:
options.ConfigureAccessKey(tobytes(access_key),
tobytes(secret_key))
Expand Down
2 changes: 0 additions & 2 deletions python/pyarrow/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@
from pyarrow._s3 import S3FileSystem, initialize_s3, finalize_s3 # noqa
except ImportError:
pass
else:
initialize_s3()
19 changes: 0 additions & 19 deletions python/pyarrow/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,3 @@ def minio_server():
finally:
if proc is not None:
proc.kill()


@pytest.fixture(scope='session')
def minio_client(minio_server):
minio = pytest.importorskip('minio')
address, access_key, secret_key = minio_server
return minio.Minio(
address,
access_key=access_key,
secret_key=secret_key,
secure=False
)


@pytest.fixture(scope='session')
def minio_bucket(minio_client):
bucket_name = 'pyarrow-bucket'
minio_client.make_bucket(bucket_name)
return bucket_name
1 change: 0 additions & 1 deletion python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def subtree_localfs(request, tempdir, localfs):
@pytest.fixture
def s3fs(request, minio_server):
from pyarrow.fs import S3FileSystem
# initialize_s3()

address, access_key, secret_key = minio_server
bucket = 'pyarrow-filesystem/'
Expand Down

0 comments on commit c1df10b

Please sign in to comment.