Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5200af1
s3 filesystem bindings
kszucs Sep 18, 2019
dd41d21
imports [skip ci]
kszucs Sep 18, 2019
1551b52
wip [skip ci]
kszucs Sep 19, 2019
a343950
testing suite
kszucs Sep 20, 2019
44aedfd
stat test
kszucs Sep 20, 2019
c0b9162
test requirements; flake8
kszucs Sep 22, 2019
45a2a17
docstrings
kszucs Sep 22, 2019
9ce7180
cmake format; fix orc cimport
kszucs Sep 22, 2019
9042c7e
use S3FS_DIR
kszucs Sep 22, 2019
f25ae5a
travis
kszucs Sep 22, 2019
efa05d2
use minio for dask.s3fs test too
kszucs Sep 22, 2019
2cb19d1
conditional import of test dependencies
kszucs Sep 22, 2019
68eb591
enable PYARROW_WITH_S3 on appveyor
kszucs Sep 22, 2019
7daf566
fix syntax error in travis script
kszucs Sep 22, 2019
7800c75
appveyor flag
kszucs Sep 22, 2019
72e56a6
enable S3 in travis python builds
kszucs Sep 23, 2019
8cbe0ee
travis osx
kszucs Sep 23, 2019
fb0f281
travis minio install script
kszucs Sep 23, 2019
041cad4
executable flag
kszucs Sep 23, 2019
d372287
install minio in the conda-toolchain build
kszucs Sep 23, 2019
8585a60
py2 compat
kszucs Sep 23, 2019
88e0c9f
py2 compat
kszucs Sep 23, 2019
2be25ce
auto initialize s3 on import
kszucs Sep 23, 2019
00340ed
fixture error handling
kszucs Sep 23, 2019
098048a
more compat
kszucs Sep 23, 2019
c541b3e
comment left
kszucs Sep 23, 2019
38dcb88
rat
kszucs Sep 24, 2019
45436f7
cython flake8
kszucs Sep 24, 2019
751cfd4
resolve a couple of review comments; enum workaround
kszucs Sep 24, 2019
fee57a9
remove accidentally committed files
kszucs Sep 24, 2019
d399643
simplify test suite
kszucs Sep 24, 2019
f70f9fb
remove minio-client dependency
kszucs Sep 24, 2019
192ab65
flake8
kszucs Sep 24, 2019
c1df10b
initialization in first use
kszucs Sep 25, 2019
4478458
fix read() issue
kszucs Sep 25, 2019
db89859
rename to s3fs
kszucs Sep 25, 2019
98bd91a
remove commented tests
kszucs Sep 25, 2019
73e6625
S3Options
kszucs Sep 26, 2019
384c960
Resolve review comments
kszucs Sep 30, 2019
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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ matrix:
- if [ $ARROW_CI_CPP_AFFECTED != "1" ] && [ $ARROW_CI_JAVA_AFFECTED != "1" ]; then exit; fi
- $TRAVIS_BUILD_DIR/ci/travis_install_clang_tools.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_linux.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_minio.sh
# If either C++ or Python changed, we must install the C++ libraries
- git submodule update --init
- $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh
Expand All @@ -110,12 +111,14 @@ matrix:
- ARROW_TRAVIS_USE_SYSTEM_JAVA=1
- ARROW_TRAVIS_USE_TOOLCHAIN=1
- ARROW_TRAVIS_VALGRIND=1
- ARROW_TRAVIS_S3=1
# TODO(wesm): Run the benchmarks outside of Travis
# - ARROW_TRAVIS_PYTHON_BENCHMARKS=1
before_script:
- if [ $ARROW_CI_PYTHON_AFFECTED != "1" ] && [ $ARROW_CI_DOCS_AFFECTED != "1" ]; then exit; fi
- $TRAVIS_BUILD_DIR/ci/travis_install_clang_tools.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_linux.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_minio.sh
- $TRAVIS_BUILD_DIR/ci/travis_install_toolchain.sh
script:
- $TRAVIS_BUILD_DIR/ci/travis_script_java.sh || travis_terminate 1
Expand All @@ -136,6 +139,7 @@ matrix:
- ARROW_TRAVIS_PLASMA=1
- ARROW_TRAVIS_FLIGHT=1
- ARROW_TRAVIS_ORC=1
- ARROW_TRAVIS_S3=1
- ARROW_TRAVIS_PARQUET=1
# TODO(ARROW-4763): llvm and llvmdev packages are in conflict:
# https://github.com/conda-forge/llvmdev-feedstock/issues/60
Expand All @@ -149,6 +153,7 @@ matrix:
- if [ $ARROW_CI_CPP_AFFECTED != "1" ] && [ $ARROW_CI_JAVA_AFFECTED != "1" ]; then exit; fi
# If either C++ or Python changed, we must install the C++ libraries
- git submodule update --init
- $TRAVIS_BUILD_DIR/ci/travis_install_minio.sh
- $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh
script:
- $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh || travis_terminate 1
Expand All @@ -161,6 +166,7 @@ matrix:
cache:
addons:
env:
- ARROW_TRAVIS_S3=1
- ARROW_TRAVIS_PLASMA=1
- ARROW_TRAVIS_USE_TOOLCHAIN=1
- ARROW_BUILD_WARNING_LEVEL=CHECKIN
Expand All @@ -170,6 +176,7 @@ matrix:
before_script:
script:
- if [ $ARROW_CI_PYTHON_AFFECTED != "1" ]; then exit; fi
- $TRAVIS_BUILD_DIR/ci/travis_install_minio.sh
- $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 3.6
- name: "Java OpenJDK8 and OpenJDK11"
language: cpp
Expand Down
1 change: 1 addition & 0 deletions ci/conda_env_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ numpy>=1.14
pandas
pytest
pytest-faulthandler
pytest-lazy-fixture
Comment thread
kszucs marked this conversation as resolved.
pytz
setuptools
setuptools_scm=3.2.0
3 changes: 3 additions & 0 deletions ci/cpp-msvc-build-main.bat
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pip install -r requirements.txt pickle5

