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

Terminate a test based on memory use? #489

Open
cycomachead opened this issue Feb 13, 2024 · 0 comments
Open

Terminate a test based on memory use? #489

cycomachead opened this issue Feb 13, 2024 · 0 comments

Comments

@cycomachead
Copy link
Contributor

cycomachead commented Feb 13, 2024

I may be missing an option, but would there be a way to limit memory use per-test / question?

In a Gradescope AG, the following code results in the whole ok process (and thus any output parsing working) at a ~6-7s timeout on smallish machine with 768mb of ram. We can use --timeout 5 to get this down so the whole thing isn't killed, but I wonder if we could specify a per-question memory limit (which could conceivably be freed after each test case or question?)

def arange(start, end, step=1):
    """
    arange behaves just like np.arange(start, end, step).
    You only need to support positive values for step.

    >>> arange(1, 3)
    [1, 2]
    >>> arange(0, 25, 2)
    [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]
    >>> arange(999, 1231, 34)
    [999, 1033, 1067, 1101, 1135, 1169, 1203]
    """
    "*** YOUR CODE HERE ***"
    full_list = []
    new_number = start
    while new_number < end:
        full_list.append(new_number)
        new_number += start ## This is the bug. should be step which fails in  2nd dockets
    return full_list 

This might be possible...
https://docs.python.org/3.12/library/resource.html#resource.setrlimit
https://www.geeksforgeeks.org/python-how-to-put-limits-on-memory-and-cpu-usage/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant