Skip to content

Commit

Permalink
Issue #1057/#1038 remove CWL demo processes
Browse files Browse the repository at this point in the history
implementation is now in openeo-geotrellis-kubernetes
  • Loading branch information
soxofaan committed Feb 25, 2025
1 parent 9f7461c commit 9d1249c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 122 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ without compromising stable operations.

## Unreleased


## 0.62.0

- `load_stac`: improve STAC requests resilience ([#818](https://github.com/Open-EO/openeo-geopyspark-driver/issues/818))
- Extract demo CWL content to package resources ([#1057](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1057))
- Disable EJR health check from batch job context ([#1066](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1066))
- `load_stac`: support empty data cubes ([#1049](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1049))
- Remove proof-of-concept CWL processes (now in openeo-geotrellis-kubernetes) from generic openeo-geopyspark-driver ([#1057](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1057)/[#1038](https://github.com/Open-EO/openeo-geopyspark-driver/issues/1038))


## 0.61.0

Expand Down
2 changes: 1 addition & 1 deletion openeogeotrellis/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.61.0a1"
__version__ = "0.62.0a1"
121 changes: 0 additions & 121 deletions openeogeotrellis/deploy/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,20 @@
Script to start a production server on Kubernetes. This script can serve as the mainApplicationFile for the SparkApplication custom resource of the spark-operator
"""

import base64
import json
import logging
import os
import re
import textwrap

from kubernetes.config.incluster_config import SERVICE_TOKEN_FILENAME

from openeo_driver.processes import ProcessArgs
from openeo_driver.ProcessGraphDeserializer import (
ENV_DRY_RUN_TRACER,
ProcessSpec,
non_standard_process,
)
from openeo_driver.server import run_gunicorn
from openeo_driver.util.logging import (
LOG_HANDLER_STDERR_JSON,
FlaskRequestCorrelationIdLogging,
get_logging_config,
setup_logging,
)
from openeo_driver.utils import EvalEnv
from openeo_driver.views import build_app

from openeogeotrellis import deploy
from openeogeotrellis.config import get_backend_config
from openeogeotrellis.deploy import get_socket
from openeogeotrellis.job_registry import ZkJobRegistry
from openeogeotrellis.util.runtime import get_job_id, get_request_id

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -119,111 +103,6 @@ def on_started():
)


@non_standard_process(
ProcessSpec(id="_cwl_demo", description="Proof-of-concept process to run CWL based processing.")
.param(name="name", description="Name to greet.", schema={"type": "string"}, required=False)
.returns(description="data", schema={"type": "string"})
)
def _cwl_demo(args: ProcessArgs, env: EvalEnv):
"""Proof of concept openEO process to run CWL based processing"""
name = args.get_optional(
"name",
default="World",
validator=ProcessArgs.validator_generic(
# TODO: helper to create regex based validator
lambda n: bool(re.fullmatch("^[a-zA-Z]+$", n)),
error_message="Must be a simple name, but got {actual!r}.",
),
)

if env.get(ENV_DRY_RUN_TRACER):
return "dummy"

# TODO: move this imports to top-level?
import kubernetes.config

from openeogeotrellis.integrations.calrissian import CalrissianJobLauncher, CwLSource

# TODO: better place to load this config?
if os.path.exists(SERVICE_TOKEN_FILENAME):
kubernetes.config.load_incluster_config()
else:
kubernetes.config.load_kube_config()

launcher = CalrissianJobLauncher.from_context()

cwl_source = CwLSource.from_resource(anchor="openeogeotrellis.integrations", path="cwl/hello.cwl")
correlation_id = get_job_id(default=None) or get_request_id(default=None)
cwl_arguments = [
"--message",
f"Hello {name}, greetings from {correlation_id}.",
]

results = launcher.run_cwl_workflow(
cwl_source=cwl_source,
cwl_arguments=cwl_arguments,
output_paths=["output.txt"],
)

return results["output.txt"].read(encoding="utf8")



@non_standard_process(
ProcessSpec(id="_cwl_insar", description="Proof-of-concept process to run CWL based inSAR.")
.param(name="spatial_extent", description="Spatial extent.", schema={"type": "dict"}, required=False)
.param(name="temporal_extent", description="Temporal extent.", schema={"type": "dict"}, required=False)
.returns(description="the data as a data cube", schema={})
)
def _cwl_insar(args: ProcessArgs, env: EvalEnv):
"""Proof of concept openEO process to run CWL based processing"""
spatial_extent = args.get_optional(
"spatial_extent",
default=None,
)
temporal_extent = args.get_optional(
"temporal_extent",
default=None,
)

if env.get(ENV_DRY_RUN_TRACER):
return "dummy"

from openeo_driver import dry_run

# source_id = dry_run.DataSource.load_disk_data(**kwargs).get_source_id()
# load_params = _extract_load_parameters(env, source_id=source_id)

# TODO: move this imports to top-level?
import kubernetes.config

from openeogeotrellis.integrations.calrissian import CalrissianJobLauncher, CwLSource

# TODO: better place to load this config?
if os.path.exists(SERVICE_TOKEN_FILENAME):
kubernetes.config.load_incluster_config()
else:
kubernetes.config.load_kube_config()

launcher = CalrissianJobLauncher.from_context()

cwl_source = CwLSource.from_resource(anchor="openeogeotrellis.integrations", path="cwl/insar.cwl")
input_base64_json = base64.b64encode(json.dumps(args).encode("utf8")).decode("ascii")
cwl_arguments = ["--input_base64_json", input_base64_json]

# TODO: Load the results as datacube with load_stac.
results = launcher.run_cwl_workflow(
cwl_source=cwl_source,
cwl_arguments=cwl_arguments,
output_paths=["output.txt"],
env_vars={
"AWS_ACCESS_KEY_ID": os.environ.get("SWIFT_ACCESS_KEY_ID", ""),
"AWS_SECRET_ACCESS_KEY": os.environ.get("SWIFT_SECRET_ACCESS_KEY", ""),
},
)

return results["output.txt"].read(encoding="utf8")


if __name__ == '__main__':
main()

0 comments on commit 9d1249c

Please sign in to comment.