set PYARROW_CXXFLAGS=%ARROW_CXXFLAGS%
set PYARROW_CMAKE_GENERATOR=%GENERATOR%
if "%ARROW_S3%" == "ON" (
set PYARROW_WITH_S3=ON
)
if "%ARROW_BUILD_FLIGHT%" == "ON" (
@rem ARROW-5441: bundling Arrow Flight libraries not implemented
set PYARROW_BUNDLE_ARROW_CPP=OFF
Expand Down
8 changes: 0 additions & 8 deletions ci/travis_install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ if [ "$ARROW_TRAVIS_GANDIVA" == "1" ]; then
sudo apt-get install -y -qq llvm-$ARROW_LLVM_MAJOR_VERSION-dev
fi

if [ "$ARROW_TRAVIS_S3" == "1" ]; then
# Download the Minio S3 server into PATH
S3FS_DIR=~/.local/bin/
mkdir -p $S3FS_DIR
wget --directory-prefix $S3FS_DIR https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x $S3FS_DIR/minio
fi

if [ "$ARROW_TRAVIS_USE_SYSTEM" == "1" ]; then
if [ "$DISTRO_CODENAME" == "xenial" ]; then
# TODO(ARROW-4761): Install libzstd-dev once we support zstd<1
Expand Down
35 changes: 35 additions & 0 deletions ci/travis_install_minio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -e
set -x

if [ "$ARROW_TRAVIS_S3" == "1" ]; then
# Download the Minio S3 server into PATH
if [ $TRAVIS_OS_NAME = "osx" ]; then
MINIO_URL=https://dl.min.io/server/minio/release/darwin-amd64/minio
else
MINIO_URL=https://dl.min.io/server/minio/release/linux-amd64/minio
fi

S3FS_DIR=~/.local/bin/
mkdir -p $S3FS_DIR
wget --directory-prefix $S3FS_DIR $MINIO_URL
chmod +x $S3FS_DIR/minio
fi
2 changes: 1 addition & 1 deletion ci/travis_install_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ if [ "$ARROW_CI_RUBY_AFFECTED" = "1" ]; then
run_brew bundle --file=$TRAVIS_BUILD_DIR/cpp/Brewfile --verbose
run_brew bundle --file=$TRAVIS_BUILD_DIR/c_glib/Brewfile --verbose
rm ${brew_log_path}
fi
fi
8 changes: 8 additions & 0 deletions ci/travis_script_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ CMAKE_COMMON_FLAGS="-DARROW_EXTRA_ERROR_CONTEXT=ON"

PYTHON_CPP_BUILD_TARGETS="arrow_python-all plasma parquet"

if [ "$ARROW_TRAVIS_S3" == "1" ]; then
CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_S3=ON"
fi

if [ "$ARROW_TRAVIS_FLIGHT" == "1" ]; then
CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_FLIGHT=ON"
fi
Expand Down Expand Up @@ -164,6 +168,9 @@ export PYARROW_BUILD_TYPE=$ARROW_BUILD_TYPE
export PYARROW_WITH_PARQUET=1
export PYARROW_WITH_PLASMA=1
export PYARROW_WITH_ORC=1
if [ "$ARROW_TRAVIS_S3" == "1" ]; then
export PYARROW_WITH_S3=1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I suppose there's a leftover here or above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARROW_TRAVIS_S3 is still optional, so we need it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but look at the diff :-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean, have I removed ARROW_TRAVIS_S3 or PYARROW_WITH_S3?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this:

export PYARROW_WITH_S3=1
if [ "$ARROW_TRAVIS_S3" == "1" ]; then
  export PYARROW_WITH_S3=1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:), fixing it

