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

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

Merged
merged 2 commits into from
May 20, 2020

Conversation

adityasharad
Copy link
Contributor

@adityasharad adityasharad commented May 20, 2020

Related issues and PRs

Description

This PR adds a simple CLI entry point that:

  • reads input JSON (of type ScenarioData) from a specified input path
  • runs the model by calling into run.ts
  • writes output JSON (of type AlgorithmResult) into the specified output path

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
Copy link

vercel bot commented May 20, 2020

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

Adds a simple CLI that:
- reads input JSON (of type `ScenarioData`) from a specified input path
- runs the model by calling into `run.ts`
- writes output JSON (of type `AlgorithmResult`) into the specified output path

This allows the model to be run in a unified model UI.
Having this as part of the model repo enables the unified interface to keep up with model changes.
This file is intended as a CLI application.
@codeclimate
Copy link

codeclimate bot commented May 20, 2020

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

View more on Code Climate.

@ivan-aksamentov
Copy link
Member

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?

@ivan-aksamentov ivan-aksamentov merged commit b0ee9b4 into neherlab:master May 20, 2020
@ivan-aksamentov ivan-aksamentov mentioned this pull request Jun 7, 2020
@ivan-aksamentov ivan-aksamentov mentioned this pull request Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants