Skip to content

Commit 085bbbf

Browse files
committed
fix(simput-cli): adapt cli to new landing-page UI.
Remove obsolete options, and always use the '-i' input for converting a type. '-p' starts a server. Update docs.
1 parent bf45b10 commit 085bbbf

7 files changed

Lines changed: 81 additions & 187 deletions

File tree

README.md

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,55 +29,29 @@ $ Simput
2929
-o, --output [directory] Output directory to output to
3030
-t, --type [type] Type of input
3131

32-
--no-gui Just generate output
3332
-s, --silent Do not open the browser
3433

3534
-c, --compile [directory] Directory to compile files
3635
-m, --minify Minify compiled file
37-
-a, --add [file] Add model to list of available inputs
38-
-l, --list List model types of available as inputs
39-
-r, --remove [type] Remove model to list of available inputs
4036

4137
```
4238

4339
## Examples
4440

4541
```sh
46-
$ Simput -t pyfr -o ~/pyfr/example
42+
$ Simput -p
4743
```
4844

49-
Starts a server and opens your web browser, an empty PyFR model is loaded which you can modify. The _Save_ button will export a pyfr.json file (model) which you can then be loaded later on. The _Convert_ button will export a `pyfr.ini` file for PyFR execution.
50-
51-
As no initial model was provided, the boundary names will be autogenerated.
52-
In order to pre-define those boundary names, you can either edit the generated model (`pyfr.json`) or start with an empty model you've created like the following one.
53-
54-
my-pyfr-model.json
55-
```js
56-
{
57-
"type": "pyfr",
58-
"data": {},
59-
"external": {
60-
"boundary-names": {
61-
"User friendly name": "value-expected-by-code",
62-
"Inlet": "inlet",
63-
"Outlet": "outlet",
64-
"External walls": "external-wall"
65-
}
66-
}
67-
}
68-
```
69-
70-
Then loading it back for further edits can be performed with the following command line:
71-
72-
73-
```sh
74-
$ Simput -i my-pyfr-model.json -o ~/pyfr/example
75-
```
45+
Starts a server and opens your web browser, showing a landing page with a choice of inputs which you can create.
7646

7747
## Demos
7848

7949
There are a few supplied demos in the folder `types`, each have their own README.
8050

51+
* vCard is the simplest example, with a single type of output.
52+
* oscillator is a bit more complex, because it derives from a real benchmarking application meant to exercise in-situ analyses on hpc systems.
53+
* pyfr and vera produce input files for real applications, and are realistically complex.
54+
8155
## Development
8256

8357
```sh
@@ -99,27 +73,20 @@ $ Simput
9973
-o, --output [directory] Output directory to output to
10074
-t, --type [type] Type of input
10175

102-
--no-gui Just generate output
10376
-s, --silent Do not open the browser
10477

10578
-c, --compile [directory] Directory to compile files
10679
-m, --minify Minify compiled file
107-
-a, --add [file] Add model to list of available inputs
108-
-l, --list List model types of available as inputs
109-
-r, --remove [type] Remove model to list of available inputs
11080

11181
```
11282

113-
Then to compile pyfr and publish it:
83+
Then to compile pyfr and open a development server which watches for another compile:
11484

11585
```sh
116-
$ Simput -mc types/pyfr/src/ -t pyfr -o dist/types/
86+
$ npm run type:pyfr
87+
$ npm run dev
11788
```
11889

119-
### Degbugging
120-
121-
A recent version Firefox is preferred for debugging. Errors in Chrome do not always point to [the exact line](https://github.com/altano/handlebars-loader/issues/67#issuecomment-171128403) where the error is happening.
122-
12390
## Creating a new simulation type
12491

12592
In a separate location create a folder for your type:
@@ -142,7 +109,7 @@ Create the folder and file structure:
142109
- `[file for each property, contents are html]`
143110
- `/templates`
144111
- [template file and helpers]
145-
- `model.json`, primary data structure.
112+
- `model.js`, primary data structure.
146113
- `convert.js`, converts the model into the simulation deck format.
147114
- `parse.js`, converts a complete input file to the simput model; _recommended, not required_.
148115
- `/samples`, empty or partially full sample datasets; _recommended, not required_.
@@ -167,6 +134,16 @@ git commit -m "added [mytype]"
167134
git push
168135
```
169136

