-
Notifications
You must be signed in to change notification settings - Fork 26
feat: add initial support for XMILE/Stella models #778
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
Changes from all commits
fed74ce
0ab29b4
180e87a
5182e02
2c21f75
6436b97
b0343a1
89b98d2
6916d5f
d7c15c0
22cb090
a56e839
bff3837
a56cb1a
feefb1f
7ffe1f6
90c2051
b42ab63
48532e3
8ef4605
2032ae5
8227ded
3a26509
7748cb9
3f797c3
2c8ca56
c7d9744
4f384bd
0033fca
fe73b21
1be73de
9576ce6
44547b9
99cc6de
6c92510
0bc1444
434366c
37704f3
d4c7f7d
2097ccc
f252338
c349a04
d6808b6
c5d897c
e103751
c8dd5fd
90d523e
5d45392
8d29605
c3ba489
51d2b44
2cb691a
5f574b0
4106b82
ffbc7be
425552f
a0a0c04
2968846
b65e528
7d00640
f7bd6b5
bd8cb56
cf8f063
f24f43f
29b37f6
47be15a
0da1d4f
af199ba
7e4aa61
f28013f
940d069
631cb38
5099835
ef19899
e325d66
be3038d
34bf1d9
653bb3f
546d07f
034ed4d
ff27a52
dc97cca
8b169f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,25 +25,45 @@ export function execCmd(cmd) { | |
| } | ||
|
|
||
| /** | ||
| * Normalize a model pathname that may or may not include the .mdl extension. | ||
| * Normalize a model pathname that may or may not include the .mdl or .xmile/.stmx/.itmx extension. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The sde CLI commands previously automatically found the corresponding mdl file for a given model name. Now we do the same thing for xmile/stmx/itmx files. If there are multiple options, it throws an error and the user can specify which one by providing a full file name with extension. |
||
| * If the pathname does not end with .mdl, .xmile, .stmx, or .itmx, this will attempt to find a | ||
| * file with one of those extensions. | ||
| * If there is not a path in the model argument, default to the current working directory. | ||
| * | ||
| * Return an object with properties that look like this: | ||
| * modelDirname: '/Users/todd/src/models/arrays' | ||
| * modelName: 'arrays' | ||
| * modelPathname: '/Users/todd/src/models/arrays/arrays.mdl' | ||
| * modelKind: 'vensim' | ||
| * | ||
| * @param model A path to a Vensim model file. | ||
| * @return An object with the properties specified above. | ||
| */ | ||
| export function modelPathProps(model) { | ||
| let p = R.merge({ ext: '.mdl' }, R.pick(['dir', 'name'], path.parse(model))) | ||
| const parsedPath = path.parse(model) | ||
| if (parsedPath.ext === '') { | ||
| const exts = ['.mdl', '.xmile', '.stmx', '.itmx'] | ||
| const paths = exts.map(ext => path.join(parsedPath.dir, parsedPath.name + ext)) | ||
| const existingPaths = paths.filter(path => fs.existsSync(path)) | ||
| if (existingPaths.length > 1) { | ||
| throw new Error( | ||
| `Found multiple files that match '${model}'; please specify a file with a .mdl, .xmile, .stmx, or .itmx extension` | ||
| ) | ||
| } | ||
| if (existingPaths.length === 0) { | ||
| throw new Error(`No {mdl,xmile,stmx,itmx} file found for ${model}`) | ||
| } | ||
| parsedPath.ext = path.extname(existingPaths[0]) | ||
| } | ||
| let p = R.merge({ ext: parsedPath.ext }, R.pick(['dir', 'name'], parsedPath)) | ||
| if (R.isEmpty(p.dir)) { | ||
| p.dir = process.cwd() | ||
| } | ||
| return { | ||
| modelDirname: p.dir, | ||
| modelName: p.name, | ||
| modelPathname: path.format(p) | ||
| modelPathname: path.format(p), | ||
| modelKind: p.ext === '.mdl' ? 'vensim' : 'xmile' | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing code gen tests were written using Vensim format as the input model format, but we need new tests that cover similar things except for XMILE format (since the code gen can be different in certain cases), so I renamed these files accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this option for
sde testso that we can pass a custom name for the dat file. Before this, it assumed that the file is called{model}.dat.I could've also updated
sde testto support reading csv files in addition to dat, but I didn't want to go deep on something that's probably not used much outside of our own testing framework. So instead I just added some code to our test scripts to convert the csv files (for expected Stella results) to dat format as part of the testing process.