You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Step 4: Work with metadata and validate (Record-based workflow)
183
+
184
+
After creating a record-based metadata task, collaborators can enter metadata through the Grid interface. Once metadata entry is complete, you'll want to validate the data against your schema and identify any issues.
185
+
186
+
### The metadata curation workflow
187
+
188
+
1.**Data Entry**: Collaborators use the Grid interface (via the curation task link in the Synapse web UI) to enter metadata
189
+
2.**Grid Export**: Export the Grid session back to the RecordSet to save changes (this can be done via the web UI or programmatically)
190
+
3.**Validation**: Retrieve detailed validation results to identify schema violations
191
+
4.**Correction**: Fix any validation errors and repeat as needed
192
+
193
+
### Creating and exporting a Grid session
194
+
195
+
Validation results are only generated when a Grid session is exported back to the RecordSet. This triggers Synapse to validate each row against the bound schema. You have two options:
196
+
197
+
**Option A: Via the Synapse web UI (most common)**
198
+
199
+
Users can access the curation task through the Synapse web interface, enter/edit data in the Grid, and click the export button. This automatically generates validation results.
200
+
201
+
**Option B: Programmatically create and export a Grid session**
202
+
203
+
```python
204
+
from synapseclient import Synapse
205
+
from synapseclient.models import RecordSet
206
+
from synapseclient.models.curation import Grid
207
+
208
+
syn = Synapse()
209
+
syn.login()
210
+
211
+
# Get your RecordSet (must have a schema bound)
212
+
record_set = RecordSet(id="syn987654321").get()
213
+
214
+
# Create a Grid session from the RecordSet
215
+
grid = Grid(record_set_id=record_set.id).create()
216
+
217
+
# At this point, users can interact with the Grid (either programmatically or via web UI)
218
+
# When ready to save changes and generate validation results, export back to RecordSet
219
+
grid.export_to_record_set()
220
+
221
+
# Clean up the Grid session
222
+
grid.delete()
223
+
224
+
# Re-fetch the RecordSet to get the updated validation_file_handle_id
225
+
record_set = RecordSet(id=record_set.id).get()
226
+
```
227
+
228
+
**Important**: The `validation_file_handle_id` attribute is only populated after a Grid export operation. Until then, `get_detailed_validation_results()` will return `None`.
229
+
230
+
### Getting detailed validation results
231
+
232
+
After exporting from a Grid session with a bound schema, Synapse automatically validates each row against the schema and generates a detailed validation report. Here's how to retrieve and analyze those results:
233
+
234
+
```python
235
+
from synapseclient import Synapse
236
+
from synapseclient.models import RecordSet
237
+
238
+
syn = Synapse()
239
+
syn.login()
240
+
241
+
# After Grid export (either via web UI or programmatically)
242
+
# retrieve the updated RecordSet
243
+
record_set = RecordSet(id="syn987654321").get()
244
+
245
+
# Get detailed validation results as a pandas DataFrame
ValidationError: ["#/dateBirth: expected type: String, found: Long","#/sex: other is not a valid enum value"]
410
+
```
411
+
412
+
**Key points about validation results:**
413
+
414
+
-**Automatic generation**: Validation results are created automatically when you export data from a Grid session with a bound schema
415
+
-**Row-level detail**: Each row in your RecordSet gets its own validation status and error messages
416
+
-**Multiple violations**: The `all_validation_messages` column contains all schema violations for a row, not just the first one
417
+
-**Iterative correction**: Use the validation results to identify issues, make corrections in the Grid, export again, and re-validate
418
+
419
+
### When validation results are available
420
+
421
+
Validation results are only available after:
422
+
1. A JSON schema has been bound to the RecordSet (set `bind_schema_to_record_set=True` when creating the task)
423
+
2. Data has been entered through a Grid session
424
+
3.**The Grid session has been exported back to the RecordSet** - This is the critical step that triggers validation and populates the `validation_file_handle_id` attribute
425
+
426
+
The export can happen in two ways:
427
+
-**Via the Synapse web UI**: Users click the export/save button in the Grid interface
428
+
-**Programmatically**: Call `grid.export_to_record_set()` after creating a Grid session
429
+
430
+
If `get_detailed_validation_results()` returns `None`, the most common reason is that the Grid session hasn't been exported yet. Check that `record_set.validation_file_handle_id` is not `None` after exporting.
431
+
181
432
## Additional utilities
182
433
183
434
### Validate schema binding on folders
@@ -227,6 +478,9 @@ for curation_task in CurationTask.list(
227
478
-[query_schema_registry][synapseclient.extensions.curator.query_schema_registry] - Search for schemas in the registry
-[RecordSet.get_detailed_validation_results][synapseclient.models.RecordSet.get_detailed_validation_results] - Get detailed validation results for RecordSet data
482
+
-[Grid.create][synapseclient.models.curation.Grid.create] - Create a Grid session from a RecordSet
483
+
-[Grid.export_to_record_set][synapseclient.models.curation.Grid.export_to_record_set] - Export Grid data back to RecordSet and generate validation results
230
484
-[Folder.bind_schema][synapseclient.models.Folder.bind_schema] - Bind schemas to folders
0 commit comments