Skip to content
This repository was archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
define pre-commit (#33)
Browse files Browse the repository at this point in the history
* adding pre-commit
* apply formatting
* add CI check
* prune CI triggers
  • Loading branch information
Borda authored Jun 1, 2021
1 parent 54a8cf4 commit 1058d00
Show file tree
Hide file tree
Showing 28 changed files with 126 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ comment:
layout: header, diff
require_changes: false
behavior: default # update if exists else create new
# branches: *
# branches: *
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Now, run all tests using::
Use ``--doctest-modules`` to run doctests.
For example, run all tests and all doctests using::
```
$ pytest -v --doctest-modules --with-xunit --with-coverage pyImSegm
$ pytest -v --doctest-modules --with-xunit --with-coverage pyImSegm
```
## Test coverage
Expand All @@ -102,4 +102,4 @@ detailing the test coverage::
## Bugs
Please `report bugs on GitHub <https://github.com/Borda/pyImSegm/issues>`_.
Please `report bugs on GitHub <https://github.com/Borda/pyImSegm/issues>`_.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Any dependent changes have been merged and published in downstream modules
2 changes: 2 additions & 0 deletions .github/workflows/ci-experiment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on: # Trigger the workflow on push or pull request, but only for the master bra
branches: [master]
pull_request:
branches: [master]
types: [opened, reopened, ready_for_review, synchronize]

jobs:

bash-expt:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/ci-install-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ name: Install pkg
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
- push
- pull_request
push:
branches: [ master ]
pull_request: { }

jobs:
pkg-check:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
Expand All @@ -19,7 +19,7 @@ jobs:

- name: Install dependenies
run: |
pip install --upgrade cython setuptools wheel check-manifest twine==3.2 "numpy<1.17"
pip install --upgrade cython setuptools wheel check-manifest twine==3.2
- name: Check package
run: |
Expand All @@ -44,7 +44,6 @@ jobs:
matrix:
os: [ubuntu-20.04, macOS-10.15] # , windows-2019
python-version: [3.7]

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v2
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: CI testing

# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the master branch
- push
- pull_request
push:
branches: [ master ]
pull_request: {}

jobs:
pytest:
Expand All @@ -12,8 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macOS-10.15] # , windows-2019
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-20.04, macOS-10.15] # , windows-2019
python-version: [3.6, 3.8, 3.9]
requires: ['latest']
include:
- os: ubuntu-18.04
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ jobs:
- name: isort
run: isort --check-only .

pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2

- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v2
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}

- uses: pre-commit/[email protected]
# this action also provides an additional behaviour when used in private repositories
# when configured with a github token, the action will push back fixes to the pull request branch
# with:
# token: ${{ secrets.GITHUB_TOKEN }}

#typing-check-mypy:
# runs-on: ubuntu-20.04
# steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ coverage.xml
.hypothesis/

# Documentation
docs/build
docs/build
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
default_language_version:
python: python3.8

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
# submodules: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: pretty-format-json

#- repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.5.7
# hooks:
# - id: autopep8
# name: fixing PEP8

- repo: https://github.com/PyCQA/isort
rev: 5.8.0
hooks:
- id: isort
name: imports
require_serial: false

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.31.0
hooks:
- id: yapf
name: formatting
language: python
require_serial: false

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
name: PEP8
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ recursive-include imsegm *.py *.pyx
include setup.*

# Exclude build configs
exclude *.yml
exclude *.yml *.yaml
# Exclude testing
exclude pytest.*
recursive-exclude tests *
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ Reference: _Borovec J., Kybic J., Sugimoto, A. (2017). **Region growing using su

