Skip to content

Commit 5723903

Browse files
In progress commit on branch dev.
1 parent c0a47de commit 5723903

22 files changed

+190
-304
lines changed

.github/workflows/build.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ name: Build and test
1111
# Arguments:
1212
# event_name: pull_request
1313
# event_cond: true
14-
# trigger: -not-available- # not available via repository_dispatch (there's no pull request to test!)
14+
# trigger: -not-available- # not available via repository_dispatch (we'd need a way to specify which pull request we want tested; not obvious if that's possible)
1515

1616

1717
on:
1818
repository_dispatch:
1919
pull_request:
2020
branches:
2121
- master
22-
2322

2423
jobs:
2524
check_version:
@@ -86,7 +85,7 @@ jobs:
8685
if: ((github.event_name == 'pull_request' && (true)) || (github.event_name == 'repository_dispatch' && contains(github.event.action, '-trigger -not-available- ') && ((contains(github.event.action, '-os windows-2016') && matrix.os == 'windows-2016') || (contains(github.event.action, '-os ubuntu-16.04') && matrix.os == 'ubuntu-16.04') || (contains(github.event.action, '-os macOS-10.14') && matrix.os == 'macOS-10.14') || contains(github.event.action, '-os *')) && ((contains(github.event.action, '-pv 2.7.13') && matrix.python-version == '2.7.13') || (contains(github.event.action, '-pv 3.5.4') && matrix.python-version == '3.5.4') || (contains(github.event.action, '-pv 3.6.2') && matrix.python-version == '3.6.2') || (contains(github.event.action, '-pv 3.7.0') && matrix.python-version == '3.7.0') || contains(github.event.action, '-pv *'))))
8786
run: |
8887
cp README.rst README.rst.old
89-
python command.py genreadme
88+
python command.py readme
9089
python -c "import io
9190
import sys
9291
readme = io.open('README.rst', 'r', encoding='utf-8')

.github/workflows/deploy.yml

+4-19
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
matrix:
2929
os: [ubuntu-16.04]
3030
python-version: [3.7.0]
31-
pytorch-version: [1.2.0]
31+
pytorch-version: [1.2.0, 1.3.0]
3232

