Skip to main content

HTTP/WebSocket client for the JuniperCascor neural network training service

Project description

juniper-cascor-client

Python HTTP/WebSocket client for the JuniperCascor cascade correlation neural network training service.

Ecosystem Compatibility

This package is part of the Juniper ecosystem. Compatible with:

juniper-data juniper-cascor juniper-canopy
0.4.x 0.3.x 0.2.x

Installation

pip install juniper-cascor-client

Usage

REST Client

from juniper_cascor_client import JuniperCascorClient

with JuniperCascorClient("http://localhost:8200") as client:
    # Create a network
    client.create_network(input_size=2, output_size=2, learning_rate=0.01)

    # Start training
    client.start_training(
        dataset={"source": "inline"},
        inline_data={
            "train_x": [[0, 0], [1, 0], [0, 1], [1, 1]],
            "train_y": [[1, 0], [0, 1], [0, 1], [1, 0]],
        },
        epochs=100,
    )

    # Check status
    status = client.get_training_status()
    print(status["data"]["training_active"])

    # Get metrics
    metrics = client.get_metrics()
    print(f"Loss: {metrics['data']['train_loss']}")

WebSocket Training Stream

import asyncio
from juniper_cascor_client import CascorTrainingStream

async def monitor():
    async with CascorTrainingStream("ws://localhost:8200") as stream:
        async for message in stream:
            if message["type"] == "metrics":
                print(f"Epoch {message['data']['epoch']}: loss={message['data']['train_loss']}")
            elif message["type"] == "cascade_add":
                print(f"New hidden unit added!")

asyncio.run(monitor())

WebSocket Control

import asyncio
from juniper_cascor_client import CascorControlStream

async def control():
    async with CascorControlStream("ws://localhost:8200") as ctrl:
        result = await ctrl.command("start", {"epochs": 200})
        print(result)

asyncio.run(control())

API Reference

JuniperCascorClient

Method Description
health_check() Service health check
is_alive() Liveness probe
is_ready() Readiness probe
wait_for_ready(timeout) Wait for service readiness
create_network(**kwargs) Create a CasCor network
get_network() Get network state
delete_network() Destroy network
get_topology() Network topology for visualization
get_statistics() Network weight statistics
start_training(...) Start async training
stop_training() Stop training
pause_training() Pause training
resume_training() Resume training
reset_training() Reset state
get_training_status() Current training status
get_training_params() Training parameters
get_metrics() Current metrics
get_metrics_history(count) Metrics history
get_dataset() Dataset metadata
get_decision_boundary(resolution) Decision boundary grid

CascorTrainingStream

Async WebSocket client for /ws/training. Supports async iteration and callbacks.

CascorControlStream

Async WebSocket client for /ws/control. Send commands and receive responses.

Juniper Ecosystem

This package is part of the Juniper Cascade Correlation Neural Network Research Platform.

Package Description Install
juniper-data-client Dataset service client pip install juniper-data-client
juniper-cascor-client Neural network service client (this package) pip install juniper-cascor-client
juniper-cascor-worker Distributed training worker pip install juniper-cascor-worker

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

juniper_cascor_client-0.3.0.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

juniper_cascor_client-0.3.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file juniper_cascor_client-0.3.0.tar.gz.

File metadata

  • Download URL: juniper_cascor_client-0.3.0.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for juniper_cascor_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6da2b263748307e5707d03e78a5f7b409ebe22108195b47a84c423f34552fcd7
MD5 0a7981a0af41cd9a6eda5e4b4229ce9c
BLAKE2b-256 e1a5d7be1ef791ebe63c45c54054a244b78ac4fb4fca87bed8b8830bfe3c1e97

See more details on using hashes here.

Provenance

The following attestation bundles were made for juniper_cascor_client-0.3.0.tar.gz:

Publisher: publish.yml on pcalnon/juniper-cascor-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file juniper_cascor_client-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for juniper_cascor_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 deb181d9465134b88a07f4a7d6f6b069aa7713b06e362bb86e526e4b33f97708
MD5 fe7b0f0a6a423d47991c0ed9b06cfa56
BLAKE2b-256 503248c061b2853f6a672c134ea4526c36be8f457ff7ac8c21a91efb8a8992d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for juniper_cascor_client-0.3.0-py3-none-any.whl:

Publisher: publish.yml on pcalnon/juniper-cascor-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page