Skip to content

Commit

Permalink
Merge pull request #188 from pixlise/feature/v4-post-release-fixes
Browse files Browse the repository at this point in the history
Feature/v4 post release fixes
  • Loading branch information
pnemere authored Mar 25, 2024
2 parents bdb3e81 + 4266130 commit 2da9056
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
54 changes: 35 additions & 19 deletions api/coreg/import_test.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
package coreg

import "fmt"
import (
"fmt"
"log"

protos "github.com/pixlise/core/v4/generated-protos"
"google.golang.org/protobuf/encoding/protojson"
)

func printWarpXform(xform *protos.ImageMatchTransform, name string, err error) {
fmt.Printf("%v|%v\n", name, err)

if b, err := protojson.Marshal(xform); err != nil {
log.Fatalln(err)
} else {
fmt.Printf("%v\n", string(b))
}
}

func Example_readWarpedImageTransform() {
xform, name, err := readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01-A.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01-A.png"))

xform, name, err = readWarpedImageTransform("warped-zoom_1.1359177671479777-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01-A.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-zoom_1.1359177671479777-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01-A.png"))

xform, name, err = readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01.png"))

xform, name, err = readWarpedImageTransform("warped-zoom_1.1359177671479777-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-zoom_1.1359177671479777-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png"))

xform, name, err = readWarpedImageTransform("warped-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-win_216_186_167_183-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png"))

xform, name, err = readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RASS_N0450000SRLC11373_0000LMJ01.png")
fmt.Printf("%+v|%v|%v\n", xform, name, err)
printWarpXform(readWarpedImageTransform("warped-zoom_4.478153138946561-win_519_40_1232_1183-SN100D0-SC3_0921_0748732957_027RASS_N0450000SRLC11373_0000LMJ01.png"))

// Output:
// xOffset:40 yOffset:519 xScale:4.478153 yScale:4.478153|coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01-A.png|<nil>
// xOffset:186 yOffset:216 xScale:1.1359178 yScale:1.1359178|coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01-A.png|<nil>
// xOffset:40 yOffset:519 xScale:4.478153 yScale:4.478153|coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01.png|<nil>
// xOffset:186 yOffset:216 xScale:1.1359178 yScale:1.1359178|coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png|<nil>
// <nil>||Warped image name does not have expected components
// <nil>||Failed to find GDS file name section in image name: SC3_0921_0748732957_027RASS_N0450000SRLC11373_0000LMJ01. Error: Failed to parse meta from file name
// coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01-A.png|<nil>
// {"xOffset":40, "yOffset":519, "xScale":4.478153, "yScale":4.478153}
// coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01-A.png|<nil>
// {"xOffset":186, "yOffset":216, "xScale":1.1359178, "yScale":1.1359178}
// coreg-40_519-SC3_0921_0748732957_027RAS_N0450000SRLC11373_0000LMJ01.png|<nil>
// {"xOffset":40, "yOffset":519, "xScale":4.478153, "yScale":4.478153}
// coreg-186_216-PCB_0921_0748739251_000RAS_N045000032302746300020LUJ01.png|<nil>
// {"xOffset":186, "yOffset":216, "xScale":1.1359178, "yScale":1.1359178}
// |Warped image name does not have expected components
// {}
// |Failed to find GDS file name section in image name: SC3_0921_0748732957_027RASS_N0450000SRLC11373_0000LMJ01. Error: Failed to parse meta from file name
// {}
}
3 changes: 3 additions & 0 deletions internal/lambdas/data-import/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import (

"github.com/aws/aws-lambda-go/lambda"
"github.com/pixlise/core/v4/api/dataimport"
"github.com/pixlise/core/v4/api/services"
"github.com/pixlise/core/v4/core/awsutil"
"github.com/pixlise/core/v4/core/fileaccess"
"github.com/pixlise/core/v4/core/logger"
"github.com/pixlise/core/v4/core/mongoDBConnection"
)

func HandleRequest(ctx context.Context, event awsutil.Event) (string, error) {
fmt.Printf("Data Importer Lambda version: %v\n", services.ApiVersion)

configBucket := os.Getenv("CONFIG_BUCKET")
datasetBucket := os.Getenv("DATASETS_BUCKET")
manualBucket := os.Getenv("MANUAL_BUCKET")
Expand Down

0 comments on commit 2da9056

Please sign in to comment.