2023-10-23 14:58:58 +02:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct ConfigurationFile {
|
|
|
|
|
2023-10-24 11:31:08 +02:00
|
|
|
let folder: String?
|
2023-10-23 14:58:58 +02:00
|
|
|
|
2023-10-24 11:31:08 +02:00
|
|
|
let iterations: Int?
|
2023-10-23 14:58:58 +02:00
|
|
|
|
2023-10-24 11:31:08 +02:00
|
|
|
let server: String?
|
2023-10-23 14:58:58 +02:00
|
|
|
|
2023-10-24 11:31:08 +02:00
|
|
|
let authentication: String?
|
2024-10-28 19:06:45 +01:00
|
|
|
|
|
|
|
/// The number of images required to include a cap in training
|
|
|
|
let minimumImagesPerCap: Int?
|
2023-10-23 14:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extension ConfigurationFile: Decodable {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension ConfigurationFile {
|
|
|
|
|
|
|
|
init(at url: URL) throws {
|
|
|
|
guard FileManager.default.fileExists(atPath: url.path) else {
|
2023-10-23 16:49:56 +02:00
|
|
|
throw TrainingError.configurationFileMissing(url)
|
2023-10-23 14:58:58 +02:00
|
|
|
}
|
|
|
|
let data: Data
|
|
|
|
do {
|
|
|
|
data = try Data(contentsOf: url)
|
|
|
|
} catch {
|
2023-10-23 16:49:56 +02:00
|
|
|
throw TrainingError.configurationFileUnreadable(url, error)
|
2023-10-23 14:58:58 +02:00
|
|
|
}
|
|
|
|
do {
|
|
|
|
self = try JSONDecoder().decode(ConfigurationFile.self, from: data)
|
|
|
|
} catch {
|
2023-10-23 16:49:56 +02:00
|
|
|
throw TrainingError.configurationFileDecodingFailed(url, error)
|
2023-10-23 14:58:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|