Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for release #790

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: requirements-txt-fixer
Expand All @@ -13,18 +13,18 @@ repos:
- id: debug-statements

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.4.2
hooks:
- id: black
language_version: python3

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.11"
rev: "v0.4.4"
hooks:
- id: ruff

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
rev: 1.8.5
hooks:
- id: nbqa-black
- id: nbqa-ruff
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [Version 1.5.4] - 2024-05-13

- Minor fixes for documentation


## [Version 1.5.3] - 2024-01-10

- Fix `numpy<2` in anticipation of numpy 2.0 release.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def get_subclasses(cls):
module = "eolearn"

APIDOC_OPTIONS = ["--module-first", "--separate", "--no-toc", "--templatedir", os.path.join(current_dir, "_templates")]
APIDOC_EXCLUDE = ["graph.py", "eodata_io.py", "eodata_merge.py"]
APIDOC_EXCLUDE = ["graph.py", "eodata_io.py"]

shutil.rmtree(reference_dir, ignore_errors=True)
shutil.copytree(custom_reference_dir, reference_dir)
Expand Down
2 changes: 1 addition & 1 deletion eolearn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Main module of the `eolearn` package."""

__version__ = "1.5.3"
__version__ = "1.5.4"

import importlib.util
import warnings
Expand Down
2 changes: 1 addition & 1 deletion eolearn/core/eoexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(

@staticmethod
def _parse_and_validate_execution_kwargs(
execution_kwargs: Iterable[dict[EONode, dict[str, object]]]
execution_kwargs: Iterable[dict[EONode, dict[str, object]]],
) -> list[dict[EONode, dict[str, object]]]:
"""Parses and validates execution arguments provided by user and raises an error if something is wrong."""
for input_kwargs in execution_kwargs:
Expand Down
10 changes: 6 additions & 4 deletions eolearn/features/extra/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ def interpolate_data(self, data: np.ndarray, times: np.ndarray, resampled_times:

# array defining index correspondence between reference times and resampled times
min_time, max_time = np.min(resampled_times), np.max(resampled_times)
ori2res = np.array([
np.abs(resampled_times - orig_time).argmin() if min_time <= orig_time <= max_time else None
for orig_time in times
])
ori2res = np.array(
[
np.abs(resampled_times - orig_time).argmin() if min_time <= orig_time <= max_time else None
for orig_time in times
]
)

# find NaNs that start or end a time-series
row_nans, col_nans = np.where(self._get_start_end_nans(data))
Expand Down
2 changes: 1 addition & 1 deletion eolearn/io/sentinelhub_process.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Input tasks that collect data from `Sentinel-Hub Process API
"""Input tasks that collect data from `Sentinel-Hub Process API
<https://docs.sentinel-hub.com/api/latest/api/process/>`__

Copyright (c) 2017- Sinergise and contributors
Expand Down
20 changes: 11 additions & 9 deletions eolearn/visualization/eoexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,17 @@ def _get_node_descriptions(self) -> list[dict[str, Any]]:
f" usually {np.mean(durations):.4g} ± {np.std(durations):.4g} seconds"
)

descriptions.append({
"name": f"{node_name} ({node.uid})",
"uid": node.uid,
"args": {
key: value.replace("<", "&lt;").replace(">", "&gt;") # type: ignore[attr-defined]
for key, value in node.task.private_task_config.init_args.items()
},
"duration_report": duration_report,
})
descriptions.append(
{
"name": f"{node_name} ({node.uid})",
"uid": node.uid,
"args": {
key: value.replace("<", "&lt;").replace(">", "&gt;") # type: ignore[attr-defined]
for key, value in node.task.private_task_config.init_args.items()
},
"duration_report": duration_report,
}
)
return descriptions

