Upload evaluation results
Deliver the original native report and retry saved uploads without rerunning your model.
Create a reporter with a write key and submit the local file exported by Apple Evaluations. Use a test write key for evaluation development.
import Foundation
import LedgeKitTesting
let reporter = LedgeEvaluationReporter(writeKey: writeKey)
try await reporter.submit(reportURL)reportURL must identify a local file. The SDK validates its native identity,
timestamps, row count, encoding, and 4 MiB size limit. Each provided Response must
be a captured span or trace; model outputs must match the recorded transcript. It preserves the original
bytes, including metrics and samples.
Local storage
The default upload directory is under Application Support at
LedgeKit/v1/Evaluations/<credential hash>. Recreating a reporter with the same
key can retry its pending reports. Different keys use separate directories, and
the key itself is not written into the path.
To choose a directory for CI or saved artifacts:
let reporter = LedgeEvaluationReporter(
writeKey: writeKey,
localDirectory: artifactsDirectory
)The override is the exact upload directory and must be dedicated to the intended app and environment. It is separate from the location of the original exported report. When rotating a key, explicitly resubmit saved files with the replacement key for the same app and environment; a different key does not automatically adopt the previous key's default queue.
What submit means
submit(_:) saves the report under Pending before delivery. It returns after a
matching server receipt is accepted and the file is moved to Uploaded. On
failure it throws and retains the pending file.
Authentication and validation errors fail immediately. Temporary network/server errors allow up to three total attempts with short delays. Redirects are rejected. Reusing a pending result ID with different file bytes is a local conflict.
Retry saved reports
for delivery in try await reporter.retryPending() {
if let error = delivery.error {
print("Could not upload \(delivery.file.lastPathComponent): \(error)")
}
}retryPending() reads saved reports. Each returned Delivery includes the file
and an optional error string; inspect every result. Failure to read the pending
directory can throw from the method itself.
Retrying the same ID and exact file is idempotent. Retrying delivery does not execute the evaluator or call the model.
Optional execution metadata
LedgeProducer.capture(serviceName:).evaluationInfo can supply environment
metadata when your test creates the evaluation. For dataset evaluations, also
include dataset.evaluationInfo() before running. The uploader does not create
execution metadata after the fact.