Skip to content

Commit

Permalink
Correct Incorrect engine type error
Browse files Browse the repository at this point in the history
EchoWordAlignment works
  • Loading branch information
johnml1135 committed Nov 7, 2024
1 parent 089bb5b commit 0dc5784
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public Task<bool> IsEngineBuilding(string engineId, CancellationToken cancellati
return Engines.ExistsAsync(e => e.EngineId == engineId && e.CurrentBuild != null, cancellationToken);
}

public Task<IReadOnlyList<TEngine>> GetBuildingEnginesAsync(
public async Task<IReadOnlyList<TEngine>> GetBuildingEnginesAsync(
BuildJobRunnerType runner,
CancellationToken cancellationToken = default
)
{
return Engines.GetAllAsync(
return await Engines.GetAllAsync(
e => e.CurrentBuild != null && e.CurrentBuild.BuildJobRunner == runner,
cancellationToken
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ private async Task MonitorClearMLTasksPerDomain(IServiceScope scope, Cancellatio
IBuildJobService<WordAlignmentEngine>
>();

Dictionary<ITrainingEngine, IBuildJobService<ITrainingEngine>> engineToBuildServiceDict = (
Dictionary<ITrainingEngine, IBuildJobServiceBase> engineToBuildServiceDict = (
await translationBuildJobService.GetBuildingEnginesAsync(BuildJobRunnerType.ClearML, cancellationToken)
).ToDictionary(e => (ITrainingEngine)e, e => (IBuildJobService<ITrainingEngine>)translationBuildJobService);
).ToDictionary(e => (ITrainingEngine)e, e => (IBuildJobServiceBase)translationBuildJobService);

foreach (
var engine in await wordAlignmentBuildJobService.GetBuildingEnginesAsync(
Expand All @@ -65,7 +65,7 @@ var engine in await wordAlignmentBuildJobService.GetBuildingEnginesAsync(
)
)
{
engineToBuildServiceDict[engine] = (IBuildJobService<ITrainingEngine>)wordAlignmentBuildJobService;
engineToBuildServiceDict[engine] = wordAlignmentBuildJobService;
}

if (engineToBuildServiceDict.Count == 0)
Expand Down Expand Up @@ -237,7 +237,7 @@ await TrainJobFaultedAsync(

private async Task<bool> TrainJobStartedAsync(
IDataAccessContext dataAccessContext,
IBuildJobService<ITrainingEngine> buildJobService,
IBuildJobServiceBase buildJobService,
IPlatformService platformService,
string engineId,
string buildId,
Expand All @@ -260,7 +260,7 @@ private async Task<bool> TrainJobStartedAsync(
}

private async Task<bool> TrainJobCompletedAsync(
IBuildJobService<ITrainingEngine> buildJobService,
IBuildJobServiceBase buildJobService,
EngineType engineType,
string engineId,
string buildId,
Expand Down Expand Up @@ -291,7 +291,7 @@ CancellationToken cancellationToken

private async Task TrainJobFaultedAsync(
IDataAccessContext dataAccessContext,
IBuildJobService<ITrainingEngine> buildJobService,
IBuildJobServiceBase buildJobService,
IPlatformService platformService,
string engineId,
string buildId,
Expand Down Expand Up @@ -324,7 +324,7 @@ await buildJobService.BuildJobFinishedAsync(

private async Task TrainJobCanceledAsync(
IDataAccessContext dataAccessContext,
IBuildJobService<ITrainingEngine> buildJobService,
IBuildJobServiceBase buildJobService,
IPlatformService platformService,
string engineId,
string buildId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
namespace Serval.Machine.Shared.Services;

public interface IBuildJobService<TEngine>
public interface IBuildJobService<TEngine> : IBuildJobServiceBase
where TEngine : ITrainingEngine
{
Task<IReadOnlyList<TEngine>> GetBuildingEnginesAsync(
BuildJobRunnerType runner,
CancellationToken cancellationToken = default
);

Task<bool> IsEngineBuilding(string engineId, CancellationToken cancellationToken = default);

Task CreateEngineAsync(string engineId, string? name = null, CancellationToken cancellationToken = default);

Task DeleteEngineAsync(string engineId, CancellationToken cancellationToken = default);

Task<bool> StartBuildJobAsync(
BuildJobRunnerType runnerType,
EngineType engineType,
string engineId,
string buildId,
BuildStage stage,
object? data = default,
string? buildOptions = default,
CancellationToken cancellationToken = default
);

Task<(string? BuildId, BuildJobState State)> CancelBuildJobAsync(
string engineId,
CancellationToken cancellationToken = default
);

Task<bool> BuildJobStartedAsync(string engineId, string buildId, CancellationToken cancellationToken = default);

Task BuildJobFinishedAsync(
string engineId,
string buildId,
bool buildComplete,
CancellationToken cancellationToken = default
);

Task BuildJobRestartingAsync(string engineId, string buildId, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Serval.Machine.Shared.Services;

public interface IBuildJobServiceBase
{
Task<bool> IsEngineBuilding(string engineId, CancellationToken cancellationToken = default);

Task CreateEngineAsync(string engineId, string? name = null, CancellationToken cancellationToken = default);

Task DeleteEngineAsync(string engineId, CancellationToken cancellationToken = default);

Task<bool> StartBuildJobAsync(
BuildJobRunnerType runnerType,
EngineType engineType,
string engineId,
string buildId,
BuildStage stage,
object? data = default,
string? buildOptions = default,
CancellationToken cancellationToken = default
);

Task<(string? BuildId, BuildJobState State)> CancelBuildJobAsync(
string engineId,
CancellationToken cancellationToken = default
);

Task<bool> BuildJobStartedAsync(string engineId, string buildId, CancellationToken cancellationToken = default);

Task BuildJobFinishedAsync(
string engineId,
string buildId,
bool buildComplete,
CancellationToken cancellationToken = default
);

Task BuildJobRestartingAsync(string engineId, string buildId, CancellationToken cancellationToken = default);
}
Loading

0 comments on commit 0dc5784

Please sign in to comment.