quorate/services/frigate/run.fsx

35 lines
1.1 KiB
Text
Raw Permalink Normal View History

#r "/opt/fsi/packages/AWSSDK.Core.dll"
#r "/opt/fsi/packages/AWSSDK.S3.dll"
#load "model.fsx"
open System.IO
open System.Text.Json
open Amazon.Runtime
open Amazon.S3
open Amazon.S3.Model
[<CLIMutable>]
type Settings =
{ Endpoint: string
Bucket: string
Key: string
Sha256: string
Destination: string }
let settings =
JsonSerializer.Deserialize<Settings>(File.ReadAllText "/installer/settings.json")
let download (output: Stream) =
let accessKey = File.ReadAllText("/s3/accessKeyId").TrimEnd()
let secretKey = File.ReadAllText("/s3/secretAccessKey").TrimEnd()
let config =
AmazonS3Config(ServiceURL = settings.Endpoint, AuthenticationRegion = "us-east-1", ForcePathStyle = true)
use client = new AmazonS3Client(BasicAWSCredentials(accessKey, secretKey), config)
let request = GetObjectRequest(BucketName = settings.Bucket, Key = settings.Key)
use reply = client.GetObjectAsync(request).GetAwaiter().GetResult()
reply.ResponseStream.CopyTo output
let outcome = Model.install settings.Sha256 settings.Destination download
printfn "Model %A sha256:%s" outcome settings.Sha256