From commits-return-87466-archive-asf-public=cust-asf.ponee.io@mxnet.incubator.apache.org Sun Jun 2 16:21:28 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3928218064E for ; Sun, 2 Jun 2019 18:21:28 +0200 (CEST) Received: (qmail 81642 invoked by uid 500); 2 Jun 2019 16:21:27 -0000 Mailing-List: contact commits-help@mxnet.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mxnet.incubator.apache.org Delivered-To: mailing list commits@mxnet.incubator.apache.org Received: (qmail 81633 invoked by uid 99); 2 Jun 2019 16:21:27 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jun 2019 16:21:27 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7AFFC8A836; Sun, 2 Jun 2019 16:21:27 +0000 (UTC) Date: Sun, 02 Jun 2019 16:21:24 +0000 To: "commits@mxnet.apache.org" Subject: [incubator-mxnet] branch master updated: [clojure] fix: image test does not rely on s3 to run (#15122) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155949248154.6272.7013498079875209750@gitbox.apache.org> From: kedarb@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-mxnet X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6118dcc1292e728c0a383319a004a882c3d4ee63 X-Git-Newrev: 52f77c971e8a6e5c8c6942345fd6cfd058377d69 X-Git-Rev: 52f77c971e8a6e5c8c6942345fd6cfd058377d69 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. kedarb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git The following commit(s) were added to refs/heads/master by this push: new 52f77c9 [clojure] fix: image test does not rely on s3 to run (#15122) 52f77c9 is described below commit 52f77c971e8a6e5c8c6942345fd6cfd058377d69 Author: Arthur Caillau AuthorDate: Sun Jun 2 18:20:49 2019 +0200 [clojure] fix: image test does not rely on s3 to run (#15122) * [clojure] fix: image test does not rely on s3 to run * rename `with-image` to `with-file` --- .../test/org/apache/clojure_mxnet/image_test.clj | 34 +++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj b/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj index 23b88d0..b543b2d 100644 --- a/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj +++ b/contrib/clojure-package/test/org/apache/clojure_mxnet/image_test.clj @@ -19,32 +19,40 @@ (:require [org.apache.clojure-mxnet.image :as image] [org.apache.clojure-mxnet.ndarray :as ndarray] [clojure.java.io :as io] - [clojure.test :refer :all]) + [clojure.test :refer [deftest is use-fixtures]]) (:import (javax.imageio ImageIO) (java.io File))) (def tmp-dir (System/getProperty "java.io.tmpdir")) (def image-path (.getAbsolutePath (io/file tmp-dir "Pug-Cookie.jpg"))) +(def image-src-path "test/test-images/Pug-Cookie.jpg") -(defn download-image [] - (with-open [in (io/input-stream "https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg") - out (io/output-stream (io/file image-path))] +(defn- cp + "Copy from filepath `from` to filepath `to`." + [from to] + (with-open [in (io/input-stream (io/file from)) + out (io/output-stream (io/file to))] (io/copy in out))) -(defn delete-image [] - (io/delete-file image-path)) +(defn- rm + "Removes `filepath`." + [filepath] + (io/delete-file filepath)) -(defn with-downloaded-image [f] - (download-image) - (f) - (delete-image)) +(defn- with-file + "Provides `src-path` in `dest-path` for the test function `f` to use." + [src-path dest-path] + (fn [f] + (cp src-path dest-path) + (f) + (rm dest-path))) -(use-fixtures :once with-downloaded-image) +(use-fixtures :once (with-file image-src-path image-path)) (deftest test-decode-image - (let [img-arr (image/decode-image + (let [img-arr (image/decode-image (io/input-stream image-path)) - img-arr-2 (image/decode-image + img-arr-2 (image/decode-image (io/input-stream image-path) {:color-flag image/GRAYSCALE})] (is (= [576 1024 3] (ndarray/shape-vec img-arr)))