Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BM8 comparison page using Jupyter #1314

Merged
merged 46 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9e527e7
Testing plotly
wd15 Oct 8, 2021
f83a5c1
Implement code to exract yaml data as daraframe
wd15 Oct 13, 2021
fe110da
build(nix):
wd15 Oct 15, 2021
5242e8e
feature: ensure plotly notebooks display on site
wd15 Oct 15, 2021
6387bb7
update notebooks
wd15 Oct 25, 2021
c5d4632
trying out github actions
wd15 Oct 25, 2021
35d61d5
update BM8a comparison page
wd15 Oct 30, 2021
64d6ea1
Merge remote-tracking branch 'upstream/github-actions' into bm8-noteb…
wd15 Oct 30, 2021
75ca469
Merge remote-tracking branch 'origin/github-actions' into bm8-noteboo…
wd15 Oct 30, 2021
216de02
Merge branch 'master' into bm8-notebook-comparison-page
wd15 Oct 30, 2021
bd9716e
try and trigger github actions
wd15 Oct 30, 2021
05dd048
testing github actions
wd15 Oct 30, 2021
ca222d5
test github actions
wd15 Oct 30, 2021
3f16a70
testing github actions
wd15 Oct 30, 2021
4fe5514
testing github actions with nix
wd15 Nov 4, 2021
eb71db8
fix
wd15 Nov 4, 2021
5bbb902
make github actions work
wd15 Nov 4, 2021
5cf0acf
Better name for pfhub package testing with github actions
wd15 Dec 1, 2021
d82777b
build(nix): improve build
wd15 Dec 19, 2021
03c3f86
Add doctests and documenation to pfhub package
wd15 Dec 19, 2021
59ff019
Add test case for order of accuracy
wd15 Dec 20, 2021
d38fcb8
build(nix): add nbval
wd15 Dec 24, 2021
12d00ca
fix: bug fixes, small improvements
wd15 Dec 24, 2021
a993ede
Add notebook to tests
wd15 Dec 24, 2021
c741d80
All tests pass for pfhub python package
wd15 Dec 24, 2021
b8f0b3d
test: make sure notebooks are tested
wd15 Dec 27, 2021
9aeaaef
update for black
wd15 Dec 27, 2021
cef4544
test: make nbval lax on github actions
wd15 Dec 27, 2021
3f61bd6
style: clean up for linters
wd15 Dec 29, 2021
c9e043b
test: add linters to github testing
wd15 Dec 29, 2021
346772e
fix: switch to non-interactive table in BM8
wd15 Feb 14, 2022
30f51b3
fix: redirect to new notebook for BM8 results
wd15 Feb 14, 2022
ab54026
test: don't assume ordering in dataframes
wd15 Feb 15, 2022
688cfaa
fix: add layout for redirects
wd15 Feb 15, 2022
0677000
fix: ensure most notebooks are not in raw mode
wd15 Feb 23, 2022
8f857d9
build(nix): explicitly define the locale
wd15 Feb 23, 2022
0100c74
fix: blacklist broken surveymonkey link
wd15 Feb 23, 2022
c36114e
fix: switch off datatables in jupyter notebook
wd15 Feb 23, 2022
0904c36
fix: revert hackathon3 as previously fixed
wd15 Mar 1, 2022
3f7b26c
test: ensure new results/ notebooks are tested
wd15 Mar 1, 2022
babe28a
fix: move _data/pfhub -> _data/python-pfhub
wd15 Mar 2, 2022
a4f6381
build(nix): rename working directory
wd15 Mar 2, 2022
fd82e6b
test(actions): use default working directory
wd15 Mar 2, 2022
9138cb8
tests(actions): fix broken yaml file
wd15 Mar 2, 2022
ab0072d
fix: correct metadata in python-pfhub
wd15 Mar 10, 2022
2038996
docs: clean up for tkphd review
wd15 Apr 4, 2022
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
17 changes: 0 additions & 17 deletions .github/workflows/github-actions-demo.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/test-pfhub-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test PFHub Package
on: [push, pull_request]
jobs:
pfhub-nix-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./_data/python-pfhub
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v14.1
with:
nix_path: nixpkgs=channel:nixos-unstable
name: pfhub
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: nix-community
- run: nix-shell --pure --command "py.test --nbval-lax --cov-fail-under=100"
- run: nix-shell --pure --command "black --check setup.py pfhub"
- run: nix-shell --pure --command "pylint setup.py pfhub"
- run: nix-shell --pure --command "flake8 setup.py pfhub"
- run: nix-shell --pure --command "py.test --nbval-lax ../../results/benchmark*.ipynb"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ _apps/data/env_variables.yaml
_apps/box/1014649_e91k0tua_config.json
_apps/box/cert.pem
_apps/box/.coverage
.~*
_data/pfhub/.coverage
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ script:
make notebooks &&
rm -rf ./_site &&
jekyll build -d ./_site/pfhub && htmlproofer --check-html --only-4xx --allow-hash-href --empty-alt-ignore --checks-to-ignore ImageCheck --file-ignore ./_site/pfhub/node_modules ./_site &&
py.test --ignore=hackathons/hackathon1 --ignore=benchmarks --ignore=_data --nbval --sanitize-with sanitize.cfg &&
py.test --ignore=hackathons/hackathon1 --ignore=benchmarks --ignore=_data --nbval --sanitize-with sanitize.cfg --ignore=results &&
coffeelint _includes/coffee/ &&
mocha _site/pfhub/js/test.js
";
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ $(HEXBIN_OUT): $(HEXBIN_IN)

%.ipynb.raw.html: %.ipynb
jupyter-nbconvert $< --output $(notdir $@) --to html --template basic
if [ "results/" = "$(dir $@)" ]; then \
sed -i '1i {\% raw \%}' $@; \
sed -i -e '$$a{\% endraw \%}' $@; \
fi

