Custom Strategies

This document describes how AIKP authors can override the standard strategy behavior.

There are two supported approaches:

  1. TaskTemplate method override (recommended)

  2. Module override via RECIPE_DEFAULTS (legacy)

Vector strategy examples and the overall workflow are described in ocli/ai/vector_strategies/README.md.

Legacy(DEPRECATED!!!): Module override via RECIPE_DEFAULTS

Older templates can override strategies by mapping command names to module names in RECIPE_DEFAULTS in the AIKP package, and providing those modules with an execute() function.

Example mapping:

RECIPE_DEFAULTS = {
    "makegeojson": "make_geo_json",  # corresponds to make_geo_json.py
    "upload": "upload",              # corresponds to upload.py
    "publish": "publish",            # corresponds to publish.py
}

Then create the modules in your AIKP package.

make_geo_json.py

from ocli.cli.state import pass_task

@pass_task
def execute(task):
    # Generate metadata document(s)
    ...

upload.py

from ocli.cli.state import pass_task

@pass_task
def execute(task, dry_run=False, cos_key=None):
    # Upload artifacts + metadata to COS
    ...

publish.py

from ocli.cli.state import pass_task

@pass_task
def execute(task, dry_run=False, print_json=False):
    # Publish metadata document to docs DB
    ...

Notes:

  • This approach is considered legacy; prefer TaskTemplate overrides for new AIKPs.

  • Keep behavior consistent with the standard pipeline: makegeojson produces the publishable document, upload transfers it to COS, and publish posts it to docs DB.