Skip to content

Commit c4dbcc7

Browse files
committed
Merge branch 'main' of github.com:LabForComputationalVision/pyrtools
2 parents 2581f6b + e4cf002 commit c4dbcc7

8 files changed

Lines changed: 101 additions & 70 deletions

File tree

.github/workflows/ci.yml

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: build
22
on:
33
workflow_dispatch:
44
schedule:
5-
- cron: "0 0 * * 0" # weekly
5+
- cron: 0 0 * * 0 # weekly
66
pull_request:
77
branches:
8-
- main
8+
- main
99
push:
1010
branches:
11-
- main
11+
- main
1212

1313
jobs:
1414
# based on https://slashgear.github.io/how-to-split-test-by-folder-with-github-action/
@@ -17,10 +17,11 @@ jobs:
1717
outputs:
1818
notebook: ${{ steps.get-notebooks.outputs.nb }}
1919
steps:
20-
- uses: actions/checkout@v3
21-
- id: get-notebooks
20+
- uses: actions/checkout@v3
21+
- id: get-notebooks
2222
# it's weird to me, but the quotes around \n should *not* be escaped or it breaks
23-
run: echo "::set-output name=nb::$(ls TUTORIALS/*ipynb | jq -R -s -c 'split("\n")[:-1]')"
23+
run: "echo \"nb=$(ls TUTORIALS/*ipynb | jq -R -s -c 'split(\"\\n\")[:-1]')\"\
24+
\ >> $GITHUB_OUTPUT\n"
2425
notebooks:
2526
runs-on: ubuntu-latest
2627
needs: [get_notebooks]
@@ -31,22 +32,22 @@ jobs:
3132
fail-fast: false
3233
name: Execute notebooks
3334
steps:
34-
- uses: actions/checkout@v2
35-
- uses: actions/setup-python@v2
36-
with:
37-
python-version: ${{ matrix.python-version }}
38-
cache: pip
39-
cache-dependency-path: setup.py
40-
- name: Setup FFmpeg
41-
uses: FedericoCarboni/setup-ffmpeg@v1
42-
- name: Install dependencies
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
cache: pip
40+
cache-dependency-path: setup.py
41+
- name: Setup FFmpeg
42+
uses: FedericoCarboni/setup-ffmpeg@v2
43+
- name: Install dependencies
4344
# nbclient 0.5.5 is the first version that includes jupyter execute
44-
run: |
45-
pip install --upgrade --upgrade-strategy eager .
46-
pip install jupyter ipywidgets
47-
pip install "nbclient>=0.5.5"
48-
- name: Run notebooks
49-
run: "jupyter execute ${{ matrix.notebook }}.ipynb --kernel_name=python3"
45+
run: |
46+
pip install --upgrade --upgrade-strategy eager .
47+
pip install jupyter ipywidgets
48+
pip install "nbclient>=0.5.5"
49+
- name: Run notebooks
50+
run: jupyter execute ${{ matrix.notebook }}.ipynb --kernel_name=python3
5051
tests:
5152
runs-on: ubuntu-latest
5253
strategy:
@@ -55,24 +56,30 @@ jobs:
5556
fail-fast: false
5657
name: Run tests
5758
steps:
58-
- uses: actions/checkout@v2
59-
- name: Install Python 3
60-
uses: actions/setup-python@v2
61-
with:
62-
python-version: ${{ matrix.python-version }}
63-
cache: pip
64-
cache-dependency-path: setup.py
65-
- name: Install dependencies
66-
run: |
67-
# using the --upgrade and --upgrade-strategy eager flags ensures that
68-
# pip will always install the latest allowed version of all
69-
# dependencies, to make sure the cache doesn't go stale
70-
pip install --upgrade --upgrade-strategy eager .
71-
pip install coverage
72-
- name: Run tests
73-
run: 'coverage run TESTS/unitTests.py'
74-
- name: Upload to codecov
75-
run: 'bash <(curl -s https://codecov.io/bash)'
59+
- uses: actions/checkout@v3
60+
- name: Install Python 3
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: ${{ matrix.python-version }}
64+
cache: pip
65+
cache-dependency-path: setup.py
66+
- name: Install dependencies
67+
run: |
68+
# using the --upgrade and --upgrade-strategy eager flags ensures that
69+
# pip will always install the latest allowed version of all
70+
# dependencies, to make sure the cache doesn't go stale
71+
pip install --upgrade --upgrade-strategy eager .
72+
pip install coverage
73+
- name: Run tests
74+
run: |
75+
# for some reason, need to run this in the TESTS dir in order to get
76+
# coverage to work (I couldn't get an analogous .coveragerc working in
77+
# the root directory)
78+
cd TESTS && coverage run unitTests.py
79+
# generate the xml file and move it to root dir for codecov
80+
coverage xml -o ../coverage.xml
81+
- name: Upload coverage to Codecov
82+
uses: codecov/codecov-action@858dd794fbb81941b6d60b0dca860878cba60fa9 # v3.1.1
7683
all_tutorials_in_docs:
7784
runs-on: ubuntu-latest
7885
name: Check that all tutorial notebooks are included in docs
@@ -81,30 +88,31 @@ jobs:
8188
matrix:
8289
notebook: ${{fromJson(needs.get_notebooks.outputs.notebook)}}
8390
steps:
84-
- uses: actions/checkout@v2
85-
- name: Check for file
86-
shell: bash
87-
run: if [[ -z "$(grep ${{ matrix.notebook }} docs/tutorials/*nblink)" ]] ; then exit 1; fi
91+
- uses: actions/checkout@v3
92+
- name: Check for file
93+
shell: bash
94+
run: if [[ -z "$(grep ${{ matrix.notebook }} docs/tutorials/*nblink)" ]] ; then
95+
exit 1; fi
8896
no_extra_nblinks:
8997
runs-on: ubuntu-latest
9098
name: Check that we don't have any extra nblink files
9199
steps:
92-
- uses: actions/checkout@v2
93-
- name: Check same number of nblink and notebooks
94-
shell: bash
95-
run: |
96-
n_nblink=0; for file in docs/tutorials/*nblink; do let "n_nblink+=1"; done;
97-
n_ipynb=0; for file in TUTORIALS/*ipynb; do let "n_ipynb+=1"; done;
98-
if [[ $n_nblink != $n_ipynb ]]; then exit 1; fi;
100+
- uses: actions/checkout@v3
101+
- name: Check same number of nblink and notebooks
102+
shell: bash
103+
run: |
104+
n_nblink=0; for file in docs/tutorials/*nblink; do let "n_nblink+=1"; done;
105+
n_ipynb=0; for file in TUTORIALS/*ipynb; do let "n_ipynb+=1"; done;
106+
if [[ $n_nblink != $n_ipynb ]]; then exit 1; fi;
99107
100108
check:
101109
if: always()
102110
needs:
103-
- notebooks
104-
- tests
111+
- notebooks
112+
- tests
105113
runs-on: ubuntu-latest
106114
steps:
107-
- name: Decide whether all tests and notebooks succeeded
108-
uses: re-actors/alls-green@release/v1
109-
with:
110-
jobs: ${{ toJSON(needs) }}
115+
- name: Decide whether all tests and notebooks succeeded
116+
uses: re-actors/alls-green@afee1c1eac2a506084c274e9c02c8e0687b48d9e # v1.2.2
117+
with:
118+
jobs: ${{ toJSON(needs) }}

.github/workflows/deploy.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: deploy
2-
on: push
2+
on:
3+
release:
4+
types: [published]
35

46
jobs:
57
deploy:
@@ -20,5 +22,4 @@ jobs:
2022
uses: pypa/gh-action-pypi-publish@release/v1
2123
with:
2224
user: __token__
23-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
24-
repository_url: https://test.pypi.org/legacy/
25+
password: ${{ secrets.PYPI_API_TOKEN }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# pyrtools: tools for multi-scale image processing
22

33
[![PyPI Version](https://img.shields.io/pypi/v/pyrtools.svg)](https://pypi.org/project/pyrtools/)
4-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/LabForComputationalVision/pyrtools/blob/master/LICENSE)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/LabForComputationalVision/pyrtools/blob/main/LICENSE)
55
![Python version](https://img.shields.io/badge/python-3.7|3.8|3.9|3.10-blue.svg)
66
[![Build Status](https://github.com/LabForComputationalVision/pyrtools/workflows/build/badge.svg)](https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild)
77
[![Documentation Status](https://readthedocs.org/projects/pyrtools/badge/?version=latest)](https://pyrtools.readthedocs.io/en/latest/?badge=latest)
8-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.0?filepath=TUTORIALS%2F)
9-
[![codecov](https://codecov.io/gh/LabForComputationalVision/pyrtools/branch/master/graph/badge.svg?token=Ei9TYftdYi)](https://codecov.io/gh/LabForComputationalVision/pyrtools)
8+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.1?filepath=TUTORIALS%2F)
9+
[![codecov](https://codecov.io/gh/LabForComputationalVision/pyrtools/branch/main/graph/badge.svg?token=Ei9TYftdYi)](https://codecov.io/gh/LabForComputationalVision/pyrtools)
1010

1111
Briefly, the tools include:
1212
- Recursive multi-scale image decompositions (pyramids), including
@@ -41,7 +41,7 @@ run the pip command, and then adding: `from Cython.Build import
4141
cythonize` and wrapping the `ext_modules` in the `setup` call with
4242
`cythonize`, but I'm not sure.
4343

44-
If you wish to install from the master branch, it's still recommended
44+
If you wish to install from the main branch, it's still recommended
4545
to use pip, just run `pip install .` (or `pip install -e .` if you
4646
want the changes you make in the directory to be reflected in your
4747
install) from the root directory of this project. The core of this

.coveragerc renamed to TESTS/.coveragerc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[paths]
2+
source =
3+
../pyrtools
4+
*/site-packages/pyrtools
5+
16
[run]
27
branch = True
38
source = pyrtools
@@ -9,5 +14,3 @@ exclude_lines =
914
raise NotImplementedError
1015
if __name__ == .__main__.:
1116
ignore_errors = True
12-
omit =
13-
TESTS/*

TESTS/unitTests.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,25 @@ def main():
14601460
if total_size != 0 and wrote != total_size:
14611461
raise Exception("Error downloading test matfiles!")
14621462
with tarfile.open(matfiles_path + ".tar.gz") as f:
1463-
f.extractall(os.path.dirname(matfiles_path))
1463+
def is_within_directory(directory, target):
1464+
1465+
abs_directory = os.path.abspath(directory)
1466+
abs_target = os.path.abspath(target)
1467+
1468+
prefix = os.path.commonprefix([abs_directory, abs_target])
1469+
1470+
return prefix == abs_directory
1471+
1472+
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
1473+
1474+
for member in tar.getmembers():
1475+
member_path = os.path.join(path, member.name)
1476+
if not is_within_directory(path, member_path):
1477+
raise Exception("Attempted Path Traversal in Tar File")
1478+
1479+
tar.extractall(path, members, numeric_owner=numeric_owner)
1480+
1481+
1482+
safe_extract(f, os.path.dirname(matfiles_path))
14641483
os.remove(matfiles_path + ".tar.gz")
14651484
main()

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
:target: https://pypi.org/project/pyrtools/
33

44
.. |license-shield| image:: https://img.shields.io/badge/license-MIT-yellow.svg
5-
:target: https://github.com/LabForComputationalVision/pyrtools/blob/master/LICENSE
5+
:target: https://github.com/LabForComputationalVision/pyrtools/blob/main/LICENSE
66

77
.. |python-version-shield| image:: https://img.shields.io/badge/python-3.7%7C3.8%7C3.9%7C3.10-blue.svg
88

99
.. |build| image:: https://github.com/LabForComputationalVision/pyrtools/workflows/build/badge.svg
1010
:target: https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild
1111

1212
.. |binder| image:: https://mybinder.org/badge_logo.svg
13-
:target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.0?filepath=TUTORIALS%2F
13+
:target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.1?filepath=TUTORIALS%2F
1414

1515
.. pyrtools documentation master file, created by
1616
sphinx-quickstart on Mon Mar 25 17:57:12 2019.

docs/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ For more details, see the jupyter notebooks included in the
3131
`TUTORIALS/` directory, static versions of which are linked in the
3232
navigation sidebar. You can play around with a live version of them in
3333
order to test out the code before downloading on `binder
34-
<https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.0?filepath=TUTORIALS%2F>`_
34+
<https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.1?filepath=TUTORIALS%2F>`_

pyrtools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = '1.0.0'
1+
version = '1.0.1'

0 commit comments

Comments
 (0)