Skip to content

Commit 80614ae

Browse files
committed
make UdfRuntimes more minimal
and introduce temporary LegacyUdfRuntimes as default for now
1 parent 02854b3 commit 80614ae

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ and start a new "In Progress" section above it.
1919

2020
<!-- start-of-changelog -->
2121

22-
## In progress: 0.135.0
22+
## In progress: 0.136.0
23+
24+
- Start supporting custom `UdfRuntimes` implementation in `OpenEoBackendImplementation` ([#415](https://github.com/Open-EO/openeo-python-driver/issues/415))
25+
26+
27+
## 0.135.0
2328

2429
- Have `integrations.s3` for interaction with Object Storage that follows the S3 API.
2530
- `ElasticJobRegistry`: add support for pre-serialization of process graph ([Open-EO/openeo-geopyspark-driver#1232](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1232))

openeo_driver/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.136.0a1"
1+
__version__ = "0.136.0a2"

openeo_driver/backend.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,15 @@ def __str__(self):
772772

773773

774774
class UdfRuntimes(MicroService):
775-
# TODO: this implementation is highly openeo-geopyspark-driver-specific: move it to there and make this base implementation more abstract/simple
775+
def get_udf_runtimes(self) -> Dict[str, dict]:
776+
return {}
777+
778+
779+
class LegacyUdfRuntimes(UdfRuntimes):
780+
# TODO #415 this is a temporary adapter for backwards compatibility,
781+
# to allow migration of these implementation details to openeo-geopyspark-driver
782+
# (and openeo-aggregator).
783+
# To be removed when migration is done.
776784

777785
# Python libraries to list
778786
# TODO: move listing of non-generic libs to openeo-geopyspark-driver
@@ -795,7 +803,7 @@ class UdfRuntimes(MicroService):
795803
def __init__(self):
796804
pass
797805

798-
def get_python_versions(self):
806+
def _get_python_versions(self):
799807
# TODO: this assumes UDF runtime is equal to web app runtime, which is not true anymore.
800808
major, minor, patch = (str(v) for v in sys.version_info[:3])
801809
aliases = [
@@ -807,7 +815,7 @@ def get_python_versions(self):
807815
return major, aliases, default_version
808816

809817
def _get_python_udf_runtime_metadata(self):
810-
major, aliases, default_version = self.get_python_versions()
818+
major, aliases, default_version = self._get_python_versions()
811819
# TODO: get actual library version (instead of version of current environment).
812820
libraries = {
813821
p: {"version": v.split(" ", 1)[-1]}
@@ -875,7 +883,7 @@ def __init__(
875883
self.user_defined_processes = user_defined_processes
876884
self.user_files = None # TODO: implement user file storage microservice
877885
self.processing = processing
878-
self.udf_runtimes = udf_runtimes or UdfRuntimes()
886+
self.udf_runtimes = udf_runtimes or LegacyUdfRuntimes()
879887
self._conformance_classes = conformance_classes or self.DEFAULT_CONFORMANCE_CLASSES
880888

881889
# Overridable cache control header injecting decorator for static, public view functions

tests/test_backend.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import urllib.parse
33

44
import pytest
5+
import dirty_equals
56
from openeo.utils.version import ComparableVersion
67

78
from openeo_driver.backend import (
@@ -14,6 +15,7 @@
1415
UserDefinedProcessMetadata,
1516
is_not_implemented,
1617
not_implemented,
18+
LegacyUdfRuntimes,
1719
)
1820
from openeo_driver.errors import CollectionNotFoundException
1921
from openeo_driver.users import User
@@ -307,3 +309,28 @@ def test_next_parameters(self):
307309
],
308310
"links": [{"href": "https://oeo.test/jobs?offset=1234&state=foo", "rel": "next"}],
309311
}
312+
313+
314+
class TestLegacyUdfRuntimes:
315+
def test_get_udf_runtimes(self):
316+
runtimes = LegacyUdfRuntimes()
317+
assert runtimes.get_udf_runtimes() == dirty_equals.IsPartialDict(
318+
{
319+
"Python": dirty_equals.IsPartialDict(
320+
{
321+
"title": dirty_equals.IsStr(regex=".*Python.*"),
322+
"type": "language",
323+
"default": "3",
324+
"versions": dirty_equals.IsPartialDict(
325+
{
326+
"3": {
327+
"libraries": dirty_equals.IsPartialDict(
328+
{"numpy": {"version": dirty_equals.IsStr(regex=r"\d+\.\d+\.\d+")}}
329+
)
330+
},
331+
}
332+
),
333+
}
334+
)
335+
}
336+
)

0 commit comments

Comments
 (0)