Slim core dependencies; promote openai to base install - #208
Conversation
Move heavy optional packages (pandas, opencv-python, IPython) out of core into extras, with DependencyError helpers pointing at pip install vlmrun[all] or vlmrun[video]. Promote openai to core so vlmrun gw chat works out of the box with pip install vlmrun or uvx vlmrun. Remove redundant openai and cli extras. Co-authored-by: Sudeep Pillai <sudeep.pillai@gmail.com>
There was a problem hiding this comment.
🔴 Gateway availability check crashes instead of reporting status
The gateway liveness check reads a success flag that does not exist on the new HTTP library's response object (resp.is_success at vlmrun/client/gateway.py:231), so any reachable gateway that answers the health request makes the check blow up instead of returning true/false.
Impact: Users running gateway commands see an unexpected crash rather than a healthy/unhealthy result.
httpx→requests migration missed the response API difference
health() was switched from httpx.get to requests.get (vlmrun/client/gateway.py:210-216). httpx.Response exposes is_success, but requests.Response does not (it exposes ok), so line 231 raises AttributeError for every non-404 response. The exception is outside the try blocks (which only cover the request and the models fallback), so it propagates to callers such as the vlmrun gw CLI health checks. The tests still pass only because the fakes in tests/test_gateway.py:307-321 define an is_success attribute.
(Refers to line 231)
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
🟡 Documentation still claims chat completions raise a missing-dependency error
The completions helpers still document a missing-dependency error (Raises: DependencyError at vlmrun/client/agent.py:305 and vlmrun/client/agent.py:350) even though the OpenAI SDK is now imported unconditionally at module level, so the docs no longer match behavior.
Impact: Readers are told about an error condition that can never occur, which is misleading.
Docstrings not updated with the import change
agent.py now does from openai import AsyncOpenAI, OpenAI at the top (vlmrun/client/agent.py:22) and the try/except that raised DependencyError was removed from both completions and async_completions. AGENTS.md requires docstrings/docs be updated when the implementation deviates; the Raises: sections should be dropped (or replaced with an ImportError note).
(Refers to lines 304-306)
Was this helpful? React with 👍 or 👎 to provide feedback.
| if self.content: | ||
| return self.content | ||
| df = self.to_dataframe(header="name") | ||
| try: | ||
| return df.to_markdown() | ||
| except ImportError: | ||
| return df.to_string(index=False) |
There was a problem hiding this comment.
🟡 Reading document results can fail on the slim install when a table has no pre-rendered text
Table text is now produced by building a data frame with a library that is no longer installed by default (require_pandas() at vlmrun/client/types.py:808), so parsing a document result whose table lacks pre-rendered content raises a missing-dependency error.
Impact: Base-install users can hit a hard failure just from receiving a document extraction response.
Rendering happens eagerly during model validation
MarkdownPage.render_markdown is a model_validator(mode="after") (vlmrun/client/types.py:856-860) that calls render(), which calls each MarkdownTable.render() (vlmrun/client/types.py:866-874). MarkdownTable.render() returns self.content when present, but otherwise falls through to to_dataframe(header="name"), which now calls require_pandas() before the surrounding try, so a DependencyError escapes and aborts response validation. Previously pandas was a core requirement, so this path could not fail. Consider degrading gracefully (e.g. emit a plain-text/markdown table without pandas, or return the raw content/empty string) instead of raising during parsing.
Was this helpful? React with 👍 or 👎 to provide feedback.
Per review feedback, keep direct openai imports in agent.py and chat.py. The fix is releasing 0.7.4 with openai>=1.0.0 in base dependencies (already in requirements.txt from #208). Co-authored-by: Sudeep Pillai <sudeep.pillai@gmail.com>
Summary
Reduces the footprint of
pip install vlmrunby moving heavy optional packages out of core and into extras, while makingvlmrun gw chatwork out of the box.Changes
Core dependencies (smaller install)
Removed from
requirements/requirements.txt:pandasopencv-pythonIPythontabulate(unused)tqdm(unused)Added to core:
openai>=1.0.0(so CLI gateway chat works without extras)Optional extras
video:numpy,opencv-pythondoc:pypdfium2all: video + doc +pandas+ipythonopenaiandcliextras (now included in base install)Lazy imports + helpful errors
vlmrun/common/dependencies.pywithrequire_*()helpers that raiseDependencyErrorwithpip install vlmrun[<extra>]guidancetypes.py(MarkdownTable.to_dataframe),video.py,viz.py, andpdf.pyOther
requests(core dep) instead ofhttpxMarkdownTable.render()falls back toDataFrame.to_string()whentabulateis unavailableTesting
python3 -m pytest tests— 458 passed, 22 skippedSlack Thread