@@ -275,16 +275,26 @@ def load_sample_data(
275275
276276 for view in config ._districtr_maps :
277277 session = next (get_session ())
278- u = _create_districtr_map (
279- session = session ,
280- name = view .name ,
281- districtr_map_slug = view .districtr_map_slug ,
282- gerrydb_table_name = view .gerrydb_table_name ,
283- parent_layer = view .parent_layer ,
284- child_layer = view .child_layer ,
285- tiles_s3_path = view .tiles_s3_path ,
286- num_districts = view .num_districts ,
287- )
278+ districtr_map_exists = session .execute (
279+ sa .text (
280+ "select 1 from districtrmap where districtr_map_slug = :slug limit 1"
281+ ),
282+ {"slug" : view .districtr_map_slug },
283+ ).one_or_none ()
284+ if districtr_map_exists :
285+ u = districtr_map_exists .uuid
286+ logger .info (f"Districtr map { view .districtr_map_slug } already exists." )
287+ else :
288+ u = _create_districtr_map (
289+ session = session ,
290+ name = view .name ,
291+ districtr_map_slug = view .districtr_map_slug ,
292+ gerrydb_table_name = view .gerrydb_table_name ,
293+ parent_layer = view .parent_layer ,
294+ child_layer = view .child_layer ,
295+ tiles_s3_path = view .tiles_s3_path ,
296+ num_districts = view .num_districts ,
297+ )
288298
289299 if u is not None :
290300 logger .info (f"Created districtr map with UUID { u } " )
0 commit comments