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 command line interface #27

Open
benbovy opened this issue Feb 22, 2018 · 3 comments
Open

Add command line interface #27

benbovy opened this issue Feb 22, 2018 · 3 comments

Comments

@benbovy
Copy link
Member

benbovy commented Feb 22, 2018

Besides Python API, a command line interface would be nice to have for things like:

  • inspecting models -> xsimlab inspect
  • automatically generating input files for a given model -> xsimlab generate
  • running simulations -> xsimlab run

As reference, see, e.g., the command line scripts implemented in distributed based on click: https://github.com/dask/distributed/tree/master/distributed/cli

See also how to add it in conda packages as entry points:
https://github.com/conda-forge/distributed-feedstock/blob/master/recipe/meta.yaml

@Chilipp
Copy link

Chilipp commented Apr 9, 2018

Hey!

nice presentation today at EGU. I would like to suggest the model-organization package for this issue.

Besides it's automated command line API (see the example in the docs), this module organizes experiments and makes the configuration accessible and clearly arranged. One simple implementation would be

from model_organization import ModelOrganizer
import xsimlab

class XSimlabOrganizer(ModelOrganizer):

    commands = ModelOrganizer.commands[:]
    commands.insert(commands.index('init') + 1, 'run')

    def run(self, ...):
        """Run the model"""
        in_ds = xsimlab.create_setup(model=..., ...)
        out_ds = in_ds.xsimlab.run(model=...)
        out_ds.to_netcdf(self.exp_dir + 'output.nc')

if you save this into a file named model.py, this could then be run via

python model.py run # ... any arguments

See the docs for more information about the model-organization framework.

@benbovy
Copy link
Member Author

benbovy commented Apr 9, 2018

Thanks for the suggestion @Chilipp ! I haven't really looked into existing solutions for automating cmd line interface yet but I'll look into your package.

@Chilipp
Copy link

Chilipp commented Apr 9, 2018

Sure, just a hint 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants