Writing Workflows
Writing Workflows
Section titled “Writing Workflows”Workflows in Brane are written in BraneScript, a domain-specific language designed to be accessible. If you’ve used Python or JavaScript, BraneScript will feel familiar.
Prerequisites
Section titled “Prerequisites”- The Brane CLI installed
- Access to a running Brane instance (ask your administrator)
- Packages published to the instance (ask your developers)
Getting Connected
Section titled “Getting Connected”brane login http://<INSTANCE_ADDRESS> --username <YOUR_NAME>brane package search # See available packagesBraneScript Basics
Section titled “BraneScript Basics”Importing and Calling Functions
Section titled “Importing and Calling Functions”import hello_world;let result := hello_world();println(result);Variables
Section titled “Variables”let name := "Alice";let count := 42;let ratio := 3.14;let active := true;let items := [1, 2, 3];Reassignment: x := x + 1;
Data Types
Section titled “Data Types”| Type | Example | Description |
|---|---|---|
String | "hello" | Text |
Integer | 42 | Whole numbers |
Real | 3.14 | Floating-point |
Boolean | true | True or false |
Array[T] | [1, 2, 3] | Ordered collection |
Data | new Data { name := "x" } | Dataset reference |
Control Flow
Section titled “Control Flow”// If/elseif count > 10 { println("Many items");} else { println("Few items");}
// While looplet i := 0;while i < 5 { println(i); i := i + 1;}
// For loopfor item in items { println(item);}Working with Data
Section titled “Working with Data”Reference datasets on worker nodes:
let patient_data := new Data { name := "patient_records" };let summary := analyze(patient_data);println(summary);Brane runs analyze on the node where patient_records lives — data never moves.
Running Workflows
Section titled “Running Workflows”Interactive REPL
Section titled “Interactive REPL”brane workflow repl --remote http://<INSTANCE>:50053From a File
Section titled “From a File”Save your workflow to a .bs file and run it:
brane workflow run --remote http://<INSTANCE>:50053 workflow.bsLocal Mode (testing)
Section titled “Local Mode (testing)”brane workflow replOperators
Section titled “Operators”| Category | Operators |
|---|---|
| Arithmetic | +, -, *, /, % |
| Comparison | ==, !=, <, >, <=, >= |
| Logical | &&, ||, ! |
Built-in Functions
Section titled “Built-in Functions”| Function | Description |
|---|---|
println(value) | Print a value to output |
len(array) | Get array length |
commit_result(name, value) | Store a named result |
to_string(value) | Convert to string |
to_int(value) | Convert to integer |
to_real(value) | Convert to float |
Next Steps
Section titled “Next Steps”- CLI Reference for all workflow commands
- Your First Package to build your own functions