Skip to content

Commit

Permalink
fix default level of inspect process #424
Browse files Browse the repository at this point in the history
Traceback (most recent call last):
  File "/home/bossie/PycharmProjects/openeo/venv38/lib/python3.8/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/bossie/PycharmProjects/openeo/venv38/lib/python3.8/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/users/auth.py", line 95, in decorated
    return f(*args, **kwargs)
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/views.py", line 681, in result
    result = backend_implementation.processing.evaluate(process_graph=process_graph, env=env)
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py", line 301, in evaluate
    return evaluate(process_graph=process_graph, env=env)
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py", line 367, in evaluate
    convert_node(result_node, env=env.push({
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py", line 402, in convert_node
    process_result = apply_process(process_id=process_id, args=processGraph.get('arguments', {}),
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py", line 1621, in apply_process
    return process_function(args=ProcessArgs(args, process_id=process_id), env=env)
  File "/home/bossie/PycharmProjects/openeo/openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py", line 2171, in inspect
    _log.log(level=logging.getLevelName(level.upper()), msg=message)
  File "/usr/lib/python3.8/logging/__init__.py", line 1508, in log
    raise TypeError("level must be an integer")
TypeError: level must be an integer
  • Loading branch information
bossie committed Jul 9, 2024
1 parent 48bf71d commit 992f7e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and start a new "In Progress" section above it.

## In progress

- Fix default level of `inspect` process (defaults to `info`) ([#424](https://github.com/Open-EO/openeo-geopyspark-driver/issues/424))

## 0.107.1

- Update to "remote-process-definition" extension (originally called "remote-udp")
Expand Down
7 changes: 4 additions & 3 deletions openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2144,9 +2144,9 @@ def load_result(args: dict, env: EvalEnv) -> DriverDataCube:
@process_registry_100.add_function(spec=read_spec("openeo-processes/1.x/proposals/inspect.json"))
@process_registry_2xx.add_function(spec=read_spec("openeo-processes/2.x/proposals/inspect.json"))
def inspect(args: dict, env: EvalEnv):
data = extract_arg(args,"data")
message = args.get("message","")
level = args.get("level","")
data = extract_arg(args, "data")
message = args.get("message", "")
level = args.get("level", "info")
if message:
_log.log(level=logging.getLevelName(level.upper()), msg=message)
data_message = str(data)
Expand All @@ -2155,6 +2155,7 @@ def inspect(args: dict, env: EvalEnv):
_log.log(level=logging.getLevelName(level.upper()), msg=data_message)
return data


@simple_function
def text_begins(data: str, pattern: str, case_sensitive: bool = True) -> Union[bool, None]:
if data is None:
Expand Down
25 changes: 8 additions & 17 deletions tests/test_dry_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
import openeo.processes
from openeo.internal.graph_building import PGNode
from openeo.rest.datacube import DataCube
from openeo.util import BBoxDict

from openeo_driver.errors import OpenEOApiException
from openeo_driver.ProcessGraphDeserializer import evaluate, ENV_DRY_RUN_TRACER, _extract_load_parameters, \
ENV_SOURCE_CONSTRAINTS, custom_process_from_process_graph, process_registry_100, ENV_SAVE_RESULT
from openeo_driver.datacube import DriverVectorCube
from openeo_driver.datastructs import SarBackscatterArgs
from openeo_driver.delayed_vector import DelayedVector
from openeo_driver.dry_run import DryRunDataTracer, DataSource, DataTrace, ProcessType, DryRunDataCube
from openeo_driver.testing import DictSubSet, approxify, ephemeral_fileserver
from openeo_driver.util.geometry import as_geojson_feature_collection
from openeo_driver.utils import EvalEnv
from openeo_driver.workspace import Workspace
from openeo_driver.workspacerepository import WorkspaceRepository
from tests.data import get_path, load_json, TEST_DATA_ROOT

Expand Down Expand Up @@ -321,26 +318,20 @@ def test_evaluate_load_collection_and_filter_extents(dry_run_env, dry_run_tracer
}


def test_inspect(dry_run_env, dry_run_tracer):
"""temporal/bbox/band extents in load_collection *and* filter_ processes"""
@pytest.mark.parametrize("additional_arguments", [
{"level": "error"},
{},
])
def test_inspect(dry_run_env, dry_run_tracer, additional_arguments):
pg = {
"load": {
"process_id": "load_collection",
"arguments": {
"id": "S2_FOOBAR",
"spatial_extent": {"west": 0, "south": 50, "east": 5, "north": 55},
"temporal_extent": ["2020-01-01", "2020-10-10"],
"bands": ["red", "green", "blue"]
},
},
"inspect": {
"process_id": "inspect",
"arguments": {"data": {"from_node": "load"}, "level": "error", "message":"logging a message"},
"result":True
"arguments": {**{"data": 123, "message": "logging a message"}, **additional_arguments},
"result": True
},
}
cube = evaluate(pg, env=dry_run_env)

assert evaluate(pg, env=dry_run_env) == 123


def test_evaluate_merge_collections(dry_run_env, dry_run_tracer):
Expand Down

0 comments on commit 992f7e4

Please sign in to comment.