< Summary

Information
Class: InferenceEngine.Core.ModelProviders.LocalModelProvider
Assembly: InferenceEngine.Core
File(s): /home/runner/work/inference-engine-lib/inference-engine-lib/InferenceEngine.Core/ModelProviders/LocalModelProvider.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 42
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ModelPath()100%11100%
.ctor(...)100%22100%
GetModelPathAsync(...)100%22100%

File(s)

/home/runner/work/inference-engine-lib/inference-engine-lib/InferenceEngine.Core/ModelProviders/LocalModelProvider.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3using System.Threading;
 4using System.Threading.Tasks;
 5
 6namespace InferenceEngine.Core.ModelProviders
 7{
 8    /// <summary>
 9    /// Model provider for locally stored model files.
 10    /// Validates that the file exists but does not perform any network operations.
 11    /// </summary>
 12    public class LocalModelProvider : IModelProvider
 13    {
 14        /// <summary>
 15        /// The model file path (absolute or relative).
 16        /// </summary>
 5917        public string ModelPath { get; }
 18
 19        /// <summary>
 20        /// Creates a provider for a local model file.
 21        /// </summary>
 22        /// <param name="modelPath">Absolute or relative path to the .onnx model file</param>
 8323        public LocalModelProvider(string modelPath)
 24        {
 8325            ModelPath = modelPath ?? throw new ArgumentNullException(nameof(modelPath));
 8226        }
 27
 28        /// <inheritdoc />
 29        public Task<string> GetModelPathAsync(CancellationToken cancellationToken = default)
 30        {
 31            // Resolve relative paths to absolute
 5632            var fullPath = Path.GetFullPath(ModelPath);
 33
 5634            if (!File.Exists(fullPath))
 35            {
 136                throw new FileNotFoundException($"Model file not found: {fullPath}", fullPath);
 37            }
 38
 5539            return Task.FromResult(fullPath);
 40        }
 41    }
 42}