fi
if [ "$ARROW_TRAVIS_FLIGHT" == "1" ]; then
export PYARROW_WITH_FLIGHT=1
fi
Expand All @@ -177,6 +184,7 @@ python setup.py develop
python -c "import pyarrow.parquet"
python -c "import pyarrow.plasma"
python -c "import pyarrow.orc"
python -c "import pyarrow.fs"

# Ensure we do eagerly import pandas (or other expensive imports)
python < scripts/test_imports.py
Expand Down
10 changes: 10 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,16 @@ if(ARROW_S3)
include_directories(SYSTEM ${AWSSDK_INCLUDE_DIR})
message(STATUS "Found AWS SDK headers: ${AWSSDK_INCLUDE_DIR}")
message(STATUS "Found AWS SDK libraries: ${AWSSDK_LINK_LIBRARIES}")

if(APPLE)
# CoreFoundation's path is hardcoded in the CMake files provided by
# aws-sdk-cpp to use the MacOSX SDK provided by XCode which makes
# XCode a hard dependency. Command Line Tools is often used instead
# of the full XCode suite, so let the linker to find it.
set_target_properties(AWS::aws-c-common
Comment thread
kszucs marked this conversation as resolved.
Outdated
PROPERTIES INTERFACE_LINK_LIBRARIES
"-pthread;pthread;-framework CoreFoundation")
endif()
endif()