137+
## Add to compilation and landing page
138+
139+
Simput changed to a Vue.js framework, and no longer has the ability to dynamically add and load types - they must be present when Simput is built by webpack.
140+
141+
Add another script to `package.json` which compiles your type.
142+
143+
Add a call to `Simput.registerType()` for your type in `static/index.html`
144+
145+
This will likely change soon.
146+
170147
## Licensing
171148

172149
**Simput** is licensed under [BSD Clause 3](LICENSE).

documentation/content/docs/convert.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
title: Convertion helper
1+
title: Conversion helper
22
---
33

44
Once the view model is filled up by the user, we rely on a function to validate and convert the data into a structure easy to handle within a template.
55

6-
On the other hand if the proper __output__ annotations have been used in the model definition, such method can be automatically generated for you.
6+
On the other hand if the proper __output__ annotations have been used in the model definition, such method can be automatically generated for you.
77

88
The function definition is as follow:
99

@@ -39,7 +39,7 @@ module.exports = function (viewModel) {
3939

4040
## View Model structure
4141

42-
The view model is what you get from the outside world that you need to convert into a set of files. That structure is related to the definition you wrote and what the user trully filled.
42+
The view model is what you get from the outside world that you need to convert into a set of files. That structure is related to the definition you wrote and what the user actually filled in.
4343

4444
```model.js
4545
{
@@ -80,12 +80,12 @@ The view model is what you get from the outside world that you need to convert i
8080
name: "View 2 - name given by user in menu",
8181
attributeNameD: {...},
8282
attributeNameE: {...},
83-
},
83+
},
8484
{
8585
name: "View 2 - name given by user in menu",
8686
attributeNameD: {...},
8787
attributeNameE: {...},
88-
},
88+
},
8989
...
9090
],
9191
viewName3a: [

documentation/content/docs/index.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
title: Overview
22
---
33

4-
Simput is a tool for simplifying the process of writing and editing *simulation* input files.
4+
Simput is a tool for simplifying the process of writing and editing *simulation* input files.
55
It can be used as standalone tool or within other platform such as HPCCloud to streamlining input definition.
66

77
## What is SimPut?
@@ -23,23 +23,18 @@ $ Simput
2323
-i, --input [file|directory] Input file or directory
2424
-o, --output [directory] Output directory to output to
2525
-t, --type [type] Type of input
26-
27-
-n, --no-gui Just generate output
28-
-s, --silent Do not open the browser
26+
2927
-p, --port [8080] Server port
3028
(default: 8080)
3129
-c, --compile [directory] Directory to compile files
3230
-m, --minify Minify compiled file
33-
-a, --add [file] Add model to list of available inputs
34-
-l, --list List model types of available as inputs
35-
-r, --remove [type] Remove model from list of available inputs
3631
-h, --help output usage information
3732
```
3833

3934
Let's open a specific model locally for edition
4035

4136
```
42-
$ Simput -o /tmp -i types/pyfr/samples/empty/pyfr-empty-externals.json
37+
$ Simput -p
4338
Simput listening on port 8080
4439
```
4540

documentation/content/docs/model.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SimPut works around a model definition that the user have to define initially. T
1111

1212
## Format
1313

14-
The model can either be a JSON or a JavaScript file. But we recommend to use the JavaScript syntax as it will allow you to use comment and ignore other restriction that JSON is enforcing.
14+
The model can either be a JSON or a JavaScript file. We recommend using the JavaScript syntax as it will allow you to use comments and avoid other restrictions that JSON enforces.
1515

1616
```JavaScript
1717
module.exports = {
@@ -23,7 +23,7 @@ module.exports = {
2323
};
2424
```
2525

26-
vs
26+
vs
2727

2828
```JSON
2929
{
@@ -42,7 +42,7 @@ Let's look closer to the various section that can exist inside a `model.[json/js
4242
### Definitions
4343

4444
The definition is the home of the various attributes that regroup parameters that we want the user to input.
45-
An attribute is defined by a group of parameters with a title.
45+
An attribute is defined by a group of parameters with a title.
4646
Each parameter is listed in an order manner and provide the following set of fields:
4747
- __id:__ Identifiant that is used inside the attribute map within the view model.
4848
- __type:__ ['string', 'double', 'int', 'bool', ...] The type is to properly convert user input from standard UI to their actual type.
@@ -53,7 +53,7 @@ Each parameter is listed in an order manner and provide the following set of fie
5353
```
5454
module.exports = {
5555
definitions: {
56-
attributeIdentifiant: {
56+
attributeIdentifier: {
5757
label: 'User friendly string for the attribute section',
5858
parameters: [
5959
{
@@ -83,9 +83,9 @@ Attribute rendering example
8383

8484
#### Parameter
8585

86-
##### Layout
86+
##### Layout
8787

88-
When size is bigger than 1 it make sense to start providing a layout hint. Below we list known layout.
88+
When size is bigger than 1 it makes sense to start providing a layout hint. Below we list known layout hints.
8989

9090
```
9191
"parameters": [
@@ -146,8 +146,8 @@ Attribute rendering example
146146

147147
##### Show
148148

149-
An additional field can be provided to dynamically show or hide a given parameter based on a neighbor condition.
150-
The value set is always capture within an array, which force the expression to be extracted like shown below.
149+
An additional field can be provided to dynamically show or hide a given parameter based on a neighbor's value.
150+
The value set is always captured within an array, which force the expression to be extracted like shown below.
151151

152152
```
153153
"parameters": [
@@ -169,7 +169,7 @@ The value set is always capture within an array, which force the expression to b
169169

170170
##### UI
171171

172-
Sometime a single field need to have a custom presentation. A `ui` field is then use to let the user control what *presentation layer* should be used. Below are some existing `ui` implementation:
172+
Sometimes a single field needs to have a custom presentation. A `ui` field is then used to let the user control what *presentation layer* should be used. Below are some existing `ui` implementations:
173173

174174
```
175175
"attr2": {
@@ -226,7 +226,7 @@ Attribute rendering with different ui
226226
Attribute rendering with different ui
227227
</center>
228228

229-
The domain in the UI can be filled by some external data.
229+
The domain in the UI can be filled by some external data.
230230

231231
```
232232
{
@@ -241,7 +241,7 @@ The domain in the UI can be filled by some external data.
241241

242242
##### Conditional attributes
243243

244-
Parameters can be dynamically composed based on other attribute parameters and conditional expression.
244+
Parameters can be dynamically composed based on other attribute parameters and conditional expressions.
245245

246246
```
247247
"attrOr": {
@@ -273,11 +273,11 @@ Parameters can be dynamically composed based on other attribute parameters and c
273273

274274
### Views
275275

276-
Views are meant to gather several attribute/parameter into a meaningful pages that get driven based on a side menu.
277-
The label for a view is what will be display in the side menu for selecting a given view/page.
276+
Views are meant to gather several attributes/parameters into meaningful pages that get driven based on a side menu.
277+
The label for a view is what will be displayed in the side menu for selecting a given view/page.
278278
The content of the page will be defined by the __attributes__ array content that was describe above.
279-
When no __attributes__ are given, a __children__ should be used to create a nested list of other views.
280-
The __size__ for a view is used when you want to dynamically create/delete a given view.
279+
Instead of __attributes__, a __children__ array can be used to create a nested list of other views.
280+
A __size: -1__ is used for a view when you want to dynamically create/delete views in a list.
281281

282282
```
283283
views : {
@@ -309,7 +309,7 @@ views : {
309309
View menu
310310
</center>
311311

312-
To a view can be attached hooks to dynamically massage the data between transitions. This allow for instance to copy the dynamic view name into a parameter of a given attribute or expose a set of view data into some external domain so they could be used somewhere else in the input definition.
312+
Hooks can be attached to a view to dynamically massage the data between transitions. This allows, for instance, copying the dynamic view name into a parameter of a given attribute or exposing a set of view data into some external domain so they can be used somewhere else in the input definition.
313313

314314
```
315315
views : {
@@ -326,10 +326,10 @@ views : {
326326
},
327327
```
328328

329-
Note the `readOnly` option disable the view name edition from the side menu which works well if you want to use a parameter to define that view name.
330-
The `noDelete` option disable the delete action on the view. That flag can either be define at the view definition or inside the `currentViewData` that the hooks are getting passed. The 'readOnly' flag follow the same pattern regarding where its definition can be provided.
329+
Note the `readOnly` option disables the view name editing in the side menu which works well if you want to use a parameter to define that view name.
330+
The `noDelete` option disables the delete action on the view. That flag can either be defined in the view definition or inside the `currentViewData` that the hooks are getting passed. The 'readOnly' flag follows the same pattern regarding where its definition can be provided.
331331

332-
To register your own hooks, you will have to create a `hooks.js` next to your model file. The following listing illustrate what that file should looks like.
332+
To register your own hooks, you will have to create a `hooks.js` next to your model file. The following listing illustrates what that file should look like.
333333

334334
```
335335
function getExternal(dataModel) {
@@ -376,7 +376,7 @@ Hooks can also be used to alter the model definition in order to add or remove v
376376

377377
### Order
378378

379-
The order is used to define the side menu to provide the list of view in an ordered manner.
379+
The __order__ list is used to define the side menu, providing the list of views in order. A view will not appear unless it is included in this list.
380380

381381
```
382382
order: [
@@ -399,15 +399,15 @@ output: {
399399
},
400400
```
401401

402-
Currently only 2 types are available [__default__ or __template__]:
402+
Currently 2 types are available [__default__ or __template__]:
403403
- The __default__ mode is just going to serialize the data model into JSON.
404-
- The __template__ mode allow the user to define a [*Handlebars*](https://handlebarsjs.com/block_helpers.html) template to convert the JSON structure into any other format.
404+
- The __template__ mode allow the user to define a [*Handlebars*](https://handlebarsjs.com/block_helpers.html) template to convert the JSON structure into any other format.
405405

406-
The output section require additional an additional __output__ field inside each `view` definition.
406+
The output section requires an additional __output__ field inside each `view` definition.
407407

408408
#### Output inside views
409409

410-
On a view which list a set of *attributes*, you'll need to define an __output__ array that will define a mapping between view attributes into output data model.
410+
On a view which lists a set of *attributes*, you will need to define an __output__ array that defines a mapping between view attributes and the output data model.
411411

412412
Here is an example:
413413

@@ -429,12 +429,12 @@ output: [
429429

430430
Each entry in that output array should be composed of:
431431
- __extract:__ list the parameters that we want to output somewhere in the model.
432-
- __src:__ Name of the attribute that we want to extract the parameters from
432+
- __src:__ Name of the attribute that we want to extract the parameters from
433433
- __dst:__ List of mapping of where to store the given parameters
434434

435-
The left side of the *dst* entry define the path of where a given parameter should be stored which is provided on the right side of the `=`.
435+
The left side of the *dst* entry define the path where the parameter on the right side of the `=`should be stored.
436436

437-
When we want to fill an array with object the following pattern can be used:
437+
When we want to fill an array with objects the following pattern can be used:
438438

439439
```
440440
'root.elements[]+=name',
@@ -445,11 +445,10 @@ When we want to fill an array with object the following pattern can be used:
445445
```
446446

447447

448-
The `.` on the left side are used as nesting structure inside an object.
449-
The `{xxx}` are automatically replaced on the left side with the actual value of the `xxx` parameter.
450-
448+
The `.` on the left side define the nesting structure inside an object.
449+
The `{xxx}` are automatically replaced on the left side with the actual value of the `xxx` parameter.
451450

452451
### Scripts
453452

454-
External scripts can be loaded for a given type by providing at the root level a `scripts: [],` section with the list of url that the type should load in order to works.
455-
This can be useful to register custom widgets to edit your custom parameter.
453+
External scripts can be loaded for a given type by providing at the root level a `scripts: [],` section with the list of url that the type should load.
454+
This can be useful to register custom widgets to edit your custom parameters.

src/cli/converter.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ module.exports = function convert(input, outputDirectory) {
4242

4343
// write output
4444
try {
45-
const output = GLOBAL.Simput.types[type].convert(inputContents);
46-
const outputPath = toAbsolutePath(outputDirectory);
45+
const output = global.Simput.types[type].convert(inputContents);
46+
const outputPath = outputDirectory
47+
? toAbsolutePath(outputDirectory)
48+
: path.dirname(inputPath);
4749
Object.keys(output.results).forEach((el) => {
4850
fs.writeFileSync(path.join(outputPath, el), output.results[el]);
4951
const size = fs.statSync(path.join(outputPath, el)).size;

0 commit comments

Comments
 (0)