Skip to content

Commit d3e3d54

Browse files
author
dsamaey
committed
Revert "Issue #747 please the linter (ran pre-commit on all)"
This reverts commit bc54f00.
1 parent bc54f00 commit d3e3d54

File tree

9 files changed

+39
-61
lines changed

9 files changed

+39
-61
lines changed

docs/conf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
# All configuration values have a default; values that are commented out
1414
# serve to show the default.
1515

16-
import datetime
17-
1816
# If extensions (or modules to document with autodoc) are in another directory,
1917
# add these directories to sys.path here. If the directory is relative to the
2018
# documentation root, use os.path.abspath to make it absolute, like shown here.
2119
#
2220
import os
2321
import sys
22+
import datetime
2423

2524
sys.path.insert(0, os.path.abspath('.'))
2625
sys.path.insert(0, os.path.abspath('../'))
@@ -45,7 +44,6 @@
4544
]
4645

4746
import sphinx_autodoc_typehints
48-
4947
# Add any paths that contain templates here, relative to this directory.
5048
templates_path = ['_templates']
5149

docs/cookbook/sampling.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ but rather want to extract a result at specific locations.
66
Examples include extracting training data for model calibration, or computing the result for
77
areas where validation data is available.
88

9-
An important constraint is that most implementations assume that sampling is an operation
10-
on relatively small areas, of for instance up to 512x512 pixels (but often much smaller).
9+
An important constraint is that most implementations assume that sampling is an operation
10+
on relatively small areas, of for instance up to 512x512 pixels (but often much smaller).
1111
When extracting polygons with larger areas, it is recommended to look into running a separate job per 'sample'.
12-
Some more important performance notices are mentioned later in the chapter, please read them carefully
12+
Some more important performance notices are mentioned later in the chapter, please read them carefully
1313
to get best results.
1414

