public void Start(string filePath, bool watchFile) { _filePath = filePath; _reloadToken = new ModelReloadToken(); if (!File.Exists(filePath)) { throw new ArgumentException($"The provided model file {filePath} doesn't exist."); } var directory = Path.GetDirectoryName(filePath); if (string.IsNullOrEmpty(directory)) { directory = Directory.GetCurrentDirectory(); } var file = Path.GetFileName(filePath); LoadModel(); if (watchFile) { _watcher = new FileSystemWatcher(directory, file); _watcher.EnableRaisingEvents = true; _watcher.Changed += WatcherChanged; } }
public UriModelLoader(IOptions <MLOptions> contextOptions, ILogger <UriModelLoader> logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _context = contextOptions.Value?.MLContext; _reloadTimerLock = new object(); _reloadToken = new ModelReloadToken(); _stopping = new CancellationTokenSource(); _started = false; }