You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by st...@apache.org on 2018/05/14 12:30:03 UTC

[19/25] incubator-s2graph git commit: update example scripts.

update example scripts.


Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/2febaae7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/2febaae7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/2febaae7

Branch: refs/heads/master
Commit: 2febaae7b2d2eff80e53472cb22aafef8c47d5ad
Parents: b91054c
Author: DO YUNG YOON <st...@apache.org>
Authored: Mon May 14 11:39:12 2018 +0900
Committer: DO YUNG YOON <st...@apache.org>
Committed: Mon May 14 12:19:55 2018 +0900

----------------------------------------------------------------------
 example/common.sh                               | 13 +++++++++++
 example/movielens/desc.md                       |  4 ++++
 example/movielens/jobdesc.template              | 24 ++------------------
 .../movielens/schema/edge.similar.movie.graphql |  1 -
 example/postprocess.sh                          | 22 ++++++++++++++++++
 example/run.sh                                  |  4 ----
 .../core/fetcher/tensorflow/LabelImage.java     |  1 +
 .../fetcher/fasttext/FastTextFetcherTest.scala  |  7 ++++++
 .../tensorflow/InceptionFetcherTest.scala       | 10 ++++----
 9 files changed, 55 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/common.sh
----------------------------------------------------------------------
diff --git a/example/common.sh b/example/common.sh
index b7f3187..4fe65fc 100644
--- a/example/common.sh
+++ b/example/common.sh
@@ -68,3 +68,16 @@ get_labels() {
         "query": "query{Management{Labels {id name}}}"
     }'
 }
+
+update_edge_fetcher() {
+    curl -i -XPOST $REST/updateEdgeFetcher -H 'content-type: application/json' -d '
+    {
+        "label": "similar_movie",
+        "options": {
+            "fetcher": {
+                "className": "org.apache.s2graph.core.fetcher.annoy.AnnoyModelFetcher",
+                "annoyIndexFilePath": "/tmp/annoy_result"
+            }
+        }
+    }'
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/movielens/desc.md
----------------------------------------------------------------------
diff --git a/example/movielens/desc.md b/example/movielens/desc.md
index b4e4777..7837f93 100644
--- a/example/movielens/desc.md
+++ b/example/movielens/desc.md
@@ -28,3 +28,7 @@ This dataset (ml-latest-small) describes 5-star rating and free-text tagging act
 It contains 100004 ratings and 1296 tag applications across 9125 movies. 
 These data were created by 671 users between January 09, 1995 and October 16, 2016. 
 This dataset was generated on October 17, 2016.
+
+# Description
+
+This example will upload 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/movielens/jobdesc.template
----------------------------------------------------------------------
diff --git a/example/movielens/jobdesc.template b/example/movielens/jobdesc.template
index 7cb1581..19ee116 100644
--- a/example/movielens/jobdesc.template
+++ b/example/movielens/jobdesc.template
@@ -115,16 +115,6 @@
         "itemCol": "movieId",
         "ratingCol": "rating"
       }
-    },
-    {
-      "name": "build_movie_dict",
-      "inputs": [
-        "movies"
-      ],
-      "type": "sql",
-      "options": {
-        "sql": "SELECT CAST(movieId as INT) as idx FROM movies where movieId != null"
-      }
     }
   ],
   "sink": [
@@ -170,22 +160,12 @@
       "inputs": [
         "factorize_rating"
       ],
-      "type": "annoy",
+      "type": "custom",
       "options": {
+        "class": "org.apache.s2graph.s2jobs.task.custom.sink.AnnoyIndexBuildSink",
         "itemFactors": "/tmp/itemFactors",
         "path": "/tmp/annoy_result"
       }
-    },
-    {
-      "name": "dict_sink",
-      "inputs": [
-        "build_movie_dict"
-      ],
-      "type": "file",
-      "options": {
-        "format": "csv",
-        "path": "/tmp/annoy_dict"
-      }
     }
   ]
 }

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/movielens/schema/edge.similar.movie.graphql
----------------------------------------------------------------------
diff --git a/example/movielens/schema/edge.similar.movie.graphql b/example/movielens/schema/edge.similar.movie.graphql
index bb625a0..f8ac33b 100644
--- a/example/movielens/schema/edge.similar.movie.graphql
+++ b/example/movielens/schema/edge.similar.movie.graphql
@@ -45,7 +45,6 @@ mutation{
         name:"_PK"
         propNames:["score"]
       }
