Skip to content

Commit

Permalink
Merge pull request #181 from reflectometry/webview
Browse files Browse the repository at this point in the history
Webview
  • Loading branch information
pkienzle authored Sep 9, 2024
2 parents fc731f0 + 1dace04 commit 5337991
Show file tree
Hide file tree
Showing 126 changed files with 5,956 additions and 1,523 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/build-webview-jupyter-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Build webview with Jupyter for macos

on:
workflow_dispatch:

env:
branch_name: webview

jobs:
test_and_build:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
#- { os: ubuntu-latest, py: 3.8, doc: 1 }
# - { os: windows-latest, py: "3.10", exe: 1, whl: 1 }
- { os: macos-latest, py: "3.10", whl: 1 }
# all using to stable abi

steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.branch_name }}

- name: Set up Python ${{ matrix.config.py }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config.py }}

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.config.py }}

- name: Build installer
run: |
./extra/build_conda_packed_jupyter.sh
mkdir unstable
pwd
mv refl1d-webview* ./unstable/
# See the following for how to upload to a release
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
unstable/*
updateUnstable:
needs: test_and_build
runs-on: ubuntu-latest
steps:
- name: Retrieve all artifacts
uses: actions/download-artifact@v3
with:
name: artifacts

- name: show files
run: |
ls * -l
- name: Update release assets and text
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
let sid_release = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: "sid"
});
await github.rest.repos.updateRelease({
owner,
repo,
release_id: sid_release.data.id,
body: "A persistent prerelease where build artifacts for the current tip will be deposited\n\n## Last updated: " + (new Date()).toDateString()
});
// delete existing release assets (if needed) and upload new ones:
const globber = await glob.create("**");
const to_update = await globber.glob();
// const to_update = ["refl1d-webview-jupyter-0.8.15-Darwin-arm64.tar.gz", "refl1d-webview-jupyter.pkg"];
for (let fn of to_update) {
let asset_id = (sid_release.data.assets.find((a) => (a.name == fn)) ?? {}).id;
if (asset_id) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id
});
}
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: sid_release.data.id,
name: fn,
data: await fs.readFileSync(fn)
});
}
105 changes: 105 additions & 0 deletions .github/workflows/build-webview-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build webview for linux

on:
workflow_dispatch:

env:
branch_name: webview

jobs:
test_and_build:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { os: ubuntu-latest, py: 3.11, whl: 1 }
# - { os: windows-latest, py: "3.10", exe: 1, whl: 1 }
# - { os: macos-latest, py: "3.10", whl: 1 }
# all using to stable abi

steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.branch_name }}

- name: Set up Python ${{ matrix.config.py }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.config.py }}

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.config.py }}

- name: Build webview packed (linux)
run: |
./extra/build_conda_packed.sh
mkdir unstable
pwd
mv refl1d-webview* ./unstable/
# See the following for how to upload to a release
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
unstable/*
updateUnstable:
needs: test_and_build
runs-on: ubuntu-latest
steps:
- name: Retrieve all artifacts
uses: actions/download-artifact@v3
with:
name: artifacts

- name: show files
run: |
ls * -l
- name: Update release assets and text
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const path = require('path');
const { owner, repo } = context.repo;
let sid_release = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: "sid"
});
await github.rest.repos.updateRelease({
owner,
repo,
release_id: sid_release.data.id,
body: "A persistent prerelease where build artifacts for the current tip will be deposited\n\n## Last updated: " + (new Date()).toDateString()
});
// delete existing release assets (if needed) and upload new ones:
const globber = await glob.create("*", {followSymbolicLinks: false});
const full_paths = await globber.glob();
const to_update = full_paths.map((f) => path.basename(f));
console.log({to_update});
// const to_update = ["refl1d-webview-jupyter-0.8.15-Darwin-arm64.tar.gz", "refl1d-webview-jupyter.pkg"];
for (let fn of to_update) {
let asset_id = (sid_release.data.assets.find((a) => (a.name == fn)) ?? {}).id;
if (asset_id) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id
});
}
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: sid_release.data.id,
name: fn,
data: await fs.readFileSync(fn)
});
}
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Test

on:
push:
branches: [ master ]
branches: [ master_v0 ]
pull_request:
branches: [ master ]
branches: [ master_v0 ]
release:
types: [ published ]

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Build_Unstable

on:
push:
branches: [ master ]
branches: [ master_v0 ]
pull_request:
branches: [ master ]
branches: [ master_v0 ]
release:
types: [ published ]

env:
branch_name: master
branch_name: master_v0

jobs:
test_and_build:
Expand Down Expand Up @@ -108,4 +108,4 @@ jobs:
script: |
const script = require('./.github/actions/update_unstable.js');
const output = await script({github, context, glob});
console.log(output);
console.log(output);
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Refl1d/Bumps specific
.mplconfig
.project
.pydevproject
.spyderproject
.idea
*.pyd
*.pyc
**/__pycache__/
**/node_modules/
/refl1d/webview/client/dist/
*.swp
*.so
*.bak
refl1d-webview-client*.tgz
/build/
/dist/
/refl1d.egg-info/
/EGG-INFO
/doc/_build/
/doc/api/
/doc/tutorial/
Expand Down
11 changes: 9 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ include MANIFEST.in # this file
include master_builder.py
include refl1d.iss
include setup_py2exe.py
include refl1d/lib/*.h refl1d/lib/erf.c

recursive-include refl1d/lib/c *.h *.c *.cc
recursive-include refl1d/webview/client/dist *.html *.js *.css *.svg *.png
recursive-include refl1d/webview/client/src *.html *.js *.mjs *.css *.svg *.png *.ts *.vue
include refl1d/webview/client/*.html
include refl1d/webview/client/*.js
include refl1d/webview/client/*.json
include refl1d/webview/client/*.txt
include extra/*.svg extra/*.png
# Delete files
#prune this that
prune refl1d/webview/client/node_modules
6 changes: 3 additions & 3 deletions appveyor.yml.build_exe
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ init:

install:
# We need wheel installed to build wheels
- "git clone -q --branch=master https://github.com/bumps/bumps.git C:\\projects\\bumps"
#- "git clone -q --branch=master https://github.com/pkienzle/periodictable.git C:\\projects\\periodictable"
- "git clone -q --branch=master_v0 https://github.com/bumps/bumps.git C:\\projects\\bumps"
#- "git clone -q --branch=master_v0 https://github.com/pkienzle/periodictable.git C:\\projects\\periodictable"
#- "%PYTHON%\\python.exe -m pip install pyinstaller"
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
- "%PYTHON%\\python.exe -m pip install -r rtd-requirements"
Expand Down Expand Up @@ -86,5 +86,5 @@ deploy:
draft: false
prerelease: false
on:
#branch: master # release from master branch only
#branch: master_v0 # release from master_v0 branch only
appveyor_repo_tag: true # deploy on tag push only (if true)
2 changes: 1 addition & 1 deletion doc/examples/magrough/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
#M1.simulate_data(0.05)
#M2.simulate_data(0.05)

problem = MultiFitProblem([M1, M2])
problem = FitProblem([M1, M2])
2 changes: 1 addition & 1 deletion doc/examples/polymer/freeform.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
H_model = Experiment(sample=H, probe=H_probe)
models = D_model, H_model

problem = MultiFitProblem(models=models)
problem = FitProblem(models=models)
2 changes: 1 addition & 1 deletion doc/examples/staj/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ example::
M1 = load_mlayer("De1_VATR.staj")
M2 = load_mlayer("De2_VATR.staj")
M1.sample[3].thickness = M2.sample[3].thickness
problem = MultiFitProblem([M1,M2])
problem = FitProblem([M1,M2])


Dura, J. A. et al. Porous Mg formation upon dehydrogenation of MgH2 thin films. Journal of Applied Physics 109, 093501–093501–7 (2011).
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/step/tethered.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
name="dz=1; dA=10; step interfaces")
models=[M0,M1,M2,S0,S1,S2]
#models=[S1]
problem = MultiFitProblem(models=models)
problem = FitProblem(models=models)
problem.name = "tethered"
2 changes: 1 addition & 1 deletion doc/examples/thick/nifilm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

#M.simulate_data(5)

problem = MultiFitProblem([M1,M2,M5])
problem = FitProblem([M1,M2,M5])
2 changes: 1 addition & 1 deletion doc/guide/fitting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ To produce plots, you will need access to the data and the theory. This
can be complex depending on how many models you are fitting and how many
datasets there are per model. For :class:`refl1d.fitproblem.FitProblem`
models, the :class:`refl1d.experiment.Experiment` object is referenced
by *problem.fitness*. For :class:`refl1d.fitproblem.MultiFitProblem` models,
by *problem.fitness*. For :class:`refl1d.fitproblem.FitProblem` models,
you need to use *problem.models[k].fitness* to access the experiment for
model *k*. Profiles and reflectivity theory are returned from methods
in experiment. The :class:`refl1d.probe.Probe` data for the experiment is
Expand Down
5 changes: 5 additions & 0 deletions explore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Explore

Files in this folder are for exploration of new algorithms or functionality that is not ready to be included in the main tree.

_No tests will be applied to this folder_
File renamed without changes.
Loading

0 comments on commit 5337991

Please sign in to comment.