LoamStream supports embedding Python and R scripts in .loam files. For example:
python"""print("hello world!")"""or with some Stores as inputs and outputs:
val input = store.at("foo.txt")val output = store.at("bar.txt")python"""with open("${input}") as in: lines = in.readlines()with open("${output}", "a") as out: for line in lines: out.write(line)""".in(input).out(output)In both cases, the code inside the python"""...""" string is written to a .py file and run with the Python interpreter. (The Python interpreter to use and the location of the generated .py files are configurable; see the loamstream.python section in Configuration.) The result of a python"""...""" declaration is that a command-line job that will invoke the Python interpreter on the generated .py file is registered with LS. (Note that Python is *not* run at that point!)
Inputs and outputs are taken into account; for example, in the second case, LS records that the Python job depends on the store input, and will write output to the store output. Stores are also interpolated to produce the .py file to run. For example, in the second case, what will actually be run is
with open("./foo.txt") as in: lines = in.readlines()with open("./bar.txt", "a") as out: for line in lines: out.write(line)It's also possible to embed analagous R code, for example:
r"""print("hello world")"""