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

feat: add plugin-config package #234

Merged
merged 25 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4582df0
fix: allow modelFiles to be empty (useful for writing tests)
chrispcampbell Sep 8, 2022
5c0ee57
feat: checkpoint work on new plugin-config-csv package and new sir ex…
chrispcampbell Sep 8, 2022
0032f43
feat: read graphs.csv
chrispcampbell Sep 8, 2022
d83380e
feat: read inputs.csv
chrispcampbell Sep 9, 2022
02a3640
fix: generate base strings and include i/o vars in returned ModelSpec
chrispcampbell Sep 9, 2022
9e7b47f
feat: add graph view code and flesh out example sir app
chrispcampbell Sep 9, 2022
2b1754c
fix: use SAVEPER of 1 since that's all we support at the moment
chrispcampbell Sep 9, 2022
4cd22bd
fix: tweak inputs and sde config
chrispcampbell Sep 9, 2022
27021f3
fix: improve sample app layout and style
chrispcampbell Sep 18, 2022
ab6f6c2
fix: remove obsolete sir config files and extra mdl copy
chrispcampbell Sep 18, 2022
88c2f5e
refactor: rename plugin-config-csv -> plugin-config
chrispcampbell Sep 18, 2022
1315620
fix: include the check plugin before vite plugin (the previous order …
chrispcampbell Sep 18, 2022
128cb64
fix: show input value in sample app
chrispcampbell Sep 18, 2022
912098c
fix: remove debug logging
chrispcampbell Sep 18, 2022
2db417d
test: update test to account for change that allows modelFiles array …
chrispcampbell Sep 18, 2022
c442cd3
test: update test to check for var ids in generated model spec file
chrispcampbell Sep 18, 2022
f1f0e29
build: include subset of sir example packages in workspace for now
chrispcampbell Sep 18, 2022
cfb536f
fix: add simple number formatting function
chrispcampbell Sep 18, 2022
243c0c9
fix: show simple legend for graph
chrispcampbell Sep 18, 2022
275d2a2
fix: remove debug logging
chrispcampbell Sep 18, 2022
2ef5ff0
fix: allow for listing dat files in model.csv
chrispcampbell Sep 18, 2022
2a4bd70
docs: add basic instructions
chrispcampbell Sep 18, 2022
9331d10
feat: show overlay with build messages in dev mode
chrispcampbell Sep 18, 2022
e489933
Merge branch 'main' into chris/229-plugin-config
chrispcampbell Sep 19, 2022
d38fce2
fix: copy the spec-types.ts file to the generated directory of the co…
chrispcampbell Sep 19, 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
4 changes: 4 additions & 0 deletions examples/sir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sde-prep
*.vdf
*.vdfx
*.3vmfx
6 changes: 6 additions & 0 deletions examples/sir/config/colors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,hex code,name,comment
blue,#0072b2,,
red,#d33700,,
green,#53bb37,,
gray,#a7a9ac,,
black,#000000,,
3 changes: 3 additions & 0 deletions examples/sir/config/graphs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,side,parent menu,graph title,menu title,mini title,vensim graph,kind,modes,units,alternate,unused 1,unused 2,unused 3,x axis min,x axis max,x axis label,unused 4,unused 5,y axis min,y axis max,y axis soft max,y axis label,y axis format,unused 6,unused 7,plot 1 variable,plot 1 source,plot 1 style,plot 1 label,plot 1 color,plot 1 unused 1,plot 1 unused 2,plot 2 variable,plot 2 source,plot 2 style,plot 2 label,plot 2 color,plot 2 unused 1,plot 2 unused 2,plot 3 variable,plot 3 source,plot 3 style,plot 3 label,plot 3 color,plot 3 unused 1,plot 3 unused 2,plot 4 variable,plot 4 source,plot 4 style,plot 4 label,plot 4 color,plot 4 unused 1,plot 4 unused 2,plot 5 variable,plot 5 source,plot 5 style,plot 5 label,plot 5 color,plot 5 unused 1,plot 5 unused 2,plot 6 variable,plot 6 source,plot 6 style,plot 6 label,plot 6 color,plot 6 unused 1,plot 6 unused 2,plot 7 variable,plot 7 source,plot 7 style,plot 7 label,plot 7 color,plot 7 unused 1,plot 7 unused 2,plot 8 variable,plot 8 source,plot 8 style,plot 8 label,plot 8 color,plot 8 unused 1,plot 8 unused 2,plot 9 variable,plot 9 source,plot 9 style,plot 9 label,plot 9 color,plot 9 unused 1,plot 9 unused 2,plot 10 variable,plot 10 source,plot 10 style,plot 10 label,plot 10 color,plot 10 unused 1,plot 10 unused 2,plot 11 variable,plot 11 source,plot 11 style,plot 11 label,plot 11 color,plot 11 unused 1,plot 11 unused 2,plot 12 variable,plot 12 source,plot 12 style,plot 12 label,plot 12 color,plot 12 unused 1,plot 12 unused 2,plot 13 variable,plot 13 source,plot 13 style,plot 13 label,plot 13 color,plot 13 unused 1,plot 13 unused 2,plot 14 variable,plot 14 source,plot 14 style,plot 14 label,plot 14 color,plot 14 unused 1,plot 14 unused 2,plot 15 variable,plot 15 source,plot 15 style,plot 15 label,plot 15 color,plot 15 unused 1,plot 15 unused 2
1,,Graphs,Infection and Recovery Rates,,,,line,,,,,,,,,,,,,2000,,people/day,,,,Infection Rate,,line,Infection Rate,blue,,,Recovery Rate,,line,Recovery Rate,red,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
2,,Graphs,Population,,,,line,,,,,,,,,,,,,12000,,people,,,,Susceptible Population S,,line,Susceptible,blue,,,Infectious Population I,,line,Infectious,red,,,Recovered Population R,,line,Recovered,green,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
4 changes: 4 additions & 0 deletions examples/sir/config/inputs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,input type,viewid,varname,label,view level,group name,slider min,slider max,slider/switch default,slider step,units,format,reversed,range 2 start,range 3 start,range 4 start,range 5 start,range 1 label,range 2 label,range 3 label,range 4 label,range 5 label,enabled value,disabled value,controlled input ids,listing label,description
1,slider,v1,Initial Contact Rate,Initial Contact Rate,,Inputs,0,5,2.5,0.1,per day,.1f,,,,,,,,,,,,,,,
2,slider,v1,Infectivity i,Infectivity,,Inputs,-2,2,0.25,0.05,(probability),.2f,,,,,,,,,,,,,,,
3,slider,v1,Average Duration of Illness d,Average Duration of Illness,,Inputs,0,10,2,1,days,,,,,,,,,,,,,,,,
2 changes: 2 additions & 0 deletions examples/sir/config/model.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
model start time,model end time,graph default min time,graph default max time,model dat files
0,200,0,100,
1 change: 1 addition & 0 deletions examples/sir/config/outputs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable name
2 changes: 2 additions & 0 deletions examples/sir/config/strings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,string
__model_name,SIR
14 changes: 14 additions & 0 deletions examples/sir/model/sir.check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=../node_modules/@sdeverywhere/plugin-check/node_modules/@sdeverywhere/check-core/schema/check.schema.json

- describe: Population Variables
tests:
- it: should be between 0 and 10000 for all input scenarios
scenarios:
- preset: matrix
datasets:
- name: Infectious Population I
- name: Recovered Population R
- name: Susceptible Population S
predicates:
- gte: 0
- lte: 10000
2 changes: 1 addition & 1 deletion models/sir/model/sir.mdl → examples/sir/model/sir.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ INITIAL TIME = 0
~ The initial time for the simulation.
|

SAVEPER = 2
SAVEPER = 1
~ Day
~ The frequency with which output is stored.
|
Expand Down
18 changes: 18 additions & 0 deletions examples/sir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "sir",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "sde bundle",
"dev": "sde dev"
},
"dependencies": {
"@sdeverywhere/cli": "^0.7.0",
"@sdeverywhere/plugin-check": "^0.1.0",
"@sdeverywhere/plugin-config": "^0.1.0",
"@sdeverywhere/plugin-vite": "^0.1.1",
"@sdeverywhere/plugin-wasm": "^0.1.0",
"@sdeverywhere/plugin-worker": "^0.1.0"
}
}
1 change: 1 addition & 0 deletions examples/sir/packages/sir-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public
29 changes: 29 additions & 0 deletions examples/sir/packages/sir-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>SIR</title>

