@@ -80,15 +80,15 @@ def get_fileset(conn, obj_string):
80
80
def main (argv ):
81
81
"""
82
82
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
84
84
Fileset to use the Fileset in the 'New Object'. Images in the `New Object` are left
85
85
unlinked to any Fileset, and can then be deleted.
86
86
Also prints an sql command(s) to update the pixels in the NEW Images only.
87
87
For Screens containing multiple Plates (Filesets), we match the Plates by Name
88
88
"""
89
89
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' )
92
92
parser .add_argument ('sql_output' , help = 'File path to output sql commands' )
93
93
parser .add_argument ("--report" , action = "store_true" , help = "Print logs" )
94
94
parser .add_argument ("--dry-run" , action = "store_true" , help = "Don't save any changes" )
@@ -121,6 +121,21 @@ def main(argv):
121
121
new_fileset = get_fileset (conn , f"Plate:{ new_plate .id } " )
122
122
swap_fileset (conn , old_fileset , new_fileset , sql_filename , args .report , args .dry_run )
123
123
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
+
124
139
else :
125
140
old_fileset = get_fileset (conn , old_object )
126
141
new_fileset = get_fileset (conn , new_object )
0 commit comments