stormlog.infer.profile

Active inference profiling runner.

Functions

classify_failure(exc)

Return the request status for a failure and its HTTP status, if any.

run_profile(config, *[, on_warning])

Run an inference profile from a resolved config.

Classes

InferenceProfiler(config, *[, run_id, ...])

Profile an OpenAI-compatible chat completions endpoint.

class stormlog.infer.profile.InferenceProfiler(config, *, run_id=None, on_warning=None)[source]

Bases: object

Profile an OpenAI-compatible chat completions endpoint.

Parameters:
  • config (ProfileConfig)

  • run_id (str | None)

  • on_warning (Callable[[str], None] | None)

run()[source]

Run profiling and return an aggregate report.

Return type:

dict[str, Any]

stormlog.infer.profile.classify_failure(exc)[source]

Return the request status for a failure and its HTTP status, if any.

urllib wraps every error from connecting and sending in URLError. A failure inside connect(), before any byte of the request was sent, is unreachable: the server never saw the request. A failure while sending, or a reset or close before the response’s status line, is delivery_unknown: the server may have received it. After the status line the server has answered, so a reset is the answer it gave: an error (or rejected) with that status. A timeout while waiting for the response, or a read that stalls, is timeout. Redirects are not followed, so a 3xx is an error.

Parameters:

exc (BaseException)

Return type:

tuple[str, int | None]

stormlog.infer.profile.run_profile(config, *, on_warning=None)[source]

Run an inference profile from a resolved config.

Parameters:
  • config (ProfileConfig)

  • on_warning (Callable[[str], None] | None)

Return type:

dict[str, Any]