20
20
lat_tube_list_file: path to yaml dict matching tubes and bands
21
21
tolerate_stray_files: True
22
22
skip_bad_books: True
23
- known_bad_books:
24
- - oper_1736874485_satp3_0000100
25
- - obs_9999999999_satp0_1111111
23
+ known_bad_books_file: path to \n -separated file listing bad books
26
24
extra_extra_files:
27
25
- Z_bookbinder_log.txt
28
26
extra_files:
@@ -153,8 +151,14 @@ def main(config: str,
153
151
bookcartobsdb .add_obs_columns (col_list )
154
152
if "skip_bad_books" not in config_dict :
155
153
config_dict ["skip_bad_books" ] = False
156
- if "known_bad_books" not in config_dict :
157
- config_dict ["known_bad_books" ] = []
154
+
155
+ config_dict ["known_bad_books" ] = []
156
+ if "known_bad_books_file" in config_dict :
157
+ try :
158
+ with open (config_dict ["known_bad_books_file" ], "r" ) as bbf :
159
+ config_dict ["known_bad_books" ] = bbf .read ().split ("\n " )
160
+ except :
161
+ raise IOError ("Bad books file couldn't be read in" )
158
162
159
163
#How far back we should look
160
164
tnow = time .time ()
@@ -192,6 +196,7 @@ def main(config: str,
192
196
193
197
logger .info (f"Found { len (bookcart )} new books in { time .time ()- tnow } s" )
194
198
#Check the books for the observations we want
199
+ bad_book_counter = 0
195
200
for bookpath in sorted (bookcart ):
196
201
if check_meta_type (bookpath ) in accept_type :
197
202
t1 = time .time ()
@@ -207,7 +212,12 @@ def main(config: str,
207
212
logger .info (f"Ran check_book in { time .time ()- t1 } s" )
208
213
except Exception as e :
209
214
if config_dict ["skip_bad_books" ]:
210
- logger .warning (f"failed to add { bookpath } " )
215
+ config_dict ["known_bad_books" ].append (book_id )
216
+ logger .error (f"failed to add { bookpath } . There are now { len (config_dict ['known_bad_books' ])} known bad books." )
217
+ bad_book_counter += 1
218
+ if "known_bad_books_file" in config_dict :
219
+ with open (config_dict ["known_bad_books_file" ], "w" ) as bbf :
220
+ bbf .write ("\n " .join (config_dict ["known_bad_books" ]))
211
221
continue
212
222
else :
213
223
raise e
@@ -226,8 +236,7 @@ def main(config: str,
226
236
for key , val in very_clean .items ():
227
237
col_list .append (key + " " + type (val ).__name__ )
228
238
bookcartobsdb .add_obs_columns (col_list )
229
- if "skip_bad_books" not in config_dict :
230
- config_dict ["skip_bad_books" ] = False
239
+
231
240
#Adding info that should be there for all observations
232
241
#Descriptive string columns
233
242
try :
@@ -326,7 +335,9 @@ def main(config: str,
326
335
logger .info (f"Finished { obs_id } in { time .time ()- t1 } s" )
327
336
else :
328
337
bookcart .remove (bookpath )
329
-
338
+ if bad_book_counter != 0 :
339
+ logger .error (f"Found { bad_book_counter } new bad books, There are now { len (config_dict ['known_bad_books' ])} known bad books." )
340
+ raise (Exception )
330
341
331
342
def get_parser (parser = None ):
332
343
if parser is None :
0 commit comments