Skip to main content

Shared utilities and base service templates for ZOO CWL runners

Project description

zoo-template-common

Common execution handler and utilities for ZOO-Project CWL workflow templates.

Overview

This package provides a simple, extensible base class (CommonExecutionHandler) for handling CWL workflow execution in ZOO-Project templates. It includes basic functionality for STAC catalog processing, pod configuration, and output management.

Features

  • CommonExecutionHandler: Base class for CWL workflow execution handlers

    • Pre/post execution hooks
    • STAC catalog output processing
    • Pod environment variable and node selector management
    • Secrets handling
    • Tool log management
  • CustomStacIO: STAC I/O class for S3 operations using boto3

    • Read/write STAC catalogs from/to S3
    • Support for both S3 and local file systems

Installation

pip install zoo-template-common

Or from Git:

pip install git+https://github.com/ZOO-Project/zoo-template-common.git@main

Usage

Basic Usage

from zoo_template_common import CommonExecutionHandler
from zoo_calrissian_runner import ZooCalrissianRunner

def my_workflow(conf, inputs, outputs):
    execution_handler = CommonExecutionHandler(conf=conf, outputs=outputs)

    runner = ZooCalrissianRunner(
        cwl=cwl,
        conf=conf,
        inputs=inputs,
        outputs=outputs,
        execution_handler=execution_handler,
    )

    exit_status = runner.execute()
    return exit_status

Extending CommonExecutionHandler

For specific use cases (e.g., EOEPCA with Workspace API integration), extend the base class:

from zoo_template_common import CommonExecutionHandler
import jwt
import requests

class EoepcaCalrissianRunnerExecutionHandler(CommonExecutionHandler):
    def __init__(self, conf, outputs):
        super().__init__(conf, outputs)
        # Add EOEPCA-specific initialization
        self.ades_rx_token = conf.get("auth_env", {}).get("jwt", "")
        self.workspace_url = conf.get("eoepca", {}).get("workspace_url", "")

    def pre_execution_hook(self):
        # Add JWT decoding, Workspace API lookup, etc.
        super().pre_execution_hook()
        # Your custom logic here

    def post_execution_hook(self, log, output, usage_report, tool_logs):
        # Add STAC catalog registration, etc.
        super().post_execution_hook(log, output, usage_report, tool_logs)
        # Your custom logic here

API Reference

CommonExecutionHandler

Methods

  • __init__(conf, outputs=None): Initialize the handler
  • pre_execution_hook(): Hook called before execution (override for custom behavior)
  • post_execution_hook(log, output, usage_report, tool_logs): Hook called after execution
  • setOutput(outputName, values): Process and set STAC catalog outputs
  • get_pod_env_vars(): Get environment variables for the calrissian pod
  • get_pod_node_selector(): Get node selector for the calrissian pod
  • get_additional_parameters(): Get additional parameters for the execution
  • get_secrets(): Get secrets for the calrissian pod
  • handle_outputs(log, output, usage_report, tool_logs): Register tool logs in service_logs

CustomStacIO

Custom STAC IO class for S3 operations.

Methods

  • read_text(source, *args, **kwargs): Read text from S3 or local file
  • write_text(dest, txt, *args, **kwargs): Write text to S3 or local file

Configuration

The handler expects configuration in the conf dictionary:

conf = {
    "lenv": {
        "usid": "unique-execution-id",
        "Identifier": "workflow-name"
    },
    "main": {
        "tmpPath": "/tmp/zoo",
        "tmpUrl": "http://example.com/temp/"
    },
    "auth_env": {
        "user": "username"
    },
    "additional_parameters": {
        "region_name": "us-east-1",
        "endpoint_url": "https://s3.amazonaws.com",
        "aws_access_key_id": "ACCESS_KEY",
        "aws_secret_access_key": "SECRET_KEY"
    }
}

Templates Using This Package

  • eoepca-proc-service-template: Extends CommonExecutionHandler with EOEPCA Workspace API integration
  • zoo-service-template (EOAP): Can use CommonExecutionHandler as-is or extend it

Development

# Clone the repository
git clone https://github.com/ZOO-Project/zoo-template-common.git
cd zoo-template-common

# Install in development mode
pip install -e .

Requirements

  • Python >= 3.8
  • loguru >= 0.7.0
  • pystac >= 1.8.0
  • pyyaml >= 6.0
  • boto3 >= 1.28.0
  • botocore >= 1.31.0

License

Apache License 2.0

Contributing

Contributions are welcome! Please submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zoo_template_common-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zoo_template_common-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file zoo_template_common-0.1.0.tar.gz.

File metadata

  • Download URL: zoo_template_common-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for zoo_template_common-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f329c6e48bf899a20470847def31604d608422f1929dbb5613b85f76a14ed3e8
MD5 bed6d764351b17a915a6e75106acebe8
BLAKE2b-256 3f67dea6725700df86f48635e36b9fd361a0ed40dc1b066d2c7b8d539ec8f1ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for zoo_template_common-0.1.0.tar.gz:

Publisher: publish-pypi.yml on ZOO-Project/zoo-template-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zoo_template_common-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zoo_template_common-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f01cd4b327710acbffc06a297f0a48ba3782186f34c1f19cc9f1121632df994
MD5 25287136f33496089825c4f8703cd11e
BLAKE2b-256 c22febeaa9965bbaf7c6b34611d9f995cf0ecd0cc5b5f2cd73349c3bee5960b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for zoo_template_common-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on ZOO-Project/zoo-template-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page