Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Running Ladon

Astha Patni edited this page Oct 2, 2017 · 1 revision

Running Ladon

Once you have written an Automation, the logical next step is to execute that Automation.

The ladon-run executable

Ladon comes packaged with a simple automation runner, fittingly named ladon-run.

When you install the ladon gem, the gem installer will automatically add the ladon-run command to your PATH. This command simply runs the script in this repository at bin/ladon-run.

Usage

If you've already installed ladon, go ahead and try it now: ladon-run -h. This should print out the usage details of the ladon-run utility:

ssnow-mbp15:ladon ssnow$ ladon-run -h
Usage: ladon-run [options]
    -a, --automation PATH            [REQUIRED] Path to the target automation script to be executed
    -s, --automation_class NAME      Name of the target Automation class to run.
    -i, --interactive PHASE_LIST     Comma-separated list of phase names to enter interactive mode BEFORE running
    -f, --flags FLAGS                Flags to give the target automation. Comma-separated list of name:value pairs; may be repeated.
    -r, --review                     Use Pry to review after target automation completes
    -p, --result_file_path PATH      File to store the formatted Result data of the ladon-run Automation
        --formatter FMT              Formatting method to call on the Result of ladon-run for output (ex: to_s)
    -h, --help                       Prints this help message

Specifying Automations

As you can see, the -a option is required, as it tells ladon-run where your Automation script is located.

Note: if the script at the path given to -a results in multiple non-abstract Automation subclasses being loaded - for example, if your script defines multiple Automations - ladon-run can't know which Automation you actually want to run. In these circumstances, ladon-run will prompt you to select the correct one. You can also bypass this interactive prompt by specifying the correct Automation class using the -s option.

Configuring the Automation

Automations are designed to take in flags; flags must be implemented with a reasonable default value, so you're never required to pass in any flags. If you want to override the default values, you must can the -f option!. This option must be proceeded by a comma-separated list of name:value pairs. If you are only specifying a single flag, you do not need a comma.

Interactive Mode

The ladon-run executable is not merely a tool for running a script and waiting for it to complete -- after all, there's more to working with and reasoning about software than that! This utility sports an interactive mode, meaning that it is capable of dropping you into an interactive debugging session at various points during the execution of the Automation.

During interactive mode, you have access to the Automation that ladon-run is harnessing, as well as any component of that Automation, including its configuration, current result data, underlying model (in the case of ModelAutomations), etc. This is pretty nifty.

This is what the -r and -i options are designed to facilitate!

The -r option will drop you into interactive mode after all phases of the Automation have completed. This is primarily useful for interrogating Ladon's intermediate representation of the Automation result.

The -i option is similar; if specified, it requires a comma-separated list of Automation phase names. This option is for dropping you into interactive mode before the specified phases are processed. For example, if you want to pause execution before a phases called config and cleanup, you would use -i cleanup,config. Note: if you specify an invalid phase name, it will be ignored.

Interactive Mode Notes
  • When you are inserted into an interactive session, you will remain in that session until you enter the exit command.
    • Upon doing so, ladon-run will automatically resume automatic execution. Nifty.
  • Enter the target_automation command to access the Automation that ladon-run is harnessing.
    • You can call methods on the target_automation as you would normally (for example, try target_automation.result!)
  • The interactive mode is facilitated via pry, which is the reason for ladon requiring it as a dependency
    • Want to go interactive directly in your automation or model? Use a binding.pry statement and ladon-run will automatically enter interactive mode
    • Install the pry-byebug gem to get byebug-style debugging features automatically in your interactive sessions!
    • Install the pry-stack_explorer gem to get nifty call stack exploration tools automatically in your interactive sessions!

Next: Contributing to Ladon