use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ExecuteRequestHandler method handleMsg.
private void handleMsg(Message message) {
kernel.sendBusyMessage(message);
executionCount += 1;
String codeString = takeCodeFrom(message);
announceTheCode(message, codeString);
Code code = CodeFactory.create(codeString, message, kernel);
code.execute(kernel, executionCount);
finishExecution(message);
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ClasspathAddMagicCommandTest method errorWhenUnknownMagicCommand.
@Test
public void errorWhenUnknownMagicCommand() {
// given
String allCode = "%unknownClasspath params";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains("Inline magic " + allCode + " not found");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class TimeItCellModeMagicCommandTest method timeitInCellMode.
@Test
public void timeitInCellMode() {
// given
String allCode = "%%timeit -r3 -n10\n" + "a = 15;\n" + "b = 111;\n" + "a * b;";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains("loop");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class TimeLineModeMagicCommandTest method timeLineMode.
@Test
public void timeLineMode() {
// given
String allCode = "%time 2*128";
Code code = CodeFactory.create(allCode, new Message(), kernel);
// when
code.getCodeFrames().get(code.getCodeFrames().size() - 1).executeLastFrame(code, this.kernel, new Message(), 1);
code.execute(kernel, 1);
// then
List<Message> std = EvaluatorResultTestWatcher.getStdouts(kernel.getPublishedMessages());
String text = (String) std.get(0).getContent().get("text");
assertThat(text).contains("CPU times");
}
use of com.twosigma.beakerx.kernel.Code in project beakerx by twosigma.
the class ClasspathAddMvnDepsMagicCommandTest method unresolvedDependency.
@Test
public void unresolvedDependency() {
// given
String allCode = CLASSPATH_ADD_MVN + " com.google.code.XXXX gson 2.6.2";
MagicCommand command = new MagicCommand(new ClasspathAddMvnMagicCommand(kernel.mavenResolverParam, kernel), allCode);
Code code = Code.createCode(allCode, singletonList(command), NO_ERRORS, new Message());
// when
code.execute(kernel, 1);
// then
List<Message> stderr = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) stderr.get(0).getContent().get("text");
assertThat(text).contains("Could not resolve dependencies for:");
assertThat(text).contains("com.google.code.XXXX : gson : 2.6.2");
}
Aggregations