Skip to content

Commit

Permalink
Merge pull request #11 from gmrukwa/develop
Browse files Browse the repository at this point in the history
Release 2.1.8
  • Loading branch information
gmrukwa committed Oct 26, 2019
2 parents 8e5cec5 + 6d5efae commit 6c55626
Show file tree
Hide file tree
Showing 96 changed files with 1,849 additions and 1,571 deletions.
10 changes: 10 additions & 0 deletions .github/actions/build-python-dist/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM spectreteam/python_msi:v5.0.0

RUN pip install --no-cache-dir --upgrade \
setuptools \
wheel \
twine

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
5 changes: 5 additions & 0 deletions .github/actions/build-python-dist/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'Build Python distribution'
description: 'Builds Python package distribution for upload'
runs:
using: 'docker'
image: 'Dockerfile'
7 changes: 7 additions & 0 deletions .github/actions/build-python-dist/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

pip install --no-cache-dir -r requirements.txt

python setup.py sdist bdist_wheel

ls dist
5 changes: 5 additions & 0 deletions .github/actions/patch-version/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:3

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions .github/actions/patch-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Patch version number'
description: 'Patches version number of the Python package'
inputs:
packageInitFile:
description: '__init__.py file that should be patched'
required: true
isAlpha:
description: 'if true, package will be annotated with alpha'
required: true
default: false
isBeta:
description: 'if true, package will be annotated with beta'
required: true
default: false
version:
description: 'version of the Python package'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.packageInitFile }}
- ${{ inputs.isAlpha }}
- ${{ inputs.isBeta }}
- ${{ inputs.version }}
16 changes: 16 additions & 0 deletions .github/actions/patch-version/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -l

TARGET=$1
IS_ALPHA=$2
IS_BETA=$3
VERSION=$4

if $IS_ALPHA; then
SUFIX=a
elif $IS_BETA; then
SUFIX=b
fi

VERSION=${VERSION}${SUFIX:+$SUFIX}
sed -i "1s/.*/__version__ = \"${VERSION}\"/" ${TARGET}
cat ${TARGET}
90 changes: 90 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build and push deployment images

on:
push:
branches:
- master
- develop
schedule:
- cron: '0 17 * * *'


env:
MAJOR: ${{ 2 }}
MINOR: ${{ 1 }}
FIXUP: ${{ 8 }}
PACKAGE_INIT_FILE: ${{ 'divik/__init__.py' }}
DOCKER_REPO: ${{ 'gmrukwa/divik' }}
IS_ALPHA: ${{ github.event_name == 'pull_request' }}
IS_BETA: ${{ github.event_name == 'push' && endsWith(github.event.ref, 'heads/develop') }}


jobs:
push_images:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Embed version to package
uses: ./.github/actions/patch-version
with:
packageInitFile: ${{ env.PACKAGE_INIT_FILE }}
isAlpha: ${{ env.IS_ALPHA }}
isBeta: ${{ env.IS_BETA }}
version: ${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.FIXUP }}
- name: Authenticate to Docker Hub
run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
- name: Build image
run: |
docker build \
--file docker/deploy.dockerfile \
--tag deployment \
.
- name: Push annotated images
run: |
if $IS_ALPHA; then
STAGE=alpha
elif $IS_BETA; then
STAGE=beta
fi
echo "STAGE=$STAGE"
docker tag deployment $DOCKER_REPO:$MAJOR.$MINOR.$FIXUP${STAGE:+-$STAGE}
docker tag deployment $DOCKER_REPO:$MAJOR.$MINOR${STAGE:+-$STAGE}
docker tag deployment $DOCKER_REPO:$MAJOR${STAGE:+-$STAGE}
docker push $DOCKER_REPO:$MAJOR.$MINOR.$FIXUP${STAGE:+-$STAGE}
docker push $DOCKER_REPO:$MAJOR.$MINOR${STAGE:+-$STAGE}
docker push $DOCKER_REPO:$MAJOR${STAGE:+-$STAGE}
- name: Push latest image for master branch
if: github.event_name == 'push' && endsWith(github.event.ref, 'heads/master')
run: |
docker tag deployment $DOCKER_REPO:latest
docker push $DOCKER_REPO:latest
push_pypi_package:

if: github.event_name != 'schedule'

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Embed version to package
uses: ./.github/actions/patch-version
with:
packageInitFile: ${{ env.PACKAGE_INIT_FILE }}
isAlpha: ${{ env.IS_ALPHA }}
isBeta: ${{ env.IS_BETA }}
version: ${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.FIXUP }}
- name: Build Python package
uses: ./.github/actions/build-python-dist
- name: Publish Python package
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run unit tests in MCR environment

on: push

jobs:
tests:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Run unit tests in MCR environment
run: docker build . --file docker/unittest.dockerfile --tag unittest
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Quilt
quilt-config/

# PyCharm
.idea/

Expand Down Expand Up @@ -105,3 +102,8 @@ ENV/

# mypy
.mypy_cache/

