SPB Git

Repository Public License

OracleExport.swift 3.6 KB 39 lines swift

1// ORIX Convert — Packages/EngineScientific/Tests/EngineScientificTests/OracleExport.swift2// Description: Development aid, skipped unless ORIX_SCI_EXPORT names a folder: writes outputs of the engine there so3//              they can be opened with outside readers (pyarrow, DuckDB, h5py, netCDF4) while developing. Not part4//              of the verification.5// Author: Simon-Pierre Boucher — contact@spboucher.ai6import Foundation7import Testing8import ConvertCore9@testable import EngineScientific1011@Suite struct OracleExport {12    @Test(.enabled(if: ProcessInfo.processInfo.environment["ORIX_SCI_EXPORT"] != nil)) func export() async throws {13        let out = URL(fileURLWithPath: ProcessInfo.processInfo.environment["ORIX_SCI_EXPORT"] ?? "/tmp/none", isDirectory: true)14        try? FileManager.default.removeItem(at: out)15        try FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)16        let temp = TempDir()17        func keep(_ r: Converted, _ name: String) throws { try FileManager.default.copyItem(at: r.file, to: out.appendingPathComponent(name)) }18        let everything = Fixture.everything(in: out)19        let classic = Fixture.classic(out.appendingPathComponent("classic1.nc"))20        _ = Fixture.classic(out.appendingPathComponent("classic2.nc"), version: 2)21        let classic5 = Fixture.classic(out.appendingPathComponent("classic5.nc"), version: 5)22        let raw4 = Fixture.netCDF4(out.appendingPathComponent("raw4.nc"))23        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/ints/i8,/ints/u8,/ints/i16,/ints/u16,/ints/i32,/ints/u32,/ints/i64,/ints/u64")]), "ints.parquet")24        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/time/values"), "fill": .string("null"), "time.decode": .bool(true)]), "nulls.parquet")25        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/time/values"), "fill": .string("null"), "parquet.compression": .string("gzip")]), "gzip.parquet")26        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/floats/f32,/floats/f64")]), "floats.parquet")27        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/compound/particles")]), "compound.parquet")28        try keep(try await convert(everything, .hdf5, to: .parquet, in: temp, options: ["variables": .string("/chunked/grid"), "layout": .string("wide")]), "wide.parquet")29        try keep(try await convert(everything, .hdf5, to: .netcdf, in: temp), "everything-as-nc4.nc")30        try keep(try await convert(everything, .hdf5, to: .hdf5, in: temp, operation: ScientificEngine.repackOperation, options: ["compression": .string("deflate")]), "everything-repacked.h5")31        try keep(try await convert(classic, .netcdf, to: .netcdf, in: temp, operation: ScientificEngine.reformatOperation), "classic-as-nc4.nc")32        try keep(try await convert(classic5, .netcdf, to: .hdf5, in: temp), "classic5-as.h5")33        try keep(try await convert(raw4, .netcdf, to: .netcdf, in: temp, operation: ScientificEngine.reformatOperation, options: ["netcdf.format": .string("netcdf4"), "compression": .string("deflate")]), "raw4-recompressed.nc")34        for (variant, name) in [("classic", "single-cdf1.nc"), ("64bit-offset", "single-cdf2.nc"), ("cdf5", "single-cdf5.nc")] {35            try keep(try await convert(Fixture.single(temp.file("single.h5")), .hdf5, to: .netcdf, in: temp, options: ["netcdf.format": .string(variant)]), name)36        }37    }38}39
Files main
Menu

Theme