Skip to content

Commit

Permalink
Merge pull request #230 from hrntsm/develop
Browse files Browse the repository at this point in the history
Release v0.10.0
  • Loading branch information
hrntsm authored Jan 27, 2024
2 parents 06bd974 + c71e631 commit 2cfe2b7
Show file tree
Hide file tree
Showing 41 changed files with 17,172 additions and 361 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: dotnet optuna tests

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.0.x"
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
- name: Test with the dotnet CLI
run: dotnet test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,4 @@ $RECYCLE.BIN/
## add by me
Tunny/Lib/python.zip
Tunny/Lib/whl.zip
!OptunaTests/TestFile/*.log
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

Please see [here](https://github.com/hrntsm/Tunny/releases) for the data released for each version.

## [v0.10.0] -2024-01-27

### Changed

- Use new JournalStorage handler to improve stability.
- old format journal storage result new can open in tunny.

### Fixed

- Does not work when human-in-the-loop continues.
- Error when reading older versions of JournalStorage.
- without constraint notification timing when output result.
- in-memory optimization result saving error.

## [v0.9.1] -2023-12-30

### Fixed
Expand Down
72 changes: 72 additions & 0 deletions Optuna/Dashboard/Handler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Diagnostics;
using System.IO;

namespace Optuna.Dashboard
{
public class Handler
{
private readonly string _dashboardPath;
private readonly string _storage;
private readonly string _host;
private readonly string _port;
private readonly string _artifactDir;

public Handler(string dashboardPath, string storagePath, string artifactDir = null, string host = "127.0.0.1", string port = "8080")
{
_dashboardPath = dashboardPath;
_storage = GetStorageArgument(storagePath);
_host = host;
_port = port;
_artifactDir = artifactDir ?? Path.GetDirectoryName(storagePath) + "/artifacts";
if (!Directory.Exists(_artifactDir))
{
Directory.CreateDirectory(_artifactDir);
}
}

private static string GetStorageArgument(string path)
{
switch (Path.GetExtension(path))
{
case ".sqlite3":
case ".db":
return @"sqlite:///" + $"\"{path}\"";
case ".log":
return $"\"{path}\"";
default:
throw new NotImplementedException();
}
}

public void Run()
{
CheckExistDashboardProcess();
string argument = $"{_storage} --host {_host} --port {_port} --artifact-dir {_artifactDir}";

var dashboard = new Process();
dashboard.StartInfo.FileName = _dashboardPath;
dashboard.StartInfo.Arguments = argument;
dashboard.StartInfo.UseShellExecute = false;
dashboard.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
dashboard.Start();

var browser = new Process();
browser.StartInfo.FileName = $@"http://{_host}:{_port}/";
browser.StartInfo.UseShellExecute = true;
browser.Start();
}

private static void CheckExistDashboardProcess()
{
Process[] dashboardProcess = Process.GetProcessesByName("optuna-dashboard");
if (dashboardProcess.Length > 0)
{
foreach (Process p in dashboardProcess)
{
p.Kill();
}
}
}
}
}
11 changes: 11 additions & 0 deletions Optuna/Optuna.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

</Project>
46 changes: 46 additions & 0 deletions Optuna/Storage/BaseStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Collections.Generic;

using Optuna.Study;
using Optuna.Trial;

namespace Optuna.Storage
{
public abstract class BaseStorage
{
// Basic study manipulation
public abstract int CreateNewStudy(StudyDirection[] studyDirections, string studyName);
public abstract void DeleteStudy(int studyId);
public abstract void SetStudyUserAttr(int studyId, string key, object value);
public abstract void SetStudySystemAttr(int studyId, string key, object value);

// Basic study access
public abstract int GetStudyIdFromName(string studyName);
public abstract string GetStudyNameFromId(int studyId);
public abstract StudyDirection[] GetStudyDirections(int studyId);
public abstract Dictionary<string, object> GetStudyUserAttrs(int studyId);
public abstract Dictionary<string, object> GetStudySystemAttrs(int studyId);
public abstract Study.Study[] GetAllStudies();

// Basic trial manipulation
public abstract int CreateNewTrial(int studyId, Trial.Trial templateTrial = null);
public abstract void SetTrailParam(int trialId, string paramName, double paramValueInternal, object distribution);
public abstract int GetTrialIdFromStudyIdTrialNumber(int studyId, int trialNumber);
public abstract int GetTrialNumberFromId(int trialId);
public abstract double GetTrialParam(int trialId, string paramName);
public abstract bool SetTrialStateValue(int trialId, TrialState state, double[] values = null);
public abstract void SetTrialIntermediateValue(int trialId, int step, double intermediateValue);
public abstract void SetTrialUserAttr(int trialId, string key, object value);
public abstract void SetTrialSystemAttr(int trialId, string key, object value);

// Basic trial access
public abstract Trial.Trial GetTrial(int trialId);
public abstract Trial.Trial[] GetAllTrials(int studyId, bool deepcopy = true);
public abstract int GetNTrials(int studyId);
public abstract Trial.Trial GetBestTrial(int studyId);
public abstract Dictionary<string, object> GetTrialParams(int trialId);
public abstract Dictionary<string, object> GetTrialUserAttrs(int trialId);
public abstract Dictionary<string, object> GetTrialSystemAttrs(int trialId);
public abstract void RemoveSession();
public abstract void CheckTrialIsUpdatable(int trialId, TrialState trialState);
}
}
16 changes: 16 additions & 0 deletions Optuna/Storage/Journal/Operation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Optuna.Storage.Journal
{
public enum JournalOperation
{
CreateStudy = 0,
DeleteStudy = 1,
SetStudyUserAttr = 2,
SetStudySystemAttr = 3,
CreateTrial = 4,
SetTrialParam = 5,
SetTrialStateValues = 6,
SetTrialIntermediateValue = 7,
SetTrialUserAttr = 8,
SetTrialSystemAttr = 9,
}
}
Loading

0 comments on commit 2cfe2b7

Please sign in to comment.