Skip to content

Commit 55c92d3

Browse files
committed
remove (now) unused ProcessSpec.to_dict_040 #47
1 parent b54daad commit 55c92d3

File tree

2 files changed

+0
-83
lines changed

2 files changed

+0
-83
lines changed

openeo_driver/processes.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ def returns(self, description: str, schema: dict) -> 'ProcessSpec':
6060
self._returns = {"description": description, "schema": schema}
6161
return self
6262

63-
def to_dict_040(self) -> dict:
64-
"""Generate process spec as (JSON-able) dictionary (API 0.4.0 style)."""
65-
# TODO #47 drop this
66-
if len(self._parameters) == 0:
67-
_log.debug("Process with no parameters")
68-
assert self._returns is not None
69-
return {**self.extra, **{
70-
"id": self.id,
71-
"description": self.description,
72-
"parameters": {
73-
p.name: {"description": p.description, "schema": p.schema, "required": p.required}
74-
for p in self._parameters
75-
},
76-
"parameter_order": [p.name for p in self._parameters],
77-
"returns": self._returns
78-
}}
79-
8063
def to_dict_100(self) -> dict:
8164
"""Generate process spec as (JSON-able) dictionary (API 1.0.0 style)."""
8265
if len(self._parameters) == 0:

tests/test_processes.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,6 @@
1515
from openeo_driver.processes import ProcessArgs, ProcessRegistry, ProcessRegistryException, ProcessSpec
1616

1717

18-
def test_process_spec_basic_040():
19-
spec = (
20-
ProcessSpec("mean", "Mean value")
21-
.param("input", "Input data", schema={"type": "array", "items": {"type": "number"}})
22-
.param("mask", "The mask", schema=ProcessSpec.RASTERCUBE, required=False)
23-
.returns("Mean value of data", schema={"type": "number"})
24-
)
25-
assert spec.to_dict_040() == {
26-
"id": "mean",
27-
"description": "Mean value",
28-
"parameters": {
29-
"input": {
30-
"description": "Input data",
31-
"required": True,
32-
"schema": {"type": "array", "items": {"type": "number"}}
33-
},
34-
"mask": {
35-
"description": "The mask",
36-
"required": False,
37-
"schema": {"type": "object", "format": "raster-cube"}
38-
}
39-
},
40-
"parameter_order": ["input", "mask"],
41-
"returns": {"description": "Mean value of data", "schema": {"type": "number"}},
42-
}
4318

4419

4520
def test_process_spec_basic_100():
@@ -70,19 +45,6 @@ def test_process_spec_basic_100():
7045
}
7146

7247

73-
def test_process_spec_no_params_040(caplog):
74-
caplog.set_level(logging.DEBUG)
75-
spec = ProcessSpec("foo", "bar").returns("output", schema={"type": "number"})
76-
assert spec.to_dict_040() == {
77-
"id": "foo",
78-
"description": "bar",
79-
"parameters": {},
80-
"parameter_order": [],
81-
"returns": {"description": "output", "schema": {"type": "number"}},
82-
}
83-
assert caplog.messages == ["Process with no parameters"]
84-
85-
8648
def test_process_spec_no_params_100(caplog):
8749
caplog.set_level(logging.DEBUG)
8850
spec = ProcessSpec("foo", "bar").returns("output", schema={"type": "number"})
@@ -269,34 +231,6 @@ def max(*args):
269231
}
270232

271233

272-
def test_process_registry_with_spec_040():
273-
reg = ProcessRegistry()
274-
275-
def add_function_with_spec(spec: ProcessSpec):
276-
def decorator(f):
277-
reg.add_function(f=f, spec=spec.to_dict_040())
278-
return f
279-
280-
return decorator
281-
282-
@add_function_with_spec(
283-
ProcessSpec("foo", "bar")
284-
.param("input", "Input", schema=ProcessSpec.RASTERCUBE)
285-
.returns(description="Output", schema=ProcessSpec.RASTERCUBE)
286-
)
287-
def foo(*args):
288-
return 42
289-
290-
assert reg.get_spec('foo') == {
291-
"id": "foo",
292-
"description": "bar",
293-
"parameters": {
294-
"input": {"description": "Input", "schema": {"type": "object", "format": "raster-cube"},
295-
"required": True},
296-
},
297-
"parameter_order": ["input"],
298-
"returns": {"description": "Output", "schema": {"type": "object", "format": "raster-cube"}}
299-
}
300234

301235

302236
def test_process_registry_with_spec_100():

0 commit comments

Comments
 (0)