SingTown AI Python Client
Project description
SingTown AI Python SDK
This SDK is designed to interact with SingTown AI Cloud Service or SingTown AI Standalone(self-hosted).
Installation
pip install singtown_ai
Usage
Login Configuration
- SingTown AI Cloud Service: The
hostis"https://ai.singtown.com". - SingTown AI Standalone (self-hosted): The
hostis something like"http://127.0.0.1:8000".
You can obtain the token and task_id from Project -> Information.
Environment Variables:
export SINGTOWN_AI_HOST="https://ai.singtown.com" # Or the cloud service URL
export SINGTOWN_AI_TOKEN="your token" # Your token
export SINGTOWN_AI_TASK_ID="your id" # Your task ID
Alternatively, set them directly in code:
SingTownAiClient(
host="https://ai.singtown.com", # Or the cloud service URL
token="your token", # Your token
task_id="your id" # Your task ID
)
Dry Run
python -m singtown_ai.dryrun --host=http://127.0.0.1:8000 --token=012345 --task_id=1
- This command will simulate 10s train task.
Basic Usage
from singtown_ai import SingTownAiClient
with SingTownAiClient() as client:
pass # Insert your code here
- This will periodically update the running status. After finished, it will post a "training succeeded" status. If an error occurs, it will post a "training failed" status.
Mock Usage
from singtown_ai import SingTownAiClient
with SingTownAiClient(mock=True) as client:
pass # Insert your code here
- Set mock=True, Will mock demo task and dataset, this is useful for debugging.
Uploading Metrics
metrics = [
{"epoch": 0, "accuracy": 0.8, "loss": 0.2},
{"epoch": 1, "accuracy": 0.9, "loss": 0.1},
]
with SingTownAiClient() as client:
client.upload_metrics(metrics)
- The field names in
metricsare not restricted, and they will appear on the Metrics page in SingTown AI.
Watching metrics.csv
with SingTownAiClient(metrics_file="metrics.csv") as client:
pass # Insert your code here
- Every 3 seconds, the SDK will parse the
metrics.csvand upload data.
Posting Logs
with SingTownAiClient() as client:
import time
for i in range(100):
client.log(f"epoch: {i}")
time.sleep(0.1)
- This will upload log strings, posting them every 3 seconds.
Download Trained Files from Server
with SingTownAiClient() as client:
client.download_trained_file("folder")
- This method will download the trained file and automatically extract it into the specified folder.
Uploading Result Files
with SingTownAiClient() as client:
client.upload_results_zip("your.zip")
- This method uploads a
.zipresult file.
Run Subprocess Command
with SingTownAiClient() as client:
client.run_subprocess("echo hello world!")
client.run_subprocess("python3 train.py", ignore_stdout=True)
- This method will run subprocess and log stdout and stderr.
- If
ignore_stdout=True, will not log stdout.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
singtown_ai-1.2.0.tar.gz
(484.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
singtown_ai-1.2.0-py3-none-any.whl
(489.9 kB
view details)
File details
Details for the file singtown_ai-1.2.0.tar.gz.
File metadata
- Download URL: singtown_ai-1.2.0.tar.gz
- Upload date:
- Size: 484.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c530d081e8fa664e8b3436446909fcddd7739807be5f3fc61329061eebb2eeda
|
|
| MD5 |
37d0e17144aefa776f4d522848fa2930
|
|
| BLAKE2b-256 |
abfe9ad1836d04045ab2b8b2645689f0a5092955d435900ddf75716c67cc9fed
|
File details
Details for the file singtown_ai-1.2.0-py3-none-any.whl.
File metadata
- Download URL: singtown_ai-1.2.0-py3-none-any.whl
- Upload date:
- Size: 489.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd8bc69e50aa7a3fede21a794595168730b5236c11183d73677198587c72ccd5
|
|
| MD5 |
f1baa13ce319cd9eaf0907da570668f6
|
|
| BLAKE2b-256 |
cf488f232de87971ec9da7e25ebbad554431f8ab4bbfc6c1cf3a9af410ca7bcb
|