load static method
Future<void>
load({
- required String modelId,
- required ModelCategory category,
- LoadOptions? options,
Load modelId under category through commons lifecycle routing.
Throws SDKException when the load fails.
Implementation
static Future<void> load({
required String modelId,
required ModelCategory category,
LoadOptions? options,
}) async {
final request = model_pb.ModelLoadRequest(
modelId: modelId,
category: category,
forceReload: true,
validateAvailability: true,
);
final framework = options?.framework;
if (framework != null) {
request.framework = framework;
}
final ignored = ignoredLoadOptionKnobs(options);
if (ignored.isNotEmpty) {
_modelGateLogger.warning(
'LoadOptions ${ignored.join(", ")} are not carried by the commons load ABI yet',
);
}
final result = await RunAnywhereModelLifecycle.shared.load(request);
if (result.hasError()) {
throw SDKException.modelLoadFailed(
modelId,
result.error.message.isNotEmpty
? result.error.message
: 'Model lifecycle load failed',
);
}
}