Skip to content

Commit

Permalink
Travis test (blue-yonder#300)
Browse files Browse the repository at this point in the history
* Seperated out unit and integration tests

* Run both test suites indepentendly

* Use the build in cache by travis for pip

* Try to use 2 cores

* First install requirements, then the project

* Try out the new stages build feature

* Next try...

* And anoter one...

* Continue..

* ...

* Caching the virtualenv did not help

* renamed build stages

* set n_jobs for pytest to auto

* fix naming of test stages

* use with notation for filehandling

* set number of cpus to 2

* limit number of jobs to 2 by pytest argument

* use write AND read mode for profiling file

* add __init__.py to test folder

* use tempfolder for profiling files
  • Loading branch information
nils-braun authored and MaxBenChrist committed Aug 25, 2017
1 parent 426cfb3 commit 6db60f4
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 37 deletions.
79 changes: 49 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
# Travis Build file for tsfresh
language: python
# We do not use sudo here, so we can use docker containers, which have better caching
sudo: false
# We want the pip folder to be cached, to speed up installation
cache:
directories:
- $HOME/.cache/pip
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
python:
- '2.7.11'
- '3.5.2'
install:
- pip install --upgrade pip
- pip install numpy
- pip install scipy
- pip install coveralls
- pip install .
- pip install -r requirements.txt
- pip install -r test-requirements.txt
- pip freeze
env:
- NUMBER_OF_CPUS=1
script:
# hack to set xdist to use only 1 node instead of 32
- sed -i 's/\-n 4/\-n 1/g' setup.cfg
- python setup.py test
deploy:
provider: pypi
user: MaxChrist
password:
secure: Jh0Z69Mh+esOpegXyXoecFOkpMhaQaiJbQVEvVvQ2K1rCmCE20a19/TGfPUrynpqOYXZvvb5Ok6CtlzAi9J5huA3MRSf4iYPsUe8i7n0FK4JU5BP7VqM3/7cQZMdD5SeYFV3e3JURDcKYfoG7N+DNb+LfluYK5MBkRLhdEVRqSeHocPY4QRzzhJi1ljX99ThdRPrsQqYaD3tpZxJhbJDgHLtvMr39+407uQSDnubvFz3iu90DZiN2fIP5bEN6PDuaGXNZMA1p40DjSkGc7epg0U4vHn6CSya1nXlqjXUqXYJY5Ha2kbMAN7hfmU+gId09+FSHQRuanKJkRqSBksVgATCAeSAiqAe3EPAsG75ewhXDeusQZMzRy7DxQzjOJG9oIyWMVmZFlIoNlpg2eifN9uUc7FfyGHiVfWwUDslszpc/81hQViMPP0NoMAop4zcWR3ChCMnHMycPQEmWuV65WfL7yN6SuTokxSmepubPtFs+4UIlI0rgZWCHVIgGZqI8LFn958pLtpQ+32Ew8HGU3IiOfao9HbGreQ2Lgqo2L2EyNDWiHfJ3oZ1+6BP/1GqI6j7x7oPdwoE1jvY4CSC7iMAiieZNnrvywvmJpZB69CGefxQJzWcm+yD03QwNBFFaabCbKwbn+q3eUOUrPRuvTkhVLRWDxQNH/zaZyuZQ+Q=
distributions: "sdist bdist_wheel"
on:
tags: true
repo: blue-yonder/tsfresh
after_success:
- coveralls
- pip install --upgrade pip wheel setuptools
- pip install numpy scipy coveralls
- pip install -r requirements.txt -r test-requirements.txt
- pip install -U .
- pip freeze
jobs:
include:
- stage: prepare cache
script: true
python: 2.7.11
- stage: prepare cache
script: true
python: 3.5.2

- stage: Run unit tests
script: py.test tests/units -n 2
python: 2.7.11
- stage: Run unit tests
script: py.test tests/units -n 2
python: 3.5.2

- stage: Run the full test suite
script:
- sed -i 's/\-n auto/\-n 2/g' setup.cfg
- python setup.py test
python: 2.7.11
after_success:
- coveralls
- stage: Run the full test suite
script:
- sed -i 's/\-n auto/\-n 2/g' setup.cfg
- python setup.py test
python: 3.5.2

- stage: Deploy to pipy
script: skip
deploy:
provider: pypi
user: MaxChrist
password:
secure: Jh0Z69Mh+esOpegXyXoecFOkpMhaQaiJbQVEvVvQ2K1rCmCE20a19/TGfPUrynpqOYXZvvb5Ok6CtlzAi9J5huA3MRSf4iYPsUe8i7n0FK4JU5BP7VqM3/7cQZMdD5SeYFV3e3JURDcKYfoG7N+DNb+LfluYK5MBkRLhdEVRqSeHocPY4QRzzhJi1ljX99ThdRPrsQqYaD3tpZxJhbJDgHLtvMr39+407uQSDnubvFz3iu90DZiN2fIP5bEN6PDuaGXNZMA1p40DjSkGc7epg0U4vHn6CSya1nXlqjXUqXYJY5Ha2kbMAN7hfmU+gId09+FSHQRuanKJkRqSBksVgATCAeSAiqAe3EPAsG75ewhXDeusQZMzRy7DxQzjOJG9oIyWMVmZFlIoNlpg2eifN9uUc7FfyGHiVfWwUDslszpc/81hQViMPP0NoMAop4zcWR3ChCMnHMycPQEmWuV65WfL7yN6SuTokxSmepubPtFs+4UIlI0rgZWCHVIgGZqI8LFn958pLtpQ+32Ew8HGU3IiOfao9HbGreQ2Lgqo2L2EyNDWiHfJ3oZ1+6BP/1GqI6j7x7oPdwoE1jvY4CSC7iMAiieZNnrvywvmJpZB69CGefxQJzWcm+yD03QwNBFFaabCbKwbn+q3eUOUrPRuvTkhVLRWDxQNH/zaZyuZQ+Q=
distributions: "sdist bdist_wheel"
on:
tags: true
repo: blue-yonder/tsfresh
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ addopts = tests
addopts =
--cov tsfresh --cov-report term-missing
--verbose
-n 4
-n auto

[aliases]
docs = build_sphinx
Expand Down
Empty file added tests/integrations/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/units/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
from tsfresh.feature_extraction.extraction import extract_features
from tsfresh.feature_extraction.settings import ComprehensiveFCParameters

import tempfile

class ExtractionTestCase(DataTestCase):
"""The unit tests in this module make sure if the time series features are created properly"""

def setUp(self):
self.n_jobs = 1
self.directory = tempfile.gettempdir()

def test_extract_features(self):
# todo: implement more methods and test more aspects
Expand Down Expand Up @@ -95,7 +97,7 @@ def test_extract_features_after_randomisation(self):
def test_profiling_file_written_out(self):

df = pd.DataFrame(data={"id": np.repeat([1, 2], 10), "val": np.random.normal(0, 1, 20)})
profiling_filename = "test_profiling.txt"
profiling_filename = os.path.join(self.directory, "test_profiling.txt")
X = extract_features(df, column_id="id",
column_value="val", n_jobs=self.n_jobs,
profile=True, profiling_filename=profiling_filename)
Expand All @@ -104,7 +106,8 @@ def test_profiling_file_written_out(self):
os.remove(profiling_filename)

def test_profiling_cumulative_file_written_out(self):
PROFILING_FILENAME = "test_profiling_cumulative.txt"

PROFILING_FILENAME = os.path.join(self.directory, "test_profiling_cumulative.txt")
PROFILING_SORTING = "cumulative"

df = pd.DataFrame(data={"id": np.repeat([1, 2], 10), "val": np.random.normal(0, 1, 20)})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions tsfresh/utilities/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def end_profiling(profiler, filename, sorting=None):
ps = pstats.Stats(profiler, stream=s).sort_stats(sorting)
ps.print_stats()

file = open(filename, "w")
_logger.info("[calculate_ts_features] Finished profiling of time series feature extraction")
file.write(s.getvalue())
file.close()
with open(filename, "w+") as f:
_logger.info("[calculate_ts_features] Finished profiling of time series feature extraction")
f.write(s.getvalue())

0 comments on commit 6db60f4

Please sign in to comment.