Interface IBaseHeartbeat
- Namespace
- OptunaSharp.Storages
- Assembly
- OptunaSharp.dll
Base interface for heartbeat. Port of optuna/storages/_heartbeat.py: BaseHeartbeat
(a mixin class in Python; an interface in C# so storage backends can combine it with
BaseStorage).
The heartbeat mechanism periodically checks whether each trial process is alive during an optimization loop.
public interface IBaseHeartbeat
Methods
GetFailedTrialCallback()
Deprecated. Get the failed-trial callback function — returns the same value as
GetHeartbeatStaleTrialCallback(). Port of the concrete, deprecated
BaseHeartbeat.get_failed_trial_callback (deprecated in v4.9.0, removed in v6.0.0);
a default interface method so every heartbeat backend inherits it, exactly as the Python
base class does.
[Obsolete("Deprecated in v4.9.0. This feature will be removed in v6.0.0. Use GetHeartbeatStaleTrialCallback instead.")]
Action<Study, FrozenTrial>? GetFailedTrialCallback()
Returns
- Action<Study, FrozenTrial>
The same callback returned by GetHeartbeatStaleTrialCallback.
GetHeartbeatInterval()
Get the heartbeat interval if it is set, otherwise null.
int? GetHeartbeatInterval()
Returns
- int?
Heartbeat interval in seconds, or null when disabled.
GetHeartbeatStaleTrialCallback()
Get the heartbeat-stale trial callback function if it is set, otherwise null.
Action<Study, FrozenTrial>? GetHeartbeatStaleTrialCallback()
Returns
- Action<Study, FrozenTrial>
Configured callback, or null if no stale-trial callback is registered.
GetStaleTrialIds(int)
Get the stale trial ids of the study (Python: _get_stale_trial_ids).
List<int> GetStaleTrialIds(int studyId)
Parameters
studyIdintStorage identifier of the study; distinct from its name.
Returns
RecordHeartbeat(int)
Record the heartbeat of the trial.
void RecordHeartbeat(int trialId)
Parameters
trialIdintStorage identifier of the trial; distinct from its per-study trial number.
Exceptions
- Exception
The heartbeat storage provider fails.