<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<script type="module" src="./src/index.js"></script>
</head>

<body>
<div id="graphs-container" class="main-section">
<select id="graph-selector"></select>
<div class="graph-outer-container">
<div id="top-graph-inner-container" class="graph-inner-container">
<canvas id="top-graph-canvas"></canvas>
</div>
<div id="top-graph-legend" class="graph-legend"></div>
</div>
</div>

<div id="inputs-container" class="main-section">
<div id="inputs-content"></div>
</div>

<div class="overlay-container"></div>
</body>
</html>
25 changes: 25 additions & 0 deletions examples/sir/packages/sir-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "sir-app",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"clean": "rm -rf public",
"lint": "eslint src --max-warnings 0",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"precommit": "../scripts/precommit",
"build": "vite build",
"dev": "vite"
},
"dependencies": {
"bootstrap-slider": "10.6.2",
"chart.js": "^2.9.4",
"jquery": "^3.5.1",
"sir-core": "^1.0.0"
},
"devDependencies": {
"@types/chart.js": "^2.9.34",
"vite": "^2.9.12"
}
}
24 changes: 24 additions & 0 deletions examples/sir/packages/sir-app/src/dev-overlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import rawMessagesHtml from '@prep/messages.html?raw'

export const messagesHtml = rawMessagesHtml

export function initOverlay() {
const overlayElem = document.getElementsByClassName('overlay-container')[0]
updateOverlay(overlayElem, messagesHtml)
}

function updateOverlay(elem, messages) {
if (messages.length > 0) {
elem.innerHTML = messages
elem.style.display = 'flex'
} else {
elem.style.display = 'none'
}
}

if (import.meta.hot) {
import.meta.hot.accept(newModule => {
const overlayElem = document.getElementsByClassName('overlay-container')[0]
updateOverlay(overlayElem, newModule.messagesHtml)
})
}
Loading