@@ -862,19 +862,19 @@ async def _run_container_engine_cmd(self, container, kind):
862862 try :
863863 websocket_url = f"{ self .websocket_url } ?kind={ kind } "
864864 logger .debug (
865- "Connecting to "
866- + websocket_url
867- + "for container "
868- + str (container .get ("Id" ))
865+ "Connecting to " +
866+ websocket_url +
867+ "for container " +
868+ str (container .get ("Id" ))
869869 )
870870 websocket = await asyncio .wait_for (
871871 websockets .connect (websocket_url ), timeout = 10.0
872872 )
873873 logger .debug (
874- "connected to "
875- + str (websocket_url )
876- + "for container "
877- + str (container .get ("Id" ))
874+ "connected to " +
875+ str (websocket_url ) +
876+ "for container " +
877+ str (container .get ("Id" ))
878878 )
879879 except Exception as e :
880880 logger .error (
@@ -954,10 +954,10 @@ async def _run_container_engine_cmd(self, container, kind):
954954 client .remove_container (container , force = True )
955955
956956 logger .debug (
957- "Container "
958- + container .get ("Id" )
959- + "exited with status code : "
960- + str (return_Code ["StatusCode" ])
957+ "Container " +
958+ container .get ("Id" ) +
959+ "exited with status code : " +
960+ str (return_Code ["StatusCode" ])
961961 )
962962
963963 except (
@@ -1095,7 +1095,7 @@ async def _run_program_directory(self, kind, program_dir):
10951095 volumes_config .update ({volumes_host [- 1 ]: {"bind" : "/app/shared" }})
10961096
10971097 # Input dir for scoring program
1098- volumes_host .extend ([self ._get_host_path (self .root_dir , "input" )])
1098+ volumes_host .extend ([self ._get_host_path (self .input_dir )])
10991099 volumes_config .update ({volumes_host [- 1 ]: {"bind" : "/app/input" }})
11001100
11011101 # NOTE: self.input_data is valid when running an ingestion program and competition task has input data
@@ -1196,6 +1196,31 @@ def _prep_cache_dir(self, max_size=MAX_CACHE_DIR_SIZE_GB):
11961196 else :
11971197 logger .info ("Cache directory does not need to be pruned!" )
11981198
1199+ def _copy_submission_to_input_res (self ):
1200+ """
1201+ Temporary backward-compatibility function.
1202+
1203+ Earlier, scoring programs expected submission files in ingestion output:
1204+ /app/input/res/
1205+
1206+ Newer changes expose submission under:
1207+ /app/ingested_program/
1208+
1209+ To avoid breaking older scoring programs, we copy the submission
1210+ directory into input/res
1211+ """
1212+
1213+ submission_directory = os .path .join (self .root_dir , "submission" )
1214+ ingestion_res_directory = os .path .join (self .root_dir , "input/res" )
1215+
1216+ # copy from submission_directory ingestion_res_directory
1217+ try :
1218+ shutil .copytree (submission_directory , ingestion_res_directory , dirs_exist_ok = True )
1219+ logger .info (f"Copied submission files to input/res successfully" )
1220+
1221+ except Exception as e :
1222+ logger .error (f"Failed to copy submission to input/res: { e } " )
1223+
11991224 def prepare (self ):
12001225 hostname = utils .nodenames .gethostname ()
12011226 if self .is_scoring :
@@ -1234,10 +1259,7 @@ def prepare(self):
12341259 cache_this_bundle = path in ("input_data" , "input/ref" )
12351260 zip_file = self ._get_bundle (url , path , cache = cache_this_bundle )
12361261
1237- # Originally the following if condition was
1238- # `if url == self.program_data and not self.is_scoring:`
1239- # Which means if url == submission and this is ingestion run
1240- # Below now we have a new condition i.e. when url == submission and this is ingestion run
1262+ # Computing checksum of the submission file during ingestion run
12411263 if url == self .submission_data and not self .is_scoring :
12421264 # We want to get a checksum of submissions so we can check if they are
12431265 # a solution, or maybe match them against other submissions later
@@ -1246,6 +1268,11 @@ def prepare(self):
12461268 logger .info (f"Checksum result: { checksum } " )
12471269 self ._update_submission ({"md5" : checksum })
12481270
1271+ # During scoring: copy submission files into "input/res"
1272+ if self .is_scoring :
1273+ # NOTE: Temporary compatibility hook (To be removed in the future)
1274+ self ._copy_submission_to_input_res ()
1275+
12491276 # For logging purposes let's dump file names
12501277 for filename in glob .iglob (self .root_dir + "**/*.*" , recursive = True ):
12511278 logger .info (filename )
0 commit comments