This directory contains samples for Swan Orchestrator. Swan Orchestrator is the Web3 cloud computing solution for tasks creation, deployment and management. User can create and manage tasks through samples under this directory. For more information checkout Swan Developer Docs.
Samples (and Swan SDK) requires you to have API Key from Swan Orchestrator.
Steps to get an API Key:
- Go to Orchestrator Dashboard. Make sure you're under the Mainnet environment.
- Login through MetaMask.
- Click the user icon on the top right.
- Click 'Show API-Key' -> 'New API Key'
- Store your API Key safely, do not share with others.
- Clone the python-sdk-docs-samples and change directory to the directory you want to use.
$ git clone https://github.com/swanchain/python-sdk-docs-samples.git
- Install and updgrade pip and virtualenv if you do not already have them.
- Create virtualenv compatible with Python 3.7+
$ python3 -m venv venv
$ source venv/bin/activate
- Install the dependencies from the requirements file
$ pip install -r requirements.txt
- public address will be required for authorization on Swan Orchestrator.
- private address will be required for signing onchain transactions.
- API key will be required for using Swan Orchestrator APIs.
WALLET_ADDRESS=<your_wallet_address>
PRIVATE_KEY=<your_private_key>
SWAN_API_KEY=<your_swan_api_key>
This example shows how to retrieve all currently available CP resources online.
$ python compute/get_instance_resources.py
This example shows detailed breakdown of instance configuration structure and usage.
$ python compute/instance_configuration_example.py
This example shows how to connect to Orchestrator.
$ python compute/connect_orchestrator.py
This example shows how to create task with Swan SDK.
$ python compute/create_task.py
This example shows how to extend a task's duration.
$ python compute/renew_task.py '<task_uuid>'
This example shows how to early terminate a task.
$ python compute/terminate_task.py '<task_uuid>'
This example shows how to get a list of tasks under the user of API Key and wallet address.
$ python compute/get_task_list.py
This example shows how to get the task deployment info.
$ python compute/get_task_deployment_info.py '<task_uuid>'
This example shows how to approve an amount for payment in advance.
$ python compute/payment_approve.py
These examples shows how to deploy specific applications.
$ python compute/hello-world.py # hello world app
$ python compute/deploy-chainnode.py # chainnode app
$ python compute/deploy-llama3-model.py # llama3 model app