Skip to content

Arcgis parameter dev#523

Draft
salabi wants to merge 16 commits intomainfrom
argis_parameter_dev
Draft

Arcgis parameter dev#523
salabi wants to merge 16 commits intomainfrom
argis_parameter_dev

Conversation

@salabi
Copy link
Copy Markdown

@salabi salabi commented Apr 13, 2026

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR improves ArcGIS fetch robustness by supporting configurable timeout, retries, and retry_backoff_seconds, and by logging which ArcGIS step failed thereby getting more successes in downloading arcgis data.

This PR also tightens and generalises plugin parameter handling around ArcGIS collection.
It extracts parameter validation into a shared utility at digital_land/utils/validate_parameter_utils.py, so plugins can define defaults and validation rules without duplicating validation code.

Tests were extended in tests/unit/test_collect.py to cover reusable validation behaviour, rejection of unknown parameters, ArcGIS default parameter expansion, and retry/failure logging.

Related Tickets & Documents

image

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above. Please refer to the Digital Land Testing Guidance for more information.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

[optional] Are there any dependencies on other PRs or Work?

@salabi salabi requested a review from eveleighoj April 13, 2026 08:47
Copy link
Copy Markdown
Contributor

@eveleighoj eveleighoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things to fix and a different approach for validation but I think it'll be worth it.

Worth reviewing the testing guidance here https://digital-land.github.io/technical-documentation/development/testing-guidance/

if there is stuff I've mentioned that isn't in there please add it in! the repo is here:

https://github.com/digital-land/technical-documentation

Comment thread digital_land/plugins/arcgis.py Outdated
except Exception as exception:
logging.warning(exception)
log["exception"] = type(exception).__name__
log["arcgis-step"] = "feature-iteration"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not alter the data in the log. the log is generic across all getters adding arcgis data in will confuse them.

This goes for further additions below as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

@@ -0,0 +1,40 @@
def positive_int(value, plugin_name, parameter_name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this and use pydantic dataclasses for validation, this removes the need for boilerplate validation. code and is easily expandable for other plugins moving forward.

dataclasses even offer validation for the parameters column in the future which I'm sure will come up.

you could even use the factory pattern instead of the if/else block in the Colector.fetch method.

you can just create a dataclass in the plugin file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been refactored into a dataclass with validation in it.
I have moved the validation into collect.py as discussed (params are validated when they are passed into get func) and made the validation generic for other plugins to use.

Comment thread tests/unit/test_collect.py Outdated
assert log["exception"] == "TypeError"


def test_arcgis_get_returns_no_partial_string_on_iteration_failure(monkeypatch):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests against. the arcgis_get function should. be in tests/unit/plugins/test_arcgis.py

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment thread tests/unit/test_collect.py Outdated
assert log["exception"] == "TypeError"


def test_arcgis_get_returns_no_partial_string_on_iteration_failure(monkeypatch):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pytest-mocker though the mocker fixture instead. it's already in the codebase and we should standardise mocking approaches

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

Copy link
Copy Markdown
Contributor

@eveleighoj eveleighoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly just a question around the expected behaviour and checking in with the product manager and data manager on how we want it to error under validation.

My thoughts are that if incorrect parameters are supplied then it should error but not exit the process.

Also you will need to rebase your changes on main as another PR has gone in

Comment thread digital_land/plugins/arcgis.py Outdated

content += "]}"
last_exception = None
for attempt in range(1, retries + 2):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retries is being used twice, both in the dumper and in our code through manual looping, do we need both?

Comment thread digital_land/collect.py Outdated
return FetchStatus.EXPIRED, None

if parameters is None:
parameters = {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to define the parameters as an empty dict here? can we just only validate if parameters aren't none otherwise pass none to the get function?

Comment thread digital_land/collect.py
Comment thread digital_land/collect.py Outdated
try:
parameters = json.loads(raw_parameters)
except json.JSONDecodeError as exc:
raise ValueError(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linked to the above but we want to think about what errors are being raised, a validation error that pydantic raises is more descriptive than a value error

Comment thread tests/unit/plugins/test_arcgis.py Outdated
from digital_land.plugins.arcgis import get as arcgis_get


def test_arcgis_get_returns_partial_string_on_iteration_failure(mocker, caplog):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny detasil but the function is called get not arcgis get, should be reflected in the tests

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

assert log["exception"] == "TypeError"


def test_fetch_passes_parameters_to_arcgis_plugin(collector, mocker):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as it's testing a method it should be inside a TestCollector class

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants