From 219f676998cfdbf1299b9d99f0cd59eafd6889ff Mon Sep 17 00:00:00 2001 From: hrntsm Date: Wed, 28 Feb 2024 10:47:10 +0900 Subject: [PATCH] Fix DateTime handling in Storage.cs and add hitl.db to OptunaTests.csproj --- Optuna/Storage/RDB/Storage.cs | 3 ++- OptunaTests/OptunaTests.csproj | 3 +++ OptunaTests/Storage/RDB/StorageTests.cs | 10 ++++++++++ OptunaTests/TestFile/hitl.db | Bin 0 -> 122880 bytes 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 OptunaTests/TestFile/hitl.db diff --git a/Optuna/Storage/RDB/Storage.cs b/Optuna/Storage/RDB/Storage.cs index 8981592a..5582b8e1 100644 --- a/Optuna/Storage/RDB/Storage.cs +++ b/Optuna/Storage/RDB/Storage.cs @@ -441,13 +441,14 @@ public Trial.Trial GetTrial(int trialId) { while (reader.Read()) { + DateTime completeTime = reader.GetValue(3) is DBNull ? DateTime.MaxValue : reader.GetDateTime(3); trial = new Trial.Trial { TrialId = trialId, Number = reader.GetInt32(0), State = (TrialState)Enum.Parse(typeof(TrialState), reader.GetString(1), true), DatetimeStart = reader.GetDateTime(2), - DatetimeComplete = reader.GetDateTime(3) + DatetimeComplete = completeTime }; } } diff --git a/OptunaTests/OptunaTests.csproj b/OptunaTests/OptunaTests.csproj index 251df602..9d7d9678 100644 --- a/OptunaTests/OptunaTests.csproj +++ b/OptunaTests/OptunaTests.csproj @@ -27,6 +27,9 @@ PreserveNewest + + PreserveNewest + diff --git a/OptunaTests/Storage/RDB/StorageTests.cs b/OptunaTests/Storage/RDB/StorageTests.cs index 4e7bf5f2..c6c21a46 100644 --- a/OptunaTests/Storage/RDB/StorageTests.cs +++ b/OptunaTests/Storage/RDB/StorageTests.cs @@ -13,6 +13,7 @@ public class SqliteStorageTests : IClassFixture, IDisposable { private readonly string _createFilePath = @"TestFile/created.db"; private readonly string _existFilePath = @"TestFile/sqlite.db"; + private readonly string _hitlFilePath = @"TestFile/hitl.db"; private readonly List _tempDBPaths = new List(); [Fact()] @@ -86,6 +87,15 @@ public void GetAllStudiesTest() Assert.Equal(3, studies.Length); } + [Fact()] + public void LoadHitlDBTest() + { + var storage = new SqliteStorage(_hitlFilePath); + Study.Study[] study = storage.GetAllStudies(); + Assert.Single(study); + Assert.Equal(DateTime.MinValue, study[0].Trials[0].DatetimeComplete); + } + public void Dispose() { foreach (string path in _tempDBPaths) diff --git a/OptunaTests/TestFile/hitl.db b/OptunaTests/TestFile/hitl.db new file mode 100644 index 0000000000000000000000000000000000000000..1ad9cf1d4bb2130fd96c294099b9dd2cf33a5710 GIT binary patch literal 122880 zcmeI5Yit`=c7SL27>X3dksmTGE0QOSy%u3p;S5PpvYRy(nU-lwa!gBEd+UH0kt2I- zJ`~Q-iA)$>Dc)Tau+aed(JuDS0*ej0K(Id=6e$YqB0t&y3vAF91&VHp0J~dYn;)B9 zqzO<2Zh_uA@8Ls~6_K^wGqB}3b06oP@0_{!&b`*m4!MaLHeQp&4G{m9saa;)%R}S1Ajxd(WB(O1({zd3Tj5RnDu<$Y&Jc!lxCJ@UYt)e z))Z#k=e5W=vA|>&m(p|TEVFoViCJ8ppFhFqS=uC4R&EM;S-dT@EUL7IIXi!GW(n7% zh&g$EO<-Q0$tIUP;Rc74YwlJId@a4l$oXU z6~!Gk*m^tKU^cbxob#T}oE0@j)T`3o%}l@(Javk^7q)Pg)+Jde<#<^&PSB7yU8Y;m zZ^~re35`jQ;+fDbVLfC-w(b-)=-Y!=L#2h@Hl9$l?AQqlG!^7eZ5`~5Z87}OlrXq? z+V2S_ljOZoi)(6nyQE0;8B?TSM(161&pWHh66^VVbRz+T96iZga%O#_gGT?VNT~!OM|$!$w0(j9bJ&AyMdgs}DbOZCrCIli1C=;+5M%Rl*ZRvAkNb zp1W+`u%=*7SmkzZkn%T#5}(tu>NIiJR1{aLe0AMO(w_~u#H0eq2Dw3%l415-diDY{ z-jMVHizfFs9jFHwAvb7!P{e3ZAFhpxcp9x;acUN7j~K@I*jxY)k=j*#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