twosigma / beakerx_kernel_groovy Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I am trying to run this code on groovy kernel and its give a strange error.
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
zipInputFile = new ZipFile(file)
list = entires.toList();
zipInputFile.getInputStream(list.get(0))
This is the exception it is giving. while running the same code works with normal execution of groovy script.
groovy.lang.MissingPropertyException: No such property: file for class: script1622875172283
at this cell line 3
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.runScript(GroovyCodeRunner.java:94)
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:59)
at com.twosigma.beakerx.groovy.evaluator.GroovyCodeRunner.call(GroovyCodeRunner.java:32)
Later I found this is happening because this kernel don't share local variables across the cells. But it still share local variable declared at last line.
So if I write,
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
String file = "C:\\Users\\user\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.bcel\\bcel\\6.5.0\\79b1975ec0c7a6c1a15e19fb3a58cc4041b4aaea\\bcel-6.5.0.jar"
zipInputFile = new ZipFile(file);
in a separate cell 'zipInputFile' will be scoped to next cell.
But when I declare variable mentioning its type. (both ways are valid in groovy)
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
String file = "C:\\Users\\user\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.bcel\\bcel\\6.5.0\\79b1975ec0c7a6c1a15e19fb3a58cc4041b4aaea\\bcel-6.5.0.jar"
ZipFile zipInputFile = new ZipFile(file);
The zipInputFile will not get scoped to the next cell. Why is this inconsistency ?
try the code on Groovy:
import java.util.function.Supplier
import java.util.stream.Stream
TableDisplay.setLoadingMode(TableDisplayLoadingMode.ENDLESS)
def generate = Stream.generate(new Supplier<Map<String, Object>>() {
def random = new Random()
def index = 0
@Override
Map<String, Object> get() {
return [
str1: index++,
str2: random.nextDouble(),
str3: random.nextFloat()
]
}
})
new TableDisplay(generate)
It will create table with limited count of rows
Expected result is endless table
We have an implementation of a kernel based on this one that incorporates the Micronaut framework (https://github.com/stainlessai/micronaut-jupyter). When we switch kernels from Groovy, however, the working directory changes and I can't figure out why.
Using this kernel from any path in the jupyter context, e.g., $HOME/my/working/dir, the code:
println new File(".").absolutePath
returns
$HOME/my/working/dir
How does this path get passed to the Groovy script code for running the cell?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.