From dfc58bd0ede1c187c1320d3e91772ac9f9f85672 Mon Sep 17 00:00:00 2001 From: k3dz0r Date: Fri, 30 Jan 2026 08:49:15 -0300 Subject: [PATCH 1/2] Rename cli/quick-guide to deploy-app. Add Python example --- .../Guides/deploy-app/deploy-app-example.md | 175 ++++++++++++++++++ .../{quick-guide.md => deploy-app/index.md} | 26 ++- docs/cli/Guides/tgwui.md | 14 +- docs/cli/Guides/unsloth.md | 4 +- docs/cli/Guides/vllm.md | 2 +- docs/fundamentals/certification.md | 6 +- docs/guides/index.md | 12 +- docusaurus.config.js | 8 +- static/files/usd_to_crypto.py | 45 +++++ 9 files changed, 254 insertions(+), 38 deletions(-) create mode 100644 docs/cli/Guides/deploy-app/deploy-app-example.md rename docs/cli/Guides/{quick-guide.md => deploy-app/index.md} (82%) create mode 100644 static/files/usd_to_crypto.py diff --git a/docs/cli/Guides/deploy-app/deploy-app-example.md b/docs/cli/Guides/deploy-app/deploy-app-example.md new file mode 100644 index 00000000..60d596e0 --- /dev/null +++ b/docs/cli/Guides/deploy-app/deploy-app-example.md @@ -0,0 +1,175 @@ +--- +id: "deploy-app-example" +title: "Example: Python script" +slug: "/guides/deploy-app/example" +sidebar_position: 1 +--- + +This guide serves as an example to the more general [deployment guide](/cli/guides/deploy-app) and shows how to deploy a Python script on Super Protocol without modifying its code. + +The [simple script](/files/usd_to_crypto.py) used here as an example calculates how much Bitcoin (BTC) and Ether (ETH) can be bought for given amount in US dollars: + +1. Reads the input amount from `input.txt` located in the same directory. +2. Fetches current prices of BTC and ETH using CoinGecko API. +3. Calculates how much BTC and ETH can be bought for this amount of USD. +4. Creates `result.txt` in the same directory and writes the result to it. + +In this deployment, the script will be the solution, and `input.txt` will be the data. + +## Prerequisites + +- Docker +- [SPCTL](/cli) + +### 0. Prepare the files + +Create a local directory `usd_to_crypto`. Download the [example script](/files/usd_to_crypto.py) and rename it to `usd_to_crypto.py`. + +Create a new file `input.txt` to serve as the data input, and add a number—USD amount, for example, `100000`. + +Copy SPCTL and its `config.json` into this directory. + +### 1. Prepare the solution + +Keep in mind that file locations inside a CVM will differ from a local run: + +- Data (`input.txt`) must be found in one of the `/sp/inputs/input-xxxx` directories. +- `result.txt` must be placed into `/sp/output` to be available to download once the execution is finished. + +1.1. Create an new file named `entrypoint.sh` and add the following code: + +```sh title="entrypoint.sh" +#!/bin/sh +set -eu + +# Fixed CVM paths (overridable if needed) +: "${INPUTS_DIR:=/sp/inputs}" +: "${OUTPUT_DIR:=/sp/output}" +: "${SCRIPT_PATH:=/usr/local/bin/usd_to_crypto.py}" + +mkdir -p "${OUTPUT_DIR}" +cd "${OUTPUT_DIR}" + +# Resolve input file +INPUT_FILE="$(find "${INPUTS_DIR}" -mindepth 2 -maxdepth 3 -type f -name 'input.txt' 2>/dev/null | sort | head -n 1 || true)" + +# Make the script's expected input file available in CWD (/sp/output) +rm -f input.txt || true +if [ -n "${INPUT_FILE}" ] && [ -f "${INPUT_FILE}" ]; then + cp -f "${INPUT_FILE}" input.txt +else + # If missing, create an empty file so the Python script emits a clean error + : > input.txt +fi + +# Run the Python script; it reads ./input.txt and writes ./result.txt here (/sp/output) +exec python3 "${SCRIPT_PATH}" +``` + +Create an new file named `Dockerfile` and add the following code: + +```dockerfile title="Dockerfile" +FROM ubuntu:22.04 + +# Non-interactive tzdata install +ENV DEBIAN_FRONTEND=noninteractive + +# System deps +RUN apt-get update && apt-get install -y \ + python3 \ + python3-pip \ + ca-certificates \ + curl \ + jq \ + openssl \ + tzdata \ + sed \ + grep \ + coreutils \ + && rm -rf /var/lib/apt/lists/* + +# Python deps +RUN pip3 install --no-cache-dir requests + +# Put the scripts where your environment expects executables +COPY usd_to_crypto.py /usr/local/bin/usd_to_crypto.py +RUN chmod +x /usr/local/bin/usd_to_crypto.py + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + +# Set /sp as workdir (doesn't matter in this case; entrypoint.sh uses /sp/output as workdir) +WORKDIR /sp + +# Set entrypoint +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +``` + +1.2. Build a Docker image: + +```shell +docker build -t usd_to_crypto . +``` + +1.3. Save and archive the image: + +```shell +docker save usd_to_crypto:latest | gzip > usd_to_crypto.tar.gz +``` + +1.4. Upload the archive: + +```shell +./spctl files upload usd_to_crypto.tar.gz \ + --filename usd_to_crypto.tar.gz \ + --output usd_to_crypto.resource.json +``` + +### 2. Prepare data + +2.1. Archive the file: + +```shell +tar -czvf input.tar.gz ./input.txt +``` + +2.2. Upload the archive: + +```shell +./spctl files upload ./input.tar.gz \ +--filename input.tar.gz \ +--output input.resource.json +``` + +### 3. Deploy + +Place an order: + +```shell +./spctl workflows create \ +--tee 7 \ +--solution ./usd_to_crypto.resource.json \ +--data ./input.resource.json +``` + +Find the order ID in the output, for example: + +``` +Workflow was created, TEE order id: ["275510"] +``` + +### 4. Download the result + +Replace `275510` with your order ID: + +```shell +./spctl orders download-result 275510 +``` + +If there is no result for your order yet, wait a couple of minutes and try again. + +Find `output/result.txt` inside the downloaded archive `result.tar.gz`. + +## Support + +If you have any issues or questions, contact Super Protocol on [Discord](https://discord.gg/superprotocol) or via the [contact form](https://superprotocol.zendesk.com/hc/en-us/requests/new). \ No newline at end of file diff --git a/docs/cli/Guides/quick-guide.md b/docs/cli/Guides/deploy-app/index.md similarity index 82% rename from docs/cli/Guides/quick-guide.md rename to docs/cli/Guides/deploy-app/index.md index 89d14492..205961f8 100644 --- a/docs/cli/Guides/quick-guide.md +++ b/docs/cli/Guides/deploy-app/index.md @@ -1,7 +1,7 @@ --- -id: "quick-guide" +id: "deploy-app" title: "Deploy Your App" -slug: "/guides/quick-guide" +slug: "/guides/deploy-app" sidebar_position: 2 --- @@ -18,13 +18,13 @@ This quick guide provides instructions on deploying your own TEE: -| **Location** | **Purpose** | **Access** | +|
**Location**
| **Purpose** |
**Access**
| | :- | :- | :- | -| `/sp/inputs/input-0001`
`/sp/inputs/input-0002`
etc. | Possible data locations | Read-only | -| `/sp/output` | Output directory for results | Write; read own files | +| `/sp/inputs/input-0001`
`/sp/inputs/input-0002`
... | Possible data locations | Read-only | +| `/sp/output` | Output directory for results | Read and write | | `/sp/certs` | Contains the order certificate, private key, and workloadInfo | Read-only | -So, your solution must find the data in `/sp/inputs` and write the results to `/sp/output`. +When you provide multiple data inputs, they are placed in separate directories inside the CVM: the first in `/sp/inputs/input-0001`, the second in `/sp/inputs/input-0002`, and so on. Your solution must find the data in `/sp/inputs` and write the results to `/sp/output`. :::important @@ -32,7 +32,9 @@ Always use absolute paths, such as `/sp/...`. ::: -You can find several Dockerfile examples in the [Super-Protocol/solutions](https://github.com/Super-Protocol/solutions) GitHub repository. +Check the [example](/cli/guides/deploy-app/example) at the end of this guide. + +More Dockerfile examples can be found in the [Super-Protocol/solutions](https://github.com/Super-Protocol/solutions) GitHub repository. ### 1.2. Build a Docker image @@ -124,17 +126,11 @@ Place an order using the [`workflows create`](/cli/commands/workflows/create) co --data ./more-data.resource.json ``` -:::note - -When you provide multiple data inputs, they are placed in separate directories inside the CVM: the first in `/sp/inputs/input-0001`, the second in `/sp/inputs/input-0002`, and so on. - -::: - Find the order ID in the output. ## 4. Download the result -Wait a few minutes and [check the order status](/cli/commands/orders/get): +Wait a few minutes and check the order status: ```shell ./spctl orders get @@ -146,7 +142,7 @@ For example: ./spctl orders get 256587 ``` -If the status is `Done`, the order is ready, and you can [download the order result](/cli/commands/orders/download-result): +If the status is `Done` or `Error`, you can [download the order result](/cli/commands/orders/download-result): ```shell ./spctl orders download-result diff --git a/docs/cli/Guides/tgwui.md b/docs/cli/Guides/tgwui.md index 87602534..0885d659 100644 --- a/docs/cli/Guides/tgwui.md +++ b/docs/cli/Guides/tgwui.md @@ -12,7 +12,7 @@ This guide provides step-by-step instructions for uploading and deploying an AI ## Prerequisites -- [SPCTL](https://docs.develop.superprotocol.com/cli/) +- [SPCTL](/cli/) - BNB and SPPI tokens (opBNB) to pay for transactions and orders ## 1. Prepare @@ -91,19 +91,20 @@ Replace `` with the tunnel order ID from the previous step. ./spctl orders download-result ``` -3.5. Extract the downloaded `result.tar.gz`, open `output/result.json`, and find the domain address. For example: +3.5. Extract the downloaded `result.tar.gz`, open `output/result.json`, and find the domain. For example: ```json title="result.json" "domain":"pret-tons-wade.superprotocol.io" ``` -Your model's web UI will be available at this address. +Your model's web UI will be available at this URL. ## 4. Prepare engine configuration files 4.1. Open the SPCTL's `config.json` and find the `workflow.resultEncryption.key` property that contains the key used for decrypting workflow results; for example: `NapSrwQRz2tL9ZftJbi6DATpCDn0BRImpSStU9xZT/s=`. -4.2. +4.2. Create configuration files: + Create a file named `engine-configuration-tgwui.json` and paste the following: @@ -184,10 +185,10 @@ Save and close the file. ## 5. Deploy the model -5.1. +5.1. Create the main order to deploy your uploaded model: + - Create the main order to deploy your uploaded model: ```shell ./spctl workflows create --tee --solution 25 --solution-configuration ./engine-configuration-tgwui.json --data ./model.resource.json @@ -198,7 +199,6 @@ Save and close the file. Note that `--solution 25` refers to [Text Generation Web UI with GPU support](https://marketplace.superprotocol.com/marketplace/models?offer=offerId%3D25). If you need the CPU version, use `--solution 26` instead. - Create the main order to deploy your uploaded model: ```shell ./spctl workflows create --tee --solution 27 --solution-configuration ./engine-configuration-comfyui.json --data ./model.resource.json diff --git a/docs/cli/Guides/unsloth.md b/docs/cli/Guides/unsloth.md index 24b46110..70ae7f67 100644 --- a/docs/cli/Guides/unsloth.md +++ b/docs/cli/Guides/unsloth.md @@ -7,11 +7,11 @@ sidebar_position: 5 This guide provides step-by-step instructions for fine-tuning an AI model using the Super Protocol packaging of [Unsloth](https://unsloth.ai/), an open-source framework for LLM fine-tuning and reinforcement learning. -The solution allows you to run fine-tuning within Super Protocol's Trusted Execution Environment (TEE). This provides enhanced security and privacy and enables a range of [confidential collaboration](https://docs.develop.superprotocol.com/cli/guides/multi-party-collab) scenarios. +The solution allows you to run fine-tuning within Super Protocol's Trusted Execution Environment (TEE). This provides enhanced security and privacy and enables a range of [confidential collaboration](/cli/guides/multi-party-collab) scenarios. ## Prerequisites -- [SPCTL](https://docs.develop.superprotocol.com/cli/) +- [SPCTL](/cli/) - Git - BNB and SPPI tokens (opBNB) to pay for transactions and orders diff --git a/docs/cli/Guides/vllm.md b/docs/cli/Guides/vllm.md index a833a22d..d701a650 100644 --- a/docs/cli/Guides/vllm.md +++ b/docs/cli/Guides/vllm.md @@ -9,7 +9,7 @@ This guide provides step-by-step instructions for running an AI model inference ## Prerequisites -- [SPCTL](https://docs.develop.superprotocol.com/cli/) +- [SPCTL](/cli/) - Git - BNB and SPPI tokens (opBNB) to pay for transactions and orders diff --git a/docs/fundamentals/certification.md b/docs/fundamentals/certification.md index 0dfd2161..4ef4e184 100644 --- a/docs/fundamentals/certification.md +++ b/docs/fundamentals/certification.md @@ -28,7 +28,7 @@ The Certification System is organized as a hierarchy of Confidential Virtual Machines (CVMs) running in TEEs, and in some other cases. These certificates are not CAs and cannot be used to sign or issue other certificates. @@ -36,7 +36,7 @@ Each level in the hierarchy receives its certificate from the level above, creat ## Trusted Loader -Trusted Loader is a special service that prepares and launches the workload associated with an order inside a CVM running in a TEE. It runs in a privileged position within the execution environment, allowing it to access the underlying attestation capabilities of the platform. Workloads themselves do not have such access. +Trusted Loader is a special service that prepares and launches the workload associated with an order inside a CVM running in a TEE. Loader occupies a privileged position within the execution environment, enabling it to access the platform's underlying attestation capabilities. Workloads themselves do not have such access. Trusted Loader also: @@ -63,7 +63,7 @@ Note that the Certification System does not determine whether a CVM is correct o Orders in Super Protocol are created with a workload description known as *Workload Info*. -Workload Info includes an array called `runtimeInfo`. It contains information about solutions and data associated with the order. Each such order component has an entry in this array, which includes: +Workload Info includes an array called `runtimeInfo` that contains information about solutions and data associated with the order. Each data and solution component of the order has an entry in this array, which includes: - Type (solution or data) - Hash diff --git a/docs/guides/index.md b/docs/guides/index.md index 31dab108..26693316 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -18,12 +18,12 @@ sidebar_position: 0 ## CLI -|
**Guide**
|
**Description**
| -| :- | :- | -| [Configure SPCTL](/cli) | How to set up SPCTL—a Super Protocol CLI tool. | -| [Configure Provider Tools](/cli/guides/provider-tools) | How to set up Provider Tools—a Super Protocol CLI utility for registering providers and creating offers. | -| [Quick Deployment Guide](/cli/guides/quick-guide) | Quick instructions on deploying a solution and data on Super Protocol. | -| [Confidential Collaboration](/cli/guides/multi-party-collab) | A scenario of confidential collaboration on Super Protocol. | +|
**Guide**
|
**Description**
| +| :- | :- | +| [Configure SPCTL](/cli) | How to set up SPCTL—a Super Protocol CLI tool. | +| [Configure Provider Tools](/cli/guides/provider-tools) | How to set up Provider Tools—a Super Protocol CLI utility for registering providers and creating offers. | +| [Quick Deployment Guide](/cli/guides/deploy-app) | Quick instructions on deploying a solution and data on Super Protocol. | +| [Confidential Collaboration](/cli/guides/multi-party-collab) | A scenario of confidential collaboration on Super Protocol. | ### Solutions diff --git a/docusaurus.config.js b/docusaurus.config.js index c3a86fd7..db773ef3 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -42,10 +42,10 @@ const config = { from: "/hackathon", to: "/hackathon/about", }, - /*{ - from: "/colab", - to: "/colab/jupyter", - },*/ + { + from: "/cli/guides/quick-guide", + to: "/cli/guides/deploy-app", + }, ], }, ], diff --git a/static/files/usd_to_crypto.py b/static/files/usd_to_crypto.py new file mode 100644 index 00000000..88da57e5 --- /dev/null +++ b/static/files/usd_to_crypto.py @@ -0,0 +1,45 @@ +import requests +import sys + +def main(): + input_file = "input.txt" + output_file = "result.txt" + + try: + # Read the input amount + with open(input_file, "r") as f: + content = f.read().strip() + if not content: + raise ValueError("Input file is empty") + + try: + usd_amount = float(content) + except ValueError: + raise ValueError("Input is not a valid number") + + # Fetch BTC and ETH prices from CoinGecko + url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd" + response = requests.get(url, timeout=10) + if response.status_code != 200: + raise RuntimeError(f"API request failed with status code {response.status_code}") + + data = response.json() + btc_price = data["bitcoin"]["usd"] + eth_price = data["ethereum"]["usd"] + + # Calculate how much BTC and ETH can be bought + btc_amount = usd_amount / btc_price + eth_amount = usd_amount / eth_price + + # Write results to output file, rounded to 6 decimals + with open(output_file, "w") as f: + f.write(f"BTC: {btc_amount:.6f}\n") + f.write(f"ETH: {eth_amount:.6f}\n") + + except Exception as e: + # Write the error message to the result file + with open(output_file, "w") as f: + f.write(f"Error: {str(e)}\n") + +if __name__ == "__main__": + main() From ea0801b561605b77510b50f8d0d44ace773bd715 Mon Sep 17 00:00:00 2001 From: k3dz0r Date: Thu, 5 Feb 2026 13:12:18 -0300 Subject: [PATCH 2/2] Minor fixes --- docs/cli/Guides/deploy-app/deploy-app-example.md | 4 ++-- docs/cli/Guides/tgwui.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/cli/Guides/deploy-app/deploy-app-example.md b/docs/cli/Guides/deploy-app/deploy-app-example.md index 60d596e0..762949db 100644 --- a/docs/cli/Guides/deploy-app/deploy-app-example.md +++ b/docs/cli/Guides/deploy-app/deploy-app-example.md @@ -36,7 +36,7 @@ Keep in mind that file locations inside a CVM will differ from a local run: - Data (`input.txt`) must be found in one of the `/sp/inputs/input-xxxx` directories. - `result.txt` must be placed into `/sp/output` to be available to download once the execution is finished. -1.1. Create an new file named `entrypoint.sh` and add the following code: +1.1. Create a new file named `entrypoint.sh` and add the following code: ```sh title="entrypoint.sh" #!/bin/sh @@ -66,7 +66,7 @@ fi exec python3 "${SCRIPT_PATH}" ``` -Create an new file named `Dockerfile` and add the following code: +Create a new file named `Dockerfile` and add the following code: ```dockerfile title="Dockerfile" FROM ubuntu:22.04 diff --git a/docs/cli/Guides/tgwui.md b/docs/cli/Guides/tgwui.md index 0885d659..66ac340a 100644 --- a/docs/cli/Guides/tgwui.md +++ b/docs/cli/Guides/tgwui.md @@ -151,7 +151,7 @@ Your model's web UI will be available at this URL. } ```
- + Create a file named `engine-configuration-comfyui.json` and paste the following: ```json title="engine-configuration-comfyui.json" @@ -198,7 +198,7 @@ Save and close the file. Note that `--solution 25` refers to [Text Generation Web UI with GPU support](https://marketplace.superprotocol.com/marketplace/models?offer=offerId%3D25). If you need the CPU version, use `--solution 26` instead. - + ```shell ./spctl workflows create --tee --solution 27 --solution-configuration ./engine-configuration-comfyui.json --data ./model.resource.json