schema_template
spyglass_workshop.schema_template
¶
Workshop schema template.
This module defines a minimal Spyglass pipeline with four tables:
MyParams— parameter lookup tableMyAnalysisSelection— staging table pairing data with parametersMyAnalysis— computed analysis tableMyAnalysis.MyPart— part table storing per-iteration results
Each table foreign-key references :class:spyglass.common.Subject, which is
pre-populated in the workshop MySQL instance.
Usage
Import this module in the Session 2 notebook to register the tables under
your personal schema (workshop_<your-username>). Then follow the
notebook instructions to populate and query them.
Exercise
Add a mean_result : float secondary field to MyAnalysis that stores
the mean of all MyPart.result values for that key. Update make
accordingly and re-run MyAnalysis().populate().
MyParams
¶
Bases: SpyglassMixin, Lookup
Analysis parameter sets.
Each row defines one named configuration for MyAnalysis.make.
The params blob stores a dictionary of keyword arguments passed
directly to the analysis function.
Source code in src/spyglass_workshop/schema_template.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
insert_default()
classmethod
¶
Insert the default parameter sets defined in contents.
Source code in src/spyglass_workshop/schema_template.py
54 55 56 57 | |
MyAnalysisSelection
¶
Bases: SpyglassMixin, Manual
Pairs of subjects and parameter sets to be analyzed.
Insert rows here to schedule work for MyAnalysis().populate().
Only the combinations you insert will be processed.
Source code in src/spyglass_workshop/schema_template.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
insert_all(param_name='default')
classmethod
¶
Insert every subject paired with the given parameter set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param_name
|
str
|
Name of the parameter set to pair with each subject. |
'default'
|
Source code in src/spyglass_workshop/schema_template.py
73 74 75 76 77 78 79 80 81 82 83 84 85 | |
MyAnalysis
¶
Bases: SpyglassMixin, Computed
Computed analysis results.
Populated automatically by MyAnalysis().populate(), which calls
make for every unprocessed row in MyAnalysisSelection.
Source code in src/spyglass_workshop/schema_template.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
MyPart
¶
Bases: SpyglassMixinPart, Part
Per-iteration results.
One row per iteration of the analysis loop defined in
MyAnalysis.make.
Source code in src/spyglass_workshop/schema_template.py
102 103 104 105 106 107 108 109 110 111 112 113 114 | |
make(key)
¶
Populate one row of MyAnalysis and its part table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
dict
|
Primary key dict provided by |
required |
Source code in src/spyglass_workshop/schema_template.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
summarize(key)
staticmethod
¶
Return a summary dict for a given key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str or dict
|
Restriction identifying one |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Keys: |
Source code in src/spyglass_workshop/schema_template.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |