Procházet zdrojové kódy

circle.yml / pull request 375

Summary: Configuration file for CircleCI's continuous integration platform.

Reviewed By: EdouardGrave

Differential Revision: D5496187

fbshipit-source-id: 805cbbdcd5734e03a6a37652cb1d851ce582af49
Christian Puhrsch před 8 roky
rodič
revize
f356ca9fff

+ 138 - 0
.circleci/circle.yml

@@ -0,0 +1,138 @@
+# Python CircleCI 2.0 configuration file
+#
+# Check https://circleci.com/docs/2.0/language-python/ for more details
+#
+# Copyright (c) 2016-present, Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+#
+
+# Maybe one day this will work
+#   "mac":
+#     macos:
+#       xcode: "9.0"
+#     working_directory: ~/repo
+#     steps:
+#       - checkout
+#       - run:
+#           command: |
+#             . .circleci/cmake_test.sh
+
+version: 2
+jobs:
+  "py361":
+    docker:
+      - image: circleci/python:3.6.1
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            sudo pip install pybind11
+            sudo python setup.py install
+            . .circleci/cmake_test.sh
+
+  "py353":
+    docker:
+      - image: circleci/python:3.5.3
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            sudo pip install pybind11
+            sudo python setup.py install
+            . .circleci/cmake_test.sh
+
+  "py346":
+    docker:
+      - image: circleci/python:3.4.6
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            sudo pip install pybind11
+            sudo python setup.py install
+            . .circleci/cmake_test.sh
+
+  "py336":
+    docker:
+      - image: circleci/python:3.3.6
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            sudo pip install pybind11
+            sudo python setup.py install
+            . .circleci/cmake_test.sh
+
+  "py2713":
+    docker:
+      - image: circleci/python:2.7.13
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            sudo pip install pybind11
+            sudo python setup.py install
+            . .circleci/cmake_test.sh
+
+  "gcc5":
+    docker:
+      - image: gcc:5
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            . .circleci/gcc_test.sh
+
+  "gcc6":
+    docker:
+      - image: gcc:6
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            . .circleci/gcc_test.sh
+
+  "gcc7":
+    docker:
+      - image: gcc:7
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            . .circleci/gcc_test.sh
+
+  "gcclatest":
+    docker:
+      - image: gcc:latest
+    working_directory: ~/repo
+    steps:
+      - checkout
+      - run:
+          command: |
+            . .circleci/gcc_test.sh
+
+workflows:
+  version: 2
+  build:
+    jobs:
+      - "py361"
+      - "py353"
+      - "py346"
+      - "py336"
+      - "py2713"
+      - "gcc5"
+      - "gcc6"
+      - "gcc7"
+      - "gcclatest"

+ 20 - 0
.circleci/cmake_test.sh

@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2016-present, Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+#
+
+RESULTDIR=result
+DATADIR=data
+
+sudo apt-get install cmake
+./.circleci/pull_data.sh
+mkdir buildc && cd buildc && cmake .. && make && cd ..
+cp buildc/fasttext .
+./fasttext supervised -input "${DATADIR}/dbpedia.train" -output "${RESULTDIR}/dbpedia" -dim 10 -lr 0.1 -wordNgrams 2 -minCount 1 -bucket 10000000 -epoch 5 -thread 4 -verbose 0
+./fasttext test "${RESULTDIR}/dbpedia.bin" "${DATADIR}/dbpedia.test"
+./fasttext predict "${RESULTDIR}/dbpedia.bin" "${DATADIR}/dbpedia.test" > "${RESULTDIR}/dbpedia.test.predict"

+ 18 - 0
.circleci/gcc_test.sh

@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2016-present, Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+#
+
+RESULTDIR=result
+DATADIR=data
+
+./.circleci/pull_data.sh
+make opt
+./fasttext supervised -input "${DATADIR}/dbpedia.train" -output "${RESULTDIR}/dbpedia" -dim 10 -lr 0.1 -wordNgrams 2 -minCount 1 -bucket 10000000 -epoch 5 -thread 4 -verbose 0
+./fasttext test "${RESULTDIR}/dbpedia.bin" "${DATADIR}/dbpedia.test"
+./fasttext predict "${RESULTDIR}/dbpedia.bin" "${DATADIR}/dbpedia.test" > "${RESULTDIR}/dbpedia.test.predict"

+ 34 - 0
.circleci/pull_data.sh

@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2016-present, Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+#
+
+myshuf() {
+  perl -MList::Util=shuffle -e 'print shuffle(<>);' "$@";
+}
+
+normalize_text() {
+  tr '[:upper:]' '[:lower:]' | sed -e 's/^/__label__/g' | \
+    sed -e "s/'/ ' /g" -e 's/"//g' -e 's/\./ \. /g' -e 's/<br \/>/ /g' \
+        -e 's/,/ , /g' -e 's/(/ ( /g' -e 's/)/ ) /g' -e 's/\!/ \! /g' \
+        -e 's/\?/ \? /g' -e 's/\;/ /g' -e 's/\:/ /g' | tr -s " " | myshuf
+}
+
+RESULTDIR=result
+DATADIR=data
+
+mkdir -p "${RESULTDIR}"
+mkdir -p "${DATADIR}"
+
+if [ ! -f "${DATADIR}/dbpedia.train" ]
+then
+  wget -c "https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz" -O "${DATADIR}/dbpedia_csv.tar.gz"
+  tar -xzvf "${DATADIR}/dbpedia_csv.tar.gz" -C "${DATADIR}"
+  cat "${DATADIR}/dbpedia_csv/train.csv" | normalize_text > "${DATADIR}/dbpedia.train"
+  cat "${DATADIR}/dbpedia_csv/test.csv" | normalize_text > "${DATADIR}/dbpedia.test"
+fi

+ 1 - 1
README.md

@@ -85,7 +85,7 @@ There is also the master branch that contains all of our most recent work, but c
 ```
 $ wget https://github.com/facebookresearch/fastText/archive/v0.1.0.zip
 $ unzip v0.1.0.zip
-$ cd fastText-v0.1.0
+$ cd fastText-0.1.0
 $ make
 ```
  

+ 6 - 4
setup.py

@@ -18,11 +18,12 @@ import sys
 import setuptools
 import os
 
-__version__ = '0.0.2'
+__version__ = '0.0.3'
 FASTTEXT_SRC = "src"
 
 # Based on https://github.com/pybind/python_example
 
+
 class get_pybind_include(object):
     """Helper class to determine the pybind11 include path
     The purpose of this class is to postpone importing pybind11
@@ -101,10 +102,11 @@ class BuildExt(build_ext):
         'unix': [],
     }
 
-    if sys.platform == 'darwin':
-        c_opts['unix'] += ['-stdlib=libc++', '-mmacosx-version-min=10.7']
-
     def build_extensions(self):
+        if sys.platform == 'darwin':
+            if has_flag(self.compiler, '-stdlib=libc++'):
+                self.c_opts['unix'] += ['-stdlib=libc++']
+            self.c_opts['unix'] += ['-mmacosx-version-min=10.7']
         ct = self.compiler.compiler_type
         opts = self.c_opts.get(ct, [])
         if ct == 'unix':

+ 1 - 1
tutorials/supervised-learning.md

@@ -22,7 +22,7 @@ $ unzip v0.1.0.zip
 Move to the fastText directory and build it:
 
 ```
-$ cd fastText-v0.1.0
+$ cd fastText-0.1.0
 $ make
 ```