• Stars
    star
    231
  • Rank 173,434 (Top 4 %)
  • Language
    Erlang
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cuneiform distributed programming language

Cuneiform: Data analysis open and general

hex.pm Build Status

Cuneiform is a large-scale data analysis functional programming language. It is open because it easily integrates foreign tools and libraries, e.g., Python libraries or command line tools. It is general because it has the expressive power of a functional programming language while using the independence of sub-expressions to automatically parallelize programs. Cuneiform uses distributed Erlang to scalably run in cluster and cloud environments.

cuneiform-lang.org

Usage

Compiling

Having rebar3 available on your system, compile the project by entering

rebar3 escriptize

Displaying Cuneiform Help

Compiling the Cuneiform client using rebar3 escriptize creates an Erlang script file _build/default/bin/cfl which allows starting Cuneiform via the command line.

To display a help text enter

_build/default/bin/cfl --help

This will show the command line synopsis, which looks like the following:

Usage: cfl [-v] [-h] [-n <n_wrk>] [-w <wrk_dir>] [-r <repo_dir>]
           [-d <data_dir>]

  -v, --version   Show cf_worker version.
  -h, --help      Show command line options.
  -n, --n_wrk     Number of worker processes to start. 0 means auto-detect 
                  available processors.
  -w, --wrk_dir   Working directory in which workers store temporary files.
  -r, --repo_dir  Repository directory for intermediate and output data.
  -d, --data_dir  Data directory where input data is located.

This script is self-contained and can be moved around to, e.g., ~/bin/cfl. From here on we assume that the cfl script is accessible in your system path and that we can start it by just entering cfl instead of _build/default/bin/cfl.

Starting an Interactive Shell

You can start a shell and program Cuneiform interactively by starting it without any command line parameters like so:

cfl

This will open a shell giving the following initial output, along with a number of status messages:

           @@WB      Cuneiform
          @@E_____
     _g@@@@@WWWWWWL  Type help for usage info
   g@@#*`3@B              quit to exit shell
  @@P    3@B
  @N____ 3@B         http://www.cuneiform-lang.org
  "W@@@WF3@B         Jorgen Brandt

1>

Note that starting Cuneiform like that will create a local instance of a Cuneiform that entails the scheduler service, a client service, and as many worker services as CPUs were detected on the host machine. To set up a distributed Cuneiform system, these services need to be started separately on multiple hosts as needed.

Running a Cuneiform Script

Alternatively, Cuneiform can be started by giving it a source file which will only output the final result of the computation. If your Cuneiform script is stored in my_script.cfl start it by entering

cfl my_script.cfl

Examples

A collection of self-contained Cuneiform examples is available under joergen7/cuneiform-examples.

Variable assignment

You can assign a value to a variable and retrieve a variable's content like so:

let x : Str =
  "foo";

x;

In the first line we assign the value "foo" to a variable named x declaring its type to be Str. In the last line we query the variable x.

Booleans and Conditions

We can branch execution based on conditions using conditional statements. Conditionals are expressions.

let x : Str =
  if true
  then
    "bla"
  else
    "blub"
  end;

x;

The above command the conditional binding the string "bla" to the variable x. Then, we query the variable.

Lists

We can construct list literals by enumerating their elements in square brackets and declaring the type of the list elements.

let xs : [Bool] =
  [true, false, true, true : Bool];

xs;

Here, we define the list xs whose elements are of type Bool giving four Boolean values of which only the second is false.

Records and Pattern Matching

A record is a collection of fields that can be accessed via their labels. Literal records can be constructed like so:

let r : <a : Str, b : Bool> =
  <a = "blub", b = false>;

( r|a );

We define a record r with two fields a and b, of types Str and Bool respectively. The field associated with a gets the value "blub" while the field associated with b gets the value false. In the last line we access the a field of the record r.

Alternatively, we can access record fields via pattern matching:

let <a = z : Str> = r;
z;

In the first line we associate the variable z with the field a of record r. In the second line we query the content of z.

Native Function Definition

Defining native functions in Cuneiform is done by giving the function name, its signature, and a body expression in curly braces:

def identity( x : Str ) -> Str {
  x
}

identity( x = "bar" );

In the first line we define the function identity which consumes an argument x of type Str and produces a return value of type Str. In the second line, the body expression is just the argument x. In the last line we call the function binding the argument x to the value "bar".

Foreign Function Definition

Defining foreign functions is done by giving the function name, its signature, the foreign language name, and the function body in mickey-mouse-eared curly braces.

def greet( person : Str ) -> <out : Str> in Bash *{
  out="Hello $person"
}*

greet( person = "Peter" );

The first line defines a foreign function greet taking one argument person of type Str and returning a tuple with a single field out of type Str. The foreign function body is given in Bash code. In the last line we call the foreign function, binding the argument person to the string value "Peter".

Iterating over Lists using For

To perform an operation on each element of a list, one can iterate using for:

let xs : [Bool] =
  [true, false, true, true : Bool];

for x : Bool <- xs do
  not x
  : Bool
end;

Here, we define a list of four Booleans and negate each element.

Aggregating Lists using Fold

We can aggregate over lists using fold:

def add( a : Str, b : Str ) -> <c : Str> in Python *{
  c = int( a )+int( b )
}*