%.ipynb.md: %.ipynb
cp -n ./template.ipynb.md $@
Expand Down
2 changes: 2 additions & 0 deletions _data/python-pfhub/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = pfhub/__init__.py
8 changes: 8 additions & 0 deletions _data/python-pfhub/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[MASTER]
extension-pkg-whitelist = numpy

[TYPECHECK]
ignored-modules = numpy, toolz.curried

[MESSAGES CONTROL]
disable = no-value-for-parameter, bad-continuation
29 changes: 29 additions & 0 deletions _data/python-pfhub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Python-PFHub

A Python module for rendering PFHub phase field data in Jupyter
notebooks using Pandas and Plotly.

## Installation

### Using Nix

If Using Cachix

$ cachix use pfhub

and then fire up a Nix shell with

$ export NIX_VERSION=21.05
$ nix-shell \
-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/${NIX_VERSION}.tar.gz \
-I pfhub=./ \
-E 'with (import <nixpkgs> {}); mkShell { buildInputs = [ (python3Packages.callPackage <pfhub> { }) ]; }'

#### Upload to cachix

$ export NIX_VERSION=21.05
$ nix-build \
-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/${NIX_VERSION}.tar.gz \
-I pfhub=./ \
-E 'with (import <nixpkgs> {}); python3Packages.callPackage <pfhub> { }' \
| cachix push pfhub
49 changes: 49 additions & 0 deletions _data/python-pfhub/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{ lib
, buildPythonPackage
, pytestCheckHook
, python
, numpy
, pytest
, toolz
, pyyaml
, pandas
, plotly
, pytestcov
, jupyter
, nbval
}:
buildPythonPackage rec {
pname = "pfhub";
version = "0.1";

src = lib.cleanSource ./.;

propagatedBuildInputs = [
numpy
pytest
toolz
pyyaml
pandas
plotly
pytestcov
jupyter
nbval
];

checkInputs = [
python
];

checkPhase = ''
${python.interpreter} -c "import pfhub; pfhub.test()"
'';

pythonImportsCheck = ["pfhub"];

meta = with lib; {
homepage = "https://github.com/usnistgov/pfhub";
description = "The Phase Field Community Hub";
license = licenses.mit;
maintainers = with maintainers; [ wd15 ];
};
}
11 changes: 11 additions & 0 deletions _data/python-pfhub/notebooks/sanitize.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[regex]
regex: '#[-0-9a-z]{36}'
replace: '#'

[regex]
regex: "[-0-9a-z]{36}"
replace: ""

[regex]
regex: '[-0-9a-z]{36}'
replace: ''
56,011 changes: 56,011 additions & 0 deletions _data/python-pfhub/notebooks/test.ipynb

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions _data/python-pfhub/pfhub/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""PFHub - Phase Field Community Hub

See the documentation at https://github.com/usnistgov/pfhub
"""


import os


def test(*args):
r"""Run all the module tests.

Equivalent to running ``py.test pfhub`` in the base

Args:
*args: add arguments to pytest

To test an installed version of PFHub use

.. code-block:: bash

$ python -c "import pfhub; pfhub.test()"

"""
import pytest # pylint: disable=import-outside-toplevel

path = os.path.join(os.path.split(__file__)[0])
pytest.main(args=[path, "--doctest-modules", "-r s"] + list(args))
112 changes: 112 additions & 0 deletions _data/python-pfhub/pfhub/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Setup for pytest
"""

import pytest


def make_yaml_content(id_, version):
"""Generate some test yaml content

Args:
id_: the benchmark id_ (e.g. "8a")
version: the version (e.g. "1")

Returns:
yaml result content as string
"""
return f"""
---
benchmark:
id: {id_}
version: {version}
metadata:
implementation:
name: code_name
author:
first: first
last: last
timestamp: 2021-12-07
data:
- name: free_energy
type: line
values:
- x: 0.0
y: 0.0
z: 0.0
- x: 1.0
y: 1.0
z: 1.0
transform:
- type: formula
expr: datum.x
as: a
- type: formula
expr: datum.y * 2
as: b
"""


def make_yaml(dir_, name, id_, version):
"""Generate a yaml file for test purposes

Args:
dir_: the result directory to write to
name: name of the result
id_: the benchmark id_ (e.g. "8a")
version: the version (e.g. "1")

Returns:
name of the file created
"""
dir_name = dir_ / name
dir_name.mkdir(exist_ok=True)
yaml_file = dir_name / "meta.yaml"
yaml_file.write_text(make_yaml_content(id_, version))
return yaml_file


@pytest.fixture
def yaml_data_file(tmp_path):
"""Generate a yaml test file

Args:
tmp_path: temporary area to use to write files

Returns:
name of the data file
"""
tmp_path.mkdir(exist_ok=True)
return make_yaml(tmp_path, "result", "1a", 1)


@pytest.fixture
def test_data_path(tmp_path):
"""Generate two result data files

Args:
tmp_path: temporary area to use to write files

Returns:
the name of the directory used for writing the files
"""
dir_ = tmp_path / "results"
dir_.mkdir(exist_ok=True)
make_yaml(dir_, "result1", "1a", 1)
make_yaml(dir_, "result2", "2a", 1)
return dir_


@pytest.fixture
def csv_file(tmp_path):
"""Generate a csv file for test purposes

Args:
tmp_path: temporary area to use to write files

Returns:
path to the csv file
"""
tmp_path.mkdir(exist_ok=True)
csv_file_path = tmp_path / "file.csv"
csv_file_path.write_text("x,y\n0,0\n1,1\n")
return csv_file_path
Loading