# 👨‍💻 Building Your First Method (Simplified Workflow) Now that you understand what it means to implement a method, here's how to actually build one — step by step — using the simplified "runtime-based" approach. We'll use the **Advanced WordCloud** method as a real-world example, you can download the full [WordCloud Advanced json](/_static/methods_examples/Advanced%20WordCloud-1.0.0.json) json definition. --- ## 🛠 1. Choose the Execution Tool or Library In this case we use [`wordcloud_cli`](https://github.com/amueller/word_cloud) (), which can be cloned from the public repository and run from shell. This tool accepts command-line options for all parameters, making it ideal for CCP. --- ## 📝 2. Define Your Goal In this case: generate a word cloud image from a text file. We want the method to be flexible, so users can customize: - Input text file - Image size - Number of words - Font size range - Optional stopwords or mask image --- ## 📁 3. Create a new empty method and define it in the 🛠 [Method / Algorithm Importer](/02_ccp_interface/05_engine_edit) page, fill the form for the creation of the new method ![define the method](/_static/imgs/define_wc_01_description.png) --- ## 🐳 4. Select a Docker Image For this example, we use a public image with Python: ![select a docker image](/_static/imgs/define_wc_02_ccpimage.png) ```json { "inputs": { "ccpimage": { "id": "ccpimage", "title": "Runtime", "description": "The image of the runtime to use for method execution. This depends on the infrastructure specific protocol for interacting with registries.", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "url", "contentMediaType": "text/plain", "default": "python:3.9.19", "readOnly": false } } } } ``` --- ## 📁 3. Prepare Inputs and Parameters In this case, we define input fields like: - `file_url` (text file URL) - `width`, `height` - Optional: `blacklist_url`, `colormask_url`, `max_words`, `min_font_size`, `max_font_size` ![input file](/_static/imgs/define_wc_03_input_file.png) ![input number](/_static/imgs/define_wc_04_input_number.png) and the other inputs ![other inputs](/_static/imgs/define_wc_05_input_others.png) the generated json is: ```json { "inputs": { "file_url": { "id": "file_url", "title": "File url", "description": "Url of the text file of words to build the word cloud", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "remotefile", "contentMediaType": "text/plain", "default": "" } }, "width": { "id": "width", "title": "Image width", "description": "output image width", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "number", "contentMediaType": "text/plain", "default": "1024" } } } } ``` --- ## 🔧 5. Write the Deploy Script This script prepares the environment. In this case: ```bash pip install wordcloud curl -L {{file_url}} -o /ccp_data/input.txt [ -n "{{blacklist_url}}" ] && curl -L {{blacklist_url}} -o /ccp_data/blacklist.txt [ -n "{{colormask_url}}" ] && curl -L {{colormask_url}} -o /ccp_data/colormask.png ``` It handles: - Dependency installation - Download of required and optional input files ![deploy script](/_static/imgs/define_wc_07_script_deploy.png) --- ## 🚀 6. Write the Execute Script This script runs the method. It uses shell logic to build the command dynamically: ```bash cmd="wordcloud_cli --text /ccp_data/input.txt --imagefile /ccp_data/wordcloud.png" cmd="$cmd --width {{width}} --height {{height}}" [ -n "{{max_words}}" ] && cmd="$cmd --max_words {{max_words}}" [ -n "{{min_font_size}}" ] && cmd="$cmd --min_font_size {{min_font_size}}" [ -n "{{max_font_size}}" ] && cmd="$cmd --max_font_size {{max_font_size}}" [ -n "{{blacklist_url}}" ] && cmd="$cmd --stopwords /ccp_data/blacklist.txt" [ -n "{{colormask_url}}" ] && cmd="$cmd --colormask /ccp_data/colormask.png" eval $cmd ``` 👉 This allows conditional inclusion of optional parameters. ![execute script](/_static/imgs/define_wc_08_script_exec.png) --- ## 📦 7. Save the Output The script writes the image to: ``` /ccp_data/wordcloud.png ``` Any file saved to `/ccp_data/`, like the input.txt downloaded in the deploy script, becomes downloadable for the user. --- ## ✅ Summary | Element | Description | |--------------------|-------------| | Docker image | `python:3.9.19` | | Install tool | `pip install wordcloud` | | Inputs | URLs and numbers (some optional) | | Deploy script | Prepares environment and downloads files | | Execute script | Builds and runs the CLI command | | Output | `/ccp_data/wordcloud.png` | --- ## 👀 Want to Build Your Own Method? Before you start, make sure you understand the basic concepts of CCP methods. 👉 See: 🐣 [Concepts for Beginners](04_concepts_for_beginners) --- ## What About Advanced Users? The method structure explained in this guide is meant to help you **get started quickly**, even if you're not a developer. However, if you're building a methods that: - Needs custom dependencies or environments - Must run on secure/private code - Should be reusable in production ...you should consider the **consolidation** workflow. ### Consolidated Methods A consolidated method: - Uses a **custom Docker image** with all dependencies pre-installed - Embeds the algorithm code inside the image (no need to clone anything) - Can work without internet access and is more stable over time - Requires a bit more technical setup, but offers maximum control 👉 See the 🐳 [Consolidation Guide](/04_methods_development/08_consolidation) for full details.