Lightning-AI / Lightning-AI/pytorch-lightning
Logging failed when using mlflow with sqlite tracking uri
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Bug description
I'm using Lightning with MLFlow. I want to use a local database to store tracked metadata, so I set the `tracking_uri` param in `MLFlowLogger` to `sqlite:////some_absolute_path/mlruns.db`. But I got `AssertionError` which says log_dir is none. Note that I'm controlling configs through lightning-cli.
### What version are you seeing the problem on?
v2.2
### How to reproduce the bug
```yaml
trainer:
logger:
class_path: MLFlowLogger
init_args:
experiment_name: test
tracking_uri: sqlite:////some_absolute_path/mlruns.db
log_model: true
```
```python
cli = LightningCLI(run=False)
```
### Error messages and logs
Traceback (most recent call last):
File "/home/user/code/main.py", line 15, in
cli_main()
File "/home/user/code/main.py", line 9, in cli_main
cli.trainer.fit(model=cli.model, datamodule=cli.datamodule)
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 543, in fit
call._call_and_handle_interrupt(
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/call.py", line 44, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 579, in _fit_impl
self._run(model, ckpt_path=ckpt_path)
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/trainer.py", line 948, in _run
call._call_setup_hook(self) # allow user to set up LightningModule in accelerator environment
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/call.py", line 93, in _call_setup_hook
_call_callback_hooks(trainer, "setup", stage=fn)
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/trainer/call.py", line 208, in _call_callback_hooks
fn(trainer, trainer.lightning_module, *args, **kwargs)
File "/home/user/miniconda3/envs/test/lib/python3.10/site-packages/lightning/pytorch/cli.py", line 247, in setup
assert log_dir is not None
AssertionError
### Environment
Current environment
```
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0): 2.2.0
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0): 1.13.1
#- Python version (e.g., 3.9): 3.10
#- OS (e.g., Linux): Linux
#- CUDA/cuDNN version: 11.6
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source): pip
#- Running environment of LightningApp (e.g. local, cloud): local
#- MLFlow version: 2.10.2
```
### More info
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the LightningCLI setup hook at lightning/pytorch/cli.py:247, where log_dir is asserted, and trace how the MLFlowLogger configuration reaches it. Reproduce the YAML configuration with the sqlite tracking URI and inspect the MLFlowLogger and CLI integration paths. Done means the configuration initializes without the AssertionError and the relevant regression behavior is covered by an existing or added test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100