41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
from pytrace.client import TraceClient
|
|
|
|
def main():
|
|
"""
|
|
An example script demonstrating how to use the TraceClient to register
|
|
a custom node with the TraceStudio Server.
|
|
"""
|
|
# Point the client to the server
|
|
client = TraceClient(base_url="http://127.0.0.1:8000")
|
|
|
|
# 1. Register our custom node with the server
|
|
print("Registering custom 'StringConcatNode'...")
|
|
try:
|
|
registration_result = client.register_node_from_file(
|
|
"example_nodes/string_nodes.py"
|
|
)
|
|
print("Registration successful:", registration_result)
|
|
except Exception as e:
|
|
print(f"Failed to register node: {e}")
|
|
return
|
|
|
|
# 2. Get the list of all available plugins from the server to verify
|
|
# that our new node is now listed.
|
|
print("\nFetching all available plugins...")
|
|
try:
|
|
plugins = client.get_plugins()
|
|
print(f"Successfully fetched {plugins['total']} plugins.")
|
|
|
|
custom_node_type = registration_result.get("node_type")
|
|
if custom_node_type in plugins.get("plugins", {}):
|
|
print(f"SUCCESS: Found registered node '{custom_node_type}' in server's plugin list.")
|
|
else:
|
|
print(f"WARNING: Could not find '{custom_node_type}' in server's plugin list.")
|
|
|
|
except Exception as e:
|
|
print(f"Failed to get plugins: {e}")
|
|
return
|
|
|
|
if __name__ == "__main__":
|
|
main()
|