Skip to content

Commit eaae175

Browse files
authored
Merge pull request #460 from pixlise/feature/detector-config-contents
Feature/detector config contents
2 parents 65417c7 + d17e55a commit eaae175

File tree

95 files changed

+2286
-1565
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2286
-1565
lines changed

api/piquant/configuration_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ func Example_piquant_ReadFieldFromPIQUANTConfigMSA() {
1111
#SOLIDANGLE : 0.224 Solid angle collected by the detector in steradians`
1212

1313
a, err := ReadFieldFromPIQUANTConfigMSA(piquantMSA, "ELEVANGLE")
14+
fmt.Printf("%v|%v\n", a, err)
15+
16+
a, err = ReadFieldFromPIQUANTConfigMSA(piquantMSA, "ELEEEVANGLE")
1417
fmt.Printf("%v|%v", a, err)
1518

1619
// Output:
1720
// 48.03|<nil>
21+
// 0|Failed to find field ELEEEVANGLE
1822
}

api/ws/handlers/piquant.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,31 @@ func HandlePiquantWriteCurrentVersionReq(req *protos.PiquantWriteCurrentVersionR
109109

110110
return &protos.PiquantWriteCurrentVersionResp{}, nil
111111
}
112+
113+
// TODO: DO A SIMPLE INTEGRATION TEST FOR THIS!!
114+
func HandlePiquantConfigFileReq(req *protos.PiquantConfigFileReq, hctx wsHelpers.HandlerContext) (*protos.PiquantConfigFileResp, error) {
115+
// Validate inputs
116+
if err := wsHelpers.CheckStringField(&req.ConfigId, "ConfigId", 1, wsHelpers.IdFieldMaxLength); err != nil {
117+
return nil, err
118+
}
119+
if err := wsHelpers.CheckStringField(&req.Version, "Version", 1, wsHelpers.IdFieldMaxLength); err != nil {
120+
return nil, err
121+
}
122+
if err := wsHelpers.CheckStringField(&req.Filename, "Filename", 1, 255); err != nil {
123+
return nil, err
124+
}
125+
126+
// Build the file path
127+
filePath := filepaths.GetDetectorConfigPath(req.ConfigId, req.Version, req.Filename)
128+
129+
// Read the file from S3
130+
fileBytes, err := hctx.Svcs.FS.ReadObject(hctx.Svcs.Config.ConfigBucket, filePath)
131+
if err != nil {
132+
hctx.Svcs.Log.Errorf("Failed to read piquant config file %v/%v: %v", hctx.Svcs.Config.ConfigBucket, filePath, err)
133+
return nil, err
134+
}
135+
136+
return &protos.PiquantConfigFileResp{
137+
Contents: string(fileBytes),
138+
}, nil
139+
}

generated-protos/detector-config-msgs.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/detector-config.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/diffraction-data.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/diffraction-detected-peak-msgs.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/diffraction-manual-msgs.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/diffraction-status-msgs.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated-protos/diffraction.pb.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)