def _render_execution_tracebacks(self, formatter: pygments.formatter.Formatter) -> list:
Expand Down
12 changes: 7 additions & 5 deletions examples/core/CoreOverview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,13 @@
}
],
"source": [
"results = workflow.execute({\n",
" load_node: {\"eopatch_folder\": \"TestEOPatch\"},\n",
" add_feature_node: {\"data\": np.zeros((68, 3), dtype=np.uint8)},\n",
" save_node: {\"eopatch_folder\": \"WorkflowEOPatch\"},\n",
"})\n",
"results = workflow.execute(\n",
" {\n",
" load_node: {\"eopatch_folder\": \"TestEOPatch\"},\n",
" add_feature_node: {\"data\": np.zeros((68, 3), dtype=np.uint8)},\n",
" save_node: {\"eopatch_folder\": \"WorkflowEOPatch\"},\n",
" }\n",
")\n",
"\n",
"results"
]
Expand Down
10 changes: 6 additions & 4 deletions examples/io/SentinelHubIO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,12 @@
"workflow_nodes = linearly_connect_tasks(input_task, add_indices, add_l2a_and_scl, add_dem, save, output_task)\n",
"workflow = EOWorkflow(workflow_nodes)\n",
"\n",
"result = workflow.execute({\n",
" workflow_nodes[0]: {\"bbox\": roi_bbox, \"time_interval\": time_interval},\n",
" workflow_nodes[-2]: {\"eopatch_folder\": \"eopatch\"},\n",
"})"
"result = workflow.execute(\n",
" {\n",
" workflow_nodes[0]: {\"bbox\": roi_bbox, \"time_interval\": time_interval},\n",
" workflow_nodes[-2]: {\"eopatch_folder\": \"eopatch\"},\n",
" }\n",
")"
]
},
{
Expand Down
34 changes: 20 additions & 14 deletions examples/land-cover-map/SI_LULC_pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,12 @@
"save_node = workflow_nodes[-1]\n",
"execution_args = []\n",
"for idx, bbox in enumerate(bbox_list[patch_ids]):\n",
" execution_args.append({\n",
" input_node: {\"bbox\": bbox, \"time_interval\": time_interval},\n",
" save_node: {\"eopatch_folder\": f\"eopatch_{idx}\"},\n",
" })\n",
" execution_args.append(\n",
" {\n",
" input_node: {\"bbox\": bbox, \"time_interval\": time_interval},\n",
" save_node: {\"eopatch_folder\": f\"eopatch_{idx}\"},\n",
" }\n",
" )\n",
"\n",
"# Execute the workflow\n",
"executor = EOExecutor(workflow, execution_args, save_logs=True)\n",
Expand Down Expand Up @@ -1329,11 +1331,13 @@
"\n",
"execution_args = []\n",
"for idx in range(len(patch_ids)):\n",
" execution_args.append({\n",
" workflow_nodes[0]: {\"eopatch_folder\": f\"eopatch_{idx}\"}, # load\n",
" workflow_nodes[-2]: {\"seed\": 42}, # sampling\n",
" workflow_nodes[-1]: {\"eopatch_folder\": f\"eopatch_{idx}\"}, # save\n",
" })\n",
" execution_args.append(\n",
" {\n",
" workflow_nodes[0]: {\"eopatch_folder\": f\"eopatch_{idx}\"}, # load\n",
" workflow_nodes[-2]: {\"seed\": 42}, # sampling\n",
" workflow_nodes[-1]: {\"eopatch_folder\": f\"eopatch_{idx}\"}, # save\n",
" }\n",
" )\n",
"\n",
"executor = EOExecutor(workflow, execution_args, save_logs=True)\n",
"executor.run(workers=5)\n",
Expand Down Expand Up @@ -2002,11 +2006,13 @@
"# Create a list of execution arguments for each patch\n",
"execution_args = []\n",
"for i in range(len(patch_ids)):\n",
" execution_args.append({\n",
" workflow_nodes[0]: {\"eopatch_folder\": f\"eopatch_{i}\"},\n",
" workflow_nodes[2]: {\"filename\": f\"{tiff_location}/prediction_eopatch_{i}.tiff\"},\n",
" workflow_nodes[3]: {\"eopatch_folder\": f\"eopatch_{i}\"},\n",
" })\n",
" execution_args.append(\n",
" {\n",
" workflow_nodes[0]: {\"eopatch_folder\": f\"eopatch_{i}\"},\n",
" workflow_nodes[2]: {\"filename\": f\"{tiff_location}/prediction_eopatch_{i}.tiff\"},\n",
" workflow_nodes[3]: {\"eopatch_folder\": f\"eopatch_{i}\"},\n",
" }\n",
" )\n",
"\n",
"# Run the executor\n",
"executor = EOExecutor(workflow, execution_args)\n",
Expand Down
8 changes: 5 additions & 3 deletions examples/water-monitor/WaterMonitorWorkflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,11 @@
"# The download task requires additional arguments at execution. These are linked to the node the task is in.\n",
"download_node = workflow_nodes[0]\n",
"\n",
"result = workflow.execute({\n",
" download_node: {\"bbox\": dam_bbox, \"time_interval\": time_interval},\n",
"})"
"result = workflow.execute(\n",
" {\n",
" download_node: {\"bbox\": dam_bbox, \"time_interval\": time_interval},\n",
" }\n",
")"
]
},
{
Expand Down
16 changes: 9 additions & 7 deletions tests/core/test_core_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@

@pytest.fixture(name="patch")
def patch_fixture() -> EOPatch:
patch = generate_eopatch({
FeatureType.DATA: ["bands", "CLP"],
FeatureType.MASK: ["CLM"],
FeatureType.MASK_TIMELESS: ["mask", "LULC", "RANDOM_UINT8"],
FeatureType.SCALAR: ["values", "CLOUD_COVERAGE"],
FeatureType.META_INFO: ["something"],
})
patch = generate_eopatch(
{
FeatureType.DATA: ["bands", "CLP"],
FeatureType.MASK: ["CLM"],
FeatureType.MASK_TIMELESS: ["mask", "LULC", "RANDOM_UINT8"],
FeatureType.SCALAR: ["values", "CLOUD_COVERAGE"],
FeatureType.META_INFO: ["something"],
}
)
patch.data["CLP_S2C"] = np.zeros_like(patch.data["CLP"])
return patch

Expand Down
28 changes: 16 additions & 12 deletions tests/core/test_eodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@

@pytest.fixture(name="mini_eopatch")
def mini_eopatch_fixture() -> EOPatch:
return generate_eopatch({
FeatureType.DATA: ["A", "B"],
FeatureType.MASK: ["C", "D"],
FeatureType.MASK_TIMELESS: ["E"],
FeatureType.META_INFO: ["beep"],
})
return generate_eopatch(
{
FeatureType.DATA: ["A", "B"],
FeatureType.MASK: ["C", "D"],
FeatureType.MASK_TIMELESS: ["E"],
FeatureType.META_INFO: ["beep"],
}
)


def test_numpy_feature_types() -> None:
Expand Down Expand Up @@ -382,12 +384,14 @@ def test_get_spatial_dimension(feature: Feature, expected_dim: tuple[int, int],
("patch", "expected_features"),
[
(
generate_eopatch({
FeatureType.DATA: ["A", "B"],
FeatureType.MASK: ["C", "D"],
FeatureType.MASK_TIMELESS: ["E"],
FeatureType.META_INFO: ["beep"],
}),
generate_eopatch(
{
FeatureType.DATA: ["A", "B"],
FeatureType.MASK: ["C", "D"],
FeatureType.MASK_TIMELESS: ["E"],
FeatureType.META_INFO: ["beep"],
}
),
[
(FeatureType.DATA, "A"),
(FeatureType.DATA, "B"),
Expand Down
16 changes: 9 additions & 7 deletions tests/core/test_eodata_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ def _silence_warnings_fixture():

@pytest.fixture(name="eopatch")
def eopatch_fixture():
eopatch = generate_eopatch({
FeatureType.DATA: ["data"],
FeatureType.MASK_TIMELESS: ["mask", "mask2"],
FeatureType.SCALAR: ["my scalar with spaces"],
FeatureType.SCALAR_TIMELESS: ["my timeless scalar with spaces"],
FeatureType.META_INFO: ["something", "something-else"],
})
eopatch = generate_eopatch(
{
FeatureType.DATA: ["data"],
FeatureType.MASK_TIMELESS: ["mask", "mask2"],
FeatureType.SCALAR: ["my scalar with spaces"],
FeatureType.SCALAR_TIMELESS: ["my timeless scalar with spaces"],
FeatureType.META_INFO: ["something", "something-else"],
}
)
eopatch.vector["my-df"] = GeoDataFrame(
{
"values": [1, 2],
Expand Down
14 changes: 8 additions & 6 deletions tests/core/test_utils/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ def test_allowed_feature_types_iterable(test_input: FeaturesSpecification, allow

@pytest.fixture(name="eopatch", scope="module")
def eopatch_fixture():
return generate_eopatch({
FeatureType.DATA: ["data", "CLP"],
FeatureType.MASK: ["data", "IS_VALID"],
FeatureType.MASK_TIMELESS: ["LULC"],
FeatureType.META_INFO: ["something"],
})
return generate_eopatch(
{
FeatureType.DATA: ["data", "CLP"],
FeatureType.MASK: ["data", "IS_VALID"],
FeatureType.MASK_TIMELESS: ["LULC"],
FeatureType.META_INFO: ["something"],
}
)


@pytest.mark.parametrize(
Expand Down
Loading