Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An experimental generic runner #3

Open
wants to merge 23 commits into
base: xianti2
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More improvements
rth committed Sep 20, 2022
commit fe10b7fcd682b2344b8fe5796512ff0a1661d732
8 changes: 7 additions & 1 deletion ramp-engine/ramp_engine/base.py
Original file line number Diff line number Diff line change
@@ -193,7 +193,13 @@ def _get_traceback(content):
if cut_exception_text > 0:
content = content[cut_exception_text:]
else:
content = content[-10000:]
content = content[-3000:]
# strip paths
content = re.sub("/[^\s]+/", '', content)
if content:
# Take only the last 2 lines
content = "\n".join(content.splitlines()[-3:])
# If data is suspiciosly long truncate it
if len(content) > 150:
content = content[-150:]
return content
16 changes: 9 additions & 7 deletions ramp-engine/ramp_engine/cpp_runner.py
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@ def get_conda_cmd(cmd: list[str], options: list[str] = None, memory="10m") -> li
"run",
"-i",
"--rm",
"--network",
"none",
"-v",
"/home/ubuntu/miniforge3/:/home/ubuntu/miniforge3/:ro",
"-v",
@@ -126,8 +128,8 @@ def is_cpp_submission(self) -> bool:

submission_dir = Path(self.config["submissions_dir"]) / self.submission

if (submission_dir / "solution.cpp").exists() and (len(
(submission_dir / "solution.cpp").read_text().strip()) > 10
if (submission_dir / "main.cpp").exists() and (
len((submission_dir / "main.cpp").read_text().strip()) > 10
):
return True
else:
@@ -164,16 +166,16 @@ def launch_submission(self):
is_cpp = self.is_cpp_submission()
if is_cpp:
bin_path = os.path.join(submission_dir, "main")
Path(submission_dir, "solution.py").unlink(missing_ok=True)

try:
subprocess.check_call(
[
"gcc",
os.path.join(submission_dir, "solution.cpp"),
os.path.join(submission_dir, "main.cpp"),
f"-I{INCLUDE_DIR / 'CPP'}",
"-lstdc++",
"-O3",
"-w",
"-o",
bin_path,
],
@@ -192,7 +194,6 @@ def launch_submission(self):
)
self._log_file.truncate(0)
else:
Path(submission_dir, "solution.cpp").unlink(missing_ok=True)
bin_path = os.path.join(submission_dir, "solution.py")
shutil.copy(INCLUDE_DIR / "python/data.py", submission_dir)

@@ -260,8 +261,9 @@ def launch_submission(self):
self._return_code = 124
return

if self._return_code > 0:
return

if self._return_code > 0:
return

# Running the model passed, clean up the log
shutil.copy(
2 changes: 1 addition & 1 deletion ramp-frontend/ramp_frontend/templates/sandbox.html
Original file line number Diff line number Diff line change
@@ -207,7 +207,7 @@ <h4 class="modal-title" id="myModalLabel">{{ category }}</h4>
<div class="row">
<div class="col-sm-12 text-center">
Note that once you make a submission, all participants of your team will be locked to the current team. <br />
By default, the C++ solution is run. To run the Python solution, `submission.cpp` should be an empty file.
By default, the C++ solution (main.cpp) is run. To run the Python solution.py, change `main.cpp` to be an empty file.
</div>
<div class="col-sm-6 text-center">
<input type="submit" value="Save for later" class="ui submit button btn btn-default" , name="saving">