An internal Scoring API that returns pre-defined, static scores without requiring any input data.
This scorer provides two scoring categories — performance and power consumption — each returning fixed scores per application and device type. It is useful when you want to assign scores based on static criteria, hardware specifications, or externally managed data sources.
For an overview of all available Scoring API samples, see docs/scoring-api-samples.md.
static-scorer/
├── Dockerfile # Container image definition
├── README.md # This file
├── app/
│ ├── main.py # FastAPI application entry point
│ └── schemas/
│ ├── config.py # Pydantic schemas for /config responses
│ └── scoring.py # Pydantic schemas for /scoring responses
└── manifests/
└── manifestwork.yaml # OCM ManifestWork for deploying to managed clusters
| Method | Path | Description |
|---|---|---|
GET |
/performance/config |
Returns the performance scorer configuration |
POST |
/performance/scoring |
Returns static performance scores |
GET |
/powerconsumption/config |
Returns the power consumption scorer configuration |
POST |
/powerconsumption/scoring |
Returns static power consumption scores |
GET |
/healthz |
Health check endpoint |
cd samples/static-scorer
podman build -t static-scorer .podman run -d -p 8000:8000 --name static-scorer --replace static-scorerCheck the performance configuration:
curl -sS http://localhost:8000/performance/config | jqCheck the power consumption configuration:
curl -sS http://localhost:8000/powerconsumption/config | jqGet performance scores:
curl -sS -X POST http://localhost:8000/performance/scoring | jqGet power consumption scores:
curl -sS -X POST http://localhost:8000/powerconsumption/scoring | jq| App | Device | Score |
|---|---|---|
| app01 | all | 80 |
| app02 | all | 80 |
| app01 | 3g.48gb | 60 |
| app02 | 3g.48gb | 55 |
| app01 | 2g.24gb | 10 |
| app02 | 2g.24gb | 15 |
| App | Device | Score |
|---|---|---|
| app01 | all | 20 |
| app02 | all | 10 |
| app01 | 3g.48gb | 30 |
| app02 | 3g.48gb | 55 |
| app01 | 2g.24gb | 80 |
| app02 | 2g.24gb | 90 |
To change the scores, edit the hard-coded values in
app/main.py.
export STATIC_SCORER_IMAGE_NAME=quay.io/dynamic-scoring/static-scorer:latest
podman tag localhost/static-scorer:latest $STATIC_SCORER_IMAGE_NAME
kind load docker-image $STATIC_SCORER_IMAGE_NAME --name cluster1
CLUSTER_NAME=cluster1 envsubst < manifests/manifestwork.yaml | kubectl apply -f - --context kind-hubThe scorer exposes the following configurations:
Performance (/performance/config):
{
"name": "example-performance-scorer",
"description": "An example performance score",
"source": {
"type": "None"
},
"scoring": {
"path": "/performance/scoring",
"params": {
"name": "example_performance_score",
"interval": 30
}
}
}Power Consumption (/powerconsumption/config):
{
"name": "example-powerconsumption-scorer",
"description": "An example power consumption score",
"source": {
"type": "None"
},
"scoring": {
"path": "/powerconsumption/scoring",
"params": {
"name": "example_powerconsumption_score",
"interval": 30
}
}
}