From 377a733d970ad96364af576a1448142bcb49e1a6 Mon Sep 17 00:00:00 2001 From: Arjun Chennu Date: Thu, 19 Dec 2019 13:09:28 +0100 Subject: [PATCH 1/3] Bugfix in dataview update_irradiance Handle case when irradiance is a dict format --- microbenthos/dataview/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/microbenthos/dataview/base.py b/microbenthos/dataview/base.py index dbd49c9..b020db5 100644 --- a/microbenthos/dataview/base.py +++ b/microbenthos/dataview/base.py @@ -364,9 +364,10 @@ def update_irradiance(self): self.logger.debug('No irradiance info found') else: - # load irradiance cycle info - linfo = dict(irradiance.attrs) + # irradiance might be hdf.Dataset or a dict + linfo = dict(getattr(irradiance, 'attrs', + irradiance['metadata'])) self.diel_period = PhysicalField(linfo['hours_total']) self.diel_zenith = PhysicalField(linfo['zenith_time']) From 6f930bd6dedc419f7d5959cfa098f60cf3cc7723 Mon Sep 17 00:00:00 2001 From: Arjun Chennu Date: Thu, 19 Dec 2019 13:09:58 +0100 Subject: [PATCH 2/3] Fixes in cli for export & added --version export model command roundtrips better --- microbenthos/cli.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/microbenthos/cli.py b/microbenthos/cli.py index af1b3de..19b0560 100644 --- a/microbenthos/cli.py +++ b/microbenthos/cli.py @@ -6,6 +6,7 @@ import click from pathlib import Path +from . import __version__ try: import click_completion @@ -173,6 +174,7 @@ def _simtime_total_callback(ctx, param, value): @click.option('--logger', help='Set specified logger to loglevel (example: microbenthos.model 20)', multiple=True, type=(str, click.IntRange(10, 40))) +@click.version_option(version=__version__) def cli(verbosity, logger): """Console entry point for microbenthos""" loglevel = 0 @@ -288,6 +290,11 @@ def cli_simulate(model_file, output_dir, exporter, overwrite, compression, click.echo('Loading model from {}'.format(model_file)) with open(model_file, 'r') as fp: defs = yaml.unsafe_load(fp) + + if 'model' not in defs and 'domain' in defs: + # model is not under a separate key, so insert it under "model" + defs = dict(model=defs) + if 'simulation' not in defs: defs['simulation'] = {} @@ -475,7 +482,8 @@ def export_video(datafile, outfile, overwrite, @export.command('model') @click.argument('model_file', type=click.File()) -@click.option('--key', help='Load this key from the input file') +@click.option('--key', help='Load this key from the input file', + default="model") @click.option('-v', '--verbose', is_flag=True, default=False, help='Set this to see verbose output') def export_model(model_file, key, verbose): @@ -502,9 +510,12 @@ def export_model(model_file, key, verbose): from pprint import pformat if verbose: click.secho('Validated dictionary!', fg='green') - + model_definition = dict(model=valid) click.secho( - yaml.dump(valid, indent=4, explicit_start=True, explicit_end=True), + yaml.dump(model_definition, + indent=4, + explicit_start=True, + explicit_end=True), fg='yellow') except ValueError: From 5155c034c4e8885f9ac731b42760bfe1302fc469 Mon Sep 17 00:00:00 2001 From: Arjun Chennu Date: Thu, 19 Dec 2019 17:29:17 +0100 Subject: [PATCH 3/3] Bump version: 0.13 --> 0.14 --- .bumpversion.cfg | 2 +- docs/conf.py | 4 ++-- microbenthos/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index aaf1ffe..ef57a9d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.13 +current_version = 0.14 commit = False tag = False parse = (?P\d+)\.(?P\d+)(\.(?P\d+))? diff --git a/docs/conf.py b/docs/conf.py index e98bf1f..0c72b13 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -87,9 +87,9 @@ # the built documents. # # The short X.Y version. -version = "0.13" +version = "0.14" # The full version, including alpha/beta/rc tags. -release = "0.13" +release = "0.14" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/microbenthos/__init__.py b/microbenthos/__init__.py index df0af76..72b10fe 100644 --- a/microbenthos/__init__.py +++ b/microbenthos/__init__.py @@ -3,7 +3,7 @@ __author__ = """Arjun Chennu""" __email__ = 'achennu@mpi-bremen.de' -__version__ = '0.13' +__version__ = '0.14' import logging diff --git a/setup.py b/setup.py index af6276f..f8dafc4 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ def get_description(): setup( name='microbenthos', - version='0.13', + version='0.14', description= \ "Modeling framework for microbenthic habitats useful for studies in " "biogeochemistry and marine microbial ecology.",