Python Swan SDK
For more detailed samples, consult SDK Samples.
For detailed description of functions, please check Key Functions.
Orchestrator
Orchestrator allows you to create task to run application instances to the powerful distributed computing providers network.
Fetch available instance resources
Before using Orchestrator to deploy task, it is necessary to know which instance resources are available. Through get_instance_resources you can get a list of available instance resources including their region information. From the output list, you can choose an instance_type by checking the description for the hardware configuration requirements.
import json
import swan
swan_orchestrator = swan.resource(api_key='<SWAN_API_KEY>', service_name='Orchestrator')
available_resources = swan_orchestrator.get_instance_resources()
print(available_resources)Sample output:
[InstanceResource({
"hardware_id": 0,
"instance_type": "C1ae.small",
"description": "CPU only \u00b7 2 vCPU \u00b7 2 GiB",
"type": "CPU",
"region": [
"Quebec-CA",
"North Carolina-US"
],
"price": "1.2",
"status": "available",
"snapshot_id": 1731441600,
"expiry_time": 1731442218
}), ...]Create and deploy a task
Deploy a simple application with Swan SDK:
It may take several minutes to get the deployment result:
A sample output:
It shows that this task has three applications. Open the URL in the web browser you will view the application's information if it is running correctly.
Check information of an existing task
With Orchestrator, you can check information for an existing task to follow up or view task deployment.
Access application instances of an existing task
With Orchestrator, you can easily get the deployed application instances for an existing task.
Renew an existing task
If you have already submitted payment for the renewal of a task, you can use the tx_hash with renew_task to extend the task.
Terminate an existing task
You can also early terminate an existing task and its application instances. By terminating task, you will stop all the related running application instances and thus you will get refund of the remaining task duration.
Last updated