diff --git a/.circleci/config.yml b/.circleci/config.yml index da4824aeacd846e93643db48e6b18d39be513d56..868edb5568e0baab1cde00dcbd4c9c6a9f814cdd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,14 +12,22 @@ jobs: - python/install-deps - python/save-cache - run: + name: Setup Code Climate test-reporter command: | - sudo pip install satella>=2.14.23 snakehouse - name: Install necessary modules + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter - run: - command: | - sudo python setup.py test name: Test - + environment: + CI: 1 + command: | + python setup.py build_ext --inplace + bash tests/test.sh + - run: + name: Send back coverage results + command: | + coverage xml + ./cc-test-reporter after-build -t coverage.py -r "221b151c896ec22d8fcb5e522aed25c52e7a9515e59390aa200131b890b718d5" workflows: main: jobs: diff --git a/.codeclimate.yml b/.codeclimate.yml index e735803d339a9ffdbdaed71589f642501f70cdbd..a9a526da9ac11773739881fbe349845308f8b2c2 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -16,7 +16,7 @@ exclude_paths: - docs/** ratings: paths: - - smokclient/** + - tempsdb/** checks: argument-count: config: diff --git a/README.md b/README.md index 9c04d17a98b79f63ff6577ebcbb465c588e6fb2e..26ff1b132acf69818f111363889843ada27715b5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [](https://pypi.python.org/pypi/tempsdb) [](http://tempsdb.readthedocs.io/en/latest/?badge=latest) [](https://codeclimate.com/github/smok-serwis/tempsdb/maintainability) +[](https://codeclimate.com/github/smok-serwis/tempsdb/test_coverage) [](https://app.circleci.com/pipelines/github/smok-serwis/tempsdb) [](https://pypi.org/project/tempsdb/) diff --git a/docs/usage.rst b/docs/usage.rst index 268e062571083fcd9106a770901b923e7b549202..94e33365b0ec53521b98907e82f251385bfa503c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -22,9 +22,14 @@ Start off by instantiating an object Note that if you specify a `gzip_level` argument in :meth:`~tempsdb.database.Database.create_series`, GZIP compression will be used. -Note that gzip-compressed series are very slow to read, since every seek needs +Note that gzip-compressed series are very slow to read the first time you open them, +since an index needs to be built each time that they are seek'ed. to start from scratch. This will be fixed in the future. +Random seeks are provided by the indexed-gzip_ library. + +.. _indexed-gzip: https://pypi.org/project/indexed-gzip/ + Also, any gzip-opened series will raise a warning, since their support is experimental at best. You can create new databases via diff --git a/requirements.txt b/requirements.txt index 39ce8d3b742bdad46630addbf64b257d9e1fb775..0f106c98ddb284aa46cebbd8e5441dba349f1522 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,6 @@ satella ujson snakehouse>=1.2.3 six +indexed_gzip +nose2 +coverage diff --git a/setup.py b/setup.py index 69dafaa661f1082e4ec743ba1ea99b7d588d4fde..b7fe35eaa552f112618a486fa2b069f5552aa62d 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,9 @@ import os import typing as tp -from Cython.Build import cythonize from satella.files import find_files from distutils.core import setup -from setuptools import Extension from snakehouse import Multibuild, build, monkey_patch_parallel_compilation @@ -15,30 +13,22 @@ def find_pyx(*path) -> tp.List[str]: monkey_patch_parallel_compilation() -# extensions = [Extension("tempsdb.chunks", ['tempsdb/chunks.pyx']), -# Extension("tempsdb.database", ['tempsdb/database.pyx']), -# Extension('tempsdb.exceptions', ['tempsdb/exceptions.pyx']), -# Extension('tempsdb.series', ['tempsdb/series.pyx']), -# Extension('tempsdb.iterators', ['tempsdb/iterators.pyx'])] -# directives = {'language_level': '3'} -m_kwargs = {} +ext_kwargs = {} +cythonize_kwargs = {} if 'CI' in os.environ: + ext_kwargs['define_macros'] = [("CYTHON_TRACE_NOGIL", "1")] directives.update(profile=True, linetrace=True, embedsignature=True) - m_kwargs['define_macros'] = [("CYTHON_TRACE_NOGIL", "1")] + cythonize_kwargs['gdb_debug'] = True setup(name='tempsdb', - version='0.5a10', + version='0.5', packages=['tempsdb'], - install_requires=['satella>=2.14.21', 'ujson'], - ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb'), **m_kwargs), ], - compiler_directives=directives), - # ext_modules=cythonize(extensions, - # gdb_debug=True, - # compiler_directives={ - # 'language_level': '3', - # }), + install_requires=['satella>=2.14.24', 'ujson', 'indexed_gzip'], + ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb'), **ext_kwargs), ], + compiler_directives=directives, + **cythonize_kwargs), python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*', test_suite="tests", zip_safe=False diff --git a/tempsdb/chunks/gzip.pyx b/tempsdb/chunks/gzip.pyx index db1895925205f253c75b377c30e135da6e160a4b..0cca5b790eaf773edeb452edb0ec44019f78f826 100644 --- a/tempsdb/chunks/gzip.pyx +++ b/tempsdb/chunks/gzip.pyx @@ -1,4 +1,5 @@ import gzip +import indexed_gzip import threading @@ -6,7 +7,7 @@ cdef class ReadWriteGzipFile: def __init__(self, path: str, compresslevel: int = gzip._COMPRESS_LEVEL_FAST): self.path = path self.compress_level = compresslevel - self.ro_file = gzip.GzipFile(path, 'rb') + self.ro_file = indexed_gzip.IndexedGzipFile(path) self.rw_file = gzip.GzipFile(path, 'ab', compresslevel=self.compress_level) self.pointer = 0 self.lock = threading.RLock() diff --git a/tempsdb/varlen.pyx b/tempsdb/varlen.pyx index 4e1b39386ea92bcebfc856b56c6c7a8a1814f395..3131c53e4d3b40bd3561decde10abe858241e8fd 100644 --- a/tempsdb/varlen.pyx +++ b/tempsdb/varlen.pyx @@ -552,7 +552,7 @@ cdef class VarlenSeries: Updates :attr:`~tempsdb.varlen.VarlenSeries.current_maximum_length`. """ - from tempsdb.series import create_series + from .series import create_series cdef: int new_name = len(self.series) diff --git a/tests/test.sh b/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6ded542a54eb496979e027bd2838fd7e0d8d8c7 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +python -m coverage run -m nose2 -vv +python -m coverage report diff --git a/unittest.Dockerfile b/unittest.Dockerfile index e3aa11357ec9d96d01b3682aa1c796aa43876629..df003ba56a1d43a0af8acc8341e3f3e4950edea4 100644 --- a/unittest.Dockerfile +++ b/unittest.Dockerfile @@ -1,6 +1,6 @@ FROM python:3.8 -RUN pip install satella snakehouse>=1.2.3 nose2 wheel ujson coverage +RUN pip install satella>=2.14.24 snakehouse nose2 wheel ujson coverage indexed_gzip ADD tempsdb /app/tempsdb ADD setup.py /app/setup.py @@ -10,5 +10,6 @@ WORKDIR /app ENV CI=true RUN python setup.py build_ext --inplace ADD tests /app/tests +RUN chmod ugo+x /app/tests/test.sh -CMD ["coverage", "run", "-m", "nose2", "-vv"] +CMD ["/app/tests/test.sh"]