let xs : [Str] = [1, 2, 3 : Str];

let sum : Str =
  fold acc : Str = 0, x : Str <- xs do
    ( add( a = acc, b = x )|c )
  end;

sum;

Here, we first define the function add which lets us add two numbers in Python and then the string list xs containing the numbers from one to three. We aggregate the sum of the numbers in xs and store it the result in the variable sum. Lastly, we query the sum variable.

System Requirements

Resources

License

Apache 2.0

More Repositories

1

gen_pnet

library for modeling Petri nets in Erlang
Erlang
62
star
2

effi

Erlang foreign function interface.
Erlang
24
star
3

gruff

A basic worker pool manager for Erlang to showcase gen_pnet.
Erlang
22
star
4

cre

common runtime environment for distributed programming languages
Erlang
20
star
5

gpull

A git repository management tool
Erlang
7
star
6

lib_combin

Basic combinatorics for Erlang lists.
Erlang
6
star
7

cf_reference

Semantic reference of the Cuneiform distributed programming language
Racket
6
star
8

lib_dp

Dynamic Programming in Erlang.
Erlang
5
star
9

cf_client

Cuneiform client implementation
Erlang
5
star
10

cuneiform-legacy

A Functional Workflow Language
Java
4
star
11

variant-call

A variant calling workflow
Ruby
4
star
12

gen_ircclient

A scaffold for Erlang IRC bots.
Erlang
4
star
13

trif

dynamically typed functional programming language with a Lisp syntax
Assembly
3
star
14

chef-bioinf-worker

Chef cookbook to set up worker node for various bioinformatics workflows
Ruby
3
star
15

cf_worker

Cuneiform worker implementation
Erlang
3
star
16

chef-cuneiform

Chef cookbook to setup vanilla Cuneiform
Ruby
3
star
17

bismark

A bisulfite read mapper and methylation caller
Perl
3
star
18

gen_workflow

A behavior for specifying data analysis applications in Erlang.
Erlang
3
star
19

lang-util

Basic utilities for language models in Common Lisp
Common Lisp
3
star
20

cfplot

Cuneiform log visualization tool
Racket
3
star
21

gen_pnet_examples

A collection of small, instructive examples using gen_pnet.
Erlang
3
star
22

lib_conf

Simple Erlang configuration handling library.
Erlang
3
star
23

cf_lang

Standalone Cuneiform interpreter
Erlang
2
star
24

cuneiform-doc

Documentation for the Cuneiform programming language
Python
2
star
25

methylation

A methylation workflow
Ruby
2
star
26

se

S-expression parser
C++
2
star
27

cf-java

Java bindings for Cuneiform
Java
2
star
28

render-farm

render farm using POV-Ray
POV-Ray SDL
2
star
29

pnet

Petri net library based on Racket threads.
Racket
2
star
30

k-means

k-means implementation, recursive, allows partitioned input data
Racket
2
star
31

cuneiform-sublime

Syntax highlighting for Cuneiform in Sublime Text 3
2
star
32

cfui

Cuneiform Workflow Management Portal
Python
2
star
33

cuneiform-examples

Collection of small, self-contained Cuneiform code examples.
2
star
34

variant-call-gatk

Germline variant calling workflow using GATK
HTML
1
star
35

plang

Racket #lang for places and parallel computing
Racket
1
star
36

cuneiform-atom

Syntax highlighting for Cuneiform in Atom
1
star
37

rna-seq

Cuneiform RNA-seq workflow
Ruby
1
star
38

metagenomics

A metagenomics workflow
Ruby
1
star
39

cuneiform_irc

A Cuneiform IRC chatterbot.
Erlang
1
star
40

phylogeny

Phylogenetic analysis of the CHASE domain in early diverging plants
Ruby
1
star
41

devilfish-flotilla

Dangerous Waters documentation site
Python
1
star
42

mqtt-client

Racket MQTT client implementation based on paho.mqtt.c
Racket
1
star
43

distributed-k-means

k-means workflow example in Cuneiform
Ruby
1
star
44

chef-misc

Miscellaneous Chef cookbooks
Ruby
1
star
45

wordcount

Canonical word count workflow
Ruby
1
star
46

chef-rebar3

rebar3 chef cookbook
Ruby
1
star
47

consensus-prediction

A consensus prediction workflow for MS data
HTML
1
star
48

gccount

Counting the GC content in a given FastA file
Ruby
1
star
49

fractal

Playground for Racket graphics
Racket
1
star
50

chip-seq

A ChIP-Seq workflow
Ruby
1
star
51

gruff_example

An example application using gruff.
Erlang
1
star
52

variant_call_rna

Variant calling on RNA-Seq data
Ruby
1
star
53

cf-model

Model implementation of Cuneiform in Erlang
Erlang
1
star
54

mirna-discovery

miRNA discovery workflow
Ruby
1
star
55

clcc

C++ language model and compiler in Common Lisp
Common Lisp
1
star
56

brief

script to create briefing documents and kneeboard pages
Awk
1
star
57

libpaho-mqtt3-x86_64-linux-natipkg

Packages libpaho-mqtt3 for the Racket package build server
Racket
1
star
58

soap

Racket SOAP
Racket
1
star