Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d715997
- bump python versions
maxsch3 Dec 20, 2023
44d8a04
- created new pipeline in .github/workflows
maxsch3 Dec 20, 2023
0ffc322
- updated pipeline
maxsch3 Dec 21, 2023
a2b579c
- removed version from tensorflow in test requirements.txt
maxsch3 Dec 21, 2023
5a67673
- removed version from tensorflow in test requirements.txt
maxsch3 Dec 21, 2023
d763b26
- updated python versions in matrix
maxsch3 Dec 21, 2023
be3b2a3
- downgraded pandas minimal requirement to enable python 3.8
maxsch3 Dec 21, 2023
7134897
- Added pythonpath to test command
maxsch3 Dec 21, 2023
7b81f0d
- added doc build test
maxsch3 Dec 21, 2023
0b95170
- removed versions from build modules
maxsch3 Dec 21, 2023
fa242ec
- updated thresholds in random tests
maxsch3 Dec 21, 2023
702ef8f
- created deploy pipeline
maxsch3 Dec 22, 2023
01a1120
- fixed if condition
maxsch3 Dec 22, 2023
0f6152d
- fixed if condition
maxsch3 Dec 22, 2023
74f57bd
- upped upload artifacts action
maxsch3 Dec 22, 2023
079a862
- added setup step
maxsch3 Dec 22, 2023
a49543c
- fixed a test threshold
maxsch3 Dec 22, 2023
f358287
- fixed a test threshold
maxsch3 Dec 22, 2023
0fa8eb4
- versions
maxsch3 Dec 22, 2023
b75a8b2
- created release pipeline
maxsch3 Dec 22, 2023
3d51bf5
use site folder
maxsch3 Dec 22, 2023
5485651
use site folder
maxsch3 Dec 22, 2023
18c1609
changed token to ssh-key
maxsch3 Dec 22, 2023
bb29518
added build pypi
maxsch3 Dec 23, 2023
a02bdf8
fixed typo in job name
maxsch3 Dec 23, 2023
db6f311
Added pypi deploy
maxsch3 Dec 24, 2023
1b0e88b
fixed name for PYPI_TOKEN
maxsch3 Dec 24, 2023
7c36ebb
set triggers for all three pipleines
maxsch3 Dec 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/master-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Python package

on:
push:
branches:
- 'master'


jobs:
test-code:
name: "Test code"

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest pytest-cov pytest-dependency
PYTHONPATH="$PYTHONPATH:./keras-batchflow" pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

page_build:
name: "Build and deploy documentation to staging"
needs: test-code
runs-on: ubuntu-latest
environment: github-pages-staging
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r build_requirements.txt
pip install -e .
- name: Build docs
run: |
mkdocs build --verbose --clean --strict
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: site
repository-name: maxsch3/keras-batchflow-test
ssh-key: ${{ secrets.GH_DEPLOY_SECRET }}
102 changes: 102 additions & 0 deletions .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Python package

on:
release:
types: ['published']


jobs:

page_build:
name: "Build documentation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
pip install -r requirements.txt
pip install -r build_requirements.txt
pip install -e .
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Build docs
run: |
mkdocs build --verbose --clean --strict
- name: Upload page artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site

pypi_build:
name: Build pypi package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
pip install -r requirements.txt
pip install -r build_requirements.txt
pip install -e .
- name: Build pypi package
run: |
python -m build
- name: Upload build package as artifact
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

deploy_page:
name: 'Deploy release documentation'
needs: [page_build, pypi_build]

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
actions: read # to download an artifact uploaded by `actions/upload-pages-artifact@v3`

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

