HumanSignal / HumanSignal/label-studio-ml-backend
BUG: kwargs configuration no longer passed to model initialization in WSGI files
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 490
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 3
Description
## Problem Summary
Configuration parameters specified via `--with` flag or `config.json` file are not being passed to model initialization in `*_wsgi.py` files, breaking customization functionality that previously worked.
## Expected Behavior
- `kwargs` from `--with` flag should be passed to model constructor
- `kwargs` from `config.json` should be passed to model constructor
- Model should initialize with custom parameters as specified in configuration
## Current Behavior
- `kwargs` are loaded and parsed correctly
- `kwargs` are only used during the `--check` validation step
- `kwargs` are **not** passed to the actual model instance used by the web app
- Model initializes with default parameters only
## Steps to Reproduce
1. Run any WSGI example with custom kwargs: `python examples/yolo/_wsgi.py --with param=value`
2. Observe that the web app uses default model parameters
## Code Analysis
In `examples/yolo/_wsgi.py` (and other WSGI files):
```python
kwargs = get_kwargs_from_config()
if args.kwargs:
kwargs.update(parse_kwargs())
if args.check:
model = YOLO(**kwargs) # ✅ kwargs used here
app = init_app(
model_class=YOLO, # ❌ kwargs not passed here
basic_auth_user=args.basic_auth_user,
basic_auth_pass=args.basic_auth_pass,
)
```
## Root Cause
The `init_app()` function appears to have removed support for passing `**kwargs` to the model constructor, but the argument parsing logic was left intact, creating a misleading interface.
## Questions
1. **Is this an intentional breaking change?** Should kwargs support be removed entirely?
2. **Is there a new recommended way** to pass model parameters other than environment variables?
3. **Should `init_app()` be updated** to accept and forward kwargs to model initialization?
## Proposed Solutions
**Option A:** Restore kwargs functionality
```python
app = init_app(
model_class=YOLO,
model_kwargs=kwargs, # Pass kwargs to init_app
basic_auth_user=args.basic_auth_user,
basic_auth_pass=args.basic_auth_pass,
)
```
**Option B:** Remove misleading argument parsing
- Remove `--with` and `--kwargs` options if they're no longer supported
- Update documentation to reflect current capabilities
## Environment
- **Affected files:** All `*_wsgi.py` files in examples/
- **Configuration methods:** Both `--with` flag and `config.json` affected
- **Impact:** High - breaks existing workflows that rely on model customization
---
**Labels:** `bug`, `breaking-change`, `configuration`, `wsgi`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with examples/yolo/_wsgi.py and compare the kwargs used during --check with the arguments passed to init_app; then inspect the other examples/*_wsgi.py files and init_app's model-construction interface. Determine whether configuration kwargs should be forwarded or the options removed, and verify that both --with and config.json affect the model used by the web app.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100