🐣 Understanding What It Means to “Implement a Method”

Many users new to CCP expect to upload a notebook and run it. However, defining a method in CCP means turning your algorithm into a structured, executable process.

This guide explains the key concepts you need to know.


1. The Algorithm is NOT the Data

When building a method:

  • Your algorithm (code) must be independent from your data.

  • CCP will allow users to pass different data to your method at runtime.

  • This means your code must accept parameters and file paths.

❌ Example of what not to do:
A Jupyter notebook with hardcoded datasets loaded from your desktop.

✅ What to do instead:
Write a Python script or function that takes arguments (e.g., input file, output path, parameters).


2. The Algorithm Must Be Executable from Shell

Your algorithm must be runnable via a command line like:

python my_tool.py --input /ccp_data/input.csv --output /ccp_data/output.txt

This allows CCP to call your method automatically.


3. Expose Parameters Explicitly

Your script must:

  • Accept mandatory and optional parameters

  • Fail gracefully if required parameters are missing

  • Print useful output to stdout or files

Example using argparse in Python:

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--input', required=True)
parser.add_argument('--output', required=True)
parser.add_argument('--threshold', type=float, default=0.5)
args = parser.parse_args()

4. Docker Image and Code Access

Your method will run inside a Docker container. You must:

  • Choose an image (e.g., python:3.9, or one with gdal, scikit-learn, etc.)

  • Make sure your code is publicly accessible via Git or file URL

Later, you’ll be able to bundle everything in a custom Docker image — this is part of the 🐳 Consolidation phase.


5. Prepare a Public Repository with Your Code

To execute your method, CCP must clone your code at runtime. You need to:

  • Prepare a public Git repository (e.g., GitHub, Gitea, GitLab)

  • Place all your source files in it: scripts, modules, data loading functions

  • Include a file to declare dependencies

Examples

  • For Python: requirements.txt

  • For R: a script like install.R with install.packages(...)

  • For Java: a built JAR with dependencies or a pom.xml for Maven

  • For Shell: just ensure all referenced commands exist in the container

Then, in your deploy script, you must:

# Clone the source code (mandatory!)
git clone https://github.com/your-user/myproject.git /src/myproject

# Install dependencies (Python example)
pip install -r /src/myproject/requirements.txt

6. Deploy and Execute Scripts

CCP separates two steps:

✅ Deploy script

Used to prepare the environment, typically:

  • Clone your repo

  • Install dependencies

  • Download input data (if needed)

✅ Execute script

Used to run the algorithm, using:

  • Inputs passed by the user

  • Paths like /ccp_data/input.csv and /ccp_data/output.txt

These scripts are defined in your method.json under additionalParameters.


7. Where to Put Inputs and Outputs

  • Use /ccp_data/ as the shared working directory

  • All files passed as input will be placed here

  • You should write all output files here too

This ensures they can be returned to the user or archived properly.


Summary

Concept What You Need to Do
Algorithm logic Make it independent from specific data
Execution Run via shell command with arguments
Parameters Clearly define required and optional
Docker Choose a suitable base image
Code access Use a public Git repo, clone it at deploy phase
Dependencies Use requirements.txt, install.R, pom.xml, etc.
Deploy phase Clone repo, install dependencies, download inputs
Execute phase Run your script using inputs placeholders
Output files Save them in /ccp_data/