diff --git a/docs/colab/cli.md b/docs/colab/cli.md new file mode 100644 index 00000000..3bb04c01 --- /dev/null +++ b/docs/colab/cli.md @@ -0,0 +1,105 @@ +--- +id: "cli" +title: "Deploy using the CLI (Docker)" +slug: "/cli" +sidebar_position: 2 +--- + +Prerequisite: +- [SPCTL](https://docs.superprotocol.com/cli/)—the Super Protocol CLI tool. + +### Prepare the solution + +1. Build a Docker image with your script or application. + +2. Save and zip the image: + +```shell +docker save :latest | gzip > .tar.gz +``` + +Replace `` with the name of your image, for example: + +```shell +docker save jupyter:latest | gzip > jupyter.tar.gz +``` + +3. Upload the archive using SPCTL: + +```shell +./spctl files upload --filename --output solution_resource.json +``` + +Replace: + +* `` with the path to the image archive +* `` with the name of the image archive + +For example: + +```shell +./spctl files upload ~/Docker/jupyter.tar.gz --filename jupyter.tar.gz --output solution_resource.json +``` + +The resulting file `solution_resource.json` contains information on how to access and decrypt the uploaded solution. + +### Deploy + +1. Place an order: + +```shell +./spctl workflows create \ +--solution solution_resource.json \ +--data .json \ +--tee 10 \ +--storage 47 \ +--skip-hardware-check \ +--orders-limit 100 +``` + +Replace `` with the path and name of a TII.JSON file. You can use the `--data` option multiple times. For example: + +```shell +./spctl workflows create \ +--solution solution_resource.json \ +--data superprotocol-file-pack-2025-08-14T13-51-26.tii.json \ +--data superprotocol-file-pack-2025-08-14T13-56-42.tii.json \ +--tee 10 \ +--storage 47 \ +--skip-hardware-check \ +--orders-limit 100 +``` + +The output will contain the order ID. + +2. Wait 15-20 minutes and check the order status: + +```shell +./spctl orders get +``` + +For example: + +```shell +./spctl orders get 244835 +``` + +3. If the order is complete, download the result: + +```shell +./spctl orders download-result +``` + +For example: + +```shell +./spctl orders download-result 244835 +``` + +4. Unzip the downloaded archive: + +```shell +tar -xvzf result.tar.gz +``` + +The execution result is located in the `output` folder. \ No newline at end of file diff --git a/docs/colab/docker.md b/docs/colab/docker.md deleted file mode 100644 index 35497f48..00000000 --- a/docs/colab/docker.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -id: "docker" -title: "Docker Image" -slug: "/docker" -sidebar_position: 1 ---- - -Work in progress... \ No newline at end of file diff --git a/docs/colab/Jupyter.md b/docs/colab/gui.md similarity index 75% rename from docs/colab/Jupyter.md rename to docs/colab/gui.md index bb254caf..287ac1be 100644 --- a/docs/colab/Jupyter.md +++ b/docs/colab/gui.md @@ -1,66 +1,63 @@ --- -id: "jupyter" -title: "Jupyter Notebook" -slug: "/" -sidebar_position: 0 +id: "gui" +title: "Deploy using the UI (Jupyter)" +slug: "/gui" +sidebar_position: 1 --- -## Log in +## Log in and get tokens -1. Open the [Marketplace](https://marketplace.superprotocol.com). - +1. Open the [Marketplace](https://marketplace.superprotocol.com). + 2. Click **Enter Marketplace** in the upper-right corner and log in using your preferred method. -## Get SPPI tokens +3. Click on your account name in the upper-right corner and select Account. -1. Click on your account name in the upper-right corner and select Account. -

- -2. In the Account window, copy your Super Wallet address and share it with your contact in Super Protocol to receive SPPI tokens. - + +4. In the Account window, copy your Super Wallet address and share it with your contact in Super Protocol to receive SPPI tokens. +

## Upload an IPYNB script or dataset -1. Open the [Marketplace Colab page](https://marketplace.superprotocol.com/order-create-colab). - -2. Press **Upload Content**, select a file or folder, and click **Upload**. The uploaded content will be automatically encrypted and placed in a decentralized file storage (Storj). - -3. Save the resulting TII.JSON file; it can be opened in any text editor. Inside: - -- Encrypted data describing how to download and decrypt the uploaded content (objects `"encryptedResource"` and `"encryptedTRI"`). -- Hash of the uploaded content, calculated before the encryption. -- Restrictions on the computing device and the solution offer (i.e., Jupyter Notebook). - +1. Open the [Marketplace Colab page](https://marketplace.superprotocol.com/order-create-colab). + +2. Press **Upload Content**, select a file or folder, and click **Upload**. The uploaded content will be automatically encrypted and placed in a decentralized file storage (Storj). + +3. Save the resulting TII.JSON file; it can be opened in any text editor. Inside: + +- Encrypted data describing how to download and decrypt the uploaded content (objects `"encryptedResource"` and `"encryptedTRI"`). +- Hash of the uploaded content, calculated before the encryption. +- Restrictions on the computing device and the solution offer (i.e., Jupyter Notebook). + TII.JSON files are safe to share. The information about the uploaded content is encrypted with the public key of the specified confidential virtual machine (`"offerId": "10"`). Only this machine can decrypt it and then download and decrypt the content itself. The machine runs inside a Trusted Execution Environment with no external access. -## Deploy - -1. Open the [Marketplace Colab page](https://marketplace.superprotocol.com/order-create-colab). - -2. Press **Run Colab**. - -3. Add the application and dataset TII.JSON files generated during the upload process. - -4. Press **Run**. When the order is created, you will be redirected to the order page. Write down the order ID; you may need it later for verification. - -5. Wait until the order is complete. For small files, it typically takes around 20 minutes, but the time can be significantly longer for large files. Use the **Extend Lease** button to add tokens to the order balance if the lease time is running out. - -6. When the order is complete (Status: Done), press **Get Result** and download the TAR.GZ archive containing the order result. - +## Place an order + +1. Open the [Marketplace Colab page](https://marketplace.superprotocol.com/order-create-colab). + +2. Press **Run Colab**. + +3. Add the application and dataset TII.JSON files generated during the upload process. + +4. Press **Run**. When the order is created, you will be redirected to the order page. Write down the order ID; you may need it later for verification. + +5. Wait until the order is complete. For small files, it typically takes around 20 minutes, but the time can be significantly longer for large files. Use the **Extend Lease** button to add tokens to the order balance if the lease time is running out. + +6. When the order is complete (Status: Done), press **Get Result** and download the TAR.GZ archive containing the order result. + 7. Unzip the downloaded archive. The execution result is located in the `output` folder. ## Verify -1. [Download and set up SPCTL](/cli/) – the Super Protocol CLI tool. - -2. Get the order report: - +1. [Download and set up SPCTL](/cli/)—the Super Protocol CLI tool. + +2. Get the order report: ```shell ./spctl orders get-report --save-to report.json @@ -74,8 +71,8 @@ Replace `` with your order ID, for example: The command will display and save the order report to the `report.json` file in the SPCTL directory. This report includes the certificate chain, order metadata, and validation result. -3. Ensure you see `Order report validation successful!` in the output. - +3. Ensure you see `Order report validation successful!` in the output. + 4. Open `report.json` in a text editor and find two entries in the `“runtimeInfo”` array that start with `"type": "Data"`. For example: ```json @@ -83,9 +80,9 @@ The command will display and save the order report to the `report.json` file in "type": "Data", "size": 12901, "hash": { - "algo": "sha256", - "hash": "8598805cd2136a4beff17559a7228854f6a8cc0b027856ea5c196fb8d0602501", - "encoding": "hex" + "algo": "sha256", + "hash": "8598805cd2136a4beff17559a7228854f6a8cc0b027856ea5c196fb8d0602501", + "encoding": "hex" } }, ``` diff --git a/docs/colab/jupyter.md b/docs/colab/jupyter.md new file mode 100644 index 00000000..54b2a7de --- /dev/null +++ b/docs/colab/jupyter.md @@ -0,0 +1,86 @@ +--- +id: "jupyter" +title: "Prepare a Jupyter Notebook script" +slug: "/" +sidebar_position: 0 +--- + +## Super Protocol TEE file system + +Inside the TEE, you have a special file structure: + +| Location | Purpose | Access | +| :---- | :---- | :---- | +| `/sp/inputs/input-0001` | Possible data location 1 | Read-only | +| `/sp/inputs/input-0002` | Possible data location 2 | Read-only | +| `/sp/outputs` | Output folder for your results | Write; you can also read own files | + +:::important + +Always use absolute paths, such as `/sp/...`. + +::: + +## 1. Prepare your script + +In the Jupyter Notebook: + +1. Locate your input file in `/sp/inputs`. + +2. Load the data; for example, from a CSV file. + +3. Process the data as needed. + +4. Write the results to `/sp/outputs` so they are saved and returned after execution. + +## 2. Find the input file + +In the TEE, locate your input file, for example `input.csv`, using the `find_input_file()` function. This function checks both input folders and returns the absolute path: + +```py +from pathlib import Path + +# Helper function to find the input file +def find_input_file(filename): +locations = [ +Path(f"/sp/inputs/input-0002/{filename}"), +Path(f"/sp/inputs/input-0001/{filename}") +] +for path in locations: +if path.exists(): +print(f"Using input file: {path}") +return path +raise FileNotFoundError(f"{filename} not found in input-0002 or input-0001") + +# Specify the input file (replace "input.csv" with the name of your file) +input_path = find_input_file("input.csv") +``` + +## 3. Read the input file + +You can load the input file using any library or method suitable for your data format. For example, with pandas: + +```py +import pandas as pd + +df = pd.read_csv(input_path) +print(df.head()) +``` + +Use `input_path` as the file location if you use another method, such as the csv module, a JSON parser, or any other library. + +## 4. Process and save the data + +After loading your data, process it in memory and save the results to `/sp/outputs`. Ensure your processed data, whether a DataFrame, list, dictionary, or other format, is ready before saving. For example: + +```py +from pathlib import Path +import pandas as pd + +# Create the output directory if it doesn't exist +output_path = Path("/sp/outputs") +output_path.mkdir(parents=True, exist_ok=True) +# Specify the output file (replace "output.csv" with the name of your file) +output_file = output_path / "output.csv" +df.to_csv(output_file, index=False) +``` \ No newline at end of file