Skip to content

Instantly share code, notes, and snippets.

@Birdasaur
Created April 15, 2025 17:26
Show Gist options
  • Save Birdasaur/23e8bed1965e517ea558e8cbf5a0b158 to your computer and use it in GitHub Desktop.
Save Birdasaur/23e8bed1965e517ea558e8cbf5a0b158 to your computer and use it in GitHub Desktop.
Python script to inject data and command Trinity over the wire using JSON
import json
import httpx
trinityURL = "http://localhost:8080";
print("switching to Hyperspace View...");
cmdJson = {
'messageType': 'command_request',
'request': 'VIEW_HYPERSPACE',
}
s = json.dumps(cmdJson)
print(s)
r = httpx.post(trinityURL, json=cmdJson)
print(r)
print("loading feature collection...");
with open('RealvsFakeAudioVectors.json') as f: #read in feature collection
#with open('CLIP_data.json') as f: #read in feature collection
fileJson = json.load(f)
#call public method that deserializes json into Trinity data and renders.
print("httpx posting feature collection...");
r = httpx.post(trinityURL, json=fileJson)
print(r)
print("Switching to Projections View...");
cmdJson = {
'messageType': 'command_request',
'request': 'VIEW_PROJECTIONS',
'delaySeconds':1.0
}
s = json.dumps(cmdJson)
print(s)
r = httpx.post(trinityURL, json=cmdJson)
print(r)
print("loading custom UMAP Config...");
with open('EuclideanUmapConfig.json') as f: #read in feature collection
fileJson = json.load(f)
print("httpx posting custom UMAP config...");
r = httpx.post(trinityURL, json=fileJson)
print(r)
print("Executing UMAP...");
cmdJson = {
'messageType': 'command_request',
'request': 'EXECUTE_UMAP',
'delaySeconds':3.0
}
s = json.dumps(cmdJson)
print(s)
r = httpx.post(trinityURL, json=cmdJson)
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment