neherlab / covid19_scenarios

Models of COVID-19 outbreak trajectories and hospital demand
https://covid19-scenarios.org
MIT License
1.36k stars 354 forks source link

Add a simple CLI for use in unified model interface #689

Closed adityasharad closed 4 years ago

adityasharad commented 4 years ago

Related issues and PRs

Description

This PR adds a simple CLI entry point that:

This allows the model to be run in a unified model UI, such as the one we are maintaining at https://github.com/covid-modeling on the GitHub side. We are already using a version of this at https://github.com/covid-modeling/model-runner to run this model, but are currently tied to my fork that has the CLI entry point and an older version of your model. Having this code as part of the model repo enables the unified interface to keep up with model changes, and so better represent the latest state of your model.

@ivan-aksamentov @nnoll I would be grateful for a review, and hope this will minimally impact your existing work. Let me know if you have questions.

Impacted Areas in the application

No changes to existing code, introduces new entry point that calls run.

Testing

  1. Usual schema preparation: yarn schema:clean && yarn schema:totypes.
  2. Write a JSON object of type ScenarioData in a file, say input-file.json. One of the existing objects in scenarios.json will work.
  3. yarn babel-node --extensions ".ts" src/algorithms/cli.ts path/to/input-file.json path/to/output-file.json
  4. This will create output data at path/to/output-file.json, which is assumed to not already exist.
vercel[bot] commented 4 years ago

This pull request is being automatically deployed with Vercel (learn more). To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/covid19-scenarios/covid19-scenarios/hvd94f70m ✅ Preview: https://covid19-scenarios-git-fork-adityasharad-unified-ui-cli.covid19-scenarios.now.sh

codeclimate[bot] commented 4 years ago

Code Climate has analyzed commit 8040a3d0 and detected 0 issues on this pull request.

View more on Code Climate.

ivan-aksamentov commented 4 years ago

Thanks! As you said, this is not exactly implementing a proper CLI and, honestly, not doing what I would expect, but I guess it does not hurt to have it around.

Would you be interested in continuing working in this direction? My main focus is still the application, but I can help here and there.

I will add a TODO list in the linked issue #663

Wouldn't it be more convenient for aggregators like "covid-modeling" to have a programmatic API instead of a CLI?