@@ -113,7 +113,9 @@ def scout( # noqa: C901
113113 error_console .print (data ["error" ])
114114 return None
115115
116- scopes_with_minoc_discrepancy : List [str ] = []
116+ storage_elements = list (data [scopes [0 ]]["observed" ].keys ())
117+ file_discrepancies : List [List ] = []
118+
117119 for scope in data .keys ():
118120 basepath = data .get (scope ).get ("basepath" )
119121 query = f"select count(*) from inventory.Artifact where uri like 'cadc:CHIMEFRB/{ basepath } %'" # noqa: E501
@@ -143,26 +145,37 @@ def scout( # noqa: C901
143145 for key in keys_missing_in_expected :
144146 data [scope ]["expected" ][key ] = 0
145147
146- if data [scope ]["observed" ]["minoc" ] > data [scope ]["expected" ]["minoc" ]:
147- scopes_with_minoc_discrepancy .append (scope )
148+ for se in storage_elements :
149+ if data [scope ]["observed" ][se ] > data [scope ]["expected" ][se ]:
150+ file_discrepancies .append ([scope , se ])
148151
149152 show_scout_results (dataset , data )
150153
151- if scopes_with_minoc_discrepancy :
152- error_console .print ("Scopes with minoc discrepancy :" )
153- for scope in scopes_with_minoc_discrepancy :
154- error_console .print (f" - { scope } " )
154+ if file_discrepancies :
155+ error_console .print ("File discrepancies :" )
156+ for scope , se in file_discrepancies :
157+ error_console .print (f" - { se } : { scope } " )
155158 ifHeal = Confirm .ask ("\n Would you like to attempt to heal this discrepancy?" )
156159 if ifHeal :
157160 basepath = data .get (scope ).get ("basepath" )
158- minoc_md5s = cadcclient .dataset_md5s (basepath )
159- # console.print(minoc_md5s)
161+ file_type = data .get (scope ).get ("filetype" )
162+ if se == "minoc" :
163+ file_md5s = cadcclient .dataset_md5s (basepath )
164+ # console.print(minoc_md5s)
165+ else :
166+ md5_url = (
167+ server
168+ + "/query/datasset/scout/md5sums"
169+ + f"?basepath={ basepath } &site={ se } &filetype={ file_type } "
170+ )
171+ response = requests .get (md5_url )
172+ file_md5s = response .json ()
160173 url = (
161174 server
162175 + "/commit/dataset/scout/sync"
163- + f"?name={ dataset } &scope={ scope } &replicate_to=minoc "
176+ + f"?name={ dataset } &scope={ scope } &replicate_to={ se } "
164177 )
165- response = requests .post (url , json = minoc_md5s )
178+ response = requests .post (url , json = file_md5s )
166179 if response .status_code == 200 :
167180 console .print (f"{ scope } - Healing successful." )
168181 else :
0 commit comments