3333
steps:
3434
- name: Checkout code
@@ -59,11 +59,6 @@ jobs:
5959
python setup.py egg_info --tag-build="-torch${{ matrix.pytorch-version }}" sdist
6060
pip install twine
6161
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
62-
cd installer
63-
python -c "import command; command.set_up()"
64-
python setup.py sdist
65-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
66-
cd ..
6762
6863
6964
deploy:
@@ -110,18 +105,13 @@ jobs:
110105
python setup.py egg_info --tag-build="-torch${{ matrix.pytorch-version }}" bdist_wheel &&
111106
pip install twine &&
112107
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/* &&
113-
cd installer &&
114-
python -c "import command.py; command.set_up()" &&
115-
python setup.py sdist &&
116-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/* &&
117-
cd .. &&
118108
python -c "import subprocess;
119109
import sys;
120110
import time;
121111
import metadata;
122112
sleep = lambda t: time.sleep(t) or True;
123113
retry = lambda fn: fn() or (sleep(20) and fn()) or (sleep(40) and fn()) or (sleep(120) and fn()) or (sleep(240) and fn());
124-
ret = retry(lambda: not subprocess.run('python -m pip install signatory_installer=={}'.format(metadata.version)).returncode);
114+
ret = retry(lambda: not subprocess.run('python -m pip install signatory==' + metadata.version + '-torch${{ matrix.pytorch-version }}').returncode);
125115
sys.exit(not ret)
126116
" &&
127117
python -m pip install iisignature &&
@@ -150,7 +140,7 @@ jobs:
150140
python command.py should_not_import
151141
retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
152142
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
153-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION
143+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}
154144
python -m pip install iisignature
155145
python -c "import os
156146
import subprocess
@@ -178,14 +168,9 @@ jobs:
178168
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py egg_info --tag-build="-torch${{ matrix.pytorch-version }}" bdist_wheel
179169
pip install twine
180170
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
181-
cd installer
182-
python -c "import command; command.set_up()"
183-
python setup.py sdist
184-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
185-
cd ..
186171
retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
187172
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
188-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION
173+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}
189174
git clone https://github.com/bottler/iisignature.git
190175
cd iisignature
191176
python setup.py install

.github/workflows/test_deployed.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
import metadata;
6363
sleep = lambda t: time.sleep(t) or True;
6464
retry = lambda fn: fn() or (sleep(20) and fn()) or (sleep(40) and fn()) or (sleep(120) and fn()) or (sleep(240) and fn());
65-
ret = retry(lambda: not subprocess.run('python -m pip install signatory_installer=={}'.format(metadata.version)).returncode);
65+
ret = retry(lambda: not subprocess.run('python -m pip install signatory==' + metadata.version + '-torch${{ matrix.pytorch-version }}').returncode);
6666
sys.exit(not ret)
6767
" &&
6868
python -m pip install iisignature &&
@@ -91,7 +91,7 @@ jobs:
9191
python command.py should_not_import
9292
retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
9393
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
94-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION
94+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}
9595
python -m pip install iisignature
9696
python -c "import os
9797
import subprocess
@@ -118,7 +118,7 @@ jobs:
118118
python command.py should_not_import
119119
retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
120120
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
121-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION
121+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}
122122
git clone https://github.com/bottler/iisignature.git
123123
cd iisignature
124124
python setup.py install

.github/workflows_templates/build.yml.template

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ name: Build and test
55
# Arguments:
66
# event_name: pull_request
77
# event_cond: true
8-
# trigger: -not-available- # not available via repository_dispatch (there's no pull request to test!)
8+
# trigger: -not-available- # not available via repository_dispatch (we'd need a way to specify which pull request we want tested; not obvious if that's possible)
99

1010

1111
<<on>>
1212
branches:
1313
- master
14-
1514

1615
jobs:
1716
check_version:
@@ -54,7 +53,7 @@ jobs:
5453
<<if_>>
5554
run: |
5655
cp README.rst README.rst.old
57-
python command.py genreadme
56+
python command.py readme
5857
python -c "import io
5958
import sys
6059
readme = io.open('README.rst', 'r', encoding='utf-8')

.github/workflows_templates/deploy.yml.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ name: Deploy and test
1515
jobs:
1616
# we need to do this first as all the linux versions install the same thing from PyPI
1717
deploy_sdist:
18-
<<strategy_single>>
18+
<<strategy_single_all_pytorch>>
1919
steps:
2020
- <<checkout_code>>
2121
with:

.github/workflows_templates/from_template.py

+32-31
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,17 @@ def _substitute(filename, **subs):
128128
linux = "ubuntu-16.04",
129129
mac = "macOS-10.14",
130130

131+
# Run on repository_dispatch and precisely one other event
132+
on = \
133+
"""on:
134+
repository_dispatch:
135+
<<event_name>>:""",
136+
137+
# Only run on repository_dispatch
138+
on_rd = "on: repository_dispatch",
139+
131140
# Versions of Python
132-
# Note that it's actually important to specify the patch number here as well for maximum compatability.
141+
# Note that it's actually important to specify the patch number here as well for maximum compatibility.
133142
# (e.g. 3.6.6 vs 3.6.9 does break things)
134143
py27 = '2.7.13',
135144
py35 = '3.5.4',
@@ -139,15 +148,7 @@ def _substitute(filename, **subs):
139148
# Versions of PyTorch
140149
pytorch12 = '1.2.0',
141150
pytorch13 = '1.3.0',
142-
143-
# Run on repository_dispatch and precisely one other event
144-
on = \
145-
"""on:
146-
repository_dispatch:
147-
<<event_name>>:""",
148-
149-
# Only run on repository_dispatch
150-
on_rd = "on: repository_dispatch",
151+
pytorch_all = '[<<pytorch12>>, <<pytorch13>>]',
151152

152153
# A strategy for every operating system and version of Python
153154
# Note that every possible combination must be specified in action_os and action_pv to have repository_dispatch work
@@ -158,7 +159,7 @@ def _substitute(filename, **subs):
158159
matrix:
159160
os: [<<windows>>, <<linux>>, <<mac>>]
160161
python-version: [<<py27>>, <<py35>>, <<py36>>, <<py37>>]
161-
pytorch-version: [<<pytorch12>>, <<pytorch13>>]
162+
pytorch-version: <<pytorch_all>>
162163
exclude:
163164
# PyTorch doesn't support this combination
164165
- os: <<windows>>
@@ -175,6 +176,16 @@ def _substitute(filename, **subs):
175176
pytorch-version: [<<pytorch12>>]
176177
""",
177178

179+
# A single Linux strategy except with all PyTorch versions
180+
strategy_single_all_pytorch = \
181+
"""runs-on: ${{ matrix.os }}
182+
strategy:
183+
matrix:
184+
os: [<<linux>>]
185+
python-version: [<<py37>>]
186+
pytorch-version: <<pytorch_all>>
187+
""",
188+
178189
# Tests whether a repository_dispatch-triggered action is triggered at all
179190
# Note that trigger is intended to have a space after it (used to distinguish similar triggers)
180191
action_trigger = "contains(github.event.action, '-trigger <<trigger>> ')",
@@ -186,7 +197,7 @@ def _substitute(filename, **subs):
186197
_action_os_linux = "(contains(github.event.action, '-os <<linux>>') && matrix.os == '<<linux>>')",
187198
_action_os_mac = "(contains(github.event.action, '-os <<mac>>') && matrix.os == '<<mac>>')",
188199
_action_os_star = "contains(github.event.action, '-os *')",
189-
action_os = "(<<_action_os_windows>> || <<_action_os_linux>> || <<_action_os_mac>> || <<_action_os_star>>)",
200+
action_os = "(<<_action_os_windows>> || <<_action_os_linux>> || <<_action_os_mac>> || <<_action_os_star>>)",
190201

191202
# Tests whether a repository_dispatch-triggered action is triggered, depending on Python version
192203
_action_pv_27 = "(contains(github.event.action, '-pv <<py27>>') && matrix.python-version == '<<py27>>')",
@@ -242,7 +253,7 @@ def _substitute(filename, **subs):
242253
python -m pip install --upgrade pip &&
243254
conda install pytorch==${{ matrix.pytorch-version }} -c pytorch -y &&
244255
python command.py should_not_import &&""",
245-
256+
246257
# Builds a bdist_wheel on Windows
247258
build_windows = ' python setup.py egg_info --tag-build="-torch${{ matrix.pytorch-version }}" bdist_wheel &&',
248259

@@ -257,7 +268,7 @@ def _substitute(filename, **subs):
257268
import metadata;
258269
sleep = lambda t: time.sleep(t) or True;
259270
retry = lambda fn: fn() or (sleep(20) and fn()) or (sleep(40) and fn()) or (sleep(120) and fn()) or (sleep(240) and fn());
260-
ret = retry(lambda: not subprocess.run('python -m pip install signatory_installer=={}'.format(metadata.version)).returncode);
271+
ret = retry(lambda: not subprocess.run('python -m pip install signatory==' + metadata.version + '-torch${{ matrix.pytorch-version }}').returncode);
261272
sys.exit(not ret)
262273
" &&""",
263274

@@ -308,7 +319,7 @@ def _substitute(filename, **subs):
308319
install_remote_linux = \
309320
""" retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
310321
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
311-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION""",
322+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}""",
312323

313324
# Runs tests on Linux
314325
test_linux = \
@@ -358,7 +369,7 @@ def _substitute(filename, **subs):
358369
install_remote_mac = \
359370
""" retry () { $* || (sleep 20 && $*) || (sleep 40 && $*) || (sleep 120 && $*) || (sleep 240 && $*); }
360371
SIGNATORY_VERSION=$(python -c "import metadata; print(metadata.version)")
361-
retry python -m pip install signatory_installer==$SIGNATORY_VERSION""",
372+
retry python -m pip install signatory==$SIGNATORY_VERSION-torch${{ matrix.pytorch-version }}""",
362373

363374
# Runs tests on Mac
364375
test_mac = \
@@ -382,25 +393,15 @@ def _substitute(filename, **subs):
382393
chmod +x $GITHUB_WORKSPACE/to_run.sh
383394
sudo -s -H -E $GITHUB_WORKSPACE/to_run.sh""",
384395

385-
# Uploads dist/* to PyPI for Windows, and uploads the installer script
396+
# Uploads dist/* to PyPI for Windows
386397
upload_windows = \
387398
r""" pip install twine &&
388-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/* &&
389-
cd installer &&
390-
python command.py setup &&
391-
python setup.py sdist &&
392-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/* &&
393-
cd .. &&""",
394-
395-
# Uploads dist/* to PyPI for Unix, and uploads the installer script
399+
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/* &&""",
400+
401+
# Uploads dist/* to PyPI for Unix
396402
upload_unix = \
397403
""" pip install twine
398-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
399-
cd installer
400-
python command.py setup
401-
python setup.py sdist
402-
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*
403-
cd ..""",
404+
twine upload -u patrick-kidger -p ${{ secrets.pypi_password }} dist/*""",
404405
) # end of global_subs
405406
global_subs['upload_mac'] = global_subs['upload_linux'] = global_subs['upload_unix']
406407

MANIFEST.in

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ include LICENSE
44
include metadata.py
55
recursive-include src *.hpp
66
recursive-include src *.inl
7-
prune test
8-
prune installer
7+
prune test

README.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ Available for Python 2.7, Python 3.5, Python 3.6, Python 3.7 and Linux, Mac, Win
2323

2424
Requires `PyTorch <http://pytorch.org/>`__.
2525

26-
Install via ``pip install signatory_installer``. Then just ``import signatory`` inside Python.
26+
Install via ``pip install signatory==<SIGNATORY_VERSION>-torch<TORCH_VERSION>``, where ``<SIGNATORY_VERSION>`` is the version of Signatory you would like to download (the most recent version is 1.1.4) and ``<TORCH_VERSION>`` is the version of PyTorch you are using (supported versions are PyTorch 1.2.0 and 1.3.0). Then just ``import signatory`` inside Python.
2727

2828

29-
The ``installer`` is because this command actually downloads a script which detects the version of PyTorch that is currently installed, and then downloads the corresponding version of Signatory. If you already know that you are using e.g. PyTorch 1.2.0 and want Signatory 1.1.4, then you can just run ``pip install signatory==1.1.4-torch1.2.0``.
29+
For example, if you are using PyTorch 1.2.0 and want Signatory 1.1.4, then you should run ``pip install signatory==1.1.4-torch1.2.0``.
30+
31+
32+
Take care **not** to run ``pip install signatory``, as this will likely download the wrong version. This care is needed due to a `limitation of PyTorch <https://github.com/pytorch/pytorch/issues/28754>`__.
3033

3134
Installation from source is also possible; please consult the `documentation <https://signatory.readthedocs.io/en/latest/pages/usage/installation.html#usage-install-from-source>`__. This also includes information on how to run the tests and benchmarks.
3235

benchmark/__init__.py

Whitespace-only changes.

test/benchmark.py benchmark/benchmark.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def time(self):
124124
try:
125125
self.time_statement() # warm up
126126
except Exception:
127-
return [math.inf]
127+
return math.inf
128128
return min(timeit.Timer(stmt=self.time_statement).repeat(repeat=self.repeat, number=self.number))
129129

130130
def memory(self):
@@ -604,7 +604,7 @@ def channels(cls, **kwargs):
604604
def depths(cls, **kwargs):
605605
"""Tests depths for a fixed number of channels."""
606606
new_kwargs = dict(sizes=((32, 128, 4),),
607-
depths=(5, 6, 7, 8, 9))
607+
depths=(4, 5, 6, 7, 8, 9))
608608
new_kwargs.update(kwargs)
609609
return cls(**new_kwargs)
610610

@@ -626,9 +626,6 @@ def graph(self, log=True, save=False):
626626

627627
fig = plt.figure()
628628
ax = fig.gca()
629-
#ax = fig.add_axes([0.1, 0.1, 0.6, 0.75])
630-
#ax = fig.add_subplot(121)
631-
#ax = plt.subplot(121)
632629

633630
_, example_row_value = next(iter(self.results))
634631
x_axes = [[] for _ in range(len(example_row_value))]
@@ -653,17 +650,19 @@ def graph(self, log=True, save=False):
653650
ax.set_ylabel("Time in seconds")
654651
if len(self.sizes) > 1:
655652
ax.set_xlabel("Number of channels")
653+
tag = '_channels'
656654
elif len(self.depths) > 1:
657655
ax.set_xlabel("Depth")
658656
if log:
659657
ax.set_yscale('log')
658+
tag = '_depths'
660659
else:
661660
raise RuntimeError
662661
start, end = ax.get_xlim()
663662
ax.xaxis.set_ticks(range(int(math.ceil(start)), int(math.floor(end)) + 1))
664663
plt.tight_layout()
665664
if save:
666-
plt.savefig(title_string.lower().replace(' ', '_').replace(':', ''))
665+
plt.savefig(title_string.lower().replace(' ', '_').replace(':', '') + tag)
667666
else:
668667
plt.show()
669668

0 commit comments

Comments
 (0)