Skip to content

Trim down exporter plugin sdk#1361

Merged
deep1401 merged 4 commits intomainfrom
fix/trim-exporter-sdk
Feb 19, 2026
Merged

Trim down exporter plugin sdk#1361
deep1401 merged 4 commits intomainfrom
fix/trim-exporter-sdk

Conversation

@deep1401
Copy link
Copy Markdown
Member

@deep1401 deep1401 commented Feb 18, 2026

Summary by CodeRabbit

  • Refactor

    • Consolidated the job wrapper mechanism for exporter plugins, enabling customizable success messages and optional inclusion of exception details in error reporting.
  • Chores

    • Updated versions for GGUF Exporter (0.2.9 → 0.2.10), LLamafile Exporter (0.1.11 → 0.1.12), and MLX Exporter (1.0.27 → 1.0.28).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This PR refactors the exporter job wrapper architecture by consolidating exporter_job_wrapper into the base job_wrapper method with new parameters (success_message and include_exception_in_error). All exporter plugins are updated to use the unified approach, with corresponding version bumps across three exporter plugins.

Changes

Cohort / File(s) Summary
SDK Plugin Infrastructure
api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py, api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py
Replaced exporter_job_wrapper decorator with overridden job_wrapper method. Enhanced base job_wrapper with success_message and include_exception_in_error parameters, conditional field population for template_name/model_adapter, and refined error handling logic.
GGUF Exporter Plugin
api/transformerlab/plugins/gguf_exporter/index.json, api/transformerlab/plugins/gguf_exporter/main.py
Updated decorator from exporter_job_wrapper to job_wrapper on gguf_export function and bumped version from 0.2.9 to 0.2.10.
Llamafile Exporter Plugin
api/transformerlab/plugins/llamafile_exporter/index.json, api/transformerlab/plugins/llamafile_exporter/main.py
Updated decorator from exporter_job_wrapper to job_wrapper on llamafile_export function and bumped version from 0.1.11 to 0.1.12.
MLX Exporter Plugin
api/transformerlab/plugins/mlx_exporter/index.json, api/transformerlab/plugins/mlx_exporter/main.py
Updated decorator from exporter_job_wrapper to job_wrapper on mlx_export function and bumped version from 1.0.27 to 1.0.28.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 The wrappers unite in harmony's call,
From scattered decorators to one handler for all,
Success messages flow and exceptions appear,
Three exporters rejoice—new versions shine clear! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Trim down exporter plugin sdk' accurately describes the main change: consolidating exporter-specific wrapper logic by replacing the dedicated exporter_job_wrapper method with an overridden job_wrapper method in the base class, removing unused imports, and bumping plugin versions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/trim-exporter-sdk

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py`:
- Line 1: The job_wrapper function is missing type annotations for its **kwargs
parameter and its return type; update the signature of job_wrapper in export.py
(the function named job_wrapper) to annotate **kwargs with an appropriate
Mapping/Dict type (e.g., **kwargs: Any or **kwargs: Mapping[str, Any]) and add a
return type hint matching the actual return (e.g., -> Any or the concrete return
type), and import Any/Mapping from typing if needed to satisfy type checking.

In `@api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py`:
- Line 12: The function job_wrapper is a decorator factory missing a return
type; update its signature to declare it returns a callable decorator (e.g., use
typing.Callable or a TypeVar: Callable[[Callable[..., Any]], Callable[..., Any]]
or more generically Callable[..., Callable[..., Any]]). Locate job_wrapper in
tlab_plugin.py and add the appropriate return type annotation (or use TypeVar F
and annotate as -> Callable[[F], F]) while keeping the existing parameter type
hints.

import traceback

from transformerlab.sdk.v1.tlab_plugin import TLabPlugin, DotDict, _run_async_from_sync
from transformerlab.sdk.v1.tlab_plugin import TLabPlugin, DotDict
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# First, check if the file exists and read its content
if [ -f "api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py" ]; then
    echo "=== File Content ===" 
    cat -n "api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py"
else
    echo "File not found"
    find . -name "export.py" -type f | head -20
fi

Repository: transformerlab/transformerlab-app

Length of output: 2298


🏁 Script executed:

#!/bin/bash

# Run the verification script from the review comment
python - <<'PY'
import ast, pathlib

try:
    path = pathlib.Path("api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py")
    content = path.read_text()
    tree = ast.parse(content)
    
    print("=== Searching for job_wrapper function ===")
    found = False
    for node in ast.walk(tree):
        if isinstance(node, ast.FunctionDef) and node.name == "job_wrapper":
            found = True
            print(f"Function: {node.name}")
            print(f"Line: {node.lineno}")
            print(f"Return annotation: {node.returns}")
            print(f"Arguments:")
            for arg in node.args.args:
                print(f"  {arg.arg}: {arg.annotation}")
            if node.args.kwarg:
                print(f"  **{node.args.kwarg.arg}: {node.args.kwarg.annotation}")
            print()
    
    if not found:
        print("job_wrapper function not found")
        print("\n=== All function definitions in file ===")
        for node in ast.walk(tree):
            if isinstance(node, ast.FunctionDef):
                print(f"  {node.name} at line {node.lineno}")
                
except FileNotFoundError:
    print("File not found at path")
except Exception as e:
    print(f"Error: {e}")
PY

Repository: transformerlab/transformerlab-app

Length of output: 322


Add type annotations for job_wrapper function parameters and return type.

The job_wrapper method at lines 39-43 is missing type annotations for **kwargs and the return type, which violates the requirement to include mandatory type hints for all function arguments and return types in Python code.

Proposed fix
+from typing import Any, Callable
 from transformerlab.sdk.v1.tlab_plugin import TLabPlugin, DotDict

     def job_wrapper(self, progress_start: int = 0, progress_end: int = 100, **kwargs):
+    def job_wrapper(
+        self,
+        progress_start: int = 0,
+        progress_end: int = 100,
+        **kwargs: Any,
+    ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/transformerlab/plugin_sdk/transformerlab/sdk/v1/export.py` at line 1, The
job_wrapper function is missing type annotations for its **kwargs parameter and
its return type; update the signature of job_wrapper in export.py (the function
named job_wrapper) to annotate **kwargs with an appropriate Mapping/Dict type
(e.g., **kwargs: Any or **kwargs: Mapping[str, Any]) and add a return type hint
matching the actual return (e.g., -> Any or the concrete return type), and
import Any/Mapping from typing if needed to satisfy type checking.

