-
Notifications
You must be signed in to change notification settings - Fork 306
Add OSS support #199
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
Merged
Merged
Add OSS support #199
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8934a0b
Add OSS support
zou000 0420de0
* Update WORKSPACE
zou000 b6a3224
* buildifier
zou000 e246e23
* fix lint
zou000 ba0b68d
* disable invalid names
zou000 d5e4c12
* address comments
zou000 1d4f891
Adress comments
zou000 5102873
* fix lint
zou000 4830c0c
* add BUILD file
zou000 ee3362d
* move symbol to top level
zou000 e0496eb
* update lib
zou000 ab06756
* remove unused BUILD rules
zou000 472b49b
* remove dependency on pre-installed dynamic libs
zou000 7982d21
* lint
zou000 1416c4b
* remove apr_passwd.c, which depneds on crypt.h, which is missing on …
zou000 474aff5
* no need for boringssl
zou000 d5b487d
* macos
zou000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package( | ||
| default_visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| licenses(["notice"]) # Apache 2.0 | ||
|
|
||
| cc_binary( | ||
| name = "python/ops/_oss_ops.so", | ||
| srcs = [ | ||
| "kernels/ossfs/oss_file_system.cc", | ||
| "kernels/ossfs/oss_file_system.h", | ||
| "ops/ossfs_ops.cc", | ||
| ], | ||
| copts = [ | ||
| "-D_GLIBCXX_USE_CXX11_ABI=0", | ||
| ], | ||
| linkshared = 1, | ||
| deps = [ | ||
| "@aliyun_oss_c_sdk", | ||
| "@local_config_tf//:libtensorflow_framework", | ||
| "@local_config_tf//:tf_header_lib", | ||
| "@minini", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # TensorFlow OSS Filesystem Extension | ||
|
|
||
| OSS is an object storage service provided by Alibaba Cloud, see [here](https://www.alibabacloud.com/product/oss) for more information about the service. | ||
|
|
||
| This module provides an extension that emulates a filesystem using the object storage service. The directory structures are encoded in object keys and file contents are stored in objects. The extension is implemented using [OSS C SDK](https://github.com/aliyun/aliyun-oss-c-sdk). | ||
|
|
||
| To use the extension, first save your OSS credential in a file, in `INI` format: | ||
|
|
||
| ``` | ||
| [OSSCredentials] | ||
| host = cn-hangzhou.oss.aliyun-inc.com | ||
| accessid = your_oss_access_id | ||
| accesskey = you_oss_access_key | ||
| ``` | ||
|
|
||
| Then set environment variable `OSS_CREDENTIALS` to the path of the file. | ||
|
|
||
| In Python code, import the extension `ossfs_op` module to use the extension with `gfile`. The files and directory URI should have `oss://` prefix, followed by a bucket name, then the directory hierarchy. | ||
|
|
||
| ```python | ||
| import tensorflow_io.oss.python.ops.ossfs_ops | ||
| from tensorflow.python.platform import gfile | ||
|
|
||
| gfile.MkDir('oss://your_bucket_name/test_dir') | ||
| ``` | ||
| With the extension installed, OSS files can be use with Dataset Ops, etc., in the same fashion as other files. | ||
|
|
||
| ```python | ||
| dataset = tf.data.TextLineDataset(["oss://bucket_name/data_dir/file1"]) | ||
| ``` | ||
|
|
||
| ## Test | ||
|
|
||
| File `tests/test_oss.py` contains basic filesystem functionality tests. See `README.md` in root directory for more information about running tests. Besides `OSS_CREDENTIALS`, the tests also require an `OSS_FS_TEST_BUCKET` environment variable containing an accessible bucket name. Make sure they are set before running `pytest tests`. You can also just run the OSS test using `pytest tests/test_oss.py` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Copyright 2016 The TensorFlow Authors. All Rights Reserved. | ||
| # | ||
| # Licensed 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. | ||
| # ============================================================================== | ||
| """Alibaba OSS File System. | ||
|
|
||
| @@ossfs_ops | ||
| """ | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
| from tensorflow_io.oss.python.ops import ossfs_ops # pylint: disable=unused-import | ||
|
|
||
| from tensorflow.python.util.all_util import remove_undocumented | ||
|
|
||
| _allowed_symbols = [ | ||
| "ossfs_ops", | ||
| ] | ||
|
|
||
| remove_undocumented(__name__, allowed_exception_list=_allowed_symbols) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.