Skip to content

Commit a5c8c28

Browse files
authoredJan 9, 2021
Update dependencies and migrate to GH Actions (#255)
* Update dependencies * Migrate to GH actions * Fix github actions * Test devel instead of just lint * Test unit only
1 parent a2a1f4d commit a5c8c28

File tree

7 files changed

+126
-59
lines changed

7 files changed

+126
-59
lines changed
 

‎.github/workflows/docs.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches: [ stable ]
6+
7+
jobs:
8+
9+
docs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Python
15+
uses: actions/setup-python@v1
16+
with:
17+
python-version: 3.8
18+
19+
- name: Build
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -e .[dev]
23+
make docs
24+
- name: Deploy
25+
uses: peaceiris/actions-gh-pages@v3
26+
with:
27+
github_token: ${{secrets.GITHUB_TOKEN}}
28+
publish_dir: docs/_build/html

‎.github/workflows/tests.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
devel:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
python-version: [3.6, 3.7, 3.8]
15+
os: [ubuntu-latest, macos-latest]
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install package
23+
run: pip install .[dev]
24+
- name: make test-devel
25+
run: make test-devel
26+
27+
readme:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix:
31+
python-version: [3.6, 3.7, 3.8]
32+
os: [ubuntu-latest, macos-latest]
33+
steps:
34+
- uses: actions/checkout@v1
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v1
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
- name: Install package and dependencies
40+
run: pip install rundoc .
41+
- name: make test-readme
42+
run: make test-readme
43+
44+
unit:
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
matrix:
48+
python-version: [3.6, 3.7, 3.8]
49+
os: [ubuntu-latest, macos-latest]
50+
steps:
51+
- uses: actions/checkout@v1
52+
- name: Set up Python ${{ matrix.python-version }}
53+
uses: actions/setup-python@v1
54+
with:
55+
python-version: ${{ matrix.python-version }}
56+
- name: Install package and dependencies
57+
run: pip install .[test]
58+
- name: make test-unit
59+
run: make test-unit

‎.travis.yml

-26
This file was deleted.

‎Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ install-test: clean-build clean-pyc ## install the package and test dependencies
8181
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
8282
pip install -e .[dev]
8383

84+
MINIMUM := $(shell sed -n '/install_requires = \[/,/]/p' setup.py | grep -v -e '[][]' | sed 's/ *\(.*\),$?$$/\1/g' | tr '>' '=')
85+
86+
.PHONY: install-minimum
87+
install-minimum: ## install the minimum supported versions of the package dependencies
88+
pip install $(MINIMUM)
89+
8490

8591
# LINT TARGETS
8692

@@ -151,11 +157,11 @@ docs: clean-docs ## generate Sphinx HTML documentation, including API docs
151157
$(MAKE) -C docs html
152158

153159
.PHONY: view-docs
154-
view-docs: docs ## view docs in browser
160+
view-docs: ## view the docs in a browser
155161
$(BROWSER) docs/_build/html/index.html
156162

157163
.PHONY: serve-docs
158-
serve-docs: view-docs ## compile the docs watching for changes
164+
serve-docs: ## compile the docs watching for changes
159165
watchmedo shell-command -W -R -D -p '*.rst;*.md' -c '$(MAKE) -C docs html' docs
160166

161167

‎README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
<p align="left">
2-
<img width=25% src="https://dai.lids.mit.edu/wp-content/uploads/2018/06/Logo_DAI_highres.png" alt=“DAI-Lab” />
3-
<i>An open source project from Data to AI Lab at MIT.</i>
2+
<a href="https://dai.lids.mit.edu">
3+
<img width=15% src="https://dai.lids.mit.edu/wp-content/uploads/2018/06/Logo_DAI_highres.png" alt="DAI-Lab" />
4+
</a>
5+
<i>An Open Source Project from the <a href="https://dai.lids.mit.edu">Data to AI Lab, at MIT</a></i>
46
</p>
57

6-
78
[![Development Status](https://img.shields.io/badge/Development%20Status-2%20--%20Pre--Alpha-yellow)](https://pypi.org/search/?c=Development+Status+%3A%3A+2+-+Pre-Alpha)
89
[![PyPi Shield](https://img.shields.io/pypi/v/mlprimitives.svg)](https://pypi.python.org/pypi/mlprimitives)
9-
[![Travis CI Shield](https://travis-ci.com/MLBazaar/MLPrimitives.svg?branch=master)](https://travis-ci.com/MLBazaar/MLPrimitives)
10+
[![Tests](https://github.com/MLBazaar/MLPrimitives/workflows/Run%20Tests/badge.svg)](https://github.com/MLBazaar/MLPrimitives/actions?query=workflow%3A%22Run+Tests%22+branch%3Amaster)
1011
[![Downloads](https://pepy.tech/badge/mlprimitives)](https://pepy.tech/project/mlprimitives)
12+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/MLBazaar/MLBlocks/master?filepath=examples/tutorials)
1113

1214
# MLPrimitives
1315

1416
Pipelines and primitives for machine learning and data science.
1517

18+
* Documentation: https://MLBazaar.github.io/MLPrimitives
19+
* Github: https://github.com/MLBazaar/MLPrimitives
1620
* License: [MIT](https://github.com/MLBazaar/MLPrimitives/blob/master/LICENSE)
1721
* Development Status: [Pre-Alpha](https://pypi.org/search/?c=Development+Status+%3A%3A+2+-+Pre-Alpha)
18-
* Documentation: https://MLBazaar.github.io/MLPrimitives
19-
* Homepage: https://github.com/MLBazaar/MLPrimitives
2022

2123
# Overview
2224

‎mlprimitives/candidates/timeseries/cyclegan.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import keras
77
import numpy as np
88
import pandas as pd
9+
import tensorflow as tf
910
from keras import backend as K
10-
from keras.layers import Input
11-
from keras.layers.merge import _Merge
11+
from keras.layers import Input, Layer
1212
from keras.models import Model
1313
from scipy import integrate, stats
1414

@@ -18,11 +18,18 @@
1818
LOGGER = logging.getLogger(__name__)
1919

2020

21-
class RandomWeightedAverage(_Merge):
22-
def _merge_function(self, inputs):
23-
alpha = K.random_uniform((64, 1, 1))
21+
class RandomWeightedAverage(Layer):
22+
def __init__(self, batch_size):
23+
super().__init__()
24+
self.batch_size = batch_size
25+
26+
def call(self, inputs, **kwargs):
27+
alpha = tf.random_uniform((self.batch_size, 1, 1, 1))
2428
return (alpha * inputs[0]) + ((1 - alpha) * inputs[1])
2529

30+
def compute_output_shape(self, input_shape):
31+
return input_shape[0]
32+
2633

2734
class CycleGAN():
2835
"""CycleGAN class"""
@@ -130,7 +137,7 @@ def _build_cyclegan(self, **kwargs):
130137
z_ = self.encoder(x)
131138
fake_x = self.critic_x(x_)
132139
valid_x = self.critic_x(x)
133-
interpolated_x = RandomWeightedAverage()([x, x_])
140+
interpolated_x = RandomWeightedAverage(self.batch_size)([x, x_])
134141

135142
validity_interpolated_x = self.critic_x(interpolated_x)
136143
partial_gp_loss_x = partial(self._gradient_penalty_loss, averaged_samples=interpolated_x)
@@ -143,7 +150,7 @@ def _build_cyclegan(self, **kwargs):
143150

144151
fake_z = self.critic_z(z_)
145152
valid_z = self.critic_z(z)
146-
interpolated_z = RandomWeightedAverage()([z, z_])
153+
interpolated_z = RandomWeightedAverage(self.batch_size)([z, z_])
147154
validity_interpolated_z = self.critic_z(interpolated_z)
148155
partial_gp_loss_z = partial(self._gradient_penalty_loss, averaged_samples=interpolated_z)
149156
partial_gp_loss_z.__name__ = 'gradient_penalty'
@@ -210,10 +217,11 @@ def predict(self, X):
210217
N-dimensional array containing the input sequences for the model.
211218
212219
Returns:
213-
ndarray:
214-
N-dimensional array containing the reconstructions for each input sequence.
215-
ndarray:
216-
N-dimensional array containing the critic scores for each input sequence.
220+
typle:
221+
ndarray:
222+
N-dimensional array containing the reconstructions for each input sequence.
223+
ndarray:
224+
N-dimensional array containing the critic scores for each input sequence.
217225
"""
218226
X = X.reshape((-1, self.shape[0], 1))
219227
z_ = self.encoder.predict(X)

‎setup.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,16 @@
2020
'mlblocks>=0.4.0.dev0,<0.5',
2121
'networkx>=2.0,<3',
2222
'nltk>=3.3,<4',
23+
'numpy<1.19.0,>=1.16.0',
2324
'opencv-python>=3.4.0.12,<5',
2425
'pandas>=1,<2',
25-
'python-louvain>=0.10,<0.14',
26+
'python-louvain>=0.10,<0.14', # community
2627
'scikit-image>=0.15',
2728
'scikit-learn>=0.21',
2829
'scipy>=1.1.0,<2',
29-
'statsmodels>=0.9.0,<1',
30+
'statsmodels>=0.9.0,<0.13',
3031
'tensorflow>=2,<2.4',
3132
'xgboost>=0.72.1,<1',
32-
33-
# Conflict fixing
34-
'docutils<0.16,>=0.10',
35-
'urllib3<1.26,>=1.20',
36-
'h5py<2.11.0,>=2.10.0',
37-
'numpy<1.19.0,>=1.16.0',
3833
]
3934

4035

@@ -45,7 +40,6 @@
4540
tests_require = [
4641
'pytest>=3.4.2',
4742
'pytest-cov>=2.6.0',
48-
'jupyter>=1.0.0,<2',
4943
'rundoc>=0.4.3,<0.5',
5044
]
5145

@@ -76,10 +70,6 @@
7670
# Advanced testing
7771
'coverage>=4.5.1,<6',
7872
'tox>=2.9.1,<4',
79-
'importlib-metadata<2.0.0,>=0.12'
80-
81-
# Jupyter
82-
'jupyter>=1.0.0',
8373
]
8474

8575
extras_require = {
@@ -126,7 +116,7 @@
126116
setup_requires=setup_requires,
127117
test_suite='tests',
128118
tests_require=tests_require,
129-
url='https://github.com/HDI-Project/MLPrimitives',
119+
url='https://github.com/MLBazaar/MLPrimitives',
130120
version='0.3.0.dev2',
131121
zip_safe=False,
132122
)

0 commit comments

Comments
 (0)
Please sign in to comment.