Skip to Content

samai_python_dependencies - The WOW Factor

samai_python_dependencies - The WOW Factor

Human-Readable Benefits - Why this module matters


The Problem It Solves

Before: Every SAM AI module had its own external_dependencies in the manifest. Installing a new module meant discovering you're missing python-docx (but wait, you import it as docx). Then another module needs beautifulsoup4 (imported as bs4). Confusion everywhere.

After: One module manages ALL Python dependencies. Install samai_python_dependencies, run pip install -r requirements.txt, and you're ready for the entire SAM AI ecosystem.


Key Benefits

For System Administrators

Benefit Description
Single requirements.txt One file installs everything SAM AI needs
Clear error messages Post-init hook tells you exactly what's missing
No import confusion Module handles python-docx → docx mapping
Optional packages marked Know which packages are required vs nice-to-have

For Developers

Benefit Description
One dependency point Just 'depends': ['samai_python_dependencies']
Utility functions check_dependency() before importing
Graceful degradation Know if optional features are available
Self-documenting DEPENDENCIES dict has descriptions and categories

For DevOps

Benefit Description
Docker-friendly requirements.txt can be pip-installed at build time
Consistent environments Same dependencies across all SAM AI deployments
Version constraints requirements.txt includes minimum versions

Real-World Scenarios

Scenario 1: New SAM AI Installation

Before: Install ai_sam_intelligence, get error about missing requests. Install it. Install ai_sam_creatives, error about markdown. Install it. Repeat for every module.
After:

pip install -r samai_python_dependencies/requirements.txt

Done. All SAM AI modules will find their dependencies.

Scenario 2: Writing a New Module

Before: Figure out which packages you need, look up their pip names vs import names, add to manifest, hope it works.
After:

'depends': ['samai_python_dependencies']

Then in your code:

from odoo.addons.samai_python_dependencies import check_dependency

if check_dependency('markdown'):
    import markdown
    # use markdown safely

Scenario 3: Debugging Import Errors

Before: "ImportError: No module named 'docx'" - Is it pip install docx? No, that's wrong. Google it... it's python-docx.
After:

from odoo.addons.samai_python_dependencies import get_package_name
print(get_package_name('docx'))  # 'python-docx'

The Import Name Problem

Python packages often have different names for pip vs import:

pip install import
python-docx docx
beautifulsoup4 bs4
Pillow PIL
scikit-learn sklearn
opencv-python cv2

This module maintains these mappings so you don't have to remember them.


Dependency Categories

The module organizes dependencies logically:

Category Packages Use Case
Document markdown, python-docx, PyPDF2, openpyxl File processing
Web requests, httpx, beautifulsoup4, lxml API calls, scraping
Data pandas, numpy Data analysis (optional)
AI openai, anthropic AI integrations (optional)

Required packages are in the manifest's external_dependencies. Optional ones are tracked but not enforced.


Before vs After Summary

Aspect Before After
Dependencies per module Scattered across manifests Centralized
Import name confusion Constant googling Handled by module
Installation Module by module One pip command
Missing package errors Cryptic ImportError Clear pip command
New module development Copy-paste dependencies Single depends line

Who Should Care?

  • DevOps Engineers: One requirements.txt to maintain
  • New Developers: No guessing about package names
  • Module Authors: Focus on features, not dependency management
  • Support Teams: Consistent dependency state across clients

Bottom Line: This module transforms Python dependency management from a scattered, confusing process into a centralized, well-documented system - making SAM AI module installation and development significantly smoother.

Was this helpful?