def run_challenge(challenge_execution: ChallengeExecution) -> Union[ChallengeResult, ChallengeResult2, ChallengeError]: print(f"Running challenge {challenge_execution.challenge.name} from repository {challenge_execution.repository}", flush=True) challenge_execution.prepare_workspace() build_result = challenge_execution.run_step('bash', 'build', 'scripts/build.sh') if build_result.code != 0: return ChallengeResult2(build=build_result) get_duration_from_stdout = True if challenge_execution.challenge.input_model == 'file' else False step_results = {build_result.name: build_result} if challenge_execution.challenge.custom_runner: for step in challenge_execution.challenge.steps: step_result = challenge_execution.run_step(step.runner, step.name, step.script, step.timeout, parameters=challenge_execution.challenge.parameters) step_results[step_result.name] = step_result if step_result.code != 0: break return ChallengeResult2(**step_results) else: run_script = run_scripts.get(challenge_execution.challenge.input_model) run_result = challenge_execution.run_step('bash', 'run', f'scripts/{run_script}', timeout=10, get_durtion_from_stdout=get_duration_from_stdout) if run_result.code != 0: return ChallengeError('Error in running the code', run_result) validate_result = challenge_execution.run_step('bash', 'validate', 'scripts/validate.sh', timeout=10) if validate_result.code != 0: return ChallengeError('Error in validating the result', validate_result) challenge_execution.run_step('bash', 'cleanup', 'scripts/cleanup.sh') return ChallengeResult(build_result, run_result, validate_result)
def run_challenge(challenge_execution: ChallengeExecution) -> Union[ChallengeResult, ChallengeError]: print(f"Running challenge {challenge_execution.challenge_name} from repository {challenge_execution.repository}", flush=True) build_result = challenge_execution.run_step('build', 'scripts/build.sh') if build_result.code != 0: return ChallengeError('Error in building the image', build_result) run_result = challenge_execution.run_step('run', 'scripts/run_in_file_program.sh') if run_result.code != 0: return ChallengeError('Error in running the code', run_result) validate_result = challenge_execution.run_step('validate', 'scripts/validate.sh', timeout=10) challenge_execution.run_step('cleanup', 'scripts/cleanup.sh') if validate_result.code != 0: return ChallengeError('Error in validating the result', validate_result) return ChallengeResult(build_result, run_result, validate_result)