Skip to content

Conversation

@zou000
Copy link
Contributor

@zou000 zou000 commented Apr 17, 2019

Fix #41

@yongtang
Copy link
Member

@zou000 Can you move the python test file to tests/ directory? In this way it could be automatically picked up by pytest.

Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

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

Looks great in general. Just left a couple small comments. Perhaps this could be some follow-up work but does OSS provide any mocking utilities similar to moto for S3 so we could write some simple unit tests?

@yongtang
Copy link
Member

If mocking is not possible, maybe some simple sanity test to make sure at least it build and runs, e.g., access some publicly accessible "hello world" file on OSS?

@zou000
Copy link
Contributor Author

zou000 commented Apr 30, 2019

@zou000 Can you move the python test file to tests/ directory? In this way it could be automatically picked up by pytest.

@zou000 Can you move the python test file to tests/ directory? In this way it could be automatically picked up by pytest.

Done.

@zou000
Copy link
Contributor Author

zou000 commented Apr 30, 2019

Looks great in general. Just left a couple small comments. Perhaps this could be some follow-up work but does OSS provide any mocking utilities similar to moto for S3 so we could write some simple unit tests?

If mocking is not possible, maybe some simple sanity test to make sure at least it build and runs, e.g., access some publicly accessible "hello world" file on OSS?

I asked around, unfortunately, it seems there is neither an OSS mocking framework nor public accessible OSS files for tests. For example the popular OSS java sdk also rely on user's own credentials for tests: https://github.com/aliyun/aliyun-oss-java-sdk/blob/master/src/test/java/com/aliyun/oss/testing/ConcurrencyTest.java#L39 I made a change to skip OSS test cases if the env variables are absent. This is not ideal but at least it can test
the OSS extension can be imported.

@terrytangyuan
Copy link
Member

Thanks! I think it’s fine for now. Could you fix the Travis build?

@zou000
Copy link
Contributor Author

zou000 commented May 1, 2019

Thanks! I think it’s fine for now. Could you fix the Travis build?

Travis CI needs to be configured to use some specific bazel flags, as described in detail in #200. I am not familiar with your travis setup and I am wondering if you or @yongtang can make a quick change? Thanks.

@yongtang
Copy link
Member

yongtang commented May 2, 2019

@zou000 the docker image of custom-op actually uses standalone mode in bazel which might create unintended consequences (something to be fixed). It relies on environment installation which could vary a lot.

In tensorflow-io, we use sandbox mode to make sure all dependency binaries are specified.

I have created a patch that should fixed the build failures. Can you apply the patch:

From dbf53e2d74e3eb90de99895c9aa83a6e9b05f9d2 Mon Sep 17 00:00:00 2001
From: Yong Tang <[email protected]>
Date: Thu, 2 May 2019 14:58:54 +0000
Subject: [PATCH] Add libexpat and fixed several dependency issues

Signed-off-by: Yong Tang <[email protected]>
---
 WORKSPACE                     | 10 ++++++++++
 third_party/libaprutil1.BUILD |  7 +++++--
 third_party/libexpat.BUILD    | 30 ++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 third_party/libexpat.BUILD

diff --git a/WORKSPACE b/WORKSPACE
index f105f64..0376dea 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -290,6 +290,16 @@ http_archive(
     ],
 )