Create your own local environment, for more see the [User Guide](https://pip.pypa.io/en/latest/user_guide.html), and install dependencies requirements.txt contains list of packages and can be installed as
```bash
@duda:~$ cd pyImSegm
@duda:~$ cd pyImSegm
@duda:~/pyImSegm$ virtualenv env
@duda:~/pyImSegm$ source env/bin/activate
(env)@duda:~/pyImSegm$ pip install -r requirements.txt
@duda:~/pyImSegm$ source env/bin/activate
(env)@duda:~/pyImSegm$ pip install -r requirements.txt
(env)@duda:~/pyImSegm$ python ...
```
and in the end terminating...
Expand Down Expand Up @@ -111,11 +111,11 @@ If loading of compiled descriptors in `cython` fails, it is automatically swappe

**Installation**

The package can be installed via pip
The package can be installed via pip
```bash
pip install git+https://github.com/Borda/pyImSegm.git
```
or using `setuptools` from a local folder
or using `setuptools` from a local folder
```bash
python setup.py install
```
Expand Down Expand Up @@ -147,7 +147,7 @@ We introduce some useful tools for work with image annotation and segmentation.
-imgs "./data-images/drosophila_ovary_slice/segm/*.png" \
-out ./data-images/drosophila_ovary_slice/segm_rgb
```
* **Visualisation:** having input image and its segmentation we can use simple visualisation which overlap the segmentation over input image.
* **Visualisation:** having input image and its segmentation we can use simple visualisation which overlap the segmentation over input image.
```bash
python handling_annotations/run_overlap_images_segms.py \
-imgs "./data-images/drosophila_ovary_slice/image/*.jpg" \
Expand All @@ -164,7 +164,7 @@ We introduce some useful tools for work with image annotation and segmentation.
```bash
python handling_annotations/run_segm_annot_relabel.py \
-out ./results/relabel_center_levels \
--label_old 2 3 --label_new 1 1
--label_old 2 3 --label_new 1 1
```


Expand Down Expand Up @@ -220,7 +220,7 @@ The previous two (un)segmentation accept [configuration file](experiments_segmen
```yaml
slic_size: 35
slic_regul: 0.2
features:
features:
color_hsv: ['mean', 'std', 'eng']
classif: 'SVM'
nb_classif_search: 150
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
show_downloads: true
theme: jekyll-theme-leap-day
theme: jekyll-theme-leap-day
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ @article{RegionGrowing2017
year = {2017},
doi = {10.1117/1.JEI.26.6.061611},
URL = {http://dx.doi.org/10.1117/1.JEI.26.6.061611}
}
}
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ myst-parser
nbsphinx>=0.8.5
pandoc
docutils
ipython
ipython
2 changes: 1 addition & 1 deletion experiments_ovary_centres/test_ovary_centers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ python experiments_ovary_centres/run_create_annotation.py
python experiments_ovary_centres/run_center_candidate_training.py
python experiments_ovary_centres/run_center_prediction.py
python experiments_ovary_centres/run_center_clustering.py
python experiments_ovary_centres/run_center_evaluation.py
python experiments_ovary_centres/run_center_evaluation.py
2 changes: 1 addition & 1 deletion experiments_ovary_detect/test_ovary_detect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ python experiments_ovary_detect/run_export_user-annot-segm.py
python experiments_ovary_detect/run_cut_segmented_objects.py
python experiments_ovary_detect/run_ellipse_annot_match.py
python experiments_ovary_detect/run_ellipse_cut_scale.py
python experiments_ovary_detect/run_egg_swap_orientation.py
python experiments_ovary_detect/run_egg_swap_orientation.py
2 changes: 1 addition & 1 deletion experiments_segmentation/test_segmentations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ python experiments_segmentation/run_segm_slic_classif_graphcut.py \
-l data-images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv \
-i "data-images/drosophila_ovary_slice/image/insitu41*.jpg" \
-cfg ./experiments_segmentation/sample_config.yml \
--visual
--visual
2 changes: 1 addition & 1 deletion handling_annotations/test_annotations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ python handling_annotations/run_segm_annot_inpaint.py \
--label 0
python handling_annotations/run_segm_annot_relabel.py \
-imgs "./data-images/drosophila_ovary_slice/center_levels/*.png" \
-out ./results/relabel_center_levels
-out ./results/relabel_center_levels
10 changes: 5 additions & 5 deletions ij_macros/convert-image_tif2png.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ print("found: " + toString(list.length));
for (i=0; i<list.length; i++){
name = list[i];
nameNew = replace(name, ".tif", ".png");
print(toString(i+1) + "#" + toString(list.length) + " -> " + name);

print(toString(i+1) + "#" + toString(list.length) + " -> " + name);
open(dirIn + name);

//run("Brightness/Contrast...");
run("Enhance Contrast", "saturated=0.35");
saveAs("PNG", dirOut + nameNew);

saveAs("PNG", dirOut + nameNew);
close();
}
6 changes: 3 additions & 3 deletions ij_macros/multiPointSet_export.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @author Jiri Borovec
* @date 13/06/2014
* @mail [email protected]
*
* @brief: This macro does export set of points from Multi-point tool
*
* @brief: This macro does export set of points from Multi-point tool
* into .csv and .txt files (the name is specified during exporting)
*/

Expand Down Expand Up @@ -40,4 +40,4 @@ for(i=0; i<lengthOf(xCoordinates); i++) {
setResult("Y", i, yCoordinates[i]);
}
updateResults();
saveAs("Results", fileName+".csv");
saveAs("Results", fileName+".csv");
26 changes: 13 additions & 13 deletions ij_macros/multiPointSet_import.ijm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @author Jiri Borovec
* @date 13/06/2014
* @mail [email protected]
*
* @brief: This macro does importing set of points from Multi-point tool
*
* @brief: This macro does importing set of points from Multi-point tool
* from .csv and .txt files (the name is specified during exporting)
*/

Expand All @@ -20,7 +20,7 @@ text = split(allText, "\n");

// define array for points
var xpoints = newArray;
var ypoints = newArray;
var ypoints = newArray;

// in case input is in TXT format
if (ext=="txt") {
Expand All @@ -32,11 +32,11 @@ if (ext=="txt") {
// loading and parsing each line
for (i = 2; i < (text.length); i++){
line = split(text[i]," ");
setOption("ExpandableArrays", true);
setOption("ExpandableArrays", true);
xpoints[i-2] = parseInt(line[iX]);
ypoints[i-2] = parseInt(line[iY]);
print("p("+i-1+") ["+xpoints[i-2]+"; "+ypoints[i-2]+"]");
}
ypoints[i-2] = parseInt(line[iY]);
print("p("+i-1+") ["+xpoints[i-2]+"; "+ypoints[i-2]+"]");
}
// in case input is in CSV format
} else if (ext=="csv") {
print("importing CSV point set...");
Expand All @@ -50,15 +50,15 @@ if (ext=="txt") {
// loading and parsing each line
for (i = 1; i < (text.length); i++){
line = split(text[i],",");
setOption("ExpandableArrays", true);
setOption("ExpandableArrays", true);
xpoints[i-1] = parseInt(line[iX]);
ypoints[i-1] = parseInt(line[iY]);
print("p("+i+") ["+xpoints[i-1]+"; "+ypoints[i-1]+"]");
}
print("p("+i+") ["+xpoints[i-1]+"; "+ypoints[i-1]+"]");
}
// in case of any other format
} else {
print("not supported format...");
print("not supported format...");
}

// show the points in the image
makeSelection("point", xpoints, ypoints);
makeSelection("point", xpoints, ypoints);
Loading

0 comments on commit 1058d00

Please sign in to comment.