simple Graph or SQL type gives "Sandbox Down" error

simple Graph or SQL type gives "Sandbox Down" error

por Jan Derriks -
Número de respuestas: 2


Using the default test jobe server or our own jobe server works fine with python or Java questions. But Graph and SQL results in:

Unexpected error while executing your code. The sandbox server may be down or overloaded. Perhaps try again shortly?

Changing the type to python3 and the editor to Graph the validation fails with error:



***Error***
Traceback (most recent call last):
  File "__tester__.python3", line 1, in <module>
    {"edgeGeometry":[],"nodeGeometry":[[101,100]],"nodes":[["A",false]],"edges":[]}
NameError: name 'false' is not defined

Where is the false coming from and how to debug the "sandbox down" errors?


En respuesta a Jan Derriks

Re: simple Graph or SQL type gives "Sandbox Down" error

por Richard Lobb -

The NameError ('false' is not defined) isn't really an error. The GraphUI generates a JSON serialisation of the graph as the "STUDENT_ANSWER" variable. The standard python3 question type attempts to execute the STUDENT_ANSWER as Python code, which it isn't, giving that error. [In Python the boolean literal for "not true" is False, with an uppercase 'f', whereas in JSON it is false, which is why you're getting that particular error.]

I have no immediate explanation of the sandbox errors. If Python is working correctly, then the built-in Graph question types, which are also in Python, should work fine too. SQL not working either is also a mystery; I can't think of any explanation that explains both those problems, so I'd be inclined to put the SQL problem to one side and focus on Python for now.

I think the first thing to do is to edit your failing graph question and click on the Customise and Template debugging checkboxes. Save the question with Validate-on-save unchecked, then preview the question. Look at the generated Python source code to see if there's anything odd in it - perhaps try running it outside of CodeRunner, too. If that doesn't solve the problem, please show me the text in the "Debug: source code from all test runs" section of the output.

Richard

En respuesta a Richard Lobb

Re: simple Graph or SQL type gives "Sandbox Down" error

por Jan Derriks -

Hi Richard,

thanks for the advice.

Using debug and custumize flags shows the following code where I used a simple print as a testcase and the answer was one node named 'F':

Debug: source code from all test runs

Run 1

import json

student_answer = """{\"edgeGeometry\":[],\"nodeGeometry\":[[134,81]],\"nodes\":[[\"F\",false]],\"edges\":[]}"""
SEPARATOR = "#<ab@17943918#@>#"

error_count = 0
def error(s):
    global error_count
    print(s)
    error_count += 1

try:
    graph_rep = json.loads(student_answer)
    node_id_to_name_map = {}
    for i, node in enumerate(graph_rep['nodes']):
        node_id_to_name_map[i] = node[0] if node[0] != '' else ('#' + str(i))
    #print("Nodes:", nodes)   BTW: DON'T uncomment this - it is an error in the default template code
    edges = graph_rep['edges']
    #print("Edges:", edges)
    graph = {}
    for node_id, node_name in sorted(node_id_to_name_map.items()):
        edges = []
        for id0, id1, edge_label in graph_rep['edges']:
            if id0 == node_id:
                edges.append((node_id_to_name_map[id1], edge_label))
            elif id1 == node_id:
                edges.append((node_id_to_name_map[id0], edge_label))
        edges.sort()
        graph[node_name] = edges

except json.JSONDecodeError as e:
    raise Exception("Oops. Illegal graph received (exception {}). Please report (unless you did something silly yourself)".format(e))


print('foobar')

 
When I copy+paste this in PyCharm it runs fine and prints "foobar", what I entered in the 'expected output' field.
But all I get is:
An unexpected error occurred. The sandbox may be down. Try again shortly.


The preview tech info is:


And the question is just to create one node named F.

Is there a step-by-step example of how to create such a simple graph question with all the right settings?

Regards,
Jan