# Write out the package configurations.
Expand Down
6 changes: 6 additions & 0 deletions cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ class ObjectInputFile : public io::RandomAccessFile {
RETURN_NOT_OK(CheckClosed());
RETURN_NOT_OK(CheckPosition(position, "read"));

nbytes = std::min(nbytes, content_length_ - position);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pitrou this is the fix for stream.read() issue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! And thanks for the tests too.

if (nbytes == 0) {
*bytes_read = 0;
return Status::OK();
}

// Read the desired range of bytes
S3Model::GetObjectResult result;
RETURN_NOT_OK(GetObjectRange(client_, path_, position, nbytes, &result));
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/s3fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ARROW_EXPORT S3FileSystem : public FileSystem {
std::unique_ptr<Impl> impl_;
};

enum class S3LogLevel { Off, Fatal, Error, Warn, Info, Debug, Trace };
enum class S3LogLevel : int8_t { Off, Fatal, Error, Warn, Info, Debug, Trace };

struct ARROW_EXPORT S3GlobalOptions {
S3LogLevel log_level;
Expand Down
11 changes: 10 additions & 1 deletion cpp/src/arrow/filesystem/s3fs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ TEST_F(TestS3FS, OpenInputStream) {
TEST_F(TestS3FS, OpenInputFile) {
std::shared_ptr<io::RandomAccessFile> file;
std::shared_ptr<Buffer> buf;
int64_t nbytes = -1, pos = -1;
int64_t nbytes = -1, pos = -1, bytes_read = 0;

// Non-existent
ASSERT_RAISES(IOError, fs_->OpenInputFile("non-existent-bucket/somefile", &file));
Expand All @@ -691,6 +691,15 @@ TEST_F(TestS3FS, OpenInputFile) {
AssertBufferEqual(*buf, "data");
ASSERT_OK(file->ReadAt(9, 20, &buf));
AssertBufferEqual(*buf, "");

char result[10];
ASSERT_OK(file->ReadAt(2, 5, &bytes_read, &result));
ASSERT_EQ(bytes_read, 5);
ASSERT_OK(file->ReadAt(5, 20, &bytes_read, &result));
ASSERT_EQ(bytes_read, 4);
ASSERT_OK(file->ReadAt(9, 0, &bytes_read, &result));
ASSERT_EQ(bytes_read, 0);

// Reading past end of file
ASSERT_RAISES(IOError, file->ReadAt(10, 20, &buf));

Expand Down
4 changes: 4 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ set(CYTHON_EXTENSIONS lib _fs _csv _json)

set(LINK_LIBS arrow_shared arrow_python_shared)

if(PYARROW_BUILD_S3)
set(CYTHON_EXTENSIONS ${CYTHON_EXTENSIONS} _s3fs)
endif()

if(PYARROW_BUILD_CUDA)
# Arrow CUDA
find_package(ArrowCuda)
Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/_csv.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ cdef class ConvertOptions:
self.options.include_missing_columns = value


cdef _get_reader(input_file, shared_ptr[InputStream]* out):
cdef _get_reader(input_file, shared_ptr[CInputStream]* out):
use_memory_map = False
get_input_stream(input_file, use_memory_map, out)

Expand Down Expand Up @@ -522,7 +522,7 @@ def read_csv(input_file, read_options=None, parse_options=None,
Contents of the CSV file as a in-memory table.
"""
cdef:
shared_ptr[InputStream] stream
shared_ptr[CInputStream] stream
CCSVReadOptions c_read_options
CCSVParseOptions c_parse_options
CCSVConvertOptions c_convert_options
Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/_cuda.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ cdef class BufferReader(NativeFile):
self.buffer = obj
self.reader = new CCudaBufferReader(self.buffer.buffer)
self.set_random_access_file(
shared_ptr[RandomAccessFile](self.reader))
shared_ptr[CRandomAccessFile](self.reader))
self.is_readable = True

def read_buffer(self, nbytes=None):
Expand Down Expand Up @@ -776,7 +776,7 @@ cdef class BufferWriter(NativeFile):
def __cinit__(self, CudaBuffer buffer):
self.buffer = buffer
self.writer = new CCudaBufferWriter(self.buffer.cuda_buffer)
self.set_output_stream(shared_ptr[OutputStream](self.writer))
self.set_output_stream(shared_ptr[COutputStream](self.writer))
self.is_writable = True

def writeat(self, int64_t position, object data):
Expand Down
68 changes: 68 additions & 0 deletions python/pyarrow/_fs.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# cython: language_level = 3

import six

from pyarrow.compat import frombytes, tobytes
from pyarrow.includes.common cimport *
from pyarrow.includes.libarrow cimport PyDateTime_from_TimePoint
from pyarrow.lib import _detect_compression
from pyarrow.lib cimport *


cpdef enum FileType:
NonExistent = <int8_t> CFileType_NonExistent
Unknown = <int8_t> CFileType_Unknown
File = <int8_t> CFileType_File
Directory = <int8_t> CFileType_Directory


cdef class FileStats:
cdef:
CFileStats stats

@staticmethod
cdef FileStats wrap(CFileStats stats)


cdef class Selector:
cdef:
CSelector selector


cdef class FileSystem:
cdef:
shared_ptr[CFileSystem] wrapped
CFileSystem* fs

cdef init(self, const shared_ptr[CFileSystem]& wrapped)


cdef class LocalFileSystem(FileSystem):
cdef:
CLocalFileSystem* localfs

cdef init(self, const shared_ptr[CFileSystem]& wrapped)


cdef class SubTreeFileSystem(FileSystem):
Comment thread
kszucs marked this conversation as resolved.
Outdated
cdef:
CSubTreeFileSystem* subtreefs

cdef init(self, const shared_ptr[CFileSystem]& wrapped)
Loading