Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ObjectStore root config handling #8445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Engine/Storage/LocalObjectStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class LocalObjectStore : IObjectStore
/// <summary>
/// Gets the default object store location
/// </summary>
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"));

/// <summary>
/// Flag indicating the state of this object storage has changed since the last <seealso cref="Persist"/> invocation
Expand Down
8 changes: 3 additions & 5 deletions Tests/Common/Storage/LocalObjectStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -33,15 +32,15 @@ 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;

[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
Expand All @@ -55,15 +54,14 @@ public void Setup()
public void Cleanup()
{
_store.DisposeSafely();
Config.Set("object-store-root", StorageRootConfigurationValue);
LocalObjectStore.DefaultObjectStore = StorageRootConfigurationValue;
try
{
Directory.Delete(TestStorageRoot, true);
}
catch
{
}
Config.Reset();

// Restore initial Log Handler
Log.LogHandler = _logHandler;
Expand Down