Skip to content

Commit 2390e44

Browse files
authored
Merge pull request #1 from rhpvorderman/init
Start on python-isal project.
2 parents 69f155b + b09659a commit 2390e44

27 files changed

+2195
-1
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
### Checklist
3+
- [ ] Pull request details were added to CHANHELOG.rst

.github/release_checklist.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Release checklist
2+
- [ ] Check outstanding issues on JIRA and Github.
3+
- [ ] Check [latest documentation](https://python-isal.readthedocs.io/en/latest/) looks fine.
4+
- [ ] Create a release branch.
5+
- [ ] Set version to a stable number.
6+
- [ ] Change current development version in `CHANGELOG.rst` to stable version.
7+
- [ ] Merge the release branch into `main`.
8+
- [ ] Create a test pypi package from the main branch. ([Instructions.](
9+
https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives
10+
))
11+
- [ ] Install the packages from the test pypi repository to see if they work.
12+
- [ ] Created an annotated tag with the stable version number. Include changes
13+
from CHANGELOG.rst.
14+
- [ ] Push tag to remote.
15+
- [ ] Push tested packages to pypi.
16+
- [ ] merge `main` branch back into `develop`.
17+
- [ ] Add updated version number to develop.
18+
- [ ] Build the new tag on readthedocs. Only build the last patch version of
19+
each minor version. So `1.1.1` and `1.2.0` but not `1.1.0`, `1.1.1` and `1.2.0`.
20+
- [ ] Create a new release on github.
21+
- [ ] Update the package on conda-forge.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ __pycache__/
66
# C extensions
77
*.so
88

9+
# Cython generated files
10+
*.c
11+
*.html
12+
913
# Distribution / packaging
1014
.Python
1115
build/

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
language: python
2+
dist: focal
3+
4+
before_install:
5+
# Install conda
6+
- export MINICONDA=${HOME}/miniconda
7+
- export PATH=${MINICONDA}/bin:${PATH}
8+
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
9+
- bash miniconda.sh -b -f -p ${MINICONDA}
10+
- conda config --set always_yes yes
11+
- conda config --add channels defaults
12+
- conda config --add channels conda-forge
13+
install:
14+
- conda create -n test python=$TRAVIS_PYTHON_VERSION isa-l tox
15+
- source activate test
16+
17+
python: 3.6 # Use the oldest supported version of python as default.
18+
script:
19+
- tox -e $TOX_ENV
20+
matrix:
21+
include:
22+
# TEST DOCS AND LINTING
23+
# Use default python3 version here.
24+
- env: TOX_ENV=docs
25+
- env: TOX_ENV=lint
26+
# UNIT TESTS
27+
# On most recent versions of python.
28+
- env: TOX_ENV=py36
29+
after_success:
30+
- pip install codecov
31+
- codecov -v # -v to make sure coverage upload works.
32+
- python: 3.7
33+
env: TOX_ENV=py37
34+
- python: 3.8
35+
env: TOX_ENV=py38

CHANGELOG.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
==========
2+
Changelog
3+
==========
4+
5+
.. Newest changes should be on top.
6+
7+
.. This document is user facing. Please word the changes in such a way
8+
.. that users understand how the changes affect the new version.
9+
10+
version 0.1.0-dev
11+
-----------------
12+
+ Add test suite that tests all possible settings for functions on the
13+
isal_zlib module.
14+
+ Create igzip module which implements all gzip functions and methods.
15+
+ Create isal_zlib module which implements all zlib functions and methods.

README.md renamed to README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# python-isal
1+
python-isal
2+
===========
3+
24
Python bindings for the [isa-l](https://github.com/intel/isa-l) library.
35

46
The Intel Infrastructure Storage Acceleration Library (isa-l) implements several key

benchmark.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import argparse
2+
import gzip
3+
import timeit
4+
import zlib
5+
from pathlib import Path
6+
from typing import Dict
7+
8+
from isal import igzip, isal_zlib # noqa: F401 used in timeit strings
9+
10+
DATA_DIR = Path(__file__).parent / "tests" / "data"
11+
COMPRESSED_FILE = DATA_DIR / "test.fastq.gz"
12+
with gzip.open(str(COMPRESSED_FILE), mode="rb") as file_h:
13+
data = file_h.read()
14+
15+
sizes: Dict[str, bytes] = {
16+
"0b": b"",
17+
"8b": data[:8],
18+
"128b": data[:128],
19+
"1kb": data[:1024],
20+
"8kb": data[:8 * 1024],
21+
"16kb": data[:16 * 1024],
22+
"32kb": data[:32 * 1024],
23+
"64kb": data[:64 * 1024],
24+
# "128kb": data[:128*1024],
25+
# "512kb": data[:512*1024]
26+
}
27+
compressed_sizes = {name: zlib.compress(data_block)
28+
for name, data_block in sizes.items()}
29+
30+
compressed_sizes_gzip = {name: gzip.compress(data_block)
31+
for name, data_block in sizes.items()}
32+
33+
34+
def show_sizes():
35+
print("zlib sizes")
36+
print("name\t" + "\t".join(str(level) for level in range(-1, 10)))
37+
for name, data_block in sizes.items():
38+
orig_size = max(len(data_block), 1)
39+
rel_sizes = (
40+
str(round(len(zlib.compress(data_block, level)) / orig_size, 3))
41+
for level in range(-1, 10))
42+
print(name + "\t" + "\t".join(rel_sizes))
43+
44+
print("isal sizes")
45+
print("name\t" + "\t".join(str(level) for level in range(0, 4)))
46+
for name, data_block in sizes.items():
47+
orig_size = max(len(data_block), 1)
48+
rel_sizes = (
49+
str(round(len(isal_zlib.compress(data_block, level)) / orig_size,
50+
3))
51+
for level in range(0, 4))
52+
print(name + "\t" + "\t".join(rel_sizes))
53+
54+
55+
def benchmark(name: str,
56+
names_and_data: Dict[str, bytes],
57+
isal_string: str,
58+
zlib_string: str,
59+
number: int = 10_000,
60+
**kwargs):
61+
print(name)
62+
print("name\tisal\tzlib\tratio")
63+
for name, data_block in names_and_data.items():
64+
timeit_kwargs = dict(globals=dict(**globals(), **locals()),
65+
number=number, **kwargs)
66+
isal_time = timeit.timeit(isal_string, **timeit_kwargs)
67+
zlib_time = timeit.timeit(zlib_string, **timeit_kwargs)
68+
isal_nanosecs = round(isal_time * (1_000_000 / number), 2)
69+
zlib_nanosecs = round(zlib_time * (1_000_000 / number), 2)
70+
ratio = round(isal_time / zlib_time, 2)
71+
print("{0}\t{1}\t{2}\t{3}".format(name,
72+
isal_nanosecs,
73+
zlib_nanosecs,
74+
ratio))
75+
76+
77+
# show_sizes()
78+
79+
def argument_parser() -> argparse.ArgumentParser:
80+
parser = argparse.ArgumentParser()
81+
parser.add_argument("--all", action="store_true")
82+
parser.add_argument("--checksums", action="store_true")
83+
parser.add_argument("--functions", action="store_true")
84+
parser.add_argument("--gzip", action="store_true")
85+
return parser
86+
87+
88+
if __name__ == "__main__":
89+
args = argument_parser().parse_args()
90+
if args.checksums or args.all:
91+
benchmark("CRC32", sizes,
92+
"isal_zlib.crc32(data_block)",
93+
"zlib.crc32(data_block)")
94+
95+
benchmark("Adler32", sizes,
96+
"isal_zlib.adler32(data_block)",
97+
"zlib.adler32(data_block)")
98+
if args.functions or args.all:
99+
benchmark("Compression", sizes,
100+
"isal_zlib.compress(data_block, 1)",
101+
"zlib.compress(data_block, 1)")
102+
103+
benchmark("Decompression", compressed_sizes,
104+
"isal_zlib.decompress(data_block)",
105+
"zlib.decompress(data_block)")
106+
107+
if args.gzip or args.all:
108+
benchmark("Compression", sizes,
109+
"igzip.compress(data_block, 1)",
110+
"gzip.compress(data_block, 1)")
111+
112+
benchmark("Decompression", compressed_sizes_gzip,
113+
"igzip.decompress(data_block)",
114+
"gzip.decompress(data_block)")

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
from distutils.dist import DistributionMetadata
8+
from pathlib import Path
9+
10+
import pkg_resources
11+
12+
# -- Project information -----------------------------------------------------
13+
14+
# Get package information from the installed package.
15+
package = pkg_resources.get_distribution("isal")
16+
metadata_file = Path(package.egg_info) / Path(package.PKG_INFO)
17+
metadata = DistributionMetadata(path=str(metadata_file))
18+
19+
project = 'python-isal'
20+
copyright = '2020, Leiden University Medical Center'
21+
author = 'Leiden University Medical Center'
22+
23+
# The short X.Y version
24+
version = package.parsed_version.base_version
25+
# The full version, including alpha/beta/rc tags
26+
release = package.version
27+
28+
29+
# -- General configuration ---------------------------------------------------
30+
31+
# Add any Sphinx extension module names here, as strings. They can be
32+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
33+
# ones.
34+
extensions = [
35+
]
36+
37+
# Add any paths that contain templates here, relative to this directory.
38+
templates_path = ['_templates']
39+
40+
# List of patterns, relative to source directory, that match files and
41+
# directories to ignore when looking for source files.
42+
# This pattern also affects html_static_path and html_extra_path.
43+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
44+
45+
46+
# -- Options for HTML output -------------------------------------------------
47+
48+
# The theme to use for HTML and HTML Help pages. See the documentation for
49+
# a list of builtin themes.
50+
#
51+
html_theme = 'alabaster'
52+
53+
# Add any paths that contain custom static files (such as style sheets) here,
54+
# relative to this directory. They are copied after the builtin static files,
55+
# so a file named "default.css" will overwrite the builtin "default.css".
56+
html_static_path = ['_static']

docs/index.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. python-isal documentation master file, created by
2+
sphinx-quickstart on Fri Sep 11 15:42:56 2020.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to python-isal's documentation!
7+
=======================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`genindex`
19+
* :ref:`modindex`
20+
* :ref:`search`

0 commit comments

Comments
 (0)