1515
Sampling can be done for points or polygons:
@@ -23,9 +23,9 @@ public url, and to load it in openEO using {py:meth}`openeo.rest.connection.Conn
2323

2424
## Sampling at point locations
2525

26-
To sample point locations, the `openeo.rest.datacube.DataCube.aggregate_spatial` method can be used. The reducer can be a
26+
To sample point locations, the `openeo.rest.datacube.DataCube.aggregate_spatial` method can be used. The reducer can be a
2727
commonly supported reducer like `min`, `max` or `mean` and will receive only one value as input in most cases. Note that
28-
in edge cases, a point can intersect with up to 4 pixels. If this is not desirable, it might be worth trying to align
28+
in edge cases, a point can intersect with up to 4 pixels. If this is not desirable, it might be worth trying to align
2929
points with pixel centers, which does require more advanced knowledge of the pixel grid of your data cube.
3030

3131
More information on `aggregate_spatial` is available [here](_aggregate-spatial-evi).

examples/archive/udf/udf_modify_spatial.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import numpy as np
21
import xarray
3-
4-
from openeo.metadata import CollectionMetadata
52
from openeo.udf import XarrayDataCube
63
from openeo.udf.debug import inspect
7-
4+
from openeo.metadata import CollectionMetadata
5+
import numpy as np
86

97
def apply_metadata(input_metadata:CollectionMetadata, context:dict) -> CollectionMetadata:
108

@@ -43,4 +41,4 @@ def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
4341
predicted_cube = xarray.DataArray(predicted_array, dims=['bands', 'x', 'y'], coords=dict(x=coord_x, y=coord_y))
4442

4543

46-
return XarrayDataCube(predicted_cube)
44+
return XarrayDataCube(predicted_cube)

openeo/extra/job_management/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -673,20 +673,20 @@ def _cancel_prolonged_job(self, job: BatchJob, row):
673673
try:
674674
# Ensure running start time is valid
675675
job_running_start_time = rfc3339.parse_datetime(row.get("running_start_time"), with_timezone=True)
676-
676+
677677
# Parse the current time into a datetime object with timezone info
678678
current_time = rfc3339.parse_datetime(rfc3339.utcnow(), with_timezone=True)
679679

680680
# Calculate the elapsed time between job start and now
681681
elapsed = current_time - job_running_start_time
682682

683683
if elapsed > self._cancel_running_job_after:
684-
684+
685685
_log.info(
686686
f"Cancelling long-running job {job.job_id} (after {elapsed}, running since {job_running_start_time})"
687687
)
688688
job.stop()
689-
689+
690690
except Exception as e:
691691
_log.error(f"Unexpected error while handling job {job.job_id}: {e}")
692692

openeo/extra/job_management/stac_job_db.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(
5353

5454
def exists(self) -> bool:
5555
return any(c.id == self.collection_id for c in self.client.get_collections())
56-
56+
5757
def _normalize_df(self, df: pd.DataFrame) -> pd.DataFrame:
5858
"""
5959
Normalize the given dataframe to be compatible with :py:class:`MultiBackendJobManager`

openeo/processes.py

+17-34
Original file line numberDiff line numberDiff line change
@@ -2867,8 +2867,7 @@ def aggregate_spatial(data, geometries, reducer, target_dimension=UNSET, context
28672867
aggregated values (i.e. no-data). The spatial dimensions are replaced by a dimension of type 'geometries'
28682868
and if `target_dimension` is not `null`, a new dimension is added.
28692869
"""
2870-
return _process(
2871-
"aggregate_spatial",
2870+
return _process('aggregate_spatial',
28722871
data=data,
28732872
geometries=geometries,
28742873
reducer=build_child_callback(reducer, parent_parameters=['data', 'context']),
@@ -2904,8 +2903,7 @@ def aggregate_spatial_window(data, reducer, size, boundary=UNSET, align=UNSET, c
29042903
labels will be set to the coordinate at the center of the window. The other dimension properties (name,
29052904
type and reference system) remain unchanged.
29062905
"""
2907-
return _process(
2908-
"aggregate_spatial_window",
2906+
return _process('aggregate_spatial_window',
29092907
data=data,
29102908
reducer=build_child_callback(reducer, parent_parameters=['data', 'context']),
29112909
size=size,
@@ -2944,8 +2942,7 @@ def aggregate_temporal(data, intervals, reducer, labels=UNSET, dimension=UNSET,
29442942
system and resolution) remain unchanged, except for the resolution and dimension labels of the given
29452943
temporal dimension.
29462944
"""
2947-
return _process(
2948-
"aggregate_temporal",
2945+
return _process('aggregate_temporal',
29492946
data=data,
29502947
intervals=intervals,
29512948
reducer=build_child_callback(reducer, parent_parameters=['data', 'context']),
@@ -2999,8 +2996,7 @@ def aggregate_temporal_period(data, period, reducer, dimension=UNSET, context=UN
29992996
the source data cube has just one dimension label `2020-01-05`, the process returns a data cube with just a
30002997
single dimension label (`2020-005`).
30012998
"""
3002-
return _process(
3003-
"aggregate_temporal_period",
2999+
return _process('aggregate_temporal_period',
30043000
data=data,
30053001
period=period,
30063002
reducer=build_child_callback(reducer, parent_parameters=['data', 'context']),
@@ -3141,8 +3137,7 @@ def apply_dimension(data, process, dimension, target_dimension=UNSET, context=UN
31413137
incrementing integers starting from zero, - the resolution changes, and - the reference system is
31423138
undefined.
31433139
"""
3144-
return _process(
3145-
"apply_dimension",
3140+
return _process('apply_dimension',
31463141
data=data,
31473142
process=build_child_callback(process, parent_parameters=['data', 'context']),
31483143
dimension=dimension,
@@ -3200,8 +3195,7 @@ def apply_neighborhood(data, process, size, overlap=UNSET, context=UNSET) -> Pro
32003195
:return: A raster data cube with the newly computed values and the same dimensions. The dimension
32013196
properties (name, type, labels, reference system and resolution) remain unchanged.
32023197
"""
3203-
return _process(
3204-
"apply_neighborhood",
3198+
return _process('apply_neighborhood',
32053199
data=data,
32063200
process=build_child_callback(process, parent_parameters=['data', 'context']),
32073201
size=size,
@@ -3230,8 +3224,7 @@ def apply_polygon(data, polygons, process, mask_value=UNSET, context=UNSET) -> P
32303224
:return: A data cube with the newly computed values and the same dimensions. The dimension properties
32313225
(name, type, labels, reference system and resolution) remain unchanged.
32323226
"""
3233-
return _process(
3234-
"apply_polygon",
3227+
return _process('apply_polygon',
32353228
data=data,
32363229
polygons=polygons,
32373230
process=build_child_callback(process, parent_parameters=['data', 'context']),
@@ -3325,8 +3318,7 @@ def ard_normalized_radar_backscatter(data, elevation_model=UNSET, contributing_a
33253318
DEM-based local incidence angles in degrees. The data returned is CARD4L compliant with corresponding
33263319
metadata.
33273320
"""
3328-
return _process(
3329-
"ard_normalized_radar_backscatter",
3321+
return _process('ard_normalized_radar_backscatter',
33303322
data=data,
33313323
elevation_model=elevation_model,
33323324
contributing_area=contributing_area,
@@ -3381,8 +3373,7 @@ def ard_surface_reflectance(data, atmospheric_correction_method, cloud_detection
33813373
(optional): Contains coefficients used for terrain illumination correction are provided for each pixel.
33823374
The data returned is CARD4L compliant with corresponding metadata.
33833375
"""
3384-
return _process(
3385-
"ard_surface_reflectance",
3376+
return _process('ard_surface_reflectance',
33863377
data=data,
33873378
atmospheric_correction_method=atmospheric_correction_method,
33883379
cloud_detection_method=cloud_detection_method,
@@ -3422,8 +3413,7 @@ def array_apply(data, process, context=UNSET) -> ProcessBuilder:
34223413
:return: An array with the newly computed values. The number of elements are the same as for the original
34233414
array.
34243415
"""
3425-
return _process(
3426-
"array_apply",
3416+
return _process('array_apply',
34273417
data=data,
34283418
process=build_child_callback(process, parent_parameters=['x', 'index', 'label', 'context']),
34293419
context=context
@@ -3513,8 +3503,7 @@ def array_filter(data, condition, context=UNSET) -> ProcessBuilder:
35133503
:return: An array filtered by the specified condition. The number of elements are less than or equal
35143504
compared to the original array.
35153505
"""
3516-
return _process(
3517-
"array_filter",
3506+
return _process('array_filter',
35183507
data=data,
35193508
condition=build_child_callback(condition, parent_parameters=['x', 'index', 'label', 'context']),
35203509
context=context
@@ -4067,8 +4056,7 @@ def filter_labels(data, condition, dimension, context=UNSET) -> ProcessBuilder:
40674056
system and resolution) remain unchanged, except that the given dimension has less (or the same) dimension
40684057
labels.
40694058
"""
4070-
return _process(
4071-
"filter_labels",
4059+
return _process('filter_labels',
40724060
data=data,
40734061
condition=build_child_callback(condition, parent_parameters=['value', 'context']),
40744062
dimension=dimension,
@@ -4168,8 +4156,7 @@ def fit_curve(data, parameters, function, ignore_nodata=UNSET) -> ProcessBuilder
41684156
41694157
:return: An array with the optimal values for the parameters.
41704158
"""
4171-
return _process(
4172-
"fit_curve",
4159+
return _process('fit_curve',
41734160
data=data,
41744161
parameters=parameters,
41754162
function=build_child_callback(function, parent_parameters=['x', 'parameters']),
@@ -4717,8 +4704,7 @@ def merge_cubes(cube1, cube2, overlap_resolver=UNSET, context=UNSET) -> ProcessB
47174704
:return: The merged data cube. See the process description for details regarding the dimensions and
47184705
dimension properties (name, type, labels, reference system and resolution).
47194706
"""
4720-
return _process(
4721-
"merge_cubes",
4707+
return _process('merge_cubes',
47224708
cube1=cube1,
47234709
cube2=cube2,
47244710
overlap_resolver=(build_child_callback(overlap_resolver, parent_parameters=['x', 'y', 'context']) if overlap_resolver not in [None, UNSET] else overlap_resolver),
@@ -4917,8 +4903,7 @@ def predict_curve(parameters, function, dimension, labels=UNSET) -> ProcessBuild
49174903
:return: A data cube with the predicted values with the provided dimension `dimension` having as many
49184904
labels as provided through `labels`.
49194905
"""
4920-
return _process(
4921-
"predict_curve",
4906+
return _process('predict_curve',
49224907
parameters=parameters,
49234908
function=build_child_callback(function, parent_parameters=['x', 'parameters']),
49244909
dimension=dimension,
@@ -5009,8 +4994,7 @@ def reduce_dimension(data, reducer, dimension, context=UNSET) -> ProcessBuilder:
50094994
dimensions decreases by one. The dimension properties (name, type, labels, reference system and resolution)
50104995
for all other dimensions remain unchanged.
50114996
"""
5012-
return _process(
5013-
"reduce_dimension",
4997+
return _process('reduce_dimension',
50144998
data=data,
50154999
reducer=build_child_callback(reducer, parent_parameters=['data', 'context']),
50165000
dimension=dimension,
@@ -5241,8 +5225,7 @@ def sar_backscatter(data, coefficient=UNSET, elevation_model=UNSET, mask=UNSET,
52415225
:return: Backscatter values corresponding to the chosen parametrization. The values are given in linear
52425226
scale.
52435227
"""
5244-
return _process(
5245-
"sar_backscatter",
5228+
return _process('sar_backscatter',
52465229
data=data,
52475230
coefficient=coefficient,
52485231
elevation_model=elevation_model,

openeo/rest/job.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
import datetime
44
import json
55
import logging
6-
import shutil
76
import time
87
import typing
98
from pathlib import Path
109
from typing import Dict, List, Optional, Union
1110

1211
import requests
12+
import shutil
1313

1414
from openeo.internal.documentation import openeo_endpoint
15-
from openeo.internal.jupyter import VisualDict, render_component, render_error
15+
from openeo.internal.jupyter import (
16+
VisualDict,
17+
render_component,
18+
render_error,
19+
)
1620
from openeo.internal.warnings import deprecated, legacy_alias
1721
from openeo.rest import (
1822
DEFAULT_DOWNLOAD_CHUNK_SIZE,

tests/internal/processes/test_generator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def apply_dimension(data, dimension, process):
284284
285285
:return: Data cube
286286
"""
287-
return _process('apply_dimension',
287+
return _process('apply_dimension',
288288
data=data,
289289
dimension=dimension,
290290
process=build_child_callback(process, parent_parameters=['data'])
@@ -332,7 +332,7 @@ def apply(data, process=UNSET):
332332
333333
:return: Data cube
334334
"""
335-
return _process('apply',
335+
return _process('apply',
336336
data=data,
337337
process=(build_child_callback(process, parent_parameters=['data']) if process not in [None, UNSET] else process)
338338
)'''

tests/rest/test_job.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212

1313
import openeo
1414
import openeo.rest.job
15-
from openeo.rest import (
16-
DEFAULT_DOWNLOAD_CHUNK_SIZE,
17-
JobFailedException,
18-
OpenEoApiPlainError,
19-
OpenEoClientException,
20-
)
15+
from openeo.rest import JobFailedException, OpenEoApiPlainError, OpenEoClientException, DEFAULT_DOWNLOAD_CHUNK_SIZE
2116
from openeo.rest.job import BatchJob, ResultAsset
2217
from openeo.rest.models.general import Link
2318
from openeo.rest.models.logs import LogEntry

0 commit comments

Comments
 (0)