41
41
import org .janelia .alignment .util .ImageProcessorCache ;
42
42
import org .janelia .render .client .RenderDataClient ;
43
43
import org .janelia .render .client .spark .LogUtilities ;
44
+ import org .slf4j .ILoggerFactory ;
44
45
import org .slf4j .Logger ;
45
46
import org .slf4j .LoggerFactory ;
46
47
48
+ import ch .qos .logback .classic .Level ;
49
+ import ch .qos .logback .classic .LoggerContext ;
50
+
47
51
/**
48
52
* Serializable task for aligning SFOVs within a single MFOV.
49
53
* This task handles fetching tile specs, deriving matches, optimizing tiles, and saving results.
@@ -69,6 +73,10 @@ public MfovPrealignTask(
69
73
this .layerMfov = layerMfov ;
70
74
}
71
75
76
+ public String toString () {
77
+ return prealignedStackId .toDevString () + "::" + layerMfov ;
78
+ }
79
+
72
80
/**
73
81
* Align and intensity correct all SFOVs within this MFOV and save the aligned tile specs to the prealigned stack.
74
82
* Both alignment and intensity correction are performed by simple translation models.
@@ -79,15 +87,8 @@ public void run()
79
87
throws IOException {
80
88
81
89
final long startTime = System .currentTimeMillis ();
82
-
83
- // Setup executor log4j for runs at Janelia which will place layerMfovDevString in the %X{context} element.
84
- // For Logs Explorer views of Google Dataproc runs, the context does not seem to be available/selectable
85
- // as a summary field. To work around this limitation, the layerMfovDevString is logged explicitly at
86
- // the entry and exit of this run method. You can then see which executorId maps to layerMfovDevString
87
- // and filter accordingly in Logs Explorer.
88
- final String layerMfovDevString = prealignedStackId .toDevString () + "::" + layerMfov ;
89
- LogUtilities .setupExecutorLog4j (layerMfovDevString );
90
- LOG .info ("run: entry, layerMfovDevString={}" , layerMfovDevString );
90
+ setupLogging ();
91
+ LOG .info ("run: entry, {}" , this );
91
92
92
93
final RenderDataClient dataClient = new RenderDataClient (baseDataUrl ,
93
94
rawSfovStackId .getOwner (),
@@ -97,14 +98,14 @@ public void run()
97
98
final ResolvedTileSpecCollection mfovTiles = fetchMfovTileSpecs (dataClient );
98
99
99
100
if (mfovTiles .getTileCount () == 0 ) {
100
- throw new IOException ("no tile specs found for " + layerMfovDevString );
101
+ throw new IOException ("no tile specs found for " + this );
101
102
}
102
103
103
104
// 2. Generate tile pairs for matching
104
105
final List <OrderedCanvasIdPair > tilePairs = generateTilePairs (mfovTiles );
105
106
106
107
if (tilePairs .isEmpty ()) {
107
- LOG .info ("[{}] run: exit, no tile pairs generated" , layerMfovDevString );
108
+ LOG .info ("run: exit, {}, no tile pairs generated" , this );
108
109
return ;
109
110
}
110
111
@@ -121,21 +122,56 @@ public void run()
121
122
dataClient .saveResolvedTiles (alignedIcTiles , prealignedStackId .getStack (), layerMfov .getZ ());
122
123
123
124
final long elapsedSeconds = (System .currentTimeMillis () - startTime ) / 1000 ;
125
+ LOG .info ("run: exit, {}, elapsedSeconds={}" , this , elapsedSeconds );
126
+ }
127
+
128
+ private void setupLogging () {
129
+
130
+ // remove info messages for these classes to reduce messages logged per MFOV from ~3100 to ~30
131
+ final String [] reducedLoggerNames = {
132
+ CanvasFeatureExtractor .class .getName (),
133
+ CanvasFeatureMatcher .class .getName (),
134
+ MatchFilter .class .getName ()
135
+ };
136
+
137
+ final ILoggerFactory factory = LoggerFactory .getILoggerFactory ();
138
+ for (final String loggerName : reducedLoggerNames ) {
139
+
140
+ if (factory instanceof LoggerContext ) {
141
+
142
+ // Janelia Spark clusters use logback
143
+ final LoggerContext loggerContext = (LoggerContext ) LoggerFactory .getILoggerFactory ();
144
+ final ch .qos .logback .classic .Logger logger = loggerContext .getLogger (loggerName );
145
+ if (logger == null ) {
146
+ throw new IllegalArgumentException ("logger with name '" + loggerName + "' not found" );
147
+ }
148
+ logger .setLevel (Level .WARN );
149
+
150
+ } else if ("org.apache.logging.slf4j.Log4jLoggerFactory" .equals (factory .getClass ().getName ())) {
151
+
152
+ // Google Dataproc Spark clusters use Log4j
153
+ org .apache .logging .log4j .core .config .Configurator .setLevel (loggerName ,
154
+ org .apache .logging .log4j .Level .WARN );
155
+
156
+ }
157
+ }
124
158
125
- LOG .info ("run: exit, layerMfovDevString={}, elapsedSeconds={}" ,
126
- layerMfovDevString , elapsedSeconds );
159
+ // Setup executor log4j for runs at Janelia which will place layerMfovDevString in the %X{context} element.
160
+ // For Logs Explorer views of Google Dataproc runs, the context does not seem to be available/selectable
161
+ // as a summary field. To work around this limitation, the layerMfovDevString is logged explicitly
162
+ // from methods in this class.
163
+ // You can then see which executorId maps to layerMfovDevString and filter accordingly in Logs Explorer.
164
+ LogUtilities .setupExecutorLog4j (this .toString ());
127
165
}
128
166
129
167
/**
130
168
* Fetch tile specs for all SFOVs belonging to this MFOV at the specified z layer.
131
169
*/
132
170
private ResolvedTileSpecCollection fetchMfovTileSpecs (final RenderDataClient dataClient ) throws IOException {
133
171
final String matchPattern = "_" + layerMfov .getSimpleMfovName () + "_" ; // limit to tiles in this MFOV
134
- final ResolvedTileSpecCollection resolvedTiles = dataClient .getResolvedTiles (rawSfovStackId .getStack (),
135
- layerMfov .getZ (),
136
- matchPattern );
137
- LOG .info ("fetchMfovTileSpecs: exit, returning collection with {} tiles" , resolvedTiles .getTileCount ());
138
- return resolvedTiles ;
172
+ return dataClient .getResolvedTiles (rawSfovStackId .getStack (),
173
+ layerMfov .getZ (),
174
+ matchPattern );
139
175
}
140
176
141
177
/**
@@ -162,8 +198,6 @@ private List<OrderedCanvasIdPair> generateTilePairs(final ResolvedTileSpecCollec
162
198
}
163
199
}
164
200
165
- LOG .info ("generateTilePairs: exit, returning {} pairs" , pairs .size ());
166
-
167
201
return pairs ;
168
202
}
169
203
@@ -176,7 +210,8 @@ private ResolvedTileSpecCollection alignTiles(
176
210
final ImageProcessorCache cache
177
211
) {
178
212
179
- LOG .info ("alignTiles: entry" );
213
+ final long startTime = System .currentTimeMillis ();
214
+ LOG .info ("alignTiles: entry, {}" , this );
180
215
181
216
// Extract features from all mfov tiles
182
217
final CanvasFeatureExtractor featureExtractor = CanvasFeatureExtractor .build (FEATURE_EXTRACTION_PARAMETERS );
@@ -218,7 +253,7 @@ private ResolvedTileSpecCollection alignTiles(
218
253
}
219
254
}
220
255
221
- LOG .info ("alignTiles: start optimization" );
256
+ LOG .info ("alignTiles: start optimization, {}" , this );
222
257
223
258
// Optimize the tiles
224
259
final TileConfiguration tc = new TileConfiguration ();
@@ -254,7 +289,9 @@ private ResolvedTileSpecCollection alignTiles(
254
289
tiles .addTransformSpecToTile (tileId , newTransformSpec , ResolvedTileSpecCollection .TransformApplicationMethod .REPLACE_LAST );
255
290
}
256
291
257
- LOG .info ("alignTiles: exit, returning collection with {} tiles" , tiles .getTileCount ());
292
+ final long elapsedSeconds = (System .currentTimeMillis () - startTime ) / 1000 ;
293
+ LOG .info ("alignTiles: exit, {}, returning collection with {} tiles, elapsedSeconds={}" ,
294
+ this , tiles .getTileCount (), elapsedSeconds );
258
295
259
296
return tiles ;
260
297
}
@@ -344,7 +381,7 @@ private ResolvedTileSpecCollection intensityCorrectTiles(
344
381
final List <OrderedCanvasIdPair > tilePairs ,
345
382
final ImageProcessorCache cache
346
383
) {
347
- LOG . info ( "intensityCorrectTiles: entry, tile count={}" , tiles . getTileCount ());
384
+
348
385
final Map <String , Tile <TranslationModel1D >> modelTiles = new HashMap <>();
349
386
350
387
// Initialize models for each tile spec
@@ -419,7 +456,7 @@ private ResolvedTileSpecCollection intensityCorrectTiles(
419
456
tileSpec .setFilterSpec (filterSpec );
420
457
}
421
458
422
- LOG .info ("intensityCorrectTiles: exit" );
459
+ LOG .info ("intensityCorrectTiles: exit, {}" , this );
423
460
return tiles ;
424
461
}
425
462
0 commit comments