Python Analytic Special Comments

There are a few special comments you can add to your Python file that tell the Python analytic module about the script.

Choosing Inputs

The analytic looks for a '#' followed by a '+' to indicate some analytic information.

For example, if your script wants a speed, size and weight, you'd have the following…

#+Speed
#+Size
#+Weight

Note that these lines need to begin at the start of the line - don't include any indentation.

Enabling Caching

If you wanted to take advantage of background caching, you can do this with the Cache option.

Note that the cache system is used on lists of events. Those events should all share a common parent, and have at least a start and end property that are UTC epoch timestamps (in seconds).

It's also a good idea to include a complete property - if the value is 1, the event can be cached.

To use the cache, you'll need to choose…

  • The name of the key in the script output that you'd like to cache items from.
  • Which points of additional data you'd like to record, and what type of data that is - either string, integer or float.

The format is the word 'Cache', followed by and equal-sign, then a vertical-bar-delmited list of input:format pairs.

For example, our Python script could output the following…

{
   "training_sessions": [ 
       {
         "start": 12933884,
         "end": 12993440,
         "best": 0,
         "speed": 45,
         "horse": "Madame Gluestick",
         "complete": 1
       },
       {
         "start": 12934884,
         "end": 12995440,
         "best": 1,
         "speed": 95.2,
         "horse": "Changing Seasons",
         "complete": 1
       }
    ]}

…and the special comment in the code would be…

#+Cache=training_sessions|horse:string|speed:float|best:int

This would cache any of our complete training_session objects, storing the horse name, speed and 'best' value for each event.

See Writing the Python Script for details.