Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ wslink==1.12.4
yarl>=1
# via aiohttp

opengeodeweb-microservice==1.*,>=1.2.0
3 changes: 2 additions & 1 deletion src/opengeodeweb_viewer/rpc/mesh/points/points_protocols.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Standard library imports
from typing import Any
import os

# Third party imports
from wslink import register as exportRpc # type: ignore
from opengeodeweb_viewer.utils_functions import exportRpc
from opengeodeweb_microservice.schemas import get_schemas_dict

# Local application imports
Expand Down
3 changes: 2 additions & 1 deletion src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import cast, Any

# Third party imports
from wslink import register as exportRpc # type: ignore
from vtkmodules.vtkIOImage import vtkPNGWriter, vtkJPEGWriter
from vtkmodules.vtkRenderingAnnotation import vtkCubeAxesActor, vtkAxesActor
from vtkmodules.vtkRenderingCore import (
Expand All @@ -27,9 +26,11 @@

# Local application imports
from opengeodeweb_viewer.utils_functions import (
exportRpc,
validate_schema,
RpcParams,
)

from opengeodeweb_viewer.vtk_protocol import VtkView
from opengeodeweb_viewer.rpc.viewer import schemas

Expand Down
21 changes: 21 additions & 0 deletions src/opengeodeweb_viewer/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@

# Third party imports
import fastjsonschema # type: ignore
import functools
import math
from typing import Any, Callable, TypeVar
from wslink import register # type: ignore
from vtkmodules.vtkRenderingCore import vtkColorTransferFunction

from opengeodeweb_microservice.schemas import SchemaDict

type RpcParams = dict[str, str]

R = TypeVar("R")


def exportRpc(rpc_id: str) -> Callable[[Callable[..., R]], Callable[..., R]]:
def decorator(function: Callable[..., R]) -> Callable[..., R]:
def wrapper(self: Any, *args: Any, **kwargs: Any) -> R:
do_stream = bool(kwargs.pop("stream", False))
print("do_stream", do_stream, flush=True)
result = function(self, *args, **kwargs)
if do_stream:
rpc_params = args[0] if args else None
self.publish(rpc_id, rpc_params)
return result

return register(rpc_id)(wrapper) # type: ignore[no-any-return]

return decorator


def validate_schema(
rpc_params: RpcParams, schema: SchemaDict, prefix: str = ""
Expand Down
Loading