Default Strategies

This document describes the built-in (“default”) strategy implementations used by OCLI when an AIKP does not provide an override.

These strategies implement the common three-step pipeline:

  1. makegeojson → generate metadata

  2. upload → move artifacts to COS

  3. publish → register document in docs DB

Where defaults are wired

The default TaskTemplate methods call the default strategy classes:

  • makegeojson → ocli/ai/makegeojson_strategy.py (GeoJsonStrategy)

  • upload → ocli/ai/upload_strategy.py (UploadStrategy)

  • publish → ocli/ai/publish_strategy.py (PublishStrategy)

The default TaskTemplate hooks are defined in ocli/classes/task_template.py.

GeoJsonStrategy (ocli/ai/makegeojson_strategy.py)

Purpose:

  • Generates a GeoJSON metadata file that describes the produced output and how it should be visualized/loaded.

How it works (high level):

  • Resolves the active recipe for the task.

  • Applies optional overrides stored in the Click context meta (COS key and friendly name overrides).

  • Computes output paths using Filenames.

  • Calls ocli.ai.export_tools.make_geo_json() to build the GeoJSON metadata structure.

  • Writes the metadata to <output>.geojson (and optionally prints it if requested).

Overrides:

  • --cos-key and --friendly-name can override recipe defaults.

  • If either starts with +, it is treated as a suffix rather than a full replacement.

UploadStrategy (ocli/ai/upload_strategy.py)

Purpose:

  • Uploads generated artifacts (and their associated metadata documents) into Cloud Object Storage (COS).

How it works (high level):

  • Creates a COS client from the recipe COS credentials (unless --dry-run).

  • Computes filenames using Filenames.

  • Determines the COS key (ResultKey) by reading it from the metadata document when needed.

  • Chooses which files to upload:

    • Default behavior: uploads the standard set of output and metadata files derived from Filenames.

    • Recipe-driven behavior: if the recipe contains upload_file_list, uploads those listed files instead.

  • Uploads each file with progress reporting (or logs intended actions in --dry-run mode).

  • If an “additional outputs” directory exists, its files are uploaded too.

Inputs:

  • Recipe COS credentials.

  • A metadata document containing properties.ResultKey (used to infer COS destination when not explicitly provided).

Unified Object Storage (S3 / COS) Architecture

All Object Storage operations (uploading results via ai upload, verifying source existence, and streaming data through GDAL VSI) share a unified credential and client management architecture in ocli.ai.COS.s3_boto.COS:

  • Single Source of Truth: COS.from_context(task=..., repo=..., config=...) dynamically resolves COS configuration from active task recipes, repository upload configs, or defaults.yaml.

  • Credential Resolution: Backed by EnvConfStore, credentials are automatically resolved from environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) or JSON credential files (~/.ocli_credentials/..., ~/.bluemix/...) supporting both aws_access_key_id and standard access_key_id formats.

  • GDAL VSI Configuration: COS.configure_gdal_vsi() configures GDAL environment settings (AWS_S3_ENDPOINT, AWS_HTTPS, AWS_VIRTUAL_HOSTING, AWS_REGION, etc.) ensuring seamless zero-download streaming across MinIO, Ceph, and AWS S3.

PublishStrategy (ocli/ai/publish_strategy.py)

Purpose:

  • Publishes (posts) the metadata document into the docs database so it is visible to the UI.

How it works (high level):

  • Selects which JSON document to publish:

    • If the recipe provides upload_file_list, publishes the configured doc_json entry.

    • Otherwise publishes the default document derived from Filenames, falling back to the “cloud document” path if needed.

    • If publishing a report workflow, publishes the report document when requested.

  • Calls publish_json() from ocli/cli/publish.py to write the document to the configured docs DB.

Overriding defaults

If your AIKP needs different behavior, override strategies rather than modifying these defaults. See Custom Strategies.