Skip to content

Commit

Permalink
Refactoring of default job settings parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
kvantricht committed Jan 7, 2025
1 parent 85587cf commit a5622ff
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
36 changes: 18 additions & 18 deletions scripts/extractions/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def prepare_job_dataframe(
def setup_extraction_functions(
collection: ExtractionCollection,
extract_value: int,
memory: str,
python_memory: str,
max_executors: int,
memory: typing.Union[str, None],
python_memory: typing.Union[str, None],
max_executors: typing.Union[int, None],
) -> tuple[typing.Callable, typing.Callable, typing.Callable]:
"""Setup the datacube creation, path generation and post-job action
functions for the given collection. Returns a tuple of three functions:
Expand All @@ -158,33 +158,33 @@ def setup_extraction_functions(
datacube_creation = {
ExtractionCollection.PATCH_SENTINEL1: partial(
create_job_patch_s1,
executor_memory=memory,
python_memory=python_memory,
max_executors=max_executors,
executor_memory=memory if memory is not None else "1800m",
python_memory=python_memory if python_memory is not None else "1900m",
max_executors=max_executors if max_executors is not None else 22,
),
ExtractionCollection.PATCH_SENTINEL2: partial(
create_job_patch_s2,
executor_memory=memory,
python_memory=python_memory,
max_executors=max_executors,
executor_memory=memory if memory is not None else "1800m",
python_memory=python_memory if python_memory is not None else "1900m",
max_executors=max_executors if max_executors is not None else 22,
),
ExtractionCollection.PATCH_METEO: partial(
create_job_patch_meteo,
executor_memory=memory,
python_memory=python_memory,
max_executors=max_executors,
executor_memory=memory if memory is not None else "1800m",
python_memory=python_memory if python_memory is not None else "1000m",
max_executors=max_executors if max_executors is not None else 22,
),
ExtractionCollection.PATCH_WORLDCEREAL: partial(
create_job_patch_worldcereal,
executor_memory=memory,
python_memory=python_memory,
max_executors=max_executors,
executor_memory=memory if memory is not None else "1800m",
python_memory=python_memory if python_memory is not None else "3000m",
max_executors=max_executors if max_executors is not None else 22,
),
ExtractionCollection.POINT_WORLDCEREAL: partial(
create_job_point_worldcereal,
executor_memory=memory,
python_memory=python_memory,
max_executors=max_executors,
executor_memory=memory if memory is not None else "1800m",
python_memory=python_memory if python_memory is not None else "3000m",
max_executors=max_executors if max_executors is not None else 22,
),
}

Expand Down
10 changes: 5 additions & 5 deletions scripts/extractions/patch_extractions/extract_patch_meteo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def create_job_dataframe_patch_meteo(
def create_job_patch_meteo(
row: pd.Series,
connection: openeo.DataCube,
provider=None,
connection_provider=None,
executor_memory: str = "2G",
python_memory: str = "1G",
max_executors: int = 22,
provider,
connection_provider,
executor_memory: str,
python_memory: str,
max_executors: int,
) -> gpd.GeoDataFrame:
start_date = row.start_date
end_date = row.end_date
Expand Down
6 changes: 3 additions & 3 deletions scripts/extractions/patch_extractions/extract_patch_s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def create_job_patch_s1(
connection: openeo.DataCube,
provider,
connection_provider,
executor_memory: str = "5G",
python_memory: str = "2G",
max_executors: int = 22,
executor_memory: str,
python_memory: str,
max_executors: int,
) -> openeo.BatchJob:
"""Creates an OpenEO BatchJob from the given row information. This job is a
S1 patch of 32x32 pixels at 20m spatial resolution."""
Expand Down
10 changes: 5 additions & 5 deletions scripts/extractions/patch_extractions/extract_patch_s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def create_job_dataframe_patch_s2(
def create_job_patch_s2(
row: pd.Series,
connection: openeo.DataCube,
provider=None,
connection_provider=None,
executor_memory: str = "5G",
python_memory: str = "2G",
max_executors: int = 22,
provider,
connection_provider,
executor_memory: str,
python_memory: str,
max_executors: int,
) -> gpd.GeoDataFrame:
start_date = row.start_date
end_date = row.end_date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def create_job_patch_worldcereal(
connection: openeo.DataCube,
provider,
connection_provider,
executor_memory: str = "5G",
python_memory: str = "2G",
max_executors: int = 22,
executor_memory: str,
python_memory: str,
max_executors: int,
) -> openeo.BatchJob:
"""Creates an OpenEO BatchJob from the given row information."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def create_job_point_worldcereal(
connection: openeo.DataCube,
provider,
connection_provider,
executor_memory: str = "5G",
python_memory: str = "2G",
max_executors: int = 22,
executor_memory: str,
python_memory: str,
max_executors: int,
):
"""Creates an OpenEO BatchJob from the given row information."""

Expand Down

0 comments on commit a5622ff

Please sign in to comment.