Skip to content

Commit

Permalink
readme add test status badge
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Sep 22, 2020
1 parent 4c1fa2c commit 49da9a5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 145 deletions.
46 changes: 13 additions & 33 deletions .github/workflows/main.yml
@@ -1,68 +1,48 @@
# Adapted from https://github.com/pytorch/examples/blob/master/.github/workflows/main.yml
# Example of how to open issues on failed tests: https://git.io/JUfDd

name: Run Tests
name: tests

on:
push:
paths:
- '**.py' # only run workflow when source files changed
pull_request:
paths:
- '**.py' # only run workflow when source files changed
- '**.py'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up latest Python 3
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Cache dependencies
# Adapted from https://git.io/JUfrK
uses: actions/cache@v2
id: cache-deps
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
path: ${ pip cache dir } # requires pip 20.1+
# Look to see if there is a cache hit for the corresponding environment file
key: ${{ runner.os }}-pip-${{ hashFiles('env.yml') }}
# Ordered list of keys to use for restoring the cache if no cache hit occurred for key
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
# Optional ordered list of alternative keys to use for restoring the cache
# if no cache was found for key
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Set up latest Python 3
if: steps.cache-deps.outputs.cache-hit != 'true'
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
python -m pip install -U pip
pip install -U pytest sklearn flake8
# Install CPU-based pytorch
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
pip install -r requirements.txt
pip install .
# Maybe use the CUDA 10.2 version instead?
# pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
- name: Run Tests
run: |
python -m pytest
- name: Open issue on failure
if: ${{ failure() }}
uses: rishabhgupta/git-action-issue@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Test suite failed on CI
body: Commit ${{ github.sha }} caused [CI run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to fail, please check why.
assignees: janosh

linting:
runs-on: ubuntu-latest
steps:
- name: Lint with flake8
# Adapted from https://git.io/JUfPw
run: |
Expand Down
108 changes: 0 additions & 108 deletions env.yml

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
@@ -1,4 +1,4 @@
# Torch MNF
# Torch MNF   [![Test Status](https://github.com/janosh/torch-mnf/workflows/tests/badge.svg)](https://github.com/janosh/torch-mnf/actions)

PyTorch implementation of Multiplicative Normalizing Flows [[1]](#mnf-bnn).

Expand Down
10 changes: 10 additions & 0 deletions requirements.txt
@@ -0,0 +1,10 @@
flake8
matplotlib
numpy
pandas
pytest
seaborn
scikit-learn
scipy
torch
torchvision
6 changes: 3 additions & 3 deletions torch_mnf/notebooks/2d.py
Expand Up @@ -71,7 +71,7 @@
print(f"number of params: {sum(p.numel() for p in model.parameters()):,}")


def train(steps=1000, n_samples=128, report_every=100, cb=None):
def train_flow(steps=1000, n_samples=128, report_every=100, cb=None):
for step in range(steps + 1):
x = sample_target_dist(n_samples)

Expand All @@ -91,7 +91,7 @@ def train(steps=1000, n_samples=128, report_every=100, cb=None):


# %%
train()
train_flow()


# %%
Expand Down Expand Up @@ -202,4 +202,4 @@ def plot_learning():


# %%
train(steps=400, cb=plot_learning)
train_flow(steps=400, cb=plot_learning)

0 comments on commit 49da9a5

Please sign in to comment.