import click from auto_grader.types import StudentVarType @click.command(help='Builds and Runs full student root. The run command is served as \n\n' + '[COMMAND] [PROCOPT] [NUMPROC] [EXECUTABLE-PREFIX]\n\n' + 'Example with defaults:\n\n' + 'mpirun -n 4 exe ') @click.argument('number', required=True, type=click.INT) @click.option('-p', '--path', default='./roots', type=click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True), help='Path to directory conaining student roots in format (student)/assignment_[NUMBER]/root_(...).') @click.option('--solution-path', default='./solutions', type=click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True), help='Path to directory conaining solution root in format assignment_[NUMBER]/. Solution must contain configuration test_config.toml defining ') @click.option('-s', '--student', default='', type=StudentVarType(), help='Specify wich student to run the test for. If omitted test is run for all found students.') @click.option('-c', '--command', default='mpirun', type=click.STRING, help='Overrides command that is used to run roots. The default command is `mpirun`.') @click.option('--procopt', default='-n ', type=click.STRING, help='Indicates the option flag to be used to specify process number from [COMMAND]. The default value is `-n `.') @click.option('-n', '--numproc', default=4, type=click.INT, help='Selects the number of mpi processes used to run the root. The default value is `4`.') @click.option('--executable-prefix', default='', type=click.STRING, help='This prefix is appended to the executable name when the run command is launched (some launchers require `./`. The default value is ``.') @click.option('--compile-command', default='make', type=click.STRING, help='Overrides command that is run to build roots. The default command is `make`.') @click.option('--clean-command', default='make distclean', type=click.STRING, help='Overrides command that is run to build roots. The default command is `make distclean`.') @click.option('-t', '--timeout', default=10, type=click.INT, help='Sets timeout of both clean and build commands, defaults to 10s.') @click.option('-e', '--exe-name', default='', type=click.STRING, help='Specify an executable name instead of determining it at runtime.') @click.pass_context def run( context, number, path, solution_path, student, command, procopt, numproc, executable_prefix, timeout, compile_command, clean_command, exe_name ): print("NOT IMPLEMENTED") pass # current_wd = os.getcwd() # students = os.listdir(path) # if student and student not in students: # click.echo( # f"{ERROR_BOX}: No student {student} in {os.path.relpath(path)}.") # return # if student: # students = [student] # asg_dirs = [os.path.join( # path, student, f"assignment_{number}") for student in students] # # for asg_dir, student in zip(asg_dirs, students): # # if not os.path.exists(asg_dir) or not os.path.isdir(asg_dir): # click.echo( # f"{WARNING_BOX}: No {student}/assignment_{number} was found, skipping...") # continue # # local_roots = [os.path.join(asg_dir, dir) # for dir in os.listdir(asg_dir) if 'root_' in dir and os.path.isdir(os.path.join(asg_dir, dir))] # if len(local_roots) == 0: # click.echo( # f"{WARNING_BOX}: No roots could be identified for {student}/assignment_{number}") # continue # click.echo(f"[{student}]:") # # for root in local_roots: # os.chdir(root) # # clean_log = clean_root(root, clean_command) # if not clean_log.run_success or not clean_log.cmd_return_code == 0: # click.echo( # f"{indent_text('[CLEAN]:' + clean_log.oneline(type_as_prefix=False), 4)}") # continue # # executables = [file for file in os.listdir( # root) if os.path.isfile(file) and file.startswith('exe-')] # for executable in executables: # os.remove(executable) # # build_log = build_root(root, compile_command, timeout=timeout) # if not build_log.run_success or not build_log.cmd_return_code == 0: # click.echo(f"{indent_text(build_log.oneline(), 4)}") # continue # executables = [file for file in os.listdir( # root) if os.path.isfile(file) and file.startswith('exe-')] # # if len(executables) == 0: # warn_string = f"[{os.path.basename(root)}]:{color_string('WARNING', 'br-yellow')} Build successfull but no exe-* was found, maybe non standard name? Skipping ..." # click.echo(f"{indent_text(warn_string, 4)}") # continue # # clean_log = clean_root(root, clean_command) # if not clean_log.run_success or not clean_log.cmd_return_code == 0: # click.echo( # f"{indent_text('[CLEAN]:' + clean_log.oneline(type_as_prefix=False), 4)}") # continue # os.chdir(current_wd)