openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

Add optional dependencies with extras for selective instrumentation

Open harsha08-2k6 opened this issue 1 month ago • 6 comments

  • [ ] I have added tests that cover my changes.
  • [ ] If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • [ ] PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation): ....
  • [ ] (If applicable) I have updated the documentation accordingly.

[!IMPORTANT] Add optional dependencies with extras in setup.py and scripts for activating Python virtual environments across different shells.

  • Setup:
    • Adds setup.py with optional dependencies using extras_require for selective instrumentation.
    • Defines groups: full, minimal, openai, langchain.
  • Virtual Environment Activation:
    • Adds Activate.ps1, activate, activate.csh, activate.fish for activating virtual environments in PowerShell, bash, csh, and fish shells.
    • Scripts manage environment variables like PATH, PYTHONHOME, and prompt settings.
  • Scripts:
    • Adds executable scripts like distro, hf, httpx, normalizer, opentelemetry-bootstrap, opentelemetry-instrument, pip, pip3, tiny-agents, tqdm for various command-line tools.
    • Scripts are set up to run with the virtual environment's Python interpreter.

This description was created by Ellipsis for 58172f5e6988e757d5c94c3a0933864feb343b6d. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Chores
    • Added Python virtual environment configuration with activation scripts for multiple shell environments (PowerShell, Bash, C shell, and Fish).
    • Configured project packaging setup with core dependencies and optional feature groups for extended functionality.

harsha08-2k6 avatar Oct 29 '25 08:10 harsha08-2k6

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 29 '25 08:10 CLAassistant

Walkthrough

This PR establishes a Python virtual environment (myenv) with shell activation scripts for PowerShell, Bash, C shell, and Fish; creates console entry point wrappers for multiple Python packages (pip, distro, opentelemetry, httpx, tqdm, etc.); adds virtual environment configuration; and includes a setup.py for packaging dependencies.

Changes

Cohort / File(s) Summary
Shell Activation Scripts
myenv/bin/Activate.ps1, myenv/bin/activate, myenv/bin/activate.csh, myenv/bin/activate.fish
Four shell-specific activation scripts that configure environment variables (VIRTUAL_ENV, PATH, PYTHONHOME), manage prompts, and provide deactivate functions for reverting environment state across PowerShell, Bash, C shell, and Fish shells.
Python Console Entry Points
myenv/bin/{distro,hf,httpx,normalizer,opentelemetry-bootstrap,opentelemetry-instrument,pip,pip3,pip3.12,tiny-agents,tqdm}
Eleven Python launcher scripts that delegate execution to their respective package main functions (e.g., distro.distro, huggingface_hub.cli.hf, pip._internal.cli.main) with argv normalization and standard shebang/encoding setup.
Python Interpreter Aliases
myenv/bin/{python,python3,python3.12}
Three minimal files serving as interpreter references/aliases to python executables.
Virtual Environment Configuration
myenv/pyvenv.cfg
Configuration file specifying venv metadata including Python version (3.12.3), home path, and system site-packages setting.
Environment Metadata
myenv/lib64
Single file containing reference text "lib".
Package Setup
setup.py
Setup configuration defining project metadata, core dependencies, and extras_require groups (full, minimal, openai, langchain) for optional instrumentation packages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • The Python console entry scripts follow a highly repetitive, homogeneous pattern (import, normalize argv, delegate to main, exit) requiring minimal per-file scrutiny
  • Shell activation scripts follow established conventions with standard environment variable management patterns
  • Configuration files (pyvenv.cfg, setup.py) are straightforward metadata
  • Attention areas: Verify that argv normalization logic correctly handles all edge cases across the entry points; confirm shell activation scripts correctly restore environment state on deactivation; review setup.py extras_require versions for compatibility

Poem

🐰 A warren of scripts, now neatly arranged, Activation and entry points—all nicely exchanged! From PowerShell's prompts to the Fish shell's gleam, The virtual nest is complete: a developer's dream! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Add optional dependencies with extras for selective instrumentation" directly and accurately describes the primary change in the changeset. The main substantive modification is the addition of setup.py, which introduces extensive extras_require groups ("full", "minimal", "openai", "langchain") enabling selective installation of instrumentation packages. While the PR includes virtual environment setup files, the title appropriately captures the core change relating to packaging configuration and optional dependency management. The phrasing is specific, clear, and conveys meaningful information without unnecessary vagueness or verbosity.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 29 '25 08:10 coderabbitai[bot]

Hey @harsha08-2k6 what's the purpose of this?

nirga avatar Oct 29 '25 11:10 nirga

hi @nirga , Virtual environment: It’s like creating a separate, isolated workspace for your Python project where you can install packages without affecting your system-wide Python. This prevents conflicts if you work on multiple projects needing different package versions. It keeps your work clean and organized.

Optional dependencies with extras: Instead of installing all packages (including many you may not use), you allow users to install only what they need, for example, just OpenAI instrumentation or LangChain instrumentation. This reduces bloat and speeds up installs.

So overall, you set up an environment to work safely without messing with your system Python and improved how the Traceloop SDK package handles dependencies to be more flexible and user-friendly. This helps developers customize their installs and avoid unnecessary packages

harsha08-2k6 avatar Oct 29 '25 12:10 harsha08-2k6

Thanks @harsha08-2k6 - can you specify which workflow you cannot do today that you'll be able to do with this?

nirga avatar Oct 29 '25 13:10 nirga

hi @nirga - Workflows that were difficult or problematic before: Sharing the exact development environment: Before, committing virtual environments (like myenv/) made the repository bulky, non-portable, and caused conflicts because of machine-specific paths.

Selective package installation: The Traceloop SDK forced users to install all instrumentation dependencies even if they only needed a few, causing long install times and extra disk usage.

Collaborative development: Without proper .gitignore rules, virtual environment artifacts could accidentally be committed and conflict with others' environments.

Reliable package management: Without version-aligned optional dependencies (extras_require), installs could break due to incompatible or unavailable packages.

Workflows you can now do successfully: Clean, lean repository management: By removing virtualenv folders from git and using .gitignore, your repo is lightweight and portable for any developer or CI system.

Flexible dependency installation: Users can install only needed instrumentation packages with commands like pip install traceloop-sdk[openai] or pip install traceloop-sdk[full].

Safe local development: Use isolated Python virtual environments locally without polluting repos or system Python.

Maintainable branching and collaboration: Clean branches without environment artifacts that can be safely pushed, reviewed, and merged.

Version reliable installs: With pinned compatible package versions in extras, your SDK installs reliably for many users.

In simple terms, your work today enables efficient, clean, and maintainable Python development and collaboration workflows that were problematic before due to environment pollution and rigid packaging.

harsha08-2k6 avatar Oct 29 '25 15:10 harsha08-2k6