From 1e06f147c5b8d9b0fee1beca711140546843e18b Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 12 Oct 2022 09:49:34 +0200 Subject: [PATCH 1/5] Pin Werkzeug to version 2.1.* Werkzeug 2.2.* hides a function used by flask-restx. The end result is that flask-restx raises an ImportError when used with a Werkzeug 2.2 --- Dockerfile | 5 +++-- environment-dev.yaml | 2 +- environment.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2396015..3b47edc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,8 @@ COPY /README.md /webproj/README.md COPY /app/main.py /app/main.py RUN pip install --upgrade pip -RUN pip install "pyproj>=3.3.0,<3.4.0" -RUN pip install flask-restx flask-cors Werkzeug +RUN pip install pyproj +RUN pip install flask-restx flask-cors +run pip install "Werkzeug>=2.1.0,<2.2.0" RUN pip install /webproj RUN pyproj sync --source-id dk_sdfe diff --git a/environment-dev.yaml b/environment-dev.yaml index 2dbeac1..98f13f1 100644 --- a/environment-dev.yaml +++ b/environment-dev.yaml @@ -5,7 +5,7 @@ channels: dependencies: - python=3.9 - pip>=20.0 - - werkzeug>=1.0 + - werkzeug=2.1 - flask>=1.0 - flask-restx>=0.1.1 - flask-cors>=3.0 diff --git a/environment.yaml b/environment.yaml index 68aa76e..4496bc0 100644 --- a/environment.yaml +++ b/environment.yaml @@ -5,7 +5,7 @@ channels: dependencies: - python=3.9 - pip>=20.0 - - werkzeug>=1.0 + - werkzeug=2.1 - flask>=1.0 - flask-restx>=0.1.1 - flask-cors>=3.0 From 8155b8d931e1b645a5ef71da1d7c932a6715c119 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 12 Oct 2022 11:16:39 +0200 Subject: [PATCH 2/5] Update HOWTORELEASE with current release procedure --- HOWTORELEASE.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/HOWTORELEASE.md b/HOWTORELEASE.md index 78d3587..503e38f 100644 --- a/HOWTORELEASE.md +++ b/HOWTORELEASE.md @@ -1,6 +1,42 @@ # Release instructions for WEBPROJ -(insert GitHub release instructions here) +1. Checkout maintenance branch + +If issueing a patch release a maintenance branch should already exists. Check it out: + +> git checkout 1.1 + +and ensure sure that all relevant commits have been backported to the maintenance branch in question. + +If a major or minor version release is being prepared, a new maintenance branch based on the +master branch needs to be created: + +> git checkout -b 1.1 + +2. Tag the latest commit on the the maintenance branch with the new version number + +On the maintenance branch the latest commit can now be tagged with the version number, e.g.: + +> git tag 1.1.1 +> git push --tags + +3. Close the GitHub milestone for the version to be released + +4. Write release notes on GitHub based on the tag created in step 2 + +5. Bump version number + +We update the version number right away in preparation for the next release. This way we can distinguish +between released versions and to-be-released versions easily. If we see an unrelease version number we know +that we are using a development version of WEBPROJ. + +`version` in `webproj\api.py` needs to be updated. After a patch release the version number is only updated +on the maintenance branch. After a major or minor release it should be updated on the master branch and subsequently +cherry-picked to the maintenance branch. + +6. Deploy in production + +After a release WEBPROJ needs to be deployed in Jenkins. ### Update docs on docs.dataforsyningen.dk WEBPROJ generates Swagger documentation through flask_restx, and Dataforsyningen uses the newer OpenAPI spec, so for now we manually convert to OpenAPI and tweak the result. From 76c95cefdb148dea271c20cfd1938ee3f6f66d0a Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 12 Oct 2022 11:23:25 +0200 Subject: [PATCH 3/5] Bump version number to 1.2.0 --- webproj/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webproj/api.py b/webproj/api.py index 061cd91..b7631b8 100644 --- a/webproj/api.py +++ b/webproj/api.py @@ -11,7 +11,7 @@ from webproj.utils import IntFloatConverter -version = "1.1.0" +version = "1.2.0" if "WEBPROJ_LIB" in os.environ: pyproj.datadir.append_data_dir(os.environ["WEBPROJ_LIB"]) From e276bdeb84d639c4ca614914d99bb04ffa151c3c Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 12 Oct 2022 14:10:20 +0200 Subject: [PATCH 4/5] Expand API with /info/ entry point The info/ entry point returns information about the current WEBPROJ instance, e.g. > curl http://127.0.0.1:5000/v1.2/info/ { "version": "1.2.0", "proj_version": "9.1.0" } --- tests/test_api.py | 12 ++++++++++++ webproj/api.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index d895fb2..b81eaae 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,4 +1,5 @@ import sys +import re import json import pprint @@ -372,3 +373,14 @@ def test_crs_units(api_from_v1_2): for srid, crsinfo in testdata.items(): api_entry = f"/{api_from_v1_2}/crs/{srid}" _assert_key_value_set(api_entry, crsinfo) + + +def test_info(api_from_v1_2): + """ + Test that the info entrypoint returns sensible values. + """ + response = _get_and_decode_response(f"/{api_from_v1_2}/info/") + + for software, version_number in response.items(): + print(software, version_number) + assert re.match(r"^\d+\.\d+\.\d+$", version_number) diff --git a/webproj/api.py b/webproj/api.py index b7631b8..9ee3f88 100644 --- a/webproj/api.py +++ b/webproj/api.py @@ -377,3 +377,15 @@ def get(self, src, dst, v1, v2, v3=None, v4=None): abort(404, message=error) return {"v1": v1, "v2": v2, "v3": v3, "v4": v4} + + +@api.route("/v1.2/info/") +class Info(Resource): + def get(self): + """ + Retrieve information about the running instance of WEBPROJ and it's constituent components. + """ + return { + "webproj_version": version, + "proj_version": pyproj.__proj_version__, + } From aabf4c659fcb6fb5e7400d865d2eba00e6b9785f Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 12 Oct 2022 14:12:10 +0200 Subject: [PATCH 5/5] Add license URL to Flask metadata ... and improve the formatting of the description slightly. --- webproj/api.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/webproj/api.py b/webproj/api.py index 9ee3f88..356f234 100644 --- a/webproj/api.py +++ b/webproj/api.py @@ -25,14 +25,21 @@ app, version=version, title="WEBPROJ", - description="## API til koordinattransformationer\n\nAPIet " - "__WEBPROJ__ giver adgang til at transformere " - "multidimensionelle koordinatsæt. \n\nTil adgang " - "benyttes Dataforsyningens brugeradgang som ved andre " - "tjenester.\n\n[Versionshistorik](/webproj.txt)", + description=( + "## API til koordinattransformationer" + "\n\n" + "API'et __WEBPROJ__ giver adgang til at transformere " + "multidimensionelle koordinatsæt." + "\n\n" + "Til adgang benyttes Dataforsyningens brugeradgang som ved andre " + "tjenester." + "\n\n" + "[Versionshistorik](/webproj.txt)" + ), terms_url="https://dataforsyningen.dk/Vilkaar", contact="support@sdfi.dk", license="MIT License", + license_url="https://raw.githubusercontent.com/SDFIdk/WEBPROJ/master/LICENSE", ) _DATA = Path(__file__).parent / Path("data.json")