-      options: "{\n    \"fetcher\": {\n        \"class\": \"org.apache.s2graph.core.fetcher.annoy.AnnoyModelFetcher\",\n        \"annoyIndexFilePath\": \"/tmp/annoy_result\"\n    }\n}"
     ) {
       isSuccess
       message

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/postprocess.sh
----------------------------------------------------------------------
diff --git a/example/postprocess.sh b/example/postprocess.sh
new file mode 100644
index 0000000..79ce327
--- /dev/null
+++ b/example/postprocess.sh
@@ -0,0 +1,22 @@
+#!/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.
+source common.sh
+
+q "update edge fetcher."
+update_edge_fetcher
+info "postprocess finished.."
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/example/run.sh
----------------------------------------------------------------------
diff --git a/example/run.sh b/example/run.sh
index 5256974..32a2397 100644
--- a/example/run.sh
+++ b/example/run.sh
@@ -40,7 +40,3 @@ sh ./create_schema.sh $SERVICE
 q "Finally, we import example data to service"
 sh ./import_data.sh $SERVICE
 [ $? -ne 0 ] && { exit -1; }
-
-#q "Run ML Model into S2Graph by importing Model."
-#sh ./import_model.sh $SERVICE
-#[ $? -ne 0 ] && { exit -1; }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/s2core/src/main/java/org/apache/s2graph/core/fetcher/tensorflow/LabelImage.java
----------------------------------------------------------------------
diff --git a/s2core/src/main/java/org/apache/s2graph/core/fetcher/tensorflow/LabelImage.java b/s2core/src/main/java/org/apache/s2graph/core/fetcher/tensorflow/LabelImage.java
index 1125cea..5fc41e1 100644
--- a/s2core/src/main/java/org/apache/s2graph/core/fetcher/tensorflow/LabelImage.java
+++ b/s2core/src/main/java/org/apache/s2graph/core/fetcher/tensorflow/LabelImage.java
@@ -12,6 +12,7 @@ import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
 
+// copied from https://github.com/tensorflow/tensorflow/blob/r1.7/tensorflow/java/src/main/java/org/tensorflow/examples/LabelImage.java
 /** Sample use of the TensorFlow Java API to label images using a pre-trained model. */
 public class LabelImage {
     private static void printUsage(PrintStream s) {

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/s2core/src/test/scala/org/apache/s2graph/core/fetcher/fasttext/FastTextFetcherTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/fetcher/fasttext/FastTextFetcherTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/fasttext/FastTextFetcherTest.scala
new file mode 100644
index 0000000..ff0fab2
--- /dev/null
+++ b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/fasttext/FastTextFetcherTest.scala
@@ -0,0 +1,7 @@
+package org.apache.s2graph.core.fetcher.fasttext
+
+import org.apache.s2graph.core.fetcher.BaseFetcherTest
+
+class FastTextFetcherTest extends BaseFetcherTest {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/2febaae7/s2core/src/test/scala/org/apache/s2graph/core/fetcher/tensorflow/InceptionFetcherTest.scala
----------------------------------------------------------------------
diff --git a/s2core/src/test/scala/org/apache/s2graph/core/fetcher/tensorflow/InceptionFetcherTest.scala b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/tensorflow/InceptionFetcherTest.scala
index 31557a7..8f754dc 100644
--- a/s2core/src/test/scala/org/apache/s2graph/core/fetcher/tensorflow/InceptionFetcherTest.scala
+++ b/s2core/src/test/scala/org/apache/s2graph/core/fetcher/tensorflow/InceptionFetcherTest.scala
@@ -42,7 +42,7 @@ class InceptionFetcherTest extends BaseFetcherTest {
         s"""
            |{
            |  "fetcher": {
-           |    "className": "org.apache.s2graph.core.fetcher.tensorflow.InceptionV3Fetcher",
+           |    "className": "org.apache.s2graph.core.fetcher.tensorflow.InceptionFetcher",
            |    "modelPath": "$modelPath"
            |  }
            |}
@@ -50,9 +50,11 @@ class InceptionFetcherTest extends BaseFetcherTest {
       val (service, column, label) = initEdgeFetcher(serviceName, columnName, labelName, Option(options))
 
       val srcVertices = Seq(
-        "http://www.gstatic.com/webp/gallery/1.jpg",
-        "http://www.gstatic.com/webp/gallery/2.jpg",
-        "http://www.gstatic.com/webp/gallery/3.jpg"
+//        "http://www.gstatic.com/webp/gallery/1.jpg",
+//        "http://www.gstatic.com/webp/gallery/2.jpg",
+//        "http://www.gstatic.com/webp/gallery/3.jpg"
+//        "https://di2ponv0v5otw.cloudfront.net/posts/2018/04/16/5ad59a6a61ca107f50032b40/m_5ad59a7750687c9f91641d8b.jpg"
+        "https://t1.daumcdn.net/news/201805/14/autonnews/20180514082041618njfp.jpg"
       )
       val stepResult = queryEdgeFetcher(service, column, label, srcVertices)