import json
from pydantic import BaseModel
from typing import Any, List
from typing import Any, List, Optional
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n "api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py" | head -20

Repository: transformerlab/transformerlab-app

Length of output: 740


🏁 Script executed:

sed -n '1,15p' "api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py" | cat -n

Repository: transformerlab/transformerlab-app

Length of output: 498


🏁 Script executed:

sed -n '95,115p' "api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py" | cat -n

Repository: transformerlab/transformerlab-app

Length of output: 983


Add a return type annotation to job_wrapper.

The function at lines 99-107 is missing a return type annotation. All parameters have type hints, but the return type is absent, which violates the mandatory type-hinting guideline. The function is a decorator factory, so it should declare that it returns a callable that accepts a callable and returns a callable.

Proposed fix
-from typing import Any, List, Optional
+from typing import Any, Callable, List, Optional
     def job_wrapper(
         self,
         progress_start: int = 0,
         progress_end: int = 100,
         wandb_project_name: str = "TLab_Training",
         manual_logging: bool = False,
         success_message: Optional[str] = None,
         include_exception_in_error: bool = False,
-    ):
+    ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/transformerlab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py` at line
12, The function job_wrapper is a decorator factory missing a return type;
update its signature to declare it returns a callable decorator (e.g., use
typing.Callable or a TypeVar: Callable[[Callable[..., Any]], Callable[..., Any]]
or more generically Callable[..., Callable[..., Any]]). Locate job_wrapper in
tlab_plugin.py and add the appropriate return type annotation (or use TypeVar F
and annotate as -> Callable[[F], F]) while keeping the existing parameter type
hints.

@sentry
Copy link
Copy Markdown

sentry bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ab/plugin_sdk/transformerlab/sdk/v1/tlab_plugin.py 0.00% 12 Missing ⚠️
...rmerlab/plugin_sdk/transformerlab/sdk/v1/export.py 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@deep1401 deep1401 merged commit e6e0f04 into main Feb 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants