Skip to content

Commit

Permalink
Merge pull request #74 from sciris/rc1.0.0
Browse files Browse the repository at this point in the history
Rc1.0.0
  • Loading branch information
cliffckerr authored Dec 14, 2023
2 parents 578f23c + c6d48f4 commit dabf696
Show file tree
Hide file tree
Showing 50 changed files with 48,903 additions and 473 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
max-parallel: 8
matrix:
python-version: ['3.9']
python-version: ['3.11']
name: Run tests
steps:
- name: Checkout sources
Expand All @@ -25,4 +25,4 @@ jobs:
run: pip install -r requirements_test.txt
- name: Run integration tests
working-directory: ./tests
run: pytest -v test_*.py --workers auto --durations=0
run: pytest -v test_*.py -n auto --durations=0
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented. If you have any updates

By import convention, components of the ScirisWeb library are listed beginning with `sw.`, e.g. `sw.ScirisApp()`.

## Version 1.0.0 (2023-12-13)
1. Updated to work with current versions of Python and JavaScript libraries.
2. Added CORS option (required for serving via React).
3. Improved exception handling.
4. Added more examples (including React).
5. Updated tests.

## Version 0.17.1 (2022-02-02)
1. Fixed regression issue with Sciris.
2. Tests switched from Travis CI to GitHub Actions.
Expand Down
3 changes: 3 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Examples

These examples illustrate simple ScirisWeb usage. In most cases, to use these examples, run `python app.py` in a terminal, and then go to `localhost:8080` in your browser.
3 changes: 3 additions & 0 deletions examples/archive/gunicorn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gunicorn

This shows example scripts for how to start an app using Gunicorn, and an NGINX configuration. These are useful for production-scale apps.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hello World

The simplest possible ScirisWeb app.
File renamed without changes.
84 changes: 0 additions & 84 deletions examples/parallel/index.html

This file was deleted.

18 changes: 0 additions & 18 deletions examples/parallel/untitled1.py

This file was deleted.

18 changes: 0 additions & 18 deletions examples/parallel/untitled2.py

This file was deleted.

44 changes: 0 additions & 44 deletions examples/parallel/untitled3.py

This file was deleted.

3 changes: 3 additions & 0 deletions examples/plotting-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Plotting with React

A simple app illustrating plotting with a backend call, implemented in React.
29 changes: 15 additions & 14 deletions examples/parallel/app.py → examples/plotting-react/app.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
'''
Usage:
python app.py
then go to localhost:8080 in your browser.
'''

# Imports
import pylab as pl
import sciris as sc
import scirisweb as sw
from dask.distributed import Client


client = Client()

runserver = False # Choose to run in the frontend or backend
runserver = True # Choose to run in the frontend or backend

# Create the app
app = sw.ScirisApp(__name__, name="ParallelComputation")

#def
app = sw.ScirisApp(__name__, name="ReactPlot", cors=True) # CORS required for React (but not Vue)

# Define the RPCs
@app.register_RPC()
def computation(seed=0, n=1000):
# Define the API
@app.route('/showgraph')
def showgraph(n=1000):

# Make graph
pl.seed(int(seed))
fig = pl.figure()
ax = fig.add_subplot(111)
xdata = pl.randn(n)
Expand All @@ -28,11 +29,11 @@ def computation(seed=0, n=1000):
ax.scatter(xdata, ydata, c=colors)

# Convert to FE
graphjson = sw.mpld3ify(fig, jsonify=False) # Convert to dict
graphjson = sw.mpld3ify(fig) # Convert to dict
return graphjson # Return the JSON representation of the Matplotlib figure

# Run the server
if __name__ == "__main__" and runserver:
app.run()
else:
computation()
showgraph()
46 changes: 46 additions & 0 deletions examples/plotting-react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>

<!-- Load core scripts -->
<head>
<title>Hello (React) World</title>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
<script src="https://mpld3.github.io/js/mpld3.v0.5.9.js"></script>
</head>

<body>
<div id="root"></div>
<script type="text/babel">

// Define the functionality
function getdots() {
axios.post('http://localhost:8080/api/showgraph') // Use a POST request to pass along the value.
.then(function (response) {
document.getElementById('randomgraph').innerHTML = ''; // Clear the DOM before redrawing
mpld3.draw_figure('randomgraph', response.data);
})
}

// Define the layout
function MyApp() {
return (
<>
<h1>Hello, React plot!</h1>
<div id="randomgraph"></div>
<button onClick={getdots}>Get new dots</button>
</>
);
}

const container = document.getElementById('root');
const root = ReactDOM.createRoot(container);
root.render(<MyApp />);

</script>
</body>

</html>
3 changes: 3 additions & 0 deletions examples/plotting-vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Plotting with Vue

A simple app illustrating plotting with a backend call, implemented in Vue.
4 changes: 2 additions & 2 deletions examples/hellograph/app.py → examples/plotting-vue/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
runserver = True # Choose to run in the frontend or backend

# Create the app
app = sw.ScirisApp(__name__, name="HelloGraph")
app = sw.ScirisApp(__name__, name="VuePlot")

# Define the API
@app.route('/showgraph')
Expand All @@ -36,4 +36,4 @@ def showgraph(n=1000):
if __name__ == "__main__" and runserver:
app.run()
else:
showgraph()
showgraph()
3 changes: 3 additions & 0 deletions examples/plotting-vue/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Assets

This folder is not used, but uses frozen versions of key libraries to help with debugging.
2 changes: 2 additions & 0 deletions examples/plotting-vue/assets/d3.v5.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/plotting-vue/assets/mpld3.v0.4.1.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions examples/plotting-vue/assets/polyfill.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit dabf696

Please sign in to comment.