+http_archive(
+    name = "libexpat",
+    build_file = "//third_party:libexpat.BUILD",
+    sha256 = "574499cba22a599393e28d99ecfa1e7fc85be7d6651d543045244d5b561cb7ff",
+    strip_prefix = "libexpat-R_2_2_6/expat",
+    urls = [
+        "http://github.com/libexpat/libexpat/archive/R_2_2_6.tar.gz",
+    ],
+)
+
 http_archive(
     name = "libapr1",
     build_file = "//third_party:libapr1.BUILD",
diff --git a/third_party/libaprutil1.BUILD b/third_party/libaprutil1.BUILD
index 6545137..ad9b6ac 100644
--- a/third_party/libaprutil1.BUILD
+++ b/third_party/libaprutil1.BUILD
@@ -4,7 +4,10 @@ licenses(["notice"])  # Apache license (for libapr1)

 cc_library(
     name = "libaprutil1",
-    srcs = [
+    srcs = glob([
+        "include/private/apu_*.h",
+        "include/private/apr_*.h",
+    ]) + [
         "buckets/apr_brigade.c",
         "buckets/apr_buckets.c",
         "buckets/apr_buckets_alloc.c",
@@ -112,10 +115,10 @@ cc_library(
         "-lrt",
         "-lcrypt",
         "-lpthread",
-        "-lexpat",
     ],
     strip_include_prefix = "include",
     deps = [
         "@libapr1",
+        "@libexpat",
     ],
 )
diff --git a/third_party/libexpat.BUILD b/third_party/libexpat.BUILD
new file mode 100644
index 0000000..f0e617c
--- /dev/null
+++ b/third_party/libexpat.BUILD
@@ -0,0 +1,30 @@
+# Description:
+#   Expat library
+
+licenses(["notice"])
+
+exports_files(["COPYING"])
+
+cc_library(
+    name = "libexpat",
+    srcs = [
+        "lib/xmlparse.c",
+        "lib/xmlrole.c",
+        "lib/xmltok.c",
+    ],
+    hdrs = glob([
+        "lib/*.h",
+    ]) + [
+        "lib/xmltok_impl.c",
+        "lib/xmltok_ns.c",
+    ],
+    copts = [
+        "-DHAVE_MEMMOVE",
+        "-DXML_POOR_ENTROPY",
+    ],
+    includes = [
+        "lib",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [],
+)
--
2.17.2

Also see attachment:
0001.patch.txt

@yongtang
Copy link
Member

yongtang commented May 2, 2019

@zou000 With the above the build should pass.

@terrytangyuan
Copy link
Member

terrytangyuan commented May 2, 2019

@yongtang Perhaps let's get that patch PR'ed into master first. Otherwise the commit history here might be messed up and we might encounter issues with the CLA.

@yongtang
Copy link
Member

yongtang commented May 2, 2019

@zou000 The PR #210 has been merged. You can rebase the master and make the following changes in libaprutil1.BUILD:

diff --git a/third_party/libaprutil1.BUILD b/third_party/libaprutil1.BUILD
index 6545137..ad9b6ac 100644
--- a/third_party/libaprutil1.BUILD
+++ b/third_party/libaprutil1.BUILD
@@ -4,7 +4,10 @@ licenses(["notice"])  # Apache license (for libapr1)
 
 cc_library(
     name = "libaprutil1",
-    srcs = [
+    srcs = glob([
+        "include/private/apu_*.h",
+        "include/private/apr_*.h",
+    ]) + [
         "buckets/apr_brigade.c",
         "buckets/apr_buckets.c",
         "buckets/apr_buckets_alloc.c",
@@ -112,10 +115,10 @@ cc_library(
         "-lrt",
         "-lcrypt",
         "-lpthread",
-        "-lexpat",
     ],
     strip_include_prefix = "include",
     deps = [
         "@libapr1",
+        "@libexpat",
     ],
 )

@zou000
Copy link
Contributor Author

zou000 commented May 2, 2019

@zou000 The PR #210 has been merged. You can rebase the master and make the following changes in libaprutil1.BUILD:
Thanks @yongtang and @terrytangyuan for looking into this and adding libexpat library. I made the change and I think it should pass CI this time.

Like @yongtang mentioned above it would be great to have a development docker container consistent with CI and release environment. #203 introduced 2 changes that accidentally made OSS work. Besides the libexpat library, the image also contains a /etc/bazelrc file that circumvented a couple of bazel-in-docker bugs. @yongtang's suggested patch also circumvented this bug, but in a different way. Personally, I think the bazelrc way is better as it makes development the same in docker and on host. Though I will leave it to you guys to decide.

I will update #200 with the info and close it.

Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

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

Thanks for the efforts! @zou000 I'll merge this once the CI passes.

@yongtang
Copy link
Member

yongtang commented May 2, 2019

@zou000 @terrytangyuan Looks like there are still some issues on certain platforms. I think you could remove -lexpat and -lcrypt, and add boringssl as the dependency

In other word, apply the following patch:

diff --git a/third_party/libaprutil1.BUILD b/third_party/libaprutil1.BUILD
index 038a361..3b0d5d0 100644
--- a/third_party/libaprutil1.BUILD
+++ b/third_party/libaprutil1.BUILD
@@ -113,13 +113,12 @@ cc_library(
     ],
     linkopts = [
         "-lrt",
-        "-lcrypt",
         "-lpthread",
-        "-lexpat",
     ],
     strip_include_prefix = "include",
     deps = [
         "@libapr1",
         "@libexpat",
+        "@boringssl//:ssl",
     ],
 )

@zou000
Copy link
Contributor Author

zou000 commented May 2, 2019 via email

@yongtang
Copy link
Member

yongtang commented May 3, 2019

@zou000 We are almost there. I managed to get MacOS building correctly with additional changes:
2efaf48

The Travis CI passed with the above commit applied on top of your PR:

https://travis-ci.org/yongtang/io/builds/527888963

Can you apply the changes in the commit and update the PR?

@zou000
Copy link
Contributor Author

zou000 commented May 3, 2019 via email

@terrytangyuan
Copy link
Member

Thanks for all the efforts!

@terrytangyuan terrytangyuan merged commit 2b4265a into tensorflow:master May 4, 2019
@zou000 zou000 deleted the oss2 branch May 4, 2019 18:12
i-ony pushed a commit to i-ony/io that referenced this pull request Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AlibabaCloud OSS support

3 participants