Caliber Documentation
website·Indexed 30 days ago
https://multiconsult-group.github.io/caliber/A Python package for managing workflows, processes, and tasks. Caliber provides tools for workflow orchestration, including a command line interface (CLI), global data object management, and Speckle integration via classes like SpeckleWorkflow and SpeckleTask. It supports Python 3.10 through 3.13.
What's inside Caliber
- Caliber is a Python package used to create and run engineering workflows. It provides a structured approach to writing Python scripts as tasks and workflows to improve code readability and collaboration. Key features include built-in automatic storage for input files, output files, and generated data to ensure traceability, as well as tight integration with the Speckle data platform for remote calculations and result storage.
Overview of Caliber features and benefits
Caliber is a framework for running Python functions organized as tasks and workflows. It provides several key advantages for developers:
- Code Structure: Enforces a task-and-workflow architecture, improving readability and providing clear direction and flow to Python scripts.
- Collaboration: Standardizes how workflows are defined, making it easier for teams to share and collaborate on code.
- Automated Data Management: Includes built-in support for the automatic storage of input files, output files, and generated data. Input files are stored alongside results to ensure traceability for post-processing.
- Speckle Integration: Tightly integrated with the Speckle data platform, allowing users to exchange workflows for remote calculations and store results externally.
Overview of Caliber engineering workflow package
Caliber is a Python package used to create and run engineering workflows. It provides a structured approach to coding by defining scripts as tasks and workflows, which improves readability and collaboration. Key features include:
- Automatic Data Storage: Built-in support for storing input files, output files, and generated data to ensure traceability and facilitate post-processing.
- Speckle Integration: Tightly connected to the Speckle data platform, allowing users to exchange workflows for remote calculations and store results.
Benefits of using Caliber for structural design workflows
Using Caliber and Python instead of traditional batch scripts for structural design provides several advantages:
- Reusability: Standardized workflow definitions and Python interfaces in packages promote collaboration and reusable code.
- Flexibility: Tasks or branches can be easily omitted to run only specific parts of the workflow (e.g., updating a subset of load cases).
- Extensibility: The workflow can be easily extended with additional Python functionality, such as data visualizations or optimizations.
Get started with the Caliber CLI
The Caliber CLI allows users to interact with the library without full knowledge of the API. Running the basecalibercommand displays the installed version, available global options (flags), and available sub-commands.caliberManage workloads with the WorkflowQueue class
Thecaliber.WorkflowQueueclass provides a mechanism to manage a queue of Workflows. It supports operations for manipulating individual workloads and persisting the queue state to either a local Speckle database or a remote Speckle Server.Use Caliber as a package or CLI tool
Once installed, Caliber can be used as a Python library via an import statement or as a command-line interface (CLI) tool directly from the terminal.# Use as a Python package import caliber# Use as a CLI tool caliberUse caliber.print for TUI and Rich integration
caliber.printis a custom implementation of the builtinprintfunction. It behaves like both the standard Pythonprintandrich.print. Its primary purpose is to integrate with the Caliber TUI; when a workflow is run via the Caliber CLI, any output sent viacaliber.printis routed to a dedicated 'Task activity' panel rather than the standard stdout. This panel accumulates messages during a task's execution and clears when a new task starts.from caliber import print # Standard text print('Hello, World!') # Rich console markup print('[bold italic blue]Hello[/bold italic blue], [red]World[/red]!')Install Caliber from source
Caliber is compatible with Python 3.10, 3.11, 3.12, and 3.13. It is installed directly from the GitHub source repository. It is recommended to use thepython -m pippattern rather than callingpipdirectly to ensure the correct Python version is targeted.# Using Python launcher py -m pip install git+https://github.com/multiconsult-group/caliber@main # Using Python python -m pip install git+https://github.com/multiconsult-group/caliber@mainVisualize a workflow via CLI
Thecaliber workflow showcommand generates a visualization of the workflow based on its JSON definition. This is used to verify that the workflow definition is correct and that all required modules/packages are imported correctly. Use the-tflag to view the visualization directly in the terminal.# Standard visualization caliber workflow show pasta.json # Terminal-based visualization caliber workflow show pasta.json -tRun a workflow using a JSON definition
Workflows can be executed via the CLI using a JSON file that describes the workflow. This JSON file can be created manually or generated using theWorkflow.to_json()method in Python. When running a workflow, Caliber activates a Text User Interface (TUI) powered by Textual for rendering output. Usectrl+dto toggle dark mode in the TUI.caliber workflow run [OPTIONS] JSONFILE # Example with the bell notification flag caliber workflow run --bell pasta.jsonAutomate bridge foundation design workflows with Caliber and Python
Caliber can be used to automate the iterative data exchange between geotechnical and structural disciplines during bridge foundation design. This is particularly useful for slender superstructures sensitive to second-order effects where soil stiffness calculations must be fed into structural finite element analyses (FEA).
Key implementation steps include:
- Creating Python interfaces to run engineering computer programs in batch mode.
- Using Caliber Workflows to collect and orchestrate these functions.
- Utilizing a Speckle server to handle data exchange between disciplines.
- Implementing a Plotly Dash dashboard to visualize soil stiffnesses stored on the Speckle server.
- Automating the generation of analysis report appendices.