-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add web app using pyodide, preact+htm and plotly Only Resolution, Flux-Ei and Flux-Freq plots so far Need Instruments.py modifications to work in javascript (explicit conversion to/from np.array and sets as pyodide does not handle these types well in proxy) Currently set up to use local js files rather than CDN * Add QE and time-distance plots Change to use plotly and pyodide from CDN Modify Instruments.py to output lines in plotMultiRepFrame if cannot import matplotlib Modify Instruments.py to respect type of phase (str / number) In Javascript, always assume it is a number... * Update gh-actions and readme * Modify MulpyRep to sim t-d graphs for single chopper inst * Update tests
- Loading branch information
Showing
9 changed files
with
684 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,23 @@ name: Run test and coverage | |
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
types: [opened, reopened, synchronize] | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run tests | ||
run: | | ||
|
@@ -23,3 +31,30 @@ jobs: | |
uses: codecov/codecov-action@v2 | ||
with: | ||
fail_ci_if_error: true | ||
|
||
- name: Upload webapp | ||
if: ${{ github.event_name == 'release' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
run: | | ||
cp -rpa webapp webtmp | ||
tar zcf webtmp/pychop.tar.gz --exclude __main__.py --exclude PyChopGui.py --exclude __pycache__ PyChop/ | ||
git checkout --force gh-pages | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Github Actions" | ||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
git rm -rf $GITHUB_REF || true | ||
rm -rf $GITHUB_REF | ||
mv webtmp $GITHUB_REF | ||
git add $GITHUB_REF | ||
git commit --allow-empty -m "Update web-app files for release $GITHUB_REF" | ||
else | ||
git rm -rf unstable/* || true | ||
mv webtmp/* unstable/* | ||
git add unstable | ||
git commit --allow-empty -m "Update web-app files for update $GITHUB_SHA" | ||
fi | ||
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/mducle/pychop.git" | ||
git push ${remote_repo} HEAD:gh-pages --follow-tags | ||
- name: Setup tmate session | ||
if: ${{ failure() }} | ||
uses: mxschmitt/action-tmate@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# PyChop Webapp | ||
|
||
The PyChop webapp is a single-page application running directly in the browser. | ||
You can edit the javascript and html code directly to change the app behaviour, | ||
but as a convenience it is nicer to use [browser-sync](https://browsersync.io/) | ||
to automatically reload when any of the code changes. | ||
|
||
Create a file `package.json` in this folder with this content: | ||
|
||
```javascript | ||
{ | ||
"scripts": { | ||
"start": "browser-sync start --server . --files . --single" | ||
}, | ||
} | ||
``` | ||
|
||
and run | ||
|
||
```shell | ||
npm start | ||
``` | ||
|
||
(You need to install [node.js](https://nodejs.org/en)). | ||
|
||
We use [preact.js](https://preactjs.com/)+[htm](https://github.com/developit/htm) to define the UI, | ||
[pyodide](https://pyodide.org) to run the Python code to do the actual calculations and | ||
[plotly](https://plotly.com/javascript/) for the graphs. | ||
These dependencies are downloaded from content delivery networks, which takes a few seconds depending | ||
on your connection speed and which are then cached. | ||
You can also download the `.js` files imported in `pychop.js` directly for faster processing. |
Oops, something went wrong.