Open benbovy opened 6 years ago
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.
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.
Sure, just a hint 😉
Besides Python API, a command line interface would be nice to have for things like:
xsimlab inspect
xsimlab generate
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/cliSee also how to add it in conda packages as entry points: https://github.com/conda-forge/distributed-feedstock/blob/master/recipe/meta.yaml