Best practice

The examples and the caliber workflow commands of the CLI described in the previous sections invite for the following best practice:

  1. Define the workflow in a Python script, e.g. main.py. Export the workflow definition to a JSON-file, e.g. main.json.

  2. Visualize the workflow by typing caliber workflow show main.json.

  3. Run the workflow by typing caliber workflow run main.json.

When you follow this structure, you facilitate for a style of working where you separate logically between workflow definition, verification and execution 👌

And by the way, if an exception is raised during your run, remember that you will always have the full traceback stored in caliber-traceback.txt for you to pass to a colleague for help.

Available types for the JSON-file

The JSON format has a limited set of types for storing data, and the built-in json module has a set of standard encoders and decoders. No special purpose encoders and decoders are implemented in Caliber. This means that your workflow definition with all args and kwargs of the tasks should contain only types that are serialized and deserialized one-to-one. On the other hand, if for example one of your args is a tuple, and the function strictly depends on this arg to be a tuple, you should explicitly translate it to a tuple in the function using tuple(...), since a tuple is serialized and deserialized as a list.

About error tracebacks

In case an exception is raised while you are running your workflow, you might notice the nicely formatted error traceback. This is Rich in action. Actually, when you run the Caliber TUI, the Rich traceback handler is automatically installed to enable this nice feature by default. The behaviour can be customized with the caliber_minimum_traceback environment variable. If an exception is raised, the traceback is also saved to a file called caliber-traceback.txt. So, if you run into trouble, and cannot find a solution, pass caliber-traceback.txt to a colleague who might help you!