diff --git a/.circleci/config.yml b/.circleci/config.yml index da4824aeacd846e93643db48e6b18d39be513d56..3514f694ec4962729ef97024803b7f2bcce642e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,13 +12,24 @@ jobs: - python/install-deps - python/save-cache - run: + name: Setup Code Climate test-reporter command: | - sudo pip install satella>=2.14.23 snakehouse + # download test reporter as a static binary + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + - run: + command: | + sudo pip install nose2 name: Install necessary modules - run: command: | - sudo python setup.py test + sudo source tests/test.sh name: Test + - run: + command: | + sudo coverage xml + sudo ./cc-test-reporter after-build -t coverage.py + name: Send back coverage results workflows: main: diff --git a/.coveragerc b/.coveragerc index 001df73cf25030d81c4bc49cc70c5ae66bd7f27f..62eb0ed383b1c0e759180db7f5d40fe46c9e9908 100644 --- a/.coveragerc +++ b/.coveragerc @@ -8,7 +8,6 @@ omit= tests/* .eggs/* setup.py - tempsdb/__init__.py [report] include= 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 2fe238cfb6d36a0700aac897d9433cd41260142e..1108e35601c77703152873f7431c2dea91d977cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ satella ujson snakehouse six +indexed_gzip diff --git a/setup.py b/setup.py index 86f800f9e42743cdbd7b111da3e265de9c98b613..6abc38c76827cf308fe49589193fa1474172fdfa 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,9 @@ import os import typing as tp - -from Cython.Build import cythonize from satella.distutils import monkey_patch_parallel_compilation from satella.files import find_files from distutils.core import setup -from setuptools import Extension from snakehouse import Multibuild, build @@ -16,28 +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'} +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) + cythonize_kwargs['gdb_debug'] = True setup(name='tempsdb', - version='0.5.0a9', + version='0.5', packages=['tempsdb'], - install_requires=['satella>=2.14.21', 'ujson'], - ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb')), ], - 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 4100c47974d0aa810a921a8938edf28b025c0d4c..9febcc3bc32f1b73e62ebec185a4117ce27adea2 100644 --- a/tempsdb/varlen.pyx +++ b/tempsdb/varlen.pyx @@ -552,6 +552,8 @@ cdef class VarlenSeries: Updates :attr:`~tempsdb.varlen.VarlenSeries.current_maximum_length`. """ + from .series import create_series + cdef: int new_name = len(self.series) int new_len = self.get_length_for(new_name) diff --git a/tests/test.sh b/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56d591d8e6dd70d36f002ec921bed9286bcb82ef --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +coverage run -m nose2 -vv +coverage report diff --git a/unittest.Dockerfile b/unittest.Dockerfile index bccaee128e06f1d891c83204193b8f90f442213e..5703b7af5b89a2f6e5b1b89ea20e96c5f52cab11 100644 --- a/unittest.Dockerfile +++ b/unittest.Dockerfile @@ -1,6 +1,6 @@ FROM python:3.8 -RUN pip install satella>=2.14.24 snakehouse 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 @@ -11,5 +11,5 @@ WORKDIR /app ENV CI=true RUN python setup.py build_ext --inplace ADD tests /app/tests - -CMD ["nose2", "-vv"] +RUN chmod ugo+x /app/tests/test.sh +CMD ["/app/tests/test.sh"]