# local tests
data.csv
xy.csv
result
24 changes: 24 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.5
install:
- requirements: requirements.txt
- requirements: docs/requirements.txt
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

56 changes: 17 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[![CodeFactor](https://www.codefactor.io/repository/github/spectre-team/spectre-divik/badge)](https://www.codefactor.io/repository/github/spectre-team/spectre-divik)
[![BCH compliance](https://bettercodehub.com/edge/badge/spectre-team/spectre-divik?branch=master)](https://bettercodehub.com/)
[![Maintainability](https://api.codeclimate.com/v1/badges/12bf3a9343ab563e2b89/maintainability)](https://codeclimate.com/github/spectre-team/spectre-divik/maintainability)
[![Windows build status](https://ci.appveyor.com/api/projects/status/962q796vgnve968u/branch/master?svg=true)](https://ci.appveyor.com/project/gmrukwa/spectre-divik/branch/master)
[![Linux build Status](https://travis-ci.org/spectre-team/spectre-divik.svg?branch=master)](https://travis-ci.org/spectre-team/spectre-divik)
[![CodeFactor](https://www.codefactor.io/repository/github/gmrukwa/divik/badge)](https://www.codefactor.io/repository/github/gmrukwa/divik)
[![BCH compliance](https://bettercodehub.com/edge/badge/gmrukwa/divik?branch=master)](https://bettercodehub.com/)
[![Maintainability](https://api.codeclimate.com/v1/badges/4cf5d42d0a0076c38445/maintainability)](https://codeclimate.com/github/gmrukwa/divik/maintainability)
![](https://github.com/gmrukwa/divik/workflows/.github/workflows/push_images.yml/badge.svg)
![](https://github.com/gmrukwa/divik/workflows/.github/workflows/unittest.yml/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/divik/badge/?version=latest)](https://divik.readthedocs.io/en/latest/?badge=latest)

![Spectre](https://user-images.githubusercontent.com/1897842/31115297-0fe2c3aa-a822-11e7-90e6-92ceccf76137.jpg)

# spectre-divik
# divik

Python implementation of Divisive iK-means (DiviK) algorithm.

# Tools within this package

> This section will be further developed soon.
1) [`divik`](./spdivik/README.md) - runs DiviK in one of many scenarios
2) [`kmeans`](./spdivik/kmeans/README.md) - runs K-means
1) [`divik`](divik/_cli/divik.md) - runs DiviK in one of many scenarios
2) [`kmeans`](divik/_cli/auto_kmeans.md) - runs K-means
3) `linkage` - runs agglomerative clustering
4) [`inspect`](./spdivik/inspect/README.md) - visualizes DiviK result
5) `visualize` - generates `.png` file with visualization of clusters
6) [`spectral`](./spdivik/spectral.md) - generates spectral embedding of a
4) [`inspect`](divik/_cli/inspect.md) - visualizes DiviK result
5) `visualize` - generates `.png` file with visualization of clusters for 2D
maps
6) [`spectral`](divik/_cli/spectral.md) - generates spectral embedding of a
dataset

# Installation
Expand All @@ -40,17 +40,16 @@ docker pull gmrukwa/divik
To install specific version, you can specify it in the command, e.g.:

```bash
docker pull gmrukwa/divik:1.12.0
docker pull gmrukwa/divik:2.1.8
```

## Python package

Prerequisites for installation of base package:

- Python 3.5
- [functional helpers](https://github.com/gmrukwa/functional-helpers)

These are required for using `divik` application:
These are required for using `divik` application and GMM-based filtering:

- [MATLAB Compiler Runtime](https://www.mathworks.com/products/compiler/matlab-runtime.html),
version 2016b or newer, installed to default path
Expand All @@ -66,38 +65,17 @@ compiled legacy code onto MCR image
- [`divik` image](https://github.com/spectre-team/spectre-divik/blob/master/dockerfile) -
installs DiviK software onto legacy code image

Functional helpers should be installed with:

```bash
pip install git+https://github.com/gmrukwa/functional-helpers.git@2e68a8801f894a14601d70db76086ada723bac35#egg=functional_helpers
```

Having prerequisites installed, one can install latest base version of the
package:

```bash
pip install git+https://github.com/spectre-team/spectre-divik.git@master#egg=spectre-divik
pip install divik
```

or any stable tagged version, e.g.:

```bash
pip install git+https://github.com/spectre-team/spectre-divik.git@v1.12.0#egg=spectre-divik
```

Installation of `divik` program dependencies can be validated via:

```bash
pip install git+https://github.com/spectre-team/spectre-divik.git@master#egg=spectre-divik[divik]
```

**Note:** *Using zsh you may need to escape square brackets with `\ `*

If you want to take advantage of using [Quilt](https://quiltdata.com) for data
management, you can install also this extra:

```bash
pip install git+https://github.com/spectre-team/spectre-divik.git@master#egg=spectre-divik[quilt_packages]
pip install divik==2.1.8
```

# References
Expand Down

0 comments on commit 6c55626

Please sign in to comment.