deploy_pypi:
name: Publish to pypi
needs: [page_build, pypi_build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/keras-batchflow
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/test-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Python package

on:
push:
branches:
- '*'
- '!master'

jobs:
test-code:
name: "Test code"

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest pytest-cov pytest-dependency
PYTHONPATH="$PYTHONPATH:./keras-batchflow" pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

test-doc-build:
name: "Test documentation build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r build_requirements.txt
pip install -e .
- name: Test doc build
run: |
mkdocs build --verbose --clean --strict
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
language: python
python:
# - "2.7"
# - "3.4"
# - "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
env:
- framework=TF1
# - framework=TF1
- framework=TF2

script:
Expand All @@ -16,7 +14,7 @@ jobs:
include:
- stage: deploy-test
if: branch = master
python: "3.6"
python: "3.10"
script: skip
install:
- pip install -r requirements_tf1.txt
Expand All @@ -34,7 +32,7 @@ jobs:
branch: master
- stage: deploy-prod
if: tag IS present
python: "3.6"
python: "3.10"
script: skip
install:
- pip install -r requirements_tf1.txt
Expand Down
12 changes: 6 additions & 6 deletions build_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setuptools-scm==3.5.0
mkdocs==1.1.2
mkdocs-jupyter==0.13.0
notebook==6.1.5
pymdown-extensions==6.3
nbconvert==5.6.1
setuptools-scm
mkdocs
mkdocs-jupyter
notebook
pymdown-extensions
nbconvert
git+https://github.com/tomchristie/mkautodoc.git#egg=mkautodoc
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pandas>=2.0.0
scikit-learn
tensorflow-cpu
8 changes: 0 additions & 8 deletions requirements_tf1.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements_tf2.txt

This file was deleted.

7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
download_url='https://github.com/maxsch3/batchflow',
license='MIT',
setup_requires=['setuptools_scm'],
install_requires=['numpy>=1.9.1',
'scipy>=0.14',
install_requires=['numpy>=1.20.0',
'scikit-learn',
'pandas'],
'pandas>=2.0.0'],
extras_require={
'visualize': ['pydot>=1.2.4'],
'tests': ['pytest',
Expand All @@ -33,7 +32,7 @@
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules'
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,15 @@ def test_transform(self):

def test_transform_many_cols(self):
ct = LocalVersionTransform([.0, 1.], cols=['var1', 'var2'])
batch = ct.transform(self.df.copy())
# make a bigger batch to make sure augmenatation will always be used on the batch
# when batch is small there is a small chance the batch will sieve through without augmentation due to its
# random nature
seed_df = self.df.sample(100, replace=True)
batch = ct.transform(seed_df.copy())
assert isinstance(batch, pd.DataFrame)
assert batch.shape == self.df.shape
assert not batch.equals(self.df)
batch = self.df.copy()
assert batch.shape == seed_df.shape
assert not batch.equals(seed_df)
batch = seed_df.copy()
batch1 = ct.transform(batch)
# test if transform does in-place transform
assert batch1.equals(batch)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 12 additions & 9 deletions test/test_feature_dropout.py → tests/test_feature_dropout.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ def test_row_dist(self):
assert binom_test(b, 1000, 0.6) > 0.01

def test_cols_dist(self):
sample_size = 1000
fd = FeatureDropout([0., 1.], ['var1', 'var2', 'label'], drop_values='', col_probs=[.5, .3, .2])
batch = fd.transform(self.df.sample(1000, replace=True))
batch = fd.transform(self.df.sample(sample_size, replace=True))
b = (batch == '').sum(axis=0)
c, p = chisquare(b, [520, 300, 180])
c, p = chisquare(b, [sample_size * .53, sample_size * .3, sample_size * .17])
assert p > 0.001

def test_uniform_col_dist(self):
sample_size = 1000
fd = FeatureDropout([0., 1.], ['var1', 'var2', 'label'], drop_values='')
batch = fd.transform(self.df.sample(1000, replace=True))
batch = fd.transform(self.df.sample(sample_size, replace=True))
b = (batch == '').sum(axis=0)
c, p = chisquare(b, [333, 333, 333])
c, p = chisquare(b, f_exp=[sample_size/3, sample_size/3, sample_size/3])
assert p > 0.01

def test_different_drop_values(self):
Expand All @@ -55,20 +57,21 @@ def test_different_drop_values(self):
assert b[1] == 0
assert b[2] == 0
b = (batch == 'v2').sum(axis=0)
assert binom_test(b[1], 1000, 0.33) > 0.01
assert binom_test(b[1], 1000, 0.33) > 0.001
assert b[0] == 0
assert b[2] == 0
b = (batch == 'v3').sum(axis=0)
assert binom_test(b[2], 1000, 0.33) > 0.01
assert binom_test(b[2], 1000, 0.33) > 0.001
assert b[0] == 0
assert b[1] == 0

def test_multiple_feature_drop(self):
sample_size = 100
fd = FeatureDropout([0., .7, .3], ['var1', 'var2', 'label'], drop_values='', col_probs=[.5, .3, .2])
batch = fd.transform(self.df.sample(1000, replace=True))
batch = fd.transform(self.df.sample(sample_size, replace=True))
b = (batch == '').sum(axis=1).value_counts().sort_index().tolist()
c, p = chisquare(b, [700, 300])
assert p > 0.01
c, p = chisquare(b, [sample_size * .7, sample_size * .3])
assert p > 0.001

def test_parameter_error_handling(self):
# column name is not str
Expand Down
Loading