Skip to main content

Python SDK for the Federated Learning Clinical Safety API

Project description

🔧 Federated Learning Clinical Safety Server SDK

This is the documentation for the Federated Learning Clinical Safety Dashboard SDK! This project provides a package for interacting with the Federated Learning Clinical Safety Dashboard Server in a type-safe and easy manner.

CI

SDK ↔ Server Integration

Using the SDK

The package is available from PyPi.

Installation

pip install federated-learning-clinical-safety-sdk

🚀 Quickstart code

from api_sdk.client import APIClient
from api_sdk.models import FlModel

# 1. Initialize
BASE_URL = "http://localhost:8000/api"       # i.e. vht-dev.shef.ac.uk/api
TOKEN    = "your_api_token_here"             # create a machine account with create_uploader <username>

client = APIClient(BASE_URL, TOKEN)

# 2. List all federated models
models = client.list_models()
for m in models:
    print(f"{m.id}: {m.name} ({m.accuracy*100:.1f}% accuracy)")

# 3. Fetch a single model by ID
model = client.get_model(model_id=1)
print(model)

# 4. Create a new model
new = FlModel(
    name="MyModel",
    accuracy=0.88,
    generalisability=0.82,
    security=0.75
)
created = client.create_model(new)
print(f"Created model ID = {created.id}")

Development

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.10+
  • Poetry

Installing poetry

Windows NT

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -

Then add to path:

%USERPROFILE%\AppData\Roaming\pypoetry\venv\Scripts

Linux/MacOS/Unix-like systems:

pipx install poetry

Publishing new versions

This repo is set up with Continuous Deployment to automatically deploy new packages to PyPi.

To deploy a new version, do the following.

  1. Bump the package version
poetry version patch
  1. Create a matching git tag
git tag v<version number (i.e. 0.1.1)>
  1. Push the tag to GitHub
git push origin v<version number from step 2 (i.e. 0.1.1)>

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

Built Distribution

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

File details

Details for the file federated_learning_clinical_safety_sdk-0.1.1.tar.gz.

File metadata

File hashes

Hashes for federated_learning_clinical_safety_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5cea4c2502c77da61e70460158abbaed05e4aa187329c91ec37d0715ae89b23f
MD5 5ec74ec028d7d2da106b8280169c2135
BLAKE2b-256 64d7afad66664480415ce7fef065bc453ba7ab40fba903e23761b71f0da63c4e

See more details on using hashes here.

File details

Details for the file federated_learning_clinical_safety_sdk-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for federated_learning_clinical_safety_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccef6f4696f69a66044a441799768625d3b0daaae14ee7fde3a250d95bb38c28
MD5 ddafb57181a1622943a2a568f94f9b2d
BLAKE2b-256 37c86c458e8ae779943df43d568e4585f7e89b60643c406b11880119409fc7fd

See more details on using hashes here.

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