From d281074e0be60c880437045d581040f64bd269a7 Mon Sep 17 00:00:00 2001 From: Martin Molinero Date: Wed, 4 Dec 2024 19:16:04 -0300 Subject: [PATCH] Improve ObjectStore root config handling --- Engine/Storage/LocalObjectStore.cs | 2 +- Tests/Common/Storage/LocalObjectStoreTests.cs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Engine/Storage/LocalObjectStore.cs b/Engine/Storage/LocalObjectStore.cs index 1f30b47c3182..d94bc4d84dc9 100644 --- a/Engine/Storage/LocalObjectStore.cs +++ b/Engine/Storage/LocalObjectStore.cs @@ -54,7 +54,7 @@ public class LocalObjectStore : IObjectStore /// /// Gets the default object store location /// - public static string DefaultObjectStore => Path.GetFullPath(Config.Get("object-store-root", "./storage")); + public static string DefaultObjectStore { get; set; } = Path.GetFullPath(Config.Get("object-store-root", "./storage")); /// /// Flag indicating the state of this object storage has changed since the last invocation diff --git a/Tests/Common/Storage/LocalObjectStoreTests.cs b/Tests/Common/Storage/LocalObjectStoreTests.cs index f804e423bac7..9f60faad306c 100644 --- a/Tests/Common/Storage/LocalObjectStoreTests.cs +++ b/Tests/Common/Storage/LocalObjectStoreTests.cs @@ -23,7 +23,6 @@ using QuantConnect.Storage; using QuantConnect.Research; using System.Collections.Generic; -using QuantConnect.Configuration; using QuantConnect.Lean.Engine.Storage; using System.Threading; @@ -33,7 +32,7 @@ namespace QuantConnect.Tests.Common.Storage public class LocalObjectStoreTests { private static readonly string TestStorageRoot = $"{Directory.GetCurrentDirectory()}/{nameof(LocalObjectStoreTests)}"; - private static readonly string StorageRootConfigurationValue = Config.Get("object-store-root"); + private static readonly string StorageRootConfigurationValue = LocalObjectStore.DefaultObjectStore; private ObjectStore _store; private ILogHandler _logHandler; @@ -41,7 +40,7 @@ public class LocalObjectStoreTests [OneTimeSetUp] public void Setup() { - Config.Set("object-store-root", TestStorageRoot); + LocalObjectStore.DefaultObjectStore = TestStorageRoot; #pragma warning disable CA2000 _store = new ObjectStore(new TestLocalObjectStore()); #pragma warning restore CA2000 @@ -55,7 +54,7 @@ public void Setup() public void Cleanup() { _store.DisposeSafely(); - Config.Set("object-store-root", StorageRootConfigurationValue); + LocalObjectStore.DefaultObjectStore = StorageRootConfigurationValue; try { Directory.Delete(TestStorageRoot, true); @@ -63,7 +62,6 @@ public void Cleanup() catch { } - Config.Reset(); // Restore initial Log Handler Log.LogHandler = _logHandler;