diff --git a/examples/workflow_editor_gui.ipynb b/examples/workflow_editor_gui.ipynb new file mode 100644 index 0000000..9650cbd --- /dev/null +++ b/examples/workflow_editor_gui.ipynb @@ -0,0 +1,104 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Interactive workflow creation" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import geoengine as ge" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "ge.initialize(\"http://localhost:3030/api\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Display editor GUI" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "65051802c71c4c968d156b5a9280e7d2", + "version_major": 2, + "version_minor": 1 + }, + "text/plain": [ + "WorkflowEditor(serverUrl='http://localhost:3030/api', token='2f91e7ea-90a0-4ac8-860e-7119d32efe25')" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "editor = ge.create_workflow_editor()\n", + "editor" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'type': 'Raster',\n", + " 'operator': {'type': 'GdalSource', 'params': {'data': 'test'}}}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "editor.workflow" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "env", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/geoengine/__init__.py b/geoengine/__init__.py index e46f844..90e993c 100644 --- a/geoengine/__init__.py +++ b/geoengine/__init__.py @@ -28,7 +28,7 @@ FeatureDataType, RasterBandDescriptor, DEFAULT_ISO_TIME_FORMAT, RasterColorizer, SingleBandRasterColorizer \ from .util import clamp_datetime_ms_ns -from .workflow import WorkflowId, Workflow, workflow_by_id, register_workflow, get_quota, update_quota +from .workflow import WorkflowId, Workflow, workflow_by_id, register_workflow, get_quota, update_quota, create_workflow_editor from .raster import RasterTile2D from . import workflow_builder diff --git a/geoengine/workflow.py b/geoengine/workflow.py index 9215727..a557fe5 100644 --- a/geoengine/workflow.py +++ b/geoengine/workflow.py @@ -42,6 +42,7 @@ from geoengine.tasks import Task, TaskId from geoengine.workflow_builder.operators import Operator as WorkflowBuilderOperator from geoengine.raster import RasterTile2D +from workflow_editor import WorkflowEditor # TODO: Define as recursive type when supported in mypy: https://github.com/python/mypy/issues/731 @@ -958,3 +959,9 @@ def update_quota(user_id: UUID, new_available_quota: int, timeout: int = 60) -> ), _request_timeout=timeout ) + + +def create_workflow_editor() -> WorkflowEditor: + session = get_session() + + return WorkflowEditor(session.server_url, session.configuration.access_token) diff --git a/setup.cfg b/setup.cfg index 1f1e36b..6e97309 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,6 +18,7 @@ package_dir = packages = find: python_requires = >=3.8 install_requires = + workflow-editor @ git+https://github.com/1lutz/workflow-editor.git geoengine-openapi-client == 0.0.4 geopandas >=0.9,<0.15 matplotlib >=3.5,<3.8