Skip to content
Closed
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
8 changes: 7 additions & 1 deletion src/SIL.Machine/Utils/PhasedProgressReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class PhasedProgressReporter
private readonly double _defaultPercentage;
private int _currentPhaseIndex = -1;
private double _percentCompleted;

private readonly double _inferenceProgress = 0; // will perform the calculation
private readonly double _fineTuneProgress = 0; // will perform the calculation

private int _step;
private int _prevPhaseLastStep;

Expand Down Expand Up @@ -68,7 +72,9 @@ protected internal virtual void Report(ProgressStatus value)

double percentCompleted = _percentCompleted + CurrentPhasePercentage * (value.PercentCompleted ?? 0);
string message = value.Message ?? Phases[_currentPhaseIndex].Message;
_progress.Report(new ProgressStatus(_step, percentCompleted, message));
_progress.Report(
new ProgressStatus(_step, percentCompleted, _fineTuneProgress, _inferenceProgress, message)
);
}
}
}
36 changes: 26 additions & 10 deletions src/SIL.Machine/Utils/ProgressStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,36 @@ namespace SIL.Machine.Utils
public struct ProgressStatus : IEquatable<ProgressStatus>
{
public ProgressStatus(int step, int stepCount, string message = null)
: this(step, stepCount == 0 ? 1.0 : (double)step / stepCount, message) { }
: this(step, stepCount == 0 ? (double?)1.0 : (double)step / stepCount, null, null, message) { }

public ProgressStatus(int step, double? percentCompleted = null, string message = null)
public ProgressStatus(
int step,
double? percentCompleted = null,
double? fineTuneProgress = null,
double? inferenceProgress = null,
string message = null
)
{
Step = step;
PercentCompleted = percentCompleted;
Message = message;
PercentCompleted = percentCompleted ?? 0.0;
FineTuneProgress = fineTuneProgress ?? 0.0;
InferenceProgress = inferenceProgress ?? 0.0;
Message = message ?? string.Empty;
}

public int Step { get; }
public double? PercentCompleted { get; }
public double? FineTuneProgress { get; }
public double? InferenceProgress { get; }
public string Message { get; }

public bool Equals(ProgressStatus other)
{
return Step == other.Step && PercentCompleted == other.PercentCompleted && Message == other.Message;
return Step == other.Step
&& PercentCompleted == other.PercentCompleted
&& FineTuneProgress == other.FineTuneProgress
&& InferenceProgress == other.InferenceProgress
&& Message == other.Message;
}

public override bool Equals(object obj)
Expand All @@ -30,11 +44,13 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
int code = 23;
code = code * 31 + Step.GetHashCode();
code = code * 31 + (PercentCompleted?.GetHashCode() ?? 0);
code = code * 31 + (Message?.GetHashCode() ?? 0);
return code;
int hash = 23;
hash = hash * 31 + Step.GetHashCode();
hash = hash * 31 + (PercentCompleted?.GetHashCode() ?? 0);
hash = hash * 31 + (FineTuneProgress?.GetHashCode() ?? 0);
hash = hash * 31 + (InferenceProgress?.GetHashCode() ?? 0);
hash = hash * 31 + (Message?.GetHashCode() ?? 0);
return hash;
}
}
}
Loading