Implementation: Atomic
Atomic components are implemented by writing a script or program in the language defined by the <launcher>
element of component.xml
. When the component is executed, it receives a properties file called a command file as an argument that contains values and paths for input files, parameters and output files, as well as various metadata. This properties file is parsed by a language-specific Anduril library, and the values are exposed to the component code.
Provided language-specific libraries and links to their documentation are:
Language | Source code folder |
---|---|
Bash | lang/bash |
Java | core/src/main/java/org/anduril/component |
Lua | lang/lua |
Matlab | lang/matlab |
Octave | lang/octave |
Perl | lang/perl |
Python | lang/python |
R | lang/r |
Scala | core/src/main/scala/org/anduril/runtime |
Example: R component
To implement the SimpleCSVFilter component whose interface we defined, we write the following R script (~/my-bundles/demo/components/SimpleCSVFilter/SimpleCSVFilter.r
):
library(componentSkeleton)
execute <- function(cf) {
input <- CSV.read(get.input(cf, 'in'))
include <- get.parameter(cf, 'include', 'boolean')
if (input.defined(cf, 'columnNames')) {
column.names <- CSV.read(get.input(cf, 'columnNames'))[,1]
if (include) {
output <- input[, column.names, drop = FALSE]
} else {
output <- input[, !(colnames(input) %in% column.names), drop = FALSE]
}
} else {
output <- input
}
CSV.write(get.output(cf, 'out'), output)
return(0)
}
main(execute)
Here we used the componentSkeleton
R library that is provided by Anduril (lang/r
). It parses the properties files in main
into an object called cf
and provides read/write functions for the CSV format defined in the tools bundle.