From 32c8864672c87e6a6d4f8d39f849dffc77f0e2ed Mon Sep 17 00:00:00 2001 From: jbannister Date: Tue, 5 Oct 2021 00:34:34 +0100 Subject: [PATCH] improvement: show version number in main GUI improvement: get changelog into github releases task: bump version number to 0.3.0 --- .circleci/config.yml | 31 ++++++++++++++----- CHANGELOG.md | 9 ++++++ CONTRIBUTING.md | 2 +- docs/conf.py | 2 +- notebooker/__init__.py | 2 +- notebooker/_entrypoints.py | 2 +- notebooker/_version.py | 1 - notebooker/version.py | 1 + notebooker/web/routes/core.py | 11 +++++++ notebooker/web/static/notebooker/header.js | 10 ++++++ .../static/notebooker/one_click_notebooks.css | 5 +++ notebooker/web/static/package.json | 2 +- notebooker/web/templates/header.html | 24 ++++++++------ setup.py | 2 +- tests/integration/web/test_core_routes.py | 11 +++++++ 15 files changed, 91 insertions(+), 24 deletions(-) delete mode 100644 notebooker/_version.py create mode 100644 notebooker/version.py diff --git a/.circleci/config.yml b/.circleci/config.yml index ad3b67a9..d527302d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,10 +20,20 @@ defaults: &defaults - run: name: Version checks command: | - grep -q $VERSION notebooker/_version.py || (echo "ERROR: Version number not found in notebooker/_version.py: $VERSION"; exit 1) + grep -q $VERSION notebooker/version.py || (echo "ERROR: Version number not found in notebooker/_version.py: $VERSION"; exit 1) grep -q $VERSION CHANGELOG.md || (echo "ERROR: Version number not found in CHANGES.md: $VERSION"; exit 1) grep -q $VERSION docs/conf.py || (echo "ERROR: Version number not found in docs/source/conf.py: $VERSION"; exit 1) grep -q $VERSION notebooker/web/static/package.json || (echo "ERROR: Version number not found in package.json: $VERSION"; exit 1) + - run: + name: Output useful stuff + command: | + echo $VERSION > "$CIRCLE_ARTIFACTS/version.txt" + # Find the lines of the changelog between releases, escape double quotes, delete empty lines + sed -n '{ /------/= }' CHANGELOG.md \ + | head -n 2 \ + | xargs -n 2 bash -c 'sed -n "s/\"/\\\\\"/g;`expr $0 + 1`,`expr $1 - 2`p" CHANGELOG.md' \ + | sed '/^$/d' \ + > "$CIRCLE_ARTIFACTS/changes.md" - run: name: Install MongoDB command: | @@ -136,10 +146,6 @@ defaults: &defaults python setup.py sdist mkdir -p "$CIRCLE_ARTIFACTS/dist" cp -r ./dist/* "$CIRCLE_ARTIFACTS/dist" - - run: - name: Upload to PyPI - command: | - echo $VERSION > "$CIRCLE_ARTIFACTS/version.txt" - run: name: Upload to PyPI command: | @@ -162,6 +168,7 @@ defaults: &defaults root: /tmp/circleci-artifacts paths: - ./*/version.txt + - ./*/changes.md - ./*/dist/* version: 2 jobs: @@ -170,7 +177,7 @@ jobs: PYTHON_VERSION: "3_6" CIRCLE_ARTIFACTS: /tmp/circleci-artifacts/3_6 CIRCLE_TEST_REPORTS: /tmp/circleci-test-results/3_6 - VERSION: 0.2.1 + VERSION: 0.3.0 PANDOC_RELEASES_URL: https://github.com/jgm/pandoc/releases YARN_STATIC_DIR: notebooker/web/static/ IMAGE_NAME: mangroup/notebooker @@ -182,7 +189,7 @@ jobs: environment: CIRCLE_ARTIFACTS: /tmp/circleci-artifacts/3_7 CIRCLE_TEST_REPORTS: /tmp/circleci-test-results/3_7 - VERSION: 0.2.1 + VERSION: 0.3.0 PANDOC_RELEASES_URL: https://github.com/jgm/pandoc/releases YARN_STATIC_DIR: notebooker/web/static/ IMAGE_NAME: mangroup/notebooker @@ -200,7 +207,15 @@ jobs: name: "Publish release on GitHub" command: | VERSION=$(cat /tmp/circleci-artifacts/3_6/version.txt) - ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -soft ${VERSION} /tmp/circleci-artifacts/3_6/dist + CHANGES=$(cat /tmp/circleci-artifacts/3_6/changes.md) + ghr -t ${GITHUB_TOKEN} \ + -u ${CIRCLE_PROJECT_USERNAME} \ + -r ${CIRCLE_PROJECT_REPONAME} \ + -c ${CIRCLE_SHA1} \ + -n ${VERSION} \ + -b "${CHANGES}" \ + -soft \ + ${VERSION} /tmp/circleci-artifacts/3_6/dist workflows: version: 2 build_all: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f2e693a..45d58abe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +0.3.0 (2021-10-05) +------------------ + +* Major feature: scheduling natively within Notebooker + * See [the docs](https://notebooker.readthedocs.io/en/latest/webapp/webapp.html#scheduling-a-report) for more info. +* Bugfix: Newer versions of uuid now work properly with Notebooker +* Improvement: See the version number in the Notebooker GUI and with a /core/version GET call. + + 0.2.1 (2021-02-11) ------------------ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85d1deac..f166e1f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ Do also make sure to run the webapp and make sure you haven't broken anything. # Releasing a new version When releasing a new version, please increment the version number in: -* `notebooker/_version.py` +* `notebooker/version.py` * `.circleci/config.yml` * `docs/config.yml` * `notebooker/web/static/package.json` diff --git a/docs/conf.py b/docs/conf.py index 3fffb12c..2be23e67 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,7 +23,7 @@ author = "Man Group Quant Tech" # The full version, including alpha/beta/rc tags -release = "0.2.1" +release = "0.3.0" # -- General configuration --------------------------------------------------- diff --git a/notebooker/__init__.py b/notebooker/__init__.py index c23ff79d..65feca01 100644 --- a/notebooker/__init__.py +++ b/notebooker/__init__.py @@ -1,3 +1,3 @@ -from ._version import __version__ +from .version import __version__ __import__("pkg_resources").declare_namespace(__name__) diff --git a/notebooker/_entrypoints.py b/notebooker/_entrypoints.py index 820b2b04..80a8b8f4 100644 --- a/notebooker/_entrypoints.py +++ b/notebooker/_entrypoints.py @@ -4,7 +4,7 @@ import click from notebooker import notebook_templates_example -from notebooker._version import __version__ +from notebooker.version import __version__ from notebooker.constants import DEFAULT_SERIALIZER from notebooker.execute_notebook import execute_notebook_entrypoint from notebooker.serialization import SERIALIZER_TO_CLI_OPTIONS diff --git a/notebooker/_version.py b/notebooker/_version.py deleted file mode 100644 index 3ced3581..00000000 --- a/notebooker/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.2.1" diff --git a/notebooker/version.py b/notebooker/version.py new file mode 100644 index 00000000..493f7415 --- /dev/null +++ b/notebooker/version.py @@ -0,0 +1 @@ +__version__ = "0.3.0" diff --git a/notebooker/web/routes/core.py b/notebooker/web/routes/core.py index bc1f2608..29f89963 100644 --- a/notebooker/web/routes/core.py +++ b/notebooker/web/routes/core.py @@ -1,5 +1,6 @@ from flask import Blueprint, jsonify, request +import notebooker.version from notebooker.utils.results import get_all_available_results_json from notebooker.web.utils import get_serializer, get_all_possible_templates, all_templates_flattened @@ -53,3 +54,13 @@ def all_possible_templates_flattened(): :returns: A JSON which is a list of all possible templates with their full names. """ return jsonify({"result": all_templates_flattened()}) + + +@core_bp.route("/core/version") +def get_version_no(): + """ + Core function which returns the Notebooker version number. + + :returns: A JSON mapping from "version" to the string repr of the version number. + """ + return jsonify({"version": notebooker.version.__version__}) diff --git a/notebooker/web/static/notebooker/header.js b/notebooker/web/static/notebooker/header.js index d8047a9f..8cc38512 100644 --- a/notebooker/web/static/notebooker/header.js +++ b/notebooker/web/static/notebooker/header.js @@ -1,4 +1,14 @@ $(document).ready(() => { + $.ajax({ + url: '/core/version', + success: (result) => { + $('#versionTitle').text("v" + result.version); + $('#versionTitle').show(); + }, + error: () => { + $('#versionTitle').hide(); + }, + }); // Check auth is enabled on our host $.ajax({ url: '/oauth/health', diff --git a/notebooker/web/static/notebooker/one_click_notebooks.css b/notebooker/web/static/notebooker/one_click_notebooks.css index 92971f36..fc5dfbff 100644 --- a/notebooker/web/static/notebooker/one_click_notebooks.css +++ b/notebooker/web/static/notebooker/one_click_notebooks.css @@ -43,3 +43,8 @@ td button i { #usernameInfo { margin-left: 0.5em; } + +#versionTitle { + width: 3em; + display: none; +} \ No newline at end of file diff --git a/notebooker/web/static/package.json b/notebooker/web/static/package.json index 99fe3625..3ae4dc80 100644 --- a/notebooker/web/static/package.json +++ b/notebooker/web/static/package.json @@ -1,6 +1,6 @@ { "name": "notebooker", - "version": "0.2.1", + "version": "0.3.0", "description": "Notebooker - Turn notebooks into reports", "dependencies": { "bootstrap-table": "1.15.3", diff --git a/notebooker/web/templates/header.html b/notebooker/web/templates/header.html index c16a1fc7..218716b7 100644 --- a/notebooker/web/templates/header.html +++ b/notebooker/web/templates/header.html @@ -43,16 +43,21 @@ Scheduler - + {% endmacro %} diff --git a/setup.py b/setup.py index c2e0f593..ded3fde5 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def get_version(): # https://packaging.python.org/guides/single-sourcing-package-version/#single-sourcing-the-version base_dir = os.path.abspath(os.path.dirname(__file__)) - version_file_loc = os.path.join(base_dir, ".", "notebooker", "_version.py") + version_file_loc = os.path.join(base_dir, ".", "notebooker", "version.py") version = {} with open(version_file_loc) as version_file: exec(version_file.read(), version) diff --git a/tests/integration/web/test_core_routes.py b/tests/integration/web/test_core_routes.py index ec06bbcb..d9511779 100644 --- a/tests/integration/web/test_core_routes.py +++ b/tests/integration/web/test_core_routes.py @@ -1,4 +1,5 @@ import json +import notebooker.version def test_create_schedule(flask_app, setup_workspace): @@ -9,3 +10,13 @@ def test_create_schedule(flask_app, setup_workspace): assert rv.status_code == 200 data = json.loads(rv.data) assert data == {"result": ["fake/report"]} + + +def test_version_number(flask_app, setup_workspace): + with flask_app.test_client() as client: + rv = client.get( + "/core/version", + ) + assert rv.status_code == 200 + data = json.loads(rv.data) + assert data == {"version": notebooker.version.__version__}