Compare commits

..

13 commits
v0.1.0 ... main

Author SHA1 Message Date
cee62f55d1 Merge pull request 'add scoring infra' (#1) from scoring into main
Reviewed-on: #1
2025-11-20 07:24:58 +00:00
1b8f3a31b8 add scoring infra 2025-11-19 14:50:14 +00:00
mbsbahru
a9a4d3a631 push the readme 2025-08-01 10:19:01 +07:00
mbsbahru
dd78487b84 create main branch, add gitignore 2025-08-01 09:59:29 +07:00
mbsbahru
cbc092987d release 2025-08-01 00:59:22 +07:00
mbsbahru
a101d84e45 release 2025-08-01 00:53:20 +07:00
e868c152e0 release 2025-08-01 00:30:05 +07:00
93b41bfa94 release 2025-08-01 00:01:05 +07:00
52e830b459 release 2025-07-31 23:56:15 +07:00
49b6f3810d change using NetVips to reduce memory load 2025-07-31 23:34:36 +07:00
mbsbahru
661c4b955c normalized the crops and optimized 2025-07-31 12:57:14 +07:00
mbsbahru
ddb324bbd4 remove dsstore 2025-07-21 00:12:11 +07:00
mbsbahru
db3c833c4c refactor into using ImageSharp 2025-07-21 00:08:32 +07:00
13 changed files with 380 additions and 220 deletions

6
.gitignore vendored
View file

@ -1,2 +1,6 @@
bin bin
obj obj
.vs
*.png
.idea
/.contest

18
LiloController.cs Normal file
View file

@ -0,0 +1,18 @@
using lilos_stitcher;
using Microsoft.AspNetCore.Mvc;
namespace LiloStitcher;
[ApiController]
[Route( "api/image" )]
public sealed class LiloController( lilos_stitcher.LiloStitcher stitcher ) : ControllerBase
{
[HttpPost]
[Route( "generate" )]
[Produces( "image/png" )]
public async Task<IActionResult> Generate( [FromBody] GenerateRequest payload, CancellationToken ct )
{
string path = await stitcher.CreateImageAsync( payload, ct );
return PhysicalFile(path, "image/png", enableRangeProcessing: false);
}
}

View file

@ -1,148 +1,137 @@
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using SkiaSharp; using NetVips;
namespace LiloStitcher; namespace lilos_stitcher;
public record GenerateRequest( public sealed record GenerateRequest(
string CanvasRect, string Canvas_Rect,
double[] CropOffset, double[] Crop_Offset,
double[] CropSize, double[] Crop_Size,
double OutputScale double Output_Scale
); );
public record struct PlateCoordinate( int Row, int Col ) public readonly record struct PlateCoordinate( int Row, int Col )
{ {
public static PlateCoordinate Parse( string token ) public static PlateCoordinate Parse( string token )
{ {
var rowPart = new string( token.TakeWhile( char.IsLetter ).ToArray() ).ToUpperInvariant(); if( string.IsNullOrWhiteSpace( token ) )
var colPart = new string( token.SkipWhile( char.IsLetter ).ToArray() ); throw new ArgumentException( "Empty coordinate." );
int row = 0; var rowPart = new string( token.TakeWhile( char.IsLetter ).ToArray() ).ToUpperInvariant();
foreach( var c in rowPart ) var colPart = new string( token.SkipWhile( char.IsLetter ).ToArray() );
{
row = row * 26 + ( c - 'A' + 1 ); int row = 0;
} foreach( char c in rowPart )
row = row * 26 + ( c - 'A' + 1 );
int.TryParse( colPart, out int col );
return new PlateCoordinate( row, int.Parse( colPart ) );
return new PlateCoordinate( row, col ); }
} }
}
public class TileCache( IMemoryCache cache ) public class TileCache( IMemoryCache cache )
{ {
private const long TileBytes = 720L * 720 * 4; private const long TileBytes = 720L * 720 * 3;
public SKBitmap? Get( string key ) => cache.TryGetValue( key, out SKBitmap? bmp ) ? bmp : null; public Image? Get( string key ) => cache.TryGetValue( key, out Image? img ) ? img : null;
public void Set( string key, SKBitmap bmp ) => public void Set( string key, Image img ) =>
cache.Set( key, bmp, new MemoryCacheEntryOptions cache.Set( key, img, new MemoryCacheEntryOptions
{ {
Size = TileBytes, Size = TileBytes,
SlidingExpiration = TimeSpan.FromMinutes( 20 ) SlidingExpiration = TimeSpan.FromMinutes( 20 )
} ); } );
} }
public class TileLoader( TileCache cache, string assetDir ) public class TileLoader( TileCache cache, string assetDir )
{ {
public async Task<SKBitmap> LoadAsync( string name, CancellationToken ct ) public async Task<Image> LoadAsync( string name, CancellationToken ct )
{ {
if( cache.Get( name ) is { } hit ) return hit; if( cache.Get( name ) is { } hit )
return hit;
var path = Path.Combine( assetDir, $"{name}.png" );
var image = await Task.Run( () =>
var bytes = await File.ReadAllBytesAsync( path, ct ).ConfigureAwait( false ); Image.NewFromFile( Path.Combine( assetDir, $"{name}.png" ), access: Enums.Access.Sequential ), ct );
using var data = SKData.CreateCopy( bytes ); cache.Set( name, image );
var bmp = SKBitmap.Decode( data ); return image;
cache.Set( name, bmp ); }
return bmp; }
}
} public class LiloStitcher( TileLoader loader )
{
public class LiloStitcher( TileLoader loader ) public async Task<string> CreateImageAsync( GenerateRequest req, CancellationToken ct )
{ {
private const int TileSize = 720; (int rowMin, int colMin, int rows, int cols) = ParseCanvas( req.Canvas_Rect );
public async Task<byte[]> CreateImageAsync( GenerateRequest req, CancellationToken ct ) Validate(req.Crop_Offset, nameof(req.Crop_Offset));
{ Validate(req.Crop_Size, nameof(req.Crop_Size));
var parts = req.CanvasRect.ToUpperInvariant().Split( ':', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries ); double scale = req.Output_Scale;
if( scale <= 0 || scale > 1 )
var part1 = PlateCoordinate.Parse( parts[0] ); throw new ArgumentOutOfRangeException( nameof( req.Output_Scale ) );
var part2 = PlateCoordinate.Parse( parts[1] );
var tiles = new List<Image>( rows * cols );
int rowMin = Math.Min( part1.Row, part2.Row ); for( int row = 0; row < rows; row++ )
int rowMax = Math.Max( part1.Row, part2.Row ); {
int colMin = Math.Min( part1.Col, part2.Col ); for( int col = 0; col < cols; col++ )
int colMax = Math.Max( part1.Col, part2.Col ); {
string id = $"{RowName( rowMin + row )}{colMin + col}";
int rows = rowMax - rowMin + 1; var tile = await loader.LoadAsync( id, ct );
int cols = colMax - colMin + 1; if( scale < 1 ) tile = tile.Resize( scale );
tiles.Add( tile );
var names = Enumerable.Range( rowMin, rows ) }
.SelectMany( r => Enumerable.Range( colMin, cols ).Select( c => $"{RowName( r )}{c}" ) ) }
.ToArray();
var mosaic = Image.Arrayjoin( tiles.ToArray(), across: cols );
var bitmaps = await Task.WhenAll( names.Select( n => loader.LoadAsync( n, ct ) ) ).ConfigureAwait( false );
int offsetX = (int)Math.Truncate( req.Crop_Offset[0] * mosaic.Width );
var fullInfo = new SKImageInfo( cols * TileSize, rows * TileSize ); int offsetY = (int)Math.Truncate( req.Crop_Offset[1] * mosaic.Height );
using var surface = SKSurface.Create( fullInfo );
var canvas = surface.Canvas; int restWidth = mosaic.Width - offsetX;
int restHeight = mosaic.Height - offsetY;
int idx = 0;
for( int row = 0; row < rows; row++ ) int cropWidth = Math.Max( 1, (int)Math.Truncate( req.Crop_Size[0] * restWidth ) );
for( int column = 0; column < cols; column++, idx++ ) int cropHeight = Math.Max( 1, (int)Math.Truncate( req.Crop_Size[1] * restHeight ) );
canvas.DrawBitmap( bitmaps[idx], column * TileSize, row * TileSize );
int cropX = (int)Math.Truncate( offsetX / 2.0 + ( restWidth - cropWidth ) / 2.0 );
using var full = new SKBitmap( fullInfo ); int cropY = (int)Math.Truncate( offsetY / 2.0 + ( restHeight - cropHeight ) / 2.0 );
surface.ReadPixels( fullInfo, full.GetPixels(), full.RowBytes, 0, 0 );
var cropped = mosaic.Crop( cropX, cropY, cropWidth, cropHeight );
ValidateFraction( req.CropOffset, 2, nameof( req.CropOffset ), inclusiveUpper: true );
ValidateFraction( req.CropSize, 2, nameof( req.CropSize ), inclusiveUpper: true ); string path = Path.Combine(Path.GetTempPath(), $"mosaic-{Guid.NewGuid():N}.png");
cropped.WriteToFile(path);
int offsetX = (int)( req.CropOffset[0] * fullInfo.Width ); return path;
int offsetY = (int)( req.CropOffset[1] * fullInfo.Height ); }
int cropWidth = (int)( req.CropSize[0] * fullInfo.Width );
int cropHeight = (int)( req.CropSize[1] * fullInfo.Height ); private static (int rowMin, int colMin, int rows, int cols) ParseCanvas( string rect )
{
if( offsetX + cropWidth > fullInfo.Width ) cropWidth = fullInfo.Width - offsetX; var parts = rect.ToUpperInvariant().Split( ':', StringSplitOptions.RemoveEmptyEntries );
if( offsetY + cropHeight > fullInfo.Height ) cropHeight = fullInfo.Height - offsetY; var part1 = PlateCoordinate.Parse( parts[0] );
var part2 = PlateCoordinate.Parse( parts[1] );
var cropRect = new SKRectI( offsetX, offsetY, offsetX + cropWidth, offsetY + cropHeight ); int rowMin = Math.Min( part1.Row, part2.Row );
using var crop = new SKBitmap( cropWidth, cropHeight ); int rowMax = Math.Max( part1.Row, part2.Row );
full.ExtractSubset( crop, cropRect ); int colMin = Math.Min( part1.Col, part2.Col );
int colMax = Math.Max( part1.Col, part2.Col );
double scale = Math.Clamp( req.OutputScale, 0.0, 1.0 ); return (rowMin, colMin, rowMax - rowMin + 1, colMax - colMin + 1);
int truncatedWidth = Math.Max( 1, (int)Math.Round( cropWidth * scale ) ); }
int truncatedHeight = Math.Max( 1, (int)Math.Round( cropHeight * scale ) );
private static void Validate( double[] arr, string name )
using var finalBmp = scale < 1.0 {
? crop.Resize( new SKSizeI( truncatedWidth, truncatedHeight ), new SKSamplingOptions( SKFilterMode.Linear ) ) if( arr is null || arr.Length < 2 )
: crop; throw new ArgumentException( $"{name} length" );
if( arr.Any( x => x < 0 || x > 1 ) )
using var image = SKImage.FromBitmap( finalBmp ); throw new ArgumentOutOfRangeException( name );
using var data = image.Encode( SKEncodedImageFormat.Png, 100 ); }
return data.ToArray();
static string RowName( int row )
static void ValidateFraction( double[] arr, int len, string name, bool inclusiveUpper ) {
{ var stringBuilder = new System.Text.StringBuilder();
for( int i = 0; i < len; i++ ) while( row > 0 )
{ {
double v = arr[i]; row--;
double upper = inclusiveUpper ? 1.0 : 1.0 - double.Epsilon; stringBuilder.Insert( 0, (char)( 'A' + row % 26 ) );
} row /= 26;
} }
return stringBuilder.ToString();
static string RowName( int row ) }
{ }
var stringBuilder = new System.Text.StringBuilder();
while( row > 0 )
{
row--;
stringBuilder.Insert( 0, (char)( 'A' + row % 26 ) );
row /= 26;
}
return stringBuilder.ToString();
}
}
}

View file

@ -1,55 +1,20 @@
 using lilos_stitcher;
using Microsoft.Extensions.Caching.Memory;
namespace LiloStitcher; var builder = WebApplication.CreateBuilder(args);
public static class Program
{
public static async Task<int> Main( string[] args )
{
try
{
var opt = new Options();
opt.CanvasRect = "A1:H12";
opt.CropOffset = [0.25, 0.25];
opt.CropSize = [0.75, 0.75];
opt.OutputScale = 0.5;
opt.OutputPath = "stitched.png";
string tileFilePath = "../stitch-a-ton/tiles1705"; NetVips.NetVips.Init();
string assetDir = Path.GetFullPath( Path.Combine( Directory.GetCurrentDirectory(), tileFilePath ) ); NetVips.NetVips.Concurrency = 3;
using var memCache = new MemoryCache( new MemoryCacheOptions { SizeLimit = 256L * 1024 * 1024 } ); builder.Services.AddControllers().AddJsonOptions(o => o.JsonSerializerOptions.PropertyNameCaseInsensitive = true);
var tileCache = new TileCache( memCache );
var loader = new TileLoader( tileCache, assetDir );
var stitcher = new LiloStitcher( loader );
var req = new GenerateRequest( builder.Services.AddMemoryCache(o => o.SizeLimit = 128L * 1024 * 1024);
opt.CanvasRect!,
opt.CropOffset!,
opt.CropSize!,
opt.OutputScale
);
Console.WriteLine( "Stitching..." ); string assetDir = Environment.GetEnvironmentVariable("ASSET_PATH_RO") ?? throw new InvalidOperationException("dir not found");
var png = await stitcher.CreateImageAsync( req, CancellationToken.None );
File.WriteAllBytes( opt.OutputPath!, png ); builder.Services.AddSingleton<TileCache>();
Console.WriteLine( $"Done. Wrote {opt.OutputPath} ({png.Length / 1024.0:F1} KB)" ); builder.Services.AddSingleton(provider => new TileLoader(provider.GetRequiredService<TileCache>(), assetDir));
return 0; builder.Services.AddSingleton<lilos_stitcher.LiloStitcher>();
}
catch( Exception ex )
{
Console.Error.WriteLine( "ERROR: " + ex.Message );
return 1;
}
}
private struct Options var app = builder.Build();
{ app.MapControllers();
public string? CanvasRect { get; set; } app.Run();
public double[]? CropOffset { get; set; }
public double[]? CropSize { get; set; }
public double OutputScale { get; set; }
public string? OutputPath { get; set; }
}
}

View file

@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5243",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7121;http://localhost:5243",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

44
README.md Normal file
View file

@ -0,0 +1,44 @@
# Lilo Stitcher API
An ASP.NET Core Web API for stitching, cropping, and scaling tiled images (720×720).
## Prerequisites
* .NET 9.0 SDK
* `ASSET_PATH_RO` environment variable containing the path to tiles directory (1,705 PNGs named A1.png…AE55.png)
## Build & Run
```bash
cd lilo-stitcher
dotnet clean
dotnet run
```
By default, the API listens on `http://localhost:5243` and `https://localhost:7121` (see [`launchSettings.json`](https://null.formulatrix.dev/fikribahru/lilo-stitcher/src/branch/main/Properties/launchSettings.json)).
## Usage
**Endpoint:** `POST /api/image/generate`
**Request Body (JSON):**
```json
{
"canvas_rect": "A1:H12",
"crop_offset": [0.25, 0.25],
"crop_size": [0.5, 0.5],
"output_scale": 1.0
}
```
**Example (using `curl`):**
```bash
curl -X POST http://localhost:5243/api/image/generate \
-H "Content-Type: application/json" \
-o output.png \
-d '{"canvas_rect":"A1:H12","crop_offset":[0.25,0.25],"crop_size":[0.5,0.5],"output_scale":1.0}'
```
The API will return a `image/png` containing the stitched, cropped, and scaled result.

View file

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
appsettings.json Normal file
View file

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View file

@ -1,17 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>lilo_stitcher_console</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.7" />
<PackageReference Include="SkiaSharp" Version="3.119.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.0" />
</ItemGroup>
</Project>

19
lilos-stitcher.csproj Normal file
View file

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>lilos_stitcher</RootNamespace>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0-preview.6.25358.103" />
<PackageReference Include="NetVips" Version="3.1.0" />
<PackageReference Include="NetVips.Native.linux-arm64" Version="8.17.1" />
<!-- <PackageReference Include="NetVips.Native.linux-x64" Version="8.17.1" />-->
</ItemGroup>
</Project>

6
lilos-stitcher.http Normal file
View file

@ -0,0 +1,6 @@
@lilos_stitcher_HostAddress = http://localhost:5243
GET {{lilos_stitcher_HostAddress}}/weatherforecast/
Accept: application/json
###

View file

@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.2.0 VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lilo-stitcher-console", "lilo-stitcher-console.csproj", "{2A1F81C9-D10F-1AE9-CA5C-0714270F48C1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lilos-stitcher", "lilos-stitcher.csproj", "{8FDFFCBC-9C8E-94D5-A96D-606027D71B44}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -10,15 +10,15 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A1F81C9-D10F-1AE9-CA5C-0714270F48C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8FDFFCBC-9C8E-94D5-A96D-606027D71B44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A1F81C9-D10F-1AE9-CA5C-0714270F48C1}.Debug|Any CPU.Build.0 = Debug|Any CPU {8FDFFCBC-9C8E-94D5-A96D-606027D71B44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A1F81C9-D10F-1AE9-CA5C-0714270F48C1}.Release|Any CPU.ActiveCfg = Release|Any CPU {8FDFFCBC-9C8E-94D5-A96D-606027D71B44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A1F81C9-D10F-1AE9-CA5C-0714270F48C1}.Release|Any CPU.Build.0 = Release|Any CPU {8FDFFCBC-9C8E-94D5-A96D-606027D71B44}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C7CD65D7-8035-4FC2-A584-06B21F732FF7} SolutionGuid = {8DD20971-C4B3-41BF-8263-D31D5D81631F}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

92
mise.toml Normal file
View file

@ -0,0 +1,92 @@
# Quick Guide
# - install mise
# - download the asset and extract them to ASSET_PATH_RO
# - mise trust mise.toml
# - mise run verify-asset
# - require hashdeep
# `hashdeep` package in debian
# or `md5deep` package in fedora
# or uncomment `tools."http:hashdeep"` below in windows
# - mise run serve
# - mise run arrange
# - mise run action
# - mise run assert
# - mise run bench
[env]
ASSET_PATH_RO = "{{ [xdg_cache_home, 'stitch-a-ton', 'asset'] | join_path }}"
CONTEST_HOST = "http://localhost:7007"
CONTEST_API = "/api/image/generate"
CONTEST_OUTPUT = "{{ [cwd, '.contest'] | join_path }}"
DOTNET_ENVIRONMENT = "Production"
ANSWER_COMMIT_HASH = "89a07b40bf0414212c96945671a012035d375a25"
[tools]
dotnet = "9"
xh = "latest"
uv = "latest"
k6 = "latest"
# uncomment these if you're on windows
#[tools."http:hashdeep"]
#version = "4.4"
#[tools."http:hashdeep".platforms]
#windows-x64 = {url = "https://github.com/jessek/hashdeep/releases/download/v4.4/md5deep-4.4.zip"}
[tasks.setup]
run = '''
{% if env.CONTEST_OUTPUT is not exists %}
mkdir .contest
{% endif %}
'''
[tasks.verify-asset]
dir = "{{ env.ASSET_PATH_RO }}"
run = '''
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/asset.txt -o ../asset.txt
hashdeep -arbvk ../asset.txt .
'''
[tasks.arrange]
depends = ['setup']
dir = "{{ env.CONTEST_OUTPUT }}"
outputs = ['answer.json', 'action.py', 'assert.py', 'bench.js', 'fuzzy.json']
run = '''
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/answer.json -o answer.json
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/action.py -o action.py
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/assert.py -o assert.py
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/bench.js -o bench.js
xh get https://null.formulatrix.dev/Contest/stitch-a-ton-answer/raw/commit/{{ env.ANSWER_COMMIT_HASH }}/fuzzy.json -o fuzzy.json
'''
[tasks.serve]
run = "dotnet run -c Release --no-launch-profile --urls {{env.CONTEST_HOST}}"
[tasks.quick]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
xh post {{env.CONTEST_HOST}}{{env.CONTEST_ENDPOINT}} canvas_rect=A1:H12 crop_offset:=[0,0] crop_size:=[1,1] output_scale:=0.25 -o quick.png
'''
[tasks.action]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
uv run --no-config --script {{ [env.CONTEST_OUTPUT, 'action.py'] | join_path }}
'''
[tasks.assert]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
uvx --no-config --with-requirements assert.py pytest assert.py
'''
[tasks.bench]
depends = ['arrange']
dir = "{{ env.CONTEST_OUTPUT }}"
run = '''
k6 run -e TARGET_URL="{{ env.CONTEST_HOST }}{{ env.CONTEST_API }}" bench.js
'''