Skip to content

Commit

Permalink
Merge pull request #337 from pixlise/feature/em-import
Browse files Browse the repository at this point in the history
Fixing scan import
  • Loading branch information
pnemere authored Nov 4, 2024
2 parents 330af45 + e95c6a2 commit a7070e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions api/endpoints/Scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ func PutScanData(params apiRouter.ApiHandlerGenericParams) error {
return err
}

params.Svcs.Log.Infof("PutScan: Read zip %v for scan %v uploaded: %v bytes", fileName, scanId, len(zippedData))
params.Svcs.Log.Infof("PutScanData: Read zip %v for scan %v uploaded: %v bytes", fileName, scanId, len(zippedData))
savePath := path.Join(s3PathStart, fileName)

err = params.Svcs.FS.WriteObject(destBucket, savePath, zippedData)
if err != nil {
return err
}

params.Svcs.Log.Infof("PutScan: Wrote: s3://%v/%v", destBucket, savePath)
params.Svcs.Log.Infof("PutScanData: Wrote: s3://%v/%v", destBucket, savePath)
return nil
}
19 changes: 12 additions & 7 deletions api/ws/handlers/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ func HandleScanUploadReq(req *protos.ScanUploadReq, hctx wsHelpers.HandlerContex
if err != nil {
return nil, err
}
logger.Infof(" Uploaded: s3://%v/%v", destBucket, savePath)

// Now save creator info
savePath = path.Join(s3PathStart, "creator.json")
Expand Down Expand Up @@ -559,23 +560,26 @@ func processEM(importId string, zipReader *zip.Reader, zippedData []byte, destBu
}

for _, rsi := range rsis {
beamName := importId + "-beamloc.csv"
beamLocalPath := filepath.Join(localTemp, beamName)
rxlPath, logPath, err := createBeamLocation(rsi, beamLocalPath, logger)
rxlPath, logPath, err := createBeamLocation(rsi, localTemp, logger)
if err != nil {
return fmt.Errorf("Beam location generation failed for RSI: %v. Error: %v", rsi, err)
// Don't fail on errors for these - we may have run beam location tool on some incomplete scan, so failure isn't terrible!
logger.Errorf("Beam location generation failed for RSI: %v. Error: %v", rsi, err)
continue
}

// Read in the beam location file
rxl, err := os.ReadFile(rxlPath)
if err != nil {
return fmt.Errorf("Failed to read generated beam location file: %v. Error: %v", rxlPath, err)
// Don't fail on errors for these - we may have run beam location tool on some incomplete scan, so failure isn't terrible!
logger.Errorf("Failed to read generated beam location file: %v. Error: %v", rxlPath, err)
continue
}

// Upload
savePath := path.Join(s3PathStart, beamName)
savePath := path.Join(s3PathStart, "beam-locations.csv")
err = fs.WriteObject(destBucket, savePath, rxl)
if err != nil {
// We do want to fail here, this isn't an error related to input data - if we have the file, we should be able to upload it
return err
}

Expand All @@ -584,7 +588,8 @@ func processEM(importId string, zipReader *zip.Reader, zippedData []byte, destBu
// Also upload the log in case it's needed
logdata, err := os.ReadFile(logPath)
if err != nil {
return fmt.Errorf("Failed to read beam geometry tool log: %v. Error: %v", logPath, err)
logger.Errorf("Failed to read beam geometry tool log: %v. Error: %v", logPath, err)
continue
}

// Upload
Expand Down

0 comments on commit a7070e5

Please sign in to comment.