Reliafy

The Python client

reliafy-client is the Python client for the API, and it installs the reliafy command line too. Pure standard library, no dependencies; you bring SurPyval (docs) for your own fits.

Install and sign in

pip install reliafy-client        # installed as reliafy-client, imported as `reliafy`

from reliafy import Client
rf = Client(token="rlf_...")      # or RELIAFY_TOKEN, or the token saved by `reliafy login`
  • Version 0.3 needs a Reliafy server with the tools API: reliafy.com has it from this release; a self-hosted server needs a build where GET /api/v1/tools answers. Against an older server the new calls stop with reliafy.ServerTooOld, and everything from 0.2 keeps working.
  • Self-hosted: Client(base_url="https://reliafy.example.com"). A local server with sign-in off needs no token.

Every tool: Client.call

Client.call(tool, action=None, /, wait=False, **args)POST /api/v1/{tool}/{action}

Call any tool action with its arguments, exactly as the Claude connector does. Leave out action for a tool without actions. wait=True (or a number of seconds) polls a long-running job until it finishes.

Parameters
toolstrrequiredThe tool, e.g. "life_data_analysis".
actionstroptionalThe action (or kind), e.g. "fit".
waitbool | floatoptionalWait for a job_id result to finish (True, or at most this many seconds).
**argsanyoptionalThe action's arguments; None values are left out.
Returns
{ … }   # the tool's result, the same JSON an AI assistant gets
rf.call("list", "models")
rf.call("life_data_analysis", "fit", distribution="weibull",
        data=[120, 340, 510, 700, 980], censored=[0, 0, 1, 0, 0], unit="hours")
rf.call("guide", topic="life_data")                       # a tool without actions
rf.call("rbd_analysis", "analyze", rbd_id="…", simulate=True, wait=True)

rf.tools()     # the tools and actions you may call (GET /api/v1/tools)
rf.spec()      # the OpenAPI spec
  • Shortcuts: rf.list(kind), rf.get(kind, id), rf.fit(data, distribution=…, censored=…), rf.reliability(model_id, times), rf.guide(topic), rf.wait(job_id).
  • reliafy.call(tool, action, **args) does the same with the configured token.
  • A refused call raises reliafy.ReliafyError with status (the HTTP status) and detail (what Reliafy said).

Files, photos and data

rf.upload_dataset("bearings.xlsx", name="Bearings")     # CSV or .xlsx, as a dataset
rf.import_rbd("plant.xml")                              # BlockSim, Open-PSA, Galileo, RePyability, the Excel template
rf.import_excel("fmea.xlsx", target="rcm")              # dataset, rcm or rbd
rf.add_photo("nameplate.jpg", target_id="…")            # Reliafy Maintenance users

rf.push_usage(fleet_id, [{"name": "Truck 01", "current_use": 5230}])
rf.push_measurements(tracked_fleet_id, file="readings.csv")
rf.push_lives(dataset_id, file="new_failures.csv")      # appends, then refits its models

Files are streamed from disk. The ingest helpers take rows, csv= text or file= a path, and are also on the module (reliafy.push_usage(…)). Reliafy Maintenance users also have push_readings for meter and condition readings.

The 0.2 functions (still supported)

Everything from 0.2 works unchanged, on any server: reliafy.configure(token=…), then the functions below. Each maps to one of the original routes; open one for its parameters and what it returns.

reliafy.models

models.push(model, name, *, data=True, unit=None)POST /api/import/models

Push a fitted SurPyval model and return its URL.

Parameters
modelSurPyval modelrequiredA fitted SurPyval distribution.
namestrrequiredModel name.
databooloptionalUpload the fitted observations too (default True → full plot, refittable). False = params only.
unitstroptionalUnit of the time axis.
Returns
"https://reliafy.com/modelling/m/a1b2…"   # str — open in the app
models.push_params(distribution, params, name, *, unit=None, extras=None)POST /api/import/models

Push a model by distribution + parameter values (no SurPyval object).

Parameters
distributionstrrequirede.g. "weibull".
paramsnumber[] | {name,value}[]requiredParameter values.
namestrrequiredModel name.
unitstroptionalTime unit.
extrasdictoptionalgamma / p / f0 for offset / LFP / zero-inflation.
Returns
"https://reliafy.com/modelling/m/…"   # str
models.list()GET /api/v1/models

Your saved models.

Returns
[ { "id": "a1b2…", "name": "Bearing life", "distribution": "Weibull",
    "kind": "distribution", "n": 30, "unit": "hours", "url": "/modelling/m/…" }, … ]
models.get(model_id)GET /api/v1/models/{id}

One model's fit.

Parameters
model_idstrrequiredModel id.
Returns
{ "id": …, "distribution": "Weibull", "params": [{name, value, se, ci}],
  "coefficients": [], "metrics": null, "gof": [{id, label, value}] }
