Cogito is a versatile Python module aimed at simplifying the development and deployment of inference services. It allows users to wrap machine learning models or any computational logic into APIs effortlessly. With cogito, you can focus on your core algorithmic functionality while the module takes care of the heavy lifting, including API structure, request handling, error management, and scalability.
Key features include:
- Ease of Use: Simplifies the process of converting your models into production-ready APIs with minimal boilerplate code.
- Customizable API: Provides flexibility to define endpoints, input/output formats, and pre- / post-processing logic.
- Scalability: Optimized to handle high-throughput scenarios with support for modern server frameworks.
- Extensibility: Easily integrates with third-party libraries, monitoring tools, or cloud services.
- Error Handling: Built-in mechanisms to catch and handle runtime issues gracefully.
make build
Then, you can install the package:
pip install cogito
cd examples
python app.py
The Cogito CLI provides several commands to initialize, scaffold, and run your inference-based projects. This guide explains the available commands and their options.
Command: init
Description: Initialize the project configuration with default or custom settings.
-s, --scaffold
: Generate a scaffold prediction class during initialization.-d, --default
: Initialize with default values without prompts.-f, --force
: Force initialization even if a configuration file already exists.
cogito-cli init [OPTIONS]
Examples:
-
Initialize with prompts:
cogito-cli init
-
Initialize with default values:
cogito-cli init --default
-
Initialize and scaffold prediction classes:
cogito-cli init --scaffold
Command: scaffold
Description: Generate prediction class files based on the routes defined in the configuration file (cogito.yaml
).
-f, --force
: Overwrite existing files if they already exist.
cogito-cli scaffold [OPTIONS]
Examples:
-
Scaffold prediction classes:
cogito-cli scaffold
-
Scaffold and overwrite existing files:
cogito-cli scaffold --force
Command: run
Description: Run the cogito application based on the configuration in the specified directory.
cogito-cli [-c context] run
Example:
- Run the cogito application located in
examples
directory:cogito-cli -c examples run
This will:
- Change the current working directory to the configuration path.
- Load the application based on the
cogito.yaml
file. - Start the FastAPI server for your inference service.