|
7 | 7 | import ispyb |
8 | 8 | import workflows.transport |
9 | 9 | from fastapi import Depends |
10 | | -from ispyb.sqlalchemy import ( |
| 10 | +from ispyb.sqlalchemy._auto_db_schema import ( |
11 | 11 | Atlas, |
12 | 12 | AutoProcProgram, |
13 | 13 | BLSample, |
@@ -198,13 +198,8 @@ def do_update_atlas( |
198 | 198 | atlas.mode = collection_mode or atlas.mode |
199 | 199 | # Optionally insert colour flags if present |
200 | 200 | if color_flags: |
201 | | - atlas.hasGrey = color_flags.get("hasGrey") |
202 | | - atlas.hasRed = color_flags.get("hasRed") |
203 | | - atlas.hasGreen = color_flags.get("hasGreen") |
204 | | - atlas.hasBlue = color_flags.get("hasBlue") |
205 | | - atlas.hasCyan = color_flags.get("hasCyan") |
206 | | - atlas.hasYellow = color_flags.get("hasYellow") |
207 | | - atlas.hasMagenta = color_flags.get("hasMagenta") |
| 201 | + for col_name, value in color_flags.items(): |
| 202 | + setattr(atlas, col_name, value) |
208 | 203 | db.add(atlas) |
209 | 204 | db.commit() |
210 | 205 | return {"success": True, "return_value": atlas.atlasId} |
@@ -247,16 +242,12 @@ def do_insert_grid_square( |
247 | 242 | stageLocationX=grid_square_parameters.x_stage_position, |
248 | 243 | stageLocationY=grid_square_parameters.y_stage_position, |
249 | 244 | pixelSize=grid_square_parameters.pixel_size, |
| 245 | + mode=grid_square_parameters.collection_mode, |
250 | 246 | ) |
251 | 247 | # Optionally insert colour flags |
252 | 248 | if color_flags: |
253 | | - record.hasGrey = color_flags.get("hasGrey") |
254 | | - record.hasRed = color_flags.get("hasRed") |
255 | | - record.hasGreen = color_flags.get("hasGreen") |
256 | | - record.hasBlue = color_flags.get("hasBlue") |
257 | | - record.hasCyan = color_flags.get("hasCyan") |
258 | | - record.hasYellow = color_flags.get("hasYellow") |
259 | | - record.hasMagenta = color_flags.get("hasMagenta") |
| 249 | + for col_name, value in color_flags.items(): |
| 250 | + setattr(record, col_name, value) |
260 | 251 | try: |
261 | 252 | with ISPyBSession() as db: |
262 | 253 | db.add(record) |
@@ -319,13 +310,8 @@ def do_update_grid_square( |
319 | 310 | grid_square.mode = grid_square_parameters.collection_mode |
320 | 311 | # Optionally insert colour flags |
321 | 312 | if color_flags: |
322 | | - grid_square.hasGrey = color_flags.get("hasGrey") |
323 | | - grid_square.hasRed = color_flags.get("hasRed") |
324 | | - grid_square.hasGreen = color_flags.get("hasGreen") |
325 | | - grid_square.hasBlue = color_flags.get("hasBlue") |
326 | | - grid_square.hasCyan = color_flags.get("hasCyan") |
327 | | - grid_square.hasYellow = color_flags.get("hasYellow") |
328 | | - grid_square.hasMagenta = color_flags.get("hasMagenta") |
| 313 | + for col_name, value in color_flags.items(): |
| 314 | + setattr(grid_square, col_name, value) |
329 | 315 | db.add(grid_square) |
330 | 316 | db.commit() |
331 | 317 | return {"success": True, "return_value": grid_square.gridSquareId} |
|
0 commit comments