From 68558f8494805ad1ef42f76ab306af9234218137 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:44:35 +0000 Subject: [PATCH 01/13] ci: update workflow files standardise format, change name of tests file --- .github/workflows/bump.yml | 8 ++++---- .github/workflows/pypi-publish.yml | 9 ++++----- .github/workflows/sync.yml | 6 +++--- .github/workflows/{main.yml => tests.yml} | 8 ++++---- 4 files changed, 15 insertions(+), 16 deletions(-) rename .github/workflows/{main.yml => tests.yml} (77%) diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index 8b17261..1bb1860 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -7,12 +7,12 @@ on: jobs: bump-version: - if: "!startsWith(github.event.head_commit.message, 'bump:')" + name: Bump version and create changelog runs-on: ubuntu-latest - name: "Bump version and create changelog" + if: "!startsWith(github.event.head_commit.message, 'bump:')" steps: - - name: Check out - uses: actions/checkout@v3 + - name: Checkout source code + uses: actions/checkout@v4 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 6866a49..d3ac620 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -10,17 +10,16 @@ permissions: jobs: deploy: + name: Deploy package to PyPI runs-on: ubuntu-latest steps: - - name: Check out - uses: actions/checkout@v3 + - name: Checkout source code + uses: actions/checkout@v4 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' + uses: actions/setup-python@5 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index bc66f38..4fec115 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -7,11 +7,11 @@ on: jobs: sync-branches: + name: Sync dev and patch branches to latest commit runs-on: ubuntu-latest - name: "Sync dev and patch branches to latest commit" steps: - - name: Check out - uses: actions/checkout@v3 + - name: Checkout source code + uses: actions/checkout@v4 with: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 diff --git a/.github/workflows/main.yml b/.github/workflows/tests.yml similarity index 77% rename from .github/workflows/main.yml rename to .github/workflows/tests.yml index 3f1c5b9..3fe7847 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/tests.yml @@ -3,18 +3,18 @@ name: Tests on: push: workflow_dispatch: + pull_request: + types: [opened, edited, reopened, synchronize] jobs: test: + name: Run tests runs-on: ubuntu-latest - steps: - name: Checkout source code - uses: actions/checkout@v3 - + uses: actions/checkout@v4 - name: Build images run: docker compose build - - name: Run tests env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} From 874835719d27806abf67633de7c4513ec159f7b0 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:44:41 +0000 Subject: [PATCH 02/13] ci: add pull request validation workflow new workflow to check commit format and code style against pre-commit config --- .github/workflows/pull-requests.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/pull-requests.yml diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml new file mode 100644 index 0000000..b9aa2bd --- /dev/null +++ b/.github/workflows/pull-requests.yml @@ -0,0 +1,27 @@ +name: Validate pull requests + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + validate-commits: + name: Validate commit messages + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Check commit message format + uses: webiny/action-conventional-commits@v1.3.0 + with: + allowed-commit-types: 'feat,fix,refactor,perf,docs,style,test,build,ci,chore,new,patch,revert,ui' + pre-commit: + name: Run pre-commit checks + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v5 + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 From d3c7fb4409c1462097a6600263e0c3a2f6b4b260 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:45:24 +0000 Subject: [PATCH 03/13] ci: update tool config update pre-commit repo versions and switch black to ruff --- .pre-commit-config.yaml | 19 +++++++++---------- pyproject.toml | 9 ++++----- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d3b017..728e347 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: /(vendor|dist)/ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-merge-conflict - id: detect-private-key @@ -11,23 +11,22 @@ repos: exclude: ^tests/helpers/ - id: trailing-whitespace - repo: https://github.com/commitizen-tools/commitizen - rev: v2.37.0 + rev: v3.30.0 hooks: - id: commitizen additional_dependencies: ["cz-nhm"] - - repo: https://github.com/psf/black - rev: 22.10.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.7.1 hooks: - - id: black + - id: ruff + args: [ '--fix', '--select', 'I', '--select', 'F401' ] + - id: ruff-format - repo: https://github.com/PyCQA/docformatter - rev: v1.5.0 + rev: eb1df34 hooks: - id: docformatter - # these can't be pulled directly from the config atm, not sure why - args: ["-i", "--wrap-summaries=88", "--wrap-descriptions=88", - "--pre-summary-newline", "--make-summary-multi-line"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.4 + rev: v4.0.0-alpha.8 hooks: - id: prettier types_or: [ javascript, vue, less, sass, scss, css ] diff --git a/pyproject.toml b/pyproject.toml index 23ea8ea..f0a9408 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,8 @@ classifiers = [ ] dependencies = [ "ckanext-versioned-datastore>=3.7.0", - "ckantools>=0.3.0", - "cachetools>=4.2.4" + "cachetools>=4.2.4", + "ckantools>=0.4.1" ] [project.optional-dependencies] @@ -66,9 +66,8 @@ version_files = [ "CITATION.cff:^version" ] -[tool.black] -line-length = 88 -skip_string_normalization = true +[tool.ruff.format] +quote-style = "single" [tool.pylint] max-line-length = 88 From 68b410f3ee3f5baf0f9e26070301375c4ebc89bc Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:45:27 +0000 Subject: [PATCH 04/13] chore: update tool details in contributing guide --- CONTRIBUTING.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97f833c..08e8762 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ This extension and [several others](https://github.com/search?q=topic:ckan+org:N The current core team consists of: - Josh ([@jrdh](https://github.com/jrdh)) - Technical Lead -- Ginger ([@alycejenni](https://github.com/alycejenni)) - Software Engineer +- Ginger ([@alycejenni](https://github.com/alycejenni)) - Senior Software Engineer ## Questions @@ -81,7 +81,10 @@ The process is generally as follows: 3. Make your changes, and commit often; each commit should only contain one change. See below for specifics on how to word your commits. 4. Push your changes back to your fork. 5. [Open a pull request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects#making-a-pull-request) in this repository, with the base branch set to **dev** and the compare branch set to your new branch. Provide a summary of your changes in the description. -6. If the automatic tests fail (these may take a while), please go back to your code and try to make them pass. You may have to update the tests themselves. You don't have to close the pull request while you're doing this; it'll update as you add further commits. +6. There are several automated checks that will run when you open the pull request. Try to make all of them pass. If you do not at least _attempt_ to make them pass, we will not merge your pull request. + 1. Tests. Update them so that they pass, if necessary. New tests are always welcome in any pull request, but if you have added a new feature that has decreased the coverage, new tests are required. + 2. Commit format validation. If you have not followed the conventional commits format for one or more of your commits, this will fail. + 3. Code format validation. If you have not formatted your code correctly (using Ruff, docformatter, and/or Prettier), this will fail. 7. Wait for feedback from one of the core maintainers. If it's been a week or so and we haven't responded, we may not have seen it. You can find other places to contact us in [SUPPORT.md](./.github/SUPPORT.md). ### Commits @@ -142,9 +145,9 @@ cz c ##### pre-commit -pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the [.pre-commit-config.yaml](./.pre-commit-config.yaml) file to see eaxtly what it's currently configured to do for this repository, but of particular note: +pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the [.pre-commit-config.yaml](./.pre-commit-config.yaml) file to see exactly what it's currently configured to do for this repository, but of particular note: -- reformats Python code with [Black](https://github.com/psf/black) +- reformats Python code with [Ruff](https://docs.astral.sh/ruff) - reformats JavaScript and stylesheets with [Prettier](https://prettier.io) - reformats docstrings with [docformatter](https://github.com/PyCQA/docformatter) - checks your commit message is correcly formatted @@ -161,15 +164,15 @@ pre-commit run Don't forget to stage any modifications that it makes! Once it runs without failing, then you can make your commit. -Something to remember is that empty docstrings will cause conflicts between Black and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty! +Something to remember is that empty docstrings will cause conflicts between Ruff and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty! ### Code changes and style guide -We generally use external style guides and tools to help us maintain standardised code. Black and Prettier will be run with pre-commit. +We generally use external style guides and tools to help us maintain standardised code. Ruff and Prettier will be run with pre-commit. #### Python -We follow the [Black style](https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html), with the notable exception that we use single quotes. +We use [Ruff](https://docs.astral.sh/ruff) to format our code, using defaults for everything except quote style (we use single quotes). We also _mostly_ use [CKAN's style](http://docs.ckan.org/en/latest/contributing/python.html), with the following exceptions: - prefer `f''` strings over `.format()` @@ -178,7 +181,7 @@ We also _mostly_ use [CKAN's style](http://docs.ckan.org/en/latest/contributing/ #### JavaScript and stylesheets (CSS, LESS, etc) -We use [Prettier](https://prettier.io) to format these files. +We use [Prettier](https://prettier.io) to format these files. As with Ruff, we use defaults for everything except quote style (we use single quotes). #### Accessibility From e9d66baefb03431406deba6066c61058f39e6912 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:45:33 +0000 Subject: [PATCH 05/13] chore: add pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..b8db874 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,4 @@ +- [ ] I have read the [section on commits and pull requests](https://github.com/NaturalHistoryMuseum/ckanext-versioned-tiledmap/blob/main/CONTRIBUTING.md#commits-and-pull-requests) in `CONTRIBUTING.md` + + +Describe your changes, tagging relevant issues where possible. From 4f15e9650122ad89de655404e4645c13028600c7 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Tue, 29 Oct 2024 17:45:43 +0000 Subject: [PATCH 06/13] build: remove version from docker compose file version specifier is deprecated --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 25e046e..c62cb6e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: ckan: build: From 4cc5eece9cc22bfda8dfb07842e98ee471999408 Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Wed, 30 Oct 2024 12:46:56 +0000 Subject: [PATCH 07/13] ci: only apply auto-fixes in pre-commit F401 returns linting errors as well as auto-fixes, so this disables the errors and just applies the fixes --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 728e347..cd0f8b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: rev: v0.7.1 hooks: - id: ruff - args: [ '--fix', '--select', 'I', '--select', 'F401' ] + args: [ '--fix', '--select', 'I', '--select', 'F401', '--fix-only' ] - id: ruff-format - repo: https://github.com/PyCQA/docformatter rev: eb1df34 From 30d40c5d3568e11ad2e45bd3f65d33ba8f80ef85 Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Wed, 30 Oct 2024 14:51:51 +0000 Subject: [PATCH 08/13] ci: add docformatter args and dependency docformatter currently can't read from pyproject.toml without tomli --- .pre-commit-config.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd0f8b7..04e9d79 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,14 +7,14 @@ repos: - id: detect-private-key - id: end-of-file-fixer - id: name-tests-test - args: ["--pytest-test-first"] + args: ['--pytest-test-first'] exclude: ^tests/helpers/ - id: trailing-whitespace - repo: https://github.com/commitizen-tools/commitizen rev: v3.30.0 hooks: - id: commitizen - additional_dependencies: ["cz-nhm"] + additional_dependencies: ['cz-nhm'] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.7.1 hooks: @@ -25,6 +25,8 @@ repos: rev: eb1df34 hooks: - id: docformatter + args: [ '-i', '--config', './pyproject.toml' ] + additional_dependencies: ['tomli'] - repo: https://github.com/pre-commit/mirrors-prettier rev: v4.0.0-alpha.8 hooks: From 808c845011894cce423c8fde34f3ebe0c68b96d3 Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Wed, 30 Oct 2024 17:31:46 +0000 Subject: [PATCH 09/13] style: automatic reformat auto reformat with ruff/docformatter/prettier after config changes --- ckanext/tiledmap/lib/helpers.py | 9 ++--- ckanext/tiledmap/lib/utils.py | 7 ++-- ckanext/tiledmap/lib/validators.py | 9 ++--- ckanext/tiledmap/plugin.py | 11 +++--- ckanext/tiledmap/routes/_helpers.py | 37 +++++++++++--------- ckanext/tiledmap/routes/map.py | 2 +- ckanext/tiledmap/theme/assets/less/maps.less | 10 ++++-- docs/_scripts/gen_api_pages.py | 1 - tests/test_helpers.py | 2 +- tests/test_route_helpers.py | 2 +- tests/test_utils.py | 3 +- tests/test_validators.py | 4 ++- 12 files changed, 57 insertions(+), 40 deletions(-) diff --git a/ckanext/tiledmap/lib/helpers.py b/ckanext/tiledmap/lib/helpers.py index 8399676..d481a31 100644 --- a/ckanext/tiledmap/lib/helpers.py +++ b/ckanext/tiledmap/lib/helpers.py @@ -12,11 +12,12 @@ def mustache_wrapper(s): def dwc_field_title(field): - ''' + """ Convert a DwC field name into a label - split on uppercase - @param field: - @return: str label - ''' + + :param field: + :returns: str label + """ title = re.sub('([A-Z]+)', r' \1', field) title = f'{title[0].upper()}{title[1:]}' return title diff --git a/ckanext/tiledmap/lib/utils.py b/ckanext/tiledmap/lib/utils.py index c94a3e1..24ff3b1 100644 --- a/ckanext/tiledmap/lib/utils.py +++ b/ckanext/tiledmap/lib/utils.py @@ -4,9 +4,10 @@ # This file is part of a project # Created by the Natural History Museum in London, UK -from ckan.plugins import toolkit import urllib.request -from cachetools import cached, TTLCache + +from cachetools import TTLCache, cached +from ckan.plugins import toolkit def get_resource_datastore_fields(resource_id): @@ -32,4 +33,4 @@ def get_tileserver_status(): else: tileserver_response_text = 'unavailable' - return tileserver_response_text \ No newline at end of file + return tileserver_response_text diff --git a/ckanext/tiledmap/lib/validators.py b/ckanext/tiledmap/lib/validators.py index bfb0097..0666c47 100644 --- a/ckanext/tiledmap/lib/validators.py +++ b/ckanext/tiledmap/lib/validators.py @@ -7,6 +7,7 @@ import re from ckan.plugins import toolkit + from ckanext.tiledmap.lib.utils import get_resource_datastore_fields @@ -16,7 +17,7 @@ def colour_validator(value, context): :param value: the value to validate :param context: the context within which this validation is taking place - :return: the validated value + :returns: the validated value """ if re.match('^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$', value): if value[0] != '#': @@ -38,7 +39,7 @@ def float_01_validator(value, context): :param value: the value :param context: the context within which this validation is taking place - :return: the validated value + :returns: the validated value """ try: value = float(value) @@ -55,7 +56,7 @@ def is_datastore_field(value, context): :param value: the value to validate :param context: the context within which this validation is taking place - :return: the value + :returns: the value """ passed_fields = value if isinstance(value, list) else [value] fields = get_resource_datastore_fields(toolkit.g.resource['id']) @@ -71,7 +72,7 @@ def is_view_id(value, context): :param value: the value to validate :param context: the context within which this validation is taking place - :return: the value + :returns: the value """ if value: data = {'id': toolkit.g.resource['id']} diff --git a/ckanext/tiledmap/plugin.py b/ckanext/tiledmap/plugin.py index 29dcffe..0467897 100755 --- a/ckanext/tiledmap/plugin.py +++ b/ckanext/tiledmap/plugin.py @@ -4,15 +4,18 @@ # This file is part of a project # Created by the Natural History Museum in London, UK + from ckan.common import json -from ckan.plugins import toolkit, implements, interfaces, SingletonPlugin +from ckan.plugins import SingletonPlugin, implements, interfaces, toolkit from ckanext.tiledmap import routes from ckanext.tiledmap.config import config as plugin_config from ckanext.tiledmap.lib import validators -from ckanext.tiledmap.lib.helpers import mustache_wrapper, dwc_field_title -from ckanext.tiledmap.lib.utils import get_resource_datastore_fields, get_tileserver_status -import urllib.request +from ckanext.tiledmap.lib.helpers import dwc_field_title, mustache_wrapper +from ckanext.tiledmap.lib.utils import ( + get_resource_datastore_fields, + get_tileserver_status, +) try: from ckanext.status.interfaces import IStatus diff --git a/ckanext/tiledmap/routes/_helpers.py b/ckanext/tiledmap/routes/_helpers.py index a5dcfac..ce55cd0 100644 --- a/ckanext/tiledmap/routes/_helpers.py +++ b/ckanext/tiledmap/routes/_helpers.py @@ -12,6 +12,7 @@ from ckan.common import json from ckan.plugins import toolkit + from ckanext.tiledmap.config import config @@ -21,12 +22,12 @@ class MapViewSettings: """ def __init__(self, fetch_id, view, resource): - ''' + """ :param fetch_id: the id of the request, as provided by the javascript module. This is used to keep track on the javascript side of the order map-info requests. :param view: the view dict :param resource: the resource dict - ''' + """ self.fetch_id = fetch_id self.view = view self.resource = resource @@ -73,7 +74,7 @@ def is_enabled(self): Returns True if at least one of the map styles (plot, grid, heat) is enabled. If none of them are, returns False. - :return: True if one map style is enabled, False if none are + :returns: True if one map style is enabled, False if none are """ return self.plot_map_enabled or self.grid_map_enabled or self.heat_map_enabled @@ -85,7 +86,7 @@ def _render_template(self, name, extra_vars): :param name: the name of the template :param extra_vars: a dict of variables to pass to the template renderer - :return: a rendered template + :returns: a rendered template """ # this is the base name of the template, if there's no format version available then we'll # just return this @@ -105,7 +106,7 @@ def render_info_template(self): """ Renders the point info template and returns the result. - :return: the rendered point info template + :returns: the rendered point info template """ return self._render_template( config['versioned_tilemap.info_template'], @@ -120,7 +121,7 @@ def render_quick_info_template(self): """ Renders the point hover info template and returns the result. - :return: the rendered point hover info template + :returns: the rendered point hover info template """ return self._render_template( config['versioned_tilemap.quick_info_template'], @@ -137,9 +138,9 @@ def get_style_params(self, style, names): retrieved from the config object. :param style: the name of the style (plot, gridded or heatmap) - :param names: the names of the parameters to retrieve, these are also used as the names in - the dict that the parameter values are stored under - :return: a dict + :param names: the names of the parameters to retrieve, these are also used as + the names in the dict that the parameter values are stored under + :returns: a dict """ params = {} for name in names: @@ -161,7 +162,7 @@ def get_extent_info(self): (e.g. [[0, 4], [70, 71]]). This is how it is returned by the datastore_query_extent action. - :return: a 3-tuple - (int, int, list) + :returns: a 3-tuple - (int, int, list) """ q, filters = extract_q_and_filters() # get query extent and counts @@ -199,7 +200,7 @@ def get_query_body(self): - the query body is then sent along with all tile requests to the tile server, which decompresses it and uses it to search elasticsearch - :return: a url safe base64 encoded, gzipped, JSON string + :returns: a url safe base64 encoded, gzipped, JSON string """ q, filters = extract_q_and_filters() result = toolkit.get_action('datastore_search')( @@ -220,7 +221,7 @@ def create_map_info(self): Using the settings available on this object, create the /map-info response dict and return it. - :return: a dict + :returns: a dict """ # get the standard map info dict (this provides a fresh one each time it's called) map_info = get_base_map_info() @@ -324,7 +325,7 @@ def build_url(*parts): Given a bunch of parts, build a URL by joining them together with a /. :param parts: the URL parts - :return: a URL string + :returns: a URL string """ return '/'.join(part.strip('/') for part in parts) @@ -334,7 +335,8 @@ def extract_q_and_filters(): Extract the q and filters query string parameters from the request. These are standard parameters in the resource views and have a standardised format too. - :return: a 2-tuple of the q value (string, or None) and the filters value (dict, or None) + :returns: a 2-tuple of the q value (string, or None) and the filters value (dict, or + None) """ # get the query if there is one q = ( @@ -364,10 +366,11 @@ def get_base_map_info(): running CKAN instance (they use either always static values or ones that are pulled from the config which can are set on boot). - A few settings are missing, these are set in MapViewSettings.create_map_info as they require - custom per-map settings that the user has control over or are dependant on the target resource. + A few settings are missing, these are set in MapViewSettings.create_map_info as they + require custom per-map settings that the user has control over or are dependant on + the target resource. - :return: a dict of settings + :returns: a dict of settings """ png_url = build_url(config['versioned_tilemap.tile_server'], '/{z}/{x}/{y}.png') utf_grid_url = build_url( diff --git a/ckanext/tiledmap/routes/map.py b/ckanext/tiledmap/routes/map.py index 0182371..73f2af4 100644 --- a/ckanext/tiledmap/routes/map.py +++ b/ckanext/tiledmap/routes/map.py @@ -16,7 +16,7 @@ def info(): """ Returns metadata about a given map in JSON form. - :return: A JSON encoded string representing the metadata + :returns: A JSON encoded string representing the metadata """ view_settings = _helpers.MapViewSettings.from_request() diff --git a/ckanext/tiledmap/theme/assets/less/maps.less b/ckanext/tiledmap/theme/assets/less/maps.less index 17c2610..a6a72d6 100644 --- a/ckanext/tiledmap/theme/assets/less/maps.less +++ b/ckanext/tiledmap/theme/assets/less/maps.less @@ -51,7 +51,10 @@ div.tiled-map-info { .info { color: #555; padding: 6px 8px; - font: 14px/16px Arial, Helvetica, sans-serif; + font: + 14px/16px Arial, + Helvetica, + sans-serif; background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 15px rgba(0, 0, 0, 0.7); border-radius: 10px; @@ -62,7 +65,10 @@ div.tiled-map-info { .small-info { color: #555; padding: 6px 8px; - font: 14px/16px Arial, Helvetica, sans-serif; + font: + 14px/16px Arial, + Helvetica, + sans-serif; background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 15px rgba(0, 0, 0, 0.7); border-radius: 10px; diff --git a/docs/_scripts/gen_api_pages.py b/docs/_scripts/gen_api_pages.py index 583d9cf..554ab11 100644 --- a/docs/_scripts/gen_api_pages.py +++ b/docs/_scripts/gen_api_pages.py @@ -1,6 +1,5 @@ # !/usr/bin/env python # encoding: utf-8 - """ Generate the code reference pages and navigation. diff --git a/tests/test_helpers.py b/tests/test_helpers.py index f2f5a3d..604c87e 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,4 +1,4 @@ -from ckanext.tiledmap.lib.helpers import mustache_wrapper, dwc_field_title +from ckanext.tiledmap.lib.helpers import dwc_field_title, mustache_wrapper def test_mustache_wrapper(): diff --git a/tests/test_route_helpers.py b/tests/test_route_helpers.py index c1cb526..943fb03 100644 --- a/tests/test_route_helpers.py +++ b/tests/test_route_helpers.py @@ -1,5 +1,5 @@ from functools import wraps -from unittest.mock import patch, MagicMock +from unittest.mock import MagicMock, patch from ckanext.tiledmap.routes._helpers import extract_q_and_filters diff --git a/tests/test_utils.py b/tests/test_utils.py index bf36122..d7188ee 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ +from unittest.mock import MagicMock, patch + from ckanext.tiledmap.lib.utils import get_resource_datastore_fields -from unittest.mock import patch, MagicMock def test_get_resource_datastore_fields(): diff --git a/tests/test_validators.py b/tests/test_validators.py index a5cbba3..78ae594 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -1,12 +1,14 @@ +from unittest.mock import MagicMock, patch + import pytest from ckan.plugins import toolkit + from ckanext.tiledmap.lib.validators import ( colour_validator, float_01_validator, is_datastore_field, is_view_id, ) -from unittest.mock import MagicMock, patch def test_colour_validator(): From 94b6b4b2c23b0fe9bab865edc78a4adeb49ef97e Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Mon, 4 Nov 2024 09:50:06 +0000 Subject: [PATCH 10/13] ci: add merge to valid commit types --- .github/workflows/pull-requests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index b9aa2bd..134e108 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -14,7 +14,7 @@ jobs: - name: Check commit message format uses: webiny/action-conventional-commits@v1.3.0 with: - allowed-commit-types: 'feat,fix,refactor,perf,docs,style,test,build,ci,chore,new,patch,revert,ui' + allowed-commit-types: 'feat,fix,refactor,perf,docs,style,test,build,ci,chore,new,patch,revert,ui,merge' pre-commit: name: Run pre-commit checks runs-on: ubuntu-latest From fbbf331bb1d3a8e87baa1b22978aea54ce1731b6 Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Mon, 4 Nov 2024 10:08:26 +0000 Subject: [PATCH 11/13] ci: fix python setup action version --- .github/workflows/pypi-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index d3ac620..bf30290 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -19,7 +19,7 @@ jobs: token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@5 + uses: actions/setup-python@v5 - name: Install dependencies run: | python -m pip install --upgrade pip From 8aa0253b7d7b278098c9c0d0e90298327f2438e2 Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Mon, 4 Nov 2024 11:18:21 +0000 Subject: [PATCH 12/13] docs: fix tests badge tests workflow file was renamed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1d5472..203910d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # ckanext-versioned-tiledmap -[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-versioned-tiledmap/main.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-versioned-tiledmap/actions/workflows/main.yml) +[![Tests](https://img.shields.io/github/actions/workflow/status/NaturalHistoryMuseum/ckanext-versioned-tiledmap/tests.yml?style=flat-square)](https://github.com/NaturalHistoryMuseum/ckanext-versioned-tiledmap/actions/workflows/tests.yml) [![Coveralls](https://img.shields.io/coveralls/github/NaturalHistoryMuseum/ckanext-versioned-tiledmap/main?style=flat-square)](https://coveralls.io/github/NaturalHistoryMuseum/ckanext-versioned-tiledmap) [![CKAN](https://img.shields.io/badge/ckan-2.9.7-orange.svg?style=flat-square)](https://github.com/ckan/ckan) [![Python](https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8-blue.svg?style=flat-square)](https://www.python.org/) From 76290288f78c6328831d15a3e87e150e2bcab73e Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Mon, 4 Nov 2024 11:24:29 +0000 Subject: [PATCH 13/13] docs: use variable logo based on colour scheme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 203910d..10c4858 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ - + + + + The Natural History Museum logo. + # ckanext-versioned-tiledmap