Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a directory for your project 

    Code Block
    languagebash
    $ mkdir workflowmyproject
    $ cd workflowmyproject/


  2. Initialize the project directory as a Git repository

    Code Block
    languagebash
    $ git init


  3. Create a KRL ruleset as a file in the repository using your favorite editor. There may be a KRL plugin for your editor

...

  1. Follow the directions in Setting Up a Git Pre-Commit Hook to Parse KRL to set up the KRL parser and ensure that KRL files are parsed before they are committed. 

  2. Add the file to the repository and commit it. 

    Code Block
    languagebash
    $ git add hello_world.krl
    $ git commit -a -m "initial commit"
    All Flushing com.windley.hello_worldrulessets parse
    [master (root-commit) 4a2f95c] initial commit
     1 file changed, 34 insertions(+)
     create mode 100644 hello_world.krl

    With the pre-commit hook in place, you're assured that there are no parse errors in your ruleset if it commits.

Register

Registering a ruleset associates its ruleset ID (RID) with a URL where it is located.

...

  1. .

...

Register the ruleset with the pico engine. There are automated ways to do this, but for initial development, you can do in manually. Navigate to the ruleset.html resource on your engine (i.e. if you engine is running at localhost:8080, then go to http://localhost:8080/ruleset.html. You can enter the URL of the ruleset in the box marked in red in the screen shot below. You can use the file: URL scheme to load the ruleset from the filesystem directly into the engine rather than relying on an external server. The file URL is the schema file:// prepended to the full pathname of the file (yes, there are three slashes): 

file:///Users/pjw/prog/picolabs/pico_lessons/workflow/hello_world.krl

   
Image Removed

The engine will parse, compile, and make your ruleset available for use by any pico in that engine. 

...

Again, you only need a register a ruleset once on any engine, even if the source code changes. The only reason to re-register a ruleset is if its RID or URL change.  

Deploy

Deploying includes two different tasks: flushing cached artifacts from the ruleset in the engine and consists of installing the ruleset in any picos it needs to run in. If the ruleset has already been installed, then it will just need to be flushed

Flushing

Because the engine compiles and caches the ruleset, whenever you make changes to the source, you need to flush the ruleset. The Git pre-commit hook you installed in the Build step does that automatically for local engines (hosted on the local machine). If you're not deploying to a local engine you will need to set up a method for flushing the ruleset as part of deploying it. You can do this manually from the registered rulesets page (at rulesets.html) on the pico engine or using a URL. 

Installing

Install the ruleset in your pico by navigating to the Rulesets tab in the pico interface. For rulesets that you've already registered, you can simply select their name from the pulldown menu and click "install ruleset". 
Image Removed
Note that you can register and install the ruleset in one step from this page for convenience by installing from a URL. 

Test 

...

Installing

Install the ruleset in your pico by navigating to the Rulesets tab in the developer interface. 
Image Added
To install the ruleset, you need its URL. If you are committing to Github, then you can use the raw URL from Github.

If you are running locally for testing, then you can install from the file using file:// followed by the full path to the KRL file. Note that you'll end up with something like file:///Users/pjw/... with three slashes after file:

Once the ruleset is installed, it will show up in the Installed Rulesets section of this page. 

Flushing

Because the engine compiles and caches the ruleset, whenever you make changes to the source, you need to flush the ruleset. For development and testing, you can do that manually from the Installed Rulesets section of the develop interface. 

Image Added

This will flush the ruleset for all picos on this instance of the pico-engine. The hash will change with each new version of the file and is unique for every version of the file. 

Test 

The developer interface includes support for testing your rulesets. See the detailed instructions for more information on how to configure and use that feature. 

The Logging tab in the pico engine UI developer interface is also helpful in debugging and testing rules. 

...

If you're releasing a ruleset for broader use beyond your own needs, you'll want to take steps to ensure others see a stable ruleset even though you may continue to work on it. Putting your ruleset on an HTTP server allows it to be registered with multiple engines

The use of versions in your ruleset can ensure that picos see the version they need to operate correctly

The first step is to decide where you want to host your rulesets. Any HTTP server will do. Here are some tips for hosting code on GitHub and AWS

...