Spaces:
Sleeping
Sleeping
Download src/ClipForge.Api/Endpoints/PipelineEndpoints.cs from clipeforge/app: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs
- Command line
-
hf download hf://spaces/clipeforge/app/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs
-
curl -L -o PipelineEndpoints.cs https://huggingface.co/spaces/clipeforge/app/resolve/main/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs
2.03 kB
| using ClipForge.Contracts.Requests; | |
| using ClipForge.Core.Interfaces.Services; | |
| using ClipForge.Workers.Jobs; | |
| using Hangfire; | |
| namespace ClipForge.Api.Endpoints; | |
| public static class PipelineEndpoints | |
| { | |
| public static void MapPipelineEndpoints(this WebApplication app) | |
| { | |
| var group = app.MapGroup("/api/pipeline").WithTags("Pipeline"); | |
| // Run full pipeline in background (Hangfire) | |
| group.MapPost("/run", (FullPipelineRequest request, IBackgroundJobClient backgroundJobs) => | |
| { | |
| backgroundJobs.Enqueue<FullPipelineJob>(job => job.ExecuteAsync(request.Niche, request.Platform, "francisca")); | |
| return Results.Accepted(value: new { Message = "Pipeline scheduled", Niche = request.Niche, Platform = request.Platform }); | |
| }); | |
| // Schedule recurring pipeline | |
| group.MapPost("/schedule", async (SchedulePipelineRequest request, ISchedulerService scheduler) => | |
| { | |
| if (string.IsNullOrEmpty(request.CronExpression)) | |
| return Results.BadRequest(new { Error = "CronExpression is required for scheduling" }); | |
| await scheduler.ScheduleRecurringGenerationAsync(request.Niche, request.CronExpression, request.Platform); | |
| return Results.Ok(new { Message = "Recurring pipeline scheduled", Niche = request.Niche, Cron = request.CronExpression }); | |
| }); | |
| // Cancel recurring job | |
| group.MapDelete("/schedule/{jobId}", async (string jobId, ISchedulerService scheduler) => | |
| { | |
| await scheduler.CancelRecurringJobAsync(jobId); | |
| return Results.Ok(new { Message = $"Job '{jobId}' cancelled" }); | |
| }); | |
| // Run full pipeline synchronously (for testing) | |
| group.MapPost("/run-sync", async (FullPipelineRequest request, FullPipelineJob job) => | |
| { | |
| await job.ExecuteAsync(request.Niche, request.Platform, request.VoiceId); | |
| return Results.Ok(new { Message = "Pipeline completed", Niche = request.Niche }); | |
| }); | |
| } | |
| } | |