Skip to content

Commit b319298

Browse files
committed
Add more doc strings to things that appear in the schema
1 parent 9307da0 commit b319298

File tree

4 files changed

+134
-6
lines changed

4 files changed

+134
-6
lines changed

src/db_service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl<F> From<String> for RawPathTemplate<F> {
5959
}
6060
}
6161

62+
/// The current configuration for a beamline
6263
#[derive(Debug)]
6364
pub struct BeamlineConfiguration {
6465
name: String,

src/graphql.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ struct Mutation;
131131
/// GraphQL type to mimic a key-value pair from the map type that GraphQL doesn't have
132132
#[derive(SimpleObject)]
133133
struct DetectorPath {
134+
/// The name of the detector that should use this path
134135
name: String,
136+
/// The path where the detector should write its data
135137
path: String,
136138
}
137139

@@ -174,15 +176,19 @@ impl Display for NonUnicodePath {
174176
impl Error for NonUnicodePath {}
175177

176178
#[Object]
179+
/// The path to a visit directory and the components used to build it
177180
impl VisitPath {
181+
/// The visit for which this is the visit directory
178182
#[instrument(skip(self))]
179183
async fn visit(&self) -> &str {
180184
&self.visit
181185
}
186+
/// This beamline for which this is the visit directory
182187
#[instrument(skip(self))]
183188
async fn beamline(&self) -> &str {
184189
&self.info.name()
185190
}
191+
/// The absolute path to the visit directory
186192
#[instrument(skip(self))]
187193
async fn directory(&self) -> async_graphql::Result<String> {
188194
Ok(path_to_string(self.info.visit()?.render(self))?)
@@ -206,6 +212,7 @@ impl FieldSource<BeamlineField> for VisitPath {
206212
}
207213

208214
#[Object]
215+
/// Paths and values related to a specific scan/data collection for a beamline
209216
impl ScanPaths {
210217
/// The visit used to generate this scan information. Should be the same as the visit passed in
211218
#[instrument(skip(self))]
@@ -249,22 +256,36 @@ impl ScanPaths {
249256
}
250257

251258
#[Object]
259+
/// The current configuration for a beamline
252260
impl CurrentConfiguration {
261+
/// The template used to build the path to the visit directory for a beamline
253262
pub async fn visit_template(&self) -> async_graphql::Result<String> {
254263
Ok(self.db_config.visit()?.to_string())
255264
}
265+
/// The template used to build the path of a scan file for a data acquisition, relative to the
266+
/// root of the visit directory.
256267
pub async fn scan_template(&self) -> async_graphql::Result<String> {
257268
Ok(self.db_config.scan()?.to_string())
258269
}
270+
/// The template used to build the path of a detector's data file for a data acquisition,
271+
/// relative to the root of the visit directory.
259272
pub async fn detector_template(&self) -> async_graphql::Result<String> {
260273
Ok(self.db_config.detector()?.to_string())
261274
}
275+
/// The latest scan number stored in the DB. This is the last scan number provided by this
276+
/// service but may not reflect the most recent scan number for a beamline if an external
277+
/// service (eg GDA) has incremented its own number tracker.
262278
pub async fn db_scan_number(&self) -> async_graphql::Result<u32> {
263279
Ok(self.db_config.scan_number())
264280
}
281+
/// The highest matching number file for this beamline in the configured tracking directory.
282+
/// May be null if no directory is available for this beamline or if there are no matching
283+
/// number files.
265284
pub async fn file_scan_number(&self) -> async_graphql::Result<Option<u32>> {
266285
Ok(self.high_file)
267286
}
287+
/// The file extension used for the file based tracking, eg using an extension of 'ext'
288+
/// would create files `1.ext`, `2.ext` etc
268289
pub async fn tracker_file_extension(&self) -> async_graphql::Result<Option<&str>> {
269290
Ok(self.db_config.tracker_file_extension())
270291
}
@@ -290,7 +311,10 @@ impl FieldSource<DetectorField> for (&str, &ScanPaths) {
290311
}
291312

292313
#[Object]
314+
/// Queries relating to numtracker configurations that have no side-effects
293315
impl Query {
316+
/// Get the visit directory information for the given beamline and visit.
317+
/// This information is not scan specific
294318
#[instrument(skip(self, ctx))]
295319
async fn paths(
296320
&self,
@@ -303,6 +327,7 @@ impl Query {
303327
Ok(VisitPath { visit, info })
304328
}
305329

330+
/// Get the current configuration for the given beamline
306331
#[instrument(skip(self, ctx))]
307332
async fn configuration(
308333
&self,
@@ -326,8 +351,9 @@ impl Query {
326351
}
327352

328353
#[Object]
354+
/// Queries that modify the state of the numtracker configuration in some way
329355
impl Mutation {
330-
/// Access scan file locations for the next scan
356+
/// Generate scan file locations for the next scan
331357
#[instrument(skip(self, ctx))]
332358
async fn scan<'ctx>(
333359
&self,
@@ -367,6 +393,7 @@ impl Mutation {
367393
})
368394
}
369395

396+
/// Add or modify the stored configuration for a beamline
370397
#[instrument(skip(self, ctx))]
371398
async fn configure<'ctx>(
372399
&self,
@@ -412,12 +439,19 @@ where
412439
}
413440
}
414441

442+
/// Changes that should be made to a beamline's configuration
415443
#[derive(Debug, InputObject)]
416444
struct ConfigurationUpdates {
445+
/// New template used to determine the visit directory
417446
visit: Option<InputTemplate<VisitTemplate>>,
447+
/// New template used to determine the relative path to the main scan file for a collection
418448
scan: Option<InputTemplate<ScanTemplate>>,
449+
/// New template used to determine the relative path for detector data files
419450
detector: Option<InputTemplate<DetectorTemplate>>,
451+
/// The highest scan number to have been allocated. The next scan files generated will use the
452+
/// next number.
420453
scan_number: Option<u32>,
454+
/// The extension of the files used to track scan numbers by GDA's numtracker facility
421455
tracker_file_extension: Option<String>,
422456
}
423457

@@ -484,6 +518,8 @@ where
484518
}
485519
}
486520

521+
/// Name of subdirectory within visit directory where data should be written.
522+
/// Can be nested (eg foo/bar) but cannot include links to parent directories (eg ../foo).
487523
// Derived Default is OK without validation as empty path is a valid subdirectory
488524
#[derive(Debug, Default)]
489525
pub struct Subdirectory(String);
@@ -544,6 +580,7 @@ impl Display for Subdirectory {
544580
}
545581
}
546582

583+
/// Detector name
547584
#[derive(Debug)]
548585
pub struct Detector(String);
549586

src/paths.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,10 @@ impl PathSpec for VisitTemplate {
193193

194194
const ABSOLUTE: bool = true;
195195
fn describe() -> &'static str {
196-
"A template describing the path to the visit directory for a beamline"
196+
concat!(
197+
"A template describing the path to the visit directory for a beamline. ",
198+
"It should be an absolute path and contain placeholders for {instrument} and {visit}."
199+
)
197200
}
198201
}
199202

@@ -204,7 +207,10 @@ impl PathSpec for ScanTemplate {
204207

205208
const ABSOLUTE: bool = false;
206209
fn describe() -> &'static str {
207-
"A template describing the location within a visit directory where the root scan file should be written"
210+
concat!(
211+
"A template describing the location within a visit directory where the root scan file should be written. ",
212+
"It should be a relative path and contain a placeholder for {scan_number} to ensure files are unique."
213+
)
208214
}
209215
}
210216

static/service_schema

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,65 @@
11

2+
"""
3+
Changes that should be made to a beamline's configuration
4+
"""
25
input ConfigurationUpdates {
6+
"""
7+
New template used to determine the visit directory
8+
"""
39
visit: VisitTemplate
10+
"""
11+
New template used to determine the relative path to the main scan file for a collection
12+
"""
413
scan: ScanTemplate
14+
"""
15+
New template used to determine the relative path for detector data files
16+
"""
517
detector: DetectorTemplate
18+
"""
19+
The highest scan number to have been allocated. The next scan files generated will use the
20+
next number.
21+
"""
622
scanNumber: Int
23+
"""
24+
The extension of the files used to track scan numbers by GDA's numtracker facility
25+
"""
726
trackerFileExtension: String
827
}
928

29+
"""
30+
The current configuration for a beamline
31+
"""
1032
type CurrentConfiguration {
33+
"""
34+
The template used to build the path to the visit directory for a beamline
35+
"""
1136
visitTemplate: String!
37+
"""
38+
The template used to build the path of a scan file for a data acquisition, relative to the
39+
root of the visit directory.
40+
"""
1241
scanTemplate: String!
42+
"""
43+
The template used to build the path of a detector's data file for a data acquisition,
44+
relative to the root of the visit directory.
45+
"""
1346
detectorTemplate: String!
47+
"""
48+
The latest scan number stored in the DB. This is the last scan number provided by this
49+
service but may not reflect the most recent scan number for a beamline if an external
50+
service (eg GDA) has incremented its own number tracker.
51+
"""
1452
dbScanNumber: Int!
53+
"""
54+
The highest matching number file for this beamline in the configured tracking directory.
55+
May be null if no directory is available for this beamline or if there are no matching
56+
number files.
57+
"""
1558
fileScanNumber: Int
59+
"""
60+
The file extension used for the file based tracking, eg using an extension of 'ext'
61+
would create files `1.ext`, `2.ext` etc
62+
"""
1663
trackerFileExtension: String
1764
}
1865

@@ -22,7 +69,13 @@ scalar Detector
2269
GraphQL type to mimic a key-value pair from the map type that GraphQL doesn't have
2370
"""
2471
type DetectorPath {
72+
"""
73+
The name of the detector that should use this path
74+
"""
2575
name: String!
76+
"""
77+
The path where the detector should write its data
78+
"""
2679
path: String!
2780
}
2881

@@ -36,19 +89,38 @@ scalar DetectorTemplate
3689

3790

3891

92+
"""
93+
Queries that modify the state of the numtracker configuration in some way
94+
"""
3995
type Mutation {
4096
"""
41-
Access scan file locations for the next scan
97+
Generate scan file locations for the next scan
4298
"""
4399
scan(beamline: String!, visit: String!, sub: Subdirectory): ScanPaths!
100+
"""
101+
Add or modify the stored configuration for a beamline
102+
"""
44103
configure(beamline: String!, config: ConfigurationUpdates!): CurrentConfiguration!
45104
}
46105

106+
"""
107+
Queries relating to numtracker configurations that have no side-effects
108+
"""
47109
type Query {
110+
"""
111+
Get the visit directory information for the given beamline and visit.
112+
This information is not scan specific
113+
"""
48114
paths(beamline: String!, visit: String!): VisitPath!
115+
"""
116+
Get the current configuration for the given beamline
117+
"""
49118
configuration(beamline: String!): CurrentConfiguration!
50119
}
51120

121+
"""
122+
Paths and values related to a specific scan/data collection for a beamline
123+
"""
52124
type ScanPaths {
53125
"""
54126
The visit used to generate this scan information. Should be the same as the visit passed in
@@ -75,21 +147,33 @@ type ScanPaths {
75147
}
76148

77149
"""
78-
A template describing the location within a visit directory where the root scan file should be written
150+
A template describing the location within a visit directory where the root scan file should be written. It should be a relative path and contain a placeholder for {scan_number} to ensure files are unique.
79151
"""
80152
scalar ScanTemplate
81153

82154

83155
scalar Subdirectory
84156

157+
"""
158+
The path to a visit directory and the components used to build it
159+
"""
85160
type VisitPath {
161+
"""
162+
The visit for which this is the visit directory
163+
"""
86164
visit: String!
165+
"""
166+
This beamline for which this is the visit directory
167+
"""
87168
beamline: String!
169+
"""
170+
The absolute path to the visit directory
171+
"""
88172
directory: String!
89173
}
90174

91175
"""
92-
A template describing the path to the visit directory for a beamline
176+
A template describing the path to the visit directory for a beamline. It should be an absolute path and contain placeholders for {instrument} and {visit}.
93177
"""
94178
scalar VisitTemplate
95179

0 commit comments

Comments
 (0)