diff --git a/README.md b/README.md index 7709ec5a2e..3e0122d9b6 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,6 @@ Model Evaluation Tools Plus (METplus) Repository [![Travis build status](https://travis-ci.org/DTCenter/METplus.svg?branch=develop)](https://travis-ci.org/DTCenter/METplus) [![Latest Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://dtcenter.github.io/METplus/) -<!-- -[![Travis DTCenter_develop build_status](https://travis-ci.org/DTCenter/METplus.svg?branch=develop)](https://travis-ci.org/DTCenter/METplus) ---> Welcome to the METplus GitHub repository hosted to the community through the Developmental Testbed Center (DTC). diff --git a/ci/docker/hooks/build b/ci/docker/hooks/build index 624e086755..f69aad3664 100644 --- a/ci/docker/hooks/build +++ b/ci/docker/hooks/build @@ -1,3 +1,7 @@ #!/bin/bash -docker build -t $IMAGE_NAME --build-arg SOURCE_BRANCH=$SOURCE_BRANCH --build-arg MET_BRANCH=develop --build-arg DO_GIT_CLONE=true . +# get version, use develop or X+6.Y for MET_BRANCH +met_branch=`$(dirname $DOCKERFILE_PATH)/hooks/get_met_version` + +echo $met_branch +docker build -t $IMAGE_NAME --build-arg SOURCE_BRANCH=$SOURCE_BRANCH --build-arg MET_BRANCH=$met_branch --build-arg DO_GIT_CLONE=true . diff --git a/ci/docker/hooks/get_met_version b/ci/docker/hooks/get_met_version new file mode 100755 index 0000000000..32c4b27639 --- /dev/null +++ b/ci/docker/hooks/get_met_version @@ -0,0 +1,14 @@ +#!/bin/bash + +# get version, use develop or X+6.Y for MET_BRANCH +version_file=$(dirname $DOCKERFILE_PATH)/../../docs/version + +if cat $version_file | egrep -q '[0-9.]+$'; then + let major=$(cut -d '.' -f1 $version_file)+6 + minor=$(cut -d '.' -f2 $version_file ) + met_branch=$major"."$minor"-latest" +else + met_branch=develop +fi + +echo $met_branch diff --git a/ci/travis_jobs/get_data_volumes.py b/ci/travis_jobs/get_data_volumes.py index e0a6afb081..5ed625c8c7 100755 --- a/ci/travis_jobs/get_data_volumes.py +++ b/ci/travis_jobs/get_data_volumes.py @@ -7,8 +7,21 @@ from docker_utils import docker_get_volumes_last_updated -# this should be set to develop or a release version, i.e. vX.Y -METPLUS_VERSION = 'develop' +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), + os.pardir, + os.pardir,))) + +from metplus import __version__ + +# METPLUS_VERSION should be set to develop or a release version, i.e. vX.Y +# if version is set to X.Y without -betaZ or -dev, use that version +# otherwise use develop +if len(__version__.split('-')) == 1: + # only get first 2 numbers from version, i.e. X.Y.Z will use vX.Y + METPLUS_VERSION = f"v{'.'.join(__version__.split('.')[:2])}" + +else: + METPLUS_VERSION = 'develop' MODEL_APP_NAMES = ('met_tool_wrapper', 'convection_allowing_models', diff --git a/docs/conf.py b/docs/conf.py index a01e0c0c0c..bd5d64e219 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,10 +13,12 @@ import os from datetime import datetime import sys -sys.path.insert(0, os.path.abspath('../ush')) +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), + os.pardir))) sys.path.append(os.path.abspath("./_ext")) print(sys.path) +from metplus import __version__ # -- Project information ----------------------------------------------------- @@ -24,12 +26,21 @@ author = 'UCAR/NCAR, NOAA, CSU/CIRA, and CU/CIRES' -# the stable version, displayed on front page of PDF -version = 'develop' -verinfo = version - # The full version, including alpha/beta/rc tags -release = f'{version}' +# i.e. 4.0-beta1-dev +release = __version__ + +# the stable version, displayed on front page of PDF extract X.Y version +# from release by splitting the string into a list +# using - as the delimeter, then getting the 1st item of the list +# if version is beta, rc, and/or dev then set version to develop for +# the documentation built for develop (not release) +if len(release.split('-')) > 1: + version = 'develop' +else: + version = f"{release.split('-')[0]}" + +verinfo = version release_year = '2020' diff --git a/metplus/__init__.py b/metplus/__init__.py new file mode 100644 index 0000000000..5c76301f8f --- /dev/null +++ b/metplus/__init__.py @@ -0,0 +1,12 @@ +import os + +def get_metplus_version(): + version_file = os.path.abspath(os.path.join(os.path.dirname(__file__), + os.pardir, + 'docs', + 'version')) + with open(version_file, 'r') as file_handle: + version = file_handle.read().strip() + return version + +__version__ = get_metplus_version() diff --git a/metplus/util/met_util.py b/metplus/util/met_util.py index ddbe4acacb..c4c26e415e 100644 --- a/metplus/util/met_util.py +++ b/metplus/util/met_util.py @@ -29,6 +29,8 @@ from . import time_util as time_util from . import metplus_check +from .. import get_metplus_version + """!@namespace met_util @brief Provides Utility functions for METplus. """ @@ -86,7 +88,7 @@ def pre_run_setup(config_inputs): from . import config_metplus - version_number = get_version_number() + version_number = get_metplus_version() print(f'Starting METplus v{version_number}') # Read config inputs and return a config instance @@ -1022,19 +1024,6 @@ def get_lead_sequence(config, input_dict=None): return out_leads -def get_version_number(): - # read version file and return value - # get top level of METplus - parents[2] is 3 directories up from current file - # which is in ush/metplus/util - metplus_base = str(Path(__file__).parents[2]) - version_file_path = os.path.join(metplus_base, - 'docs', - 'version') - - with open(version_file_path, 'r') as version_file: - return version_file.read() - - def round_0p5(val): """! Round to the nearest point five (ie 3.3 rounds to 3.5, 3.1 rounds to 3.0) Take the input value, multiply by two, round to integer diff --git a/ush/master_metplus.py b/ush/master_metplus.py index 8958cb49c2..ad713f6d66 100755 --- a/ush/master_metplus.py +++ b/ush/master_metplus.py @@ -28,6 +28,7 @@ from metplus.util import metplus_check from metplus.util import pre_run_setup, run_metplus, post_run_cleanup from metplus.util import get_process_list +from metplus import __version__ as metplus_version '''!@namespace master_metplus Main script the processes all the tasks in the PROCESS_LIST @@ -73,6 +74,10 @@ def get_config_inputs_from_command_line(): invalid flag was provided, i.e. -a. @returns list of config inputs """ + + # output version that is run to screen + print('Running METplus %s' % metplus_version) + # if not arguments were provided, print usage and exit if len(sys.argv) < 2: usage()