| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -473,6 +473,8 @@ RUN pip install flashtext && \ | |||
| 473 | 473 | pip install ggplot && \ | |
| 474 | 474 | pip install cesium && \ | |
| 475 | 475 | pip install rgf_python && \ | |
| 476 | + pip install pytext-nlp && \ | ||
| 477 | + pip install tsfresh && \ | ||
| 476 | 478 | /tmp/clean-layer.sh | |
| 477 | 479 | ||
| 478 | 480 | # Pin Vowpal Wabbit v8.6.0 because 8.6.1 does not build or install successfully | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - String cron_string = BRANCH_NAME == "master" ? "H 12 * * 1-5" : "" | ||
| 1 | + String cron_string = BRANCH_NAME == "master" ? "H 12 * * 1,3" : "" | ||
| 2 | 2 | ||
| 3 | 3 | pipeline { | |
| 4 | 4 | agent { label 'ephemeral-linux' } | |
@@ -29,14 +29,14 @@ pipeline { | |||
| 29 | 29 | } | |
| 30 | 30 | } | |
| 31 | 31 | ||
| 32 | - stage('Push CPU Untested Image') { | ||
| 32 | + stage('Push CPU Pretest Image') { | ||
| 33 | 33 | steps { | |
| 34 | - slackSend color: 'none', message: "*<${env.BUILD_URL}console|${JOB_NAME} pushing untested image>* ${GIT_COMMIT_SUMMARY}", channel: env.SLACK_CHANNEL | ||
| 34 | + slackSend color: 'none', message: "*<${env.BUILD_URL}console|${JOB_NAME} pushing pretest image>* ${GIT_COMMIT_SUMMARY}", channel: env.SLACK_CHANNEL | ||
| 35 | 35 | sh '''#!/bin/bash | |
| 36 | 36 | set -exo pipefail | |
| 37 | 37 | ||
| 38 | 38 | date | |
| 39 | - ./push ci-untested | ||
| 39 | + ./push ci-pretest | ||
| 40 | 40 | ''' | |
| 41 | 41 | } | |
| 42 | 42 | } | |
@@ -83,15 +83,15 @@ pipeline { | |||
| 83 | 83 | } | |
| 84 | 84 | } | |
| 85 | 85 | ||
| 86 | - stage('Push GPU Untested Image') { | ||
| 86 | + stage('Push GPU Pretest Image') { | ||
| 87 | 87 | agent { label 'ephemeral-linux-gpu' } | |
| 88 | 88 | steps { | |
| 89 | - slackSend color: 'none', message: "*<${env.BUILD_URL}console|${JOB_NAME} pushing untested image>* ${GIT_COMMIT_SUMMARY}", channel: env.SLACK_CHANNEL | ||
| 89 | + slackSend color: 'none', message: "*<${env.BUILD_URL}console|${JOB_NAME} pushing pretest image>* ${GIT_COMMIT_SUMMARY}", channel: env.SLACK_CHANNEL | ||
| 90 | 90 | sh '''#!/bin/bash | |
| 91 | 91 | set -exo pipefail | |
| 92 | 92 | ||
| 93 | 93 | date | |
| 94 | - ./push --gpu ci-untested | ||
| 94 | + ./push --gpu ci-pretest | ||
| 95 | 95 | ''' | |
| 96 | 96 | } | |
| 97 | 97 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,60 +1,88 @@ | |||
| 1 | - **Kaggle Kernels** allow users to run scripts against our competitions and datasets without having to download data or set up their environment. Here's [an example](https://www.kaggle.com/devinanzelmo/d/devinanzelmo/dota-2-matches/setting-up-a-prediction-problem-dota-2): | ||
| 1 | + [Kaggle Kernels](https://www.kaggle.com/kernels) allow users to run a Python Notebook in the cloud against our competitions and datasets without having to download data or set up their environment. | ||
| 2 | 2 | ||
| 3 | -  | ||
| 3 | + This repository includes our Dockerfiles for building the [CPU-only](Dockerfile) and [GPU](gpu.Dockerfile) image that runs Python Kernels on Kaggle. | ||
| 4 | 4 | ||
| 5 | - This is the Dockerfile (etc.) used for building the image that runs python scripts on Kaggle. [Here's](https://gcr.io/kaggle-images/python) the Docker image on Google Container Registry. | ||
| 5 | + Our Python Docker images are stored on Google Container Registry at: | ||
| 6 | + | ||
| 7 | + * CPU-only: [gcr.io/kaggle-images/python](https://gcr.io/kaggle-images/python) | ||
| 8 | + * GPU: private for now, we will make it public soon. | ||
| 9 | + | ||
| 10 | + Note: The base image for the GPU image is our CPU-only image. The [gpu.Dockerfile](gpu.Dockerfile) adds a few extra layers to install GPU related libraries and packages (cuda, libcudnn, pycuda etc.) and reinstall packages with specific GPU builds (torch, tensorflow and a few mores). | ||
| 6 | 11 | ||
| 7 | 12 | ## Getting started | |
| 8 | 13 | ||
| 9 | 14 | To get started with this image, read our [guide](http://blog.kaggle.com/2016/02/05/how-to-get-started-with-data-science-in-containers/) to using it yourself, or browse [Kaggle Kernels](https://www.kaggle.com/kernels) for ideas. | |
| 10 | 15 | ||
| 11 | - ## Requesting new features | ||
| 16 | + ## Requesting new packages | ||
| 12 | 17 | ||
| 13 | - **We welcome pull requests** if there are any packages you'd like to add! | ||
| 18 | + First, evaluate whether installing the package yourself in your own Kernels suits your needs. See [guide](https://github.com/Kaggle/docker-python/wiki/Missing-Packages). | ||
| 14 | 19 | ||
| 15 | - We can merge your request quickly if you check that it builds correctly. Here's how to do that. | ||
| 20 | + If you the first step above doesn't work for your use case, [open an issue](https://github.com/Kaggle/docker-python/issues/new) or a [pull request](https://github.com/Kaggle/docker-python/pulls). | ||
| 16 | 21 | ||
| 17 | - Start by running this image on your system: | ||
| 22 | + ## Opening a pull request | ||
| 18 | 23 | ||
| 19 | - ``` | ||
| 20 | - me@my-computer:/home$ docker run --rm -it gcr.io/kaggle-images/python | ||
| 21 | - root@d72b81a003e1:/# | ||
| 22 | - ``` | ||
| 24 | + 1. Update the *Dockerfile* | ||
| 25 | + 1. For changes specific to the GPU image, update the [gpu.Dockerfile](gpu.Dockerfile). | ||
| 26 | + 1. Otherwise, update the [Dockerfile](Dockerfile). | ||
| 27 | + 1. Follow the instructions below to build a new image. | ||
| 28 | + 1. Add tests for your new package. See this [example](https://github.com/Kaggle/docker-python/blob/master/tests/test_fastai.py). | ||
| 29 | + 1. Follow the instructions below to test the new image. | ||
| 30 | + 1. Open a PR on this repo and you are all set! | ||
| 23 | 31 | ||
| 24 | - Then follow the package's installation instructions for a Linux system. It could be as simple as installing via Pip: | ||
| 32 | + ## Building a new image | ||
| 25 | 33 | ||
| 26 | - ``` | ||
| 27 | - root@d72b81a003e1:/# pip install coolpackage | ||
| 28 | - Collecting coolpackage | ||
| 29 | - [...etc...] | ||
| 34 | + ```sh | ||
| 35 | + ./build | ||
| 30 | 36 | ``` | |
| 31 | 37 | ||
| 32 | - Once that's done, check that you can import it correctly. (Sometimes, if a package is missing a dependency, it throws an error when you try to import it.) | ||
| 38 | + Flags: | ||
| 33 | 39 | ||
| 34 | - ``` | ||
| 35 | - root@d72b81a003e1:/# python | ||
| 36 | - Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:53:06) | ||
| 37 | - [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux | ||
| 38 | - Type "help", "copyright", "credits" or "license" for more information. | ||
| 39 | - >>> import coolpackage | ||
| 40 | - >>> | ||
| 41 | - ``` | ||
| 40 | + * `--gpu` to build an image for GPU. | ||
| 41 | + * `--use-cache` for faster iterative builds. | ||
| 42 | 42 | ||
| 43 | - Once that's working, add the necessary lines to our [Dockerfile](https://github.com/Kaggle/docker-python/blob/master/Dockerfile). (In this case, that would mean adding `pip install coolpackage` to the last section.) | ||
| 43 | + ## Testing a new image | ||
| 44 | 44 | ||
| 45 | - Next run the build: | ||
| 45 | + A suite of tests can be found under the `/tests` folder. You can run the test using this command: | ||
| 46 | 46 | ||
| 47 | + ```sh | ||
| 48 | + ./test | ||
| 47 | 49 | ``` | |
| 48 | - ./build | ||
| 49 | - ``` | ||
| 50 | 50 | ||
| 51 | - Finally run the tests: | ||
| 51 | + Flags: | ||
| 52 | + | ||
| 53 | + * `--gpu` to test the GPU image. | ||
| 54 | + | ||
| 55 | + ## Running the image | ||
| 52 | 56 | ||
| 57 | + For the CPU-only image: | ||
| 58 | + | ||
| 59 | + ```sh | ||
| 60 | + # Run the image built locally: | ||
| 61 | + docker run --rm -it kaggle/python-build /bin/bash | ||
| 62 | + # Run the pre-built image from gcr.io | ||
| 63 | + docker run --rm -it gcr.io/kaggle-images/python /bin/bash | ||
| 53 | 64 | ``` | |
| 54 | - ./test | ||
| 65 | + | ||
| 66 | + For the GPU image: | ||
| 67 | + | ||
| 68 | + ```sh | ||
| 69 | + # Run the image built locally: | ||
| 70 | + docker run --runtime nvidia --rm -it kaggle/python-gpu-build /bin/bash | ||
| 71 | + # Run the image pre-built image from gcr.io | ||
| 72 | + # TODO: Our GPU images are not yet publicly available. | ||
| 55 | 73 | ``` | |
| 56 | 74 | ||
| 57 | - Then submit your pull request, and you're all set! | ||
| 75 | + To ensure your container can access the GPU, follow the instructions posted [here](https://github.com/Kaggle/docker-python/issues/361#issuecomment-448093930). | ||
| 76 | + | ||
| 77 | + ## Tensorflow custom pre-built wheel | ||
| 78 | + | ||
| 79 | + A Tensorflow custom pre-built wheel is used mainly for: | ||
| 80 | + | ||
| 81 | + * Faster build time: Building tensorflow from sources takes ~1h. Keeping this process outside the main build allows faster iterations when working on our Dockerfiles. | ||
| 58 | 82 | ||
| 83 | + Building Tensorflow from sources: | ||
| 59 | 84 | ||
| 85 | + * Increase performance: When building from sources, we can leverage CPU specific optimizations | ||
| 86 | + * Is required: Tensorflow with GPU support must be built from sources | ||
| 60 | 87 | ||
| 88 | + The [Dockerfile](tensorflow-whl/Dockerfile) and the [instructions](tensorflow-whl/README.md) can be found in the [tensorflow-whl folder/](tensorflow-whl/). | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,4 +54,6 @@ RUN pip uninstall -y tensorflow && \ | |||
| 54 | 54 | ||
| 55 | 55 | # Install GPU-only packages | |
| 56 | 56 | RUN pip install pycuda && \ | |
| 57 | + pip install cupy-cuda92 && \ | ||
| 58 | + pip install pynvrtc && \ | ||
| 57 | 59 | /tmp/clean-layer.sh | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,3 @@ | |||
| 1 | - # TODO(rosbo): Remove this once we fix the issue with fastai importing older libcudnn if imported prior to tensorflow | ||
| 2 | - import tensorflow | ||
| 3 | 1 | import os | |
| 4 | 2 | from google.auth import credentials | |
| 5 | 3 | from google.cloud import bigquery | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ./build | |
| 5 | 5 | ``` | |
| 6 | 6 | ||
| 7 | - # Push the new wheels | ||
| 7 | + # Push the new wheels (Kaggle Engineers only) | ||
| 8 | 8 | ||
| 9 | 9 | 1. Add an entry in the [CHANGELOG](CHANGELOG.md) with an appropriate `LABEL`. | |
| 10 | 10 | 2. Push the new image using the `LABEL` you picked above. | |
@@ -17,6 +17,12 @@ | |||
| 17 | 17 | ||
| 18 | 18 | Update the line below in the [CPU Dockerfile](../Dockerfile) and the [GPU Dockerfile](../gpu.Dockerfile) to use the new `LABEL`. | |
| 19 | 19 | ||
| 20 | + To use wheels built locally: | ||
| 21 | + ``` | ||
| 22 | + FROM kaggle/python-tensorflow-whl as tensorflow_whl | ||
| 23 | + ``` | ||
| 24 | + | ||
| 25 | + To use our pre-built wheels: | ||
| 20 | 26 | ``` | |
| 21 | 27 | FROM gcr.io/kaggle-images/python-tensorflow-whl:<LABEL> as tensorflow_whl | |
| 22 | 28 | ``` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,25 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | 2 | set -e | |
| 3 | 3 | ||
| 4 | + IMAGE_TAG='kaggle/python-build' | ||
| 5 | + IMAGE_TAG_OVERRIDE='' | ||
| 6 | + ADDITONAL_OPTS='' | ||
| 7 | + PATTERN='test*.py' | ||
| 8 | + | ||
| 4 | 9 | usage() { | |
| 5 | 10 | cat << EOF | |
| 6 | 11 | Usage: $0 [OPTIONS] | |
| 7 | 12 | Run tests for a newly-built Python Docker image. | |
| 8 | 13 | By default, it runs the tests for the CPU image. | |
| 9 | 14 | ||
| 10 | 15 | Options: | |
| 11 | - -g, --gpu Run tests for the GPU image. | ||
| 12 | - -i, --image IMAGE Run tests against the specified image | ||
| 16 | + -g, --gpu Run tests for the GPU image. | ||
| 17 | + -i, --image IMAGE Run tests against the specified image | ||
| 18 | + -p, --pattern PATTERN Pattern to match test files ($PATTERN default) | ||
| 13 | 19 | ||
| 14 | 20 | EOF | |
| 15 | 21 | } | |
| 16 | 22 | ||
| 17 | - IMAGE_TAG='kaggle/python-build' | ||
| 18 | - ADDITONAL_OPTS='' | ||
| 19 | - | ||
| 20 | 23 | while :; do | |
| 21 | 24 | case "$1" in | |
| 22 | 25 | -h|--help) | |
@@ -36,6 +39,15 @@ while :; do | |||
| 36 | 39 | IMAGE_TAG_OVERRIDE=$2 | |
| 37 | 40 | shift # skip the flag value | |
| 38 | 41 | ;; | |
| 42 | + -p|--pattern) | ||
| 43 | + if [[ -z $2 ]]; then | ||
| 44 | + usage | ||
| 45 | + printf 'ERROR: No PATTERN specified after the %s flag.\n' "$1" >&2 | ||
| 46 | + exit | ||
| 47 | + fi | ||
| 48 | + PATTERN="$2" | ||
| 49 | + shift # skip the flag value | ||
| 50 | + ;; | ||
| 39 | 51 | -?*) | |
| 40 | 52 | usage | |
| 41 | 53 | printf 'ERROR: Unknown option: %s\n' "$1" >&2 | |
@@ -54,6 +66,7 @@ fi | |||
| 54 | 66 | ||
| 55 | 67 | readonly IMAGE_TAG | |
| 56 | 68 | readonly ADDITONAL_OPTS | |
| 69 | + readonly PATTERN | ||
| 57 | 70 | ||
| 58 | 71 | set -x | |
| 59 | 72 | rm -rf /tmp/python-build | |
@@ -74,4 +87,4 @@ docker run --rm -t --read-only --net=none \ | |||
| 74 | 87 | -w=/working \ | |
| 75 | 88 | $ADDITONAL_OPTS \ | |
| 76 | 89 | "$IMAGE_TAG" \ | |
| 77 | - /bin/bash -c 'python -m unittest discover -s /input/tests' | ||
| 90 | + /bin/bash -c "python -m unittest discover -s /input/tests -p $PATTERN" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + import unittest | ||
| 2 | + | ||
| 3 | + from pytext.config.field_config import FeatureConfig | ||
| 4 | + from pytext.data.featurizer import InputRecord, SimpleFeaturizer | ||
| 5 | + | ||
| 6 | + class TestPyText(unittest.TestCase): | ||
| 7 | + | ||
| 8 | + def test_tokenize(self): | ||
| 9 | + featurizer = SimpleFeaturizer.from_config( | ||
| 10 | + SimpleFeaturizer.Config(), FeatureConfig() | ||
| 11 | + ) | ||
| 12 | + | ||
| 13 | + tokens = featurizer.featurize(InputRecord(raw_text="At eight o'clock")).tokens | ||
| 14 | + self.assertEqual(['at', 'eight', "o'clock"], tokens) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + import unittest | ||
| 2 | + | ||
| 3 | + import pandas as pd | ||
| 4 | + import numpy as np | ||
| 5 | + | ||
| 6 | + from tsfresh import extract_features | ||
| 7 | + | ||
| 8 | + class TestTsFresh(unittest.TestCase): | ||
| 9 | + def test_extract_feature(self): | ||
| 10 | + ts = pd.DataFrame({ | ||
| 11 | + 'id': np.array(['a', 'a', 'a', 'b', 'b', 'b']), | ||
| 12 | + 'time': np.array([0,1,2,0,1,2]), | ||
| 13 | + 'x': np.array([3,4,5,7,8,10]) | ||
| 14 | + }) | ||
| 15 | + extracted_features = extract_features(ts, column_id='id', column_sort='time') | ||
| 16 | + self.assertEqual(2, len(extracted_features)) | ||
| 17 | + | ||
| 18 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments