@@ -80,15 +80,15 @@ def get_fileset(conn, obj_string):
8080def main (argv ):
8181 """
8282 Swaps Fileset from 'Old Object' to 'New Object'.
83- For all the Images in the 'Old Object' (Screen, Plate, Image or Fileset), we swap the
83+ For all the Images in the 'Old Object' (Screen, Plate, Dataset, Image or Fileset), we swap the
8484 Fileset to use the Fileset in the 'New Object'. Images in the `New Object` are left
8585 unlinked to any Fileset, and can then be deleted.
8686 Also prints an sql command(s) to update the pixels in the NEW Images only.
8787 For Screens containing multiple Plates (Filesets), we match the Plates by Name
8888 """
8989 parser = argparse .ArgumentParser ()
90- parser .add_argument ('old_object' , help = 'Object:ID where Object is Screen, Plate, Image, Fileset' )
91- parser .add_argument ('new_object' , help = 'Object:ID where Object is Screen, Plate, Image, Fileset' )
90+ parser .add_argument ('old_object' , help = 'Object:ID where Object is Screen, Plate, Dataset, Image, Fileset' )
91+ parser .add_argument ('new_object' , help = 'Object:ID where Object is Screen, Plate, Dataset, Image, Fileset' )
9292 parser .add_argument ('sql_output' , help = 'File path to output sql commands' )
9393 parser .add_argument ("--report" , action = "store_true" , help = "Print logs" )
9494 parser .add_argument ("--dry-run" , action = "store_true" , help = "Don't save any changes" )
@@ -121,6 +121,21 @@ def main(argv):
121121 new_fileset = get_fileset (conn , f"Plate:{ new_plate .id } " )
122122 swap_fileset (conn , old_fileset , new_fileset , sql_filename , args .report , args .dry_run )
123123
124+ if "Dataset" in old_object :
125+ old_dataset = get_object (conn , old_object )
126+ new_dataset = get_object (conn , new_object )
127+ old_images_by_name = {}
128+ for image in old_dataset .listChildren ():
129+ old_images_by_name [image .getName ()] = image
130+
131+ for new_image in new_dataset .listChildren ():
132+ name = new_image .getName ()
133+ if name not in old_images_by_name :
134+ print (f"No Image named { name } in { old_object } " )
135+ old_fileset = get_fileset (conn , f"Image:{ old_images_by_name [name ].id } " )
136+ new_fileset = get_fileset (conn , f"Image:{ new_image .id } " )
137+ swap_fileset (conn , old_fileset , new_fileset , sql_filename , args .report , args .dry_run )
138+
124139 else :
125140 old_fileset = get_fileset (conn , old_object )
126141 new_fileset = get_fileset (conn , new_object )
0 commit comments