models.reliability(model_id, t=None, covariates=None)POST /api/v1/models/{id}/reliability

Evaluate the reliability functions.

Parameters
model_idstrrequiredModel id.
tnumberoptionalTime to evaluate at. Omit for the whole curve.
covariatesdictoptionalCovariate values for a proportional-hazards model.
Returns
{ "at": { "reliability": 0.666, "failure": 0.334, "hazard": …,
          "cumulative_hazard": …, "density": … } }   # or {"curves": {...}}
models.fit(dataset_id, distribution, name, *, mapping=None, unit=None, covariates=None, formula=None)POST /api/v1/fit

Fit and save a model from one of your datasets.

Parameters
dataset_idstrrequiredDataset to fit.
distributionstrrequirede.g. weibull, weibull_ph, best.
namestrrequiredModel name.
mappingdictrequiredRole → column, e.g. {"x": "hours", "c": "failed"}.
unitstroptionalTime unit.
covariatesstr[]optionalCovariate columns (PH).
formulastroptionalFormulaic covariate formula.
Returns
{ "id": …, "name": "Bearing life", "distribution": "Weibull", "url": "/modelling/m/…" }

reliafy.data

data.upload(name, *, csv=None, data=None)POST /api/v1/datasets

Create a dataset from CSV text or column arrays.

Parameters
namestrrequiredDataset name.
csvstroptionalRaw CSV text (with a header). Provide this or data.
datadictoptionalColumn arrays, e.g. {"hours": [...], "failed": [...]}.
Returns
{ "id": "d3…", "name": "Bearings", "n_rows": 8, "columns": ["hours","failed"], "url": "/modelling/data/…" }

reliafy.strategy

strategy.optimal_replacement(distribution, params, planned_cost, unplanned_cost, *, unit=None)POST /api/v1/strategy/optimal-replacement

Cost-optimal preventive-replacement interval.

Parameters
distributionstrrequirede.g. weibull.
paramsnumber[]requiredDistribution parameters.
planned_costnumberrequiredCost of a planned replacement.
unplanned_costnumberrequiredCost of a failure.
unitstroptionalTime unit.
Returns
{ "optimal_time": 580.5, "optimal_cost_rate": 0.51, "beneficial": true, "mttf": 1272.4 }
strategy.failure_finding(distribution, params, target_availability, *, unit=None)POST /api/v1/strategy/failure-finding

Inspection interval for a hidden (protective) function.

Parameters
distributionstrrequirede.g. exponential.
paramsnumber[]requiredDistribution parameters.
target_availabilitynumberrequiredTarget availability in (0,1), e.g. 0.99.
unitstroptionalTime unit.
Returns
{ "interval": 176.4, "method": "…", "mttf": 8760, "target_availability": 0.99 }
strategy.demonstration_test(reliability, *, confidence=0.95, mission_time=None, failures=0, test_multiple=1.0, shape=None, units=None, method='attribute', mtbf=None, design_reliability=None, design_mtbf=None, producer_risk=None, unit=None, b_life=None, shape_interval=None)POST /api/v1/strategy/demonstration-test

Plan a reliability demonstration test: units to test, test time per unit, allowed failures.

Parameters
reliabilitynumberrequiredReliability to show over one mission, in (0,1).
confidencenumberoptionalConfidence in (0,1), default 0.95.
mission_timenumberoptionalThe mission the reliability is over.
failuresintoptionalFailures allowed, default 0 (success run).
test_multiple / shapenumberoptionalTest each unit k missions, Weibull shape known.
unitsintoptionalUnits available: solve for test time per unit (needs shape).
design_reliability / design_mtbfnumberoptionalA good design's true reliability (or MTBF): its chance of passing.
producer_risknumberoptionalWith the good design: the most chance of failing it, e.g. 0.2. The plan keeps both risks and chooses the failures allowed.
b_lifenumberoptionalA B-life requirement instead of reliability: 10 for “B10 ≥ mission_time”.
shape_intervalnumber[2]optionalβ’s interval [lower, upper]: adds shape_sensitivity, warning when β is too poorly known for the plan.
Returns
{ "units": 128, "failures": 8, "consumer_risk": 0.097, "producer_risk": 0.192, "summary": "Test 128 units…", "oc_curve": {…}, "tradeoff": {…} }

reliafy.fleet

fleet.forecast(fleet_id)GET /api/v1/fleets/{id}/forecast

The live failure forecast for one of your fleets.

Parameters
fleet_idstrrequiredFleet id (from /fleet/forecasts/<id>).
Returns
{ "fleet": {id, name, model_id}, "forecast": {status, method, periods, expected_failures, …} }
  • Errors raise reliafy.ReliafyError; reads/writes are scoped to your own data.
  • Full request and response field tables are on Original routes and ingest.