Languages Example

Overview

This example shows how Guild works with various runtime languages.

Project files:

guild.yml Project Guild file
train.r R example
train.sh Bash example
train-2.sh Alternative Bash example using environment variables
Train.java Java example
train.jl Julia example

Flag Interfaces

Guild uses two general interfaces to pass flag values to programs:

  • Command line arguments
  • Environment variables

The examples in this project show the use of both. Refer to the sections below for details.

When using a command line interface, flag values may be referenced in arguments using ${FLAG_NAME}.

To include all flag arguments, use ${flag_args}. In this case, each flag is included as two arguments in the format --FLAG_ARG_NAME FLAG_VALUE.

Source Code

Operations are run in the context of a run directory, not the project directory. Required files must be copied or linked into the run directory using one of two methods:

  • Source code copy, which Guild performs automatically
  • File dependency

In the case of scripts, examples reference copied source code using the pattern .guild/sourcecode/<script>.

R Example

R port of the sample function used in Get Started with Guild AI

Run this example:

guild run r

Press Enter to run the sample training operation using the default values.

Bash Examples

There are two examples that use Bash scripts:

bash Uses command line arguments to pass flag values
bash-2 Uses environment variables to pass flag values

Both examples print flag values and exit without doing any work. They serve as patterns for scripts in any language.

Bash with Command Line args

Run this example:

guild run bash

Base with Environment Variables

Run this example:

$ guild run bash-2

Java Example

The Java examples uses a Bash command to compile Java source code and then run the compiled code.

Run this example:

guild run java

Julia Example

The Julia example requires the ArgParse modules. If it’s not installed, you can install it from the Julia command line by running:

julia> import Pkg
julia> Pkg.add("ArgParse")

Julia port of the sample function used in Get Started with Guild AI

To run the Julia example:

guild run julia