fix(viscy-utils): fall back to TensorBoard logger when wandb is absent#472
Conversation
VisCyCLI.add_arguments_to_parser unconditionally set the default trainer.logger to a WandbLogger. wandb is only an optional dependency (the `eval` extra / `test` group), not a core one, so on a base install every trainer-building subcommand (predict, preprocess, export, precompute, convert_to_anndata) crashed during class instantiation with "Requirement 'wandb>=0.12.10' not met". Pick the default logger at runtime: WandbLogger when wandb is importable, otherwise TensorBoardLogger (tensorboard is a core dependency), so the CLI is usable without the eval extra. before_instantiate_classes -> _configure_wandb_logger already no-ops for non-W&B loggers, so the TensorBoard fallback is safe. Fixes #471 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| _WANDB_RUN_TIMESTAMP_FORMAT = r"%Y%m%d-%H%M%S" | ||
|
|
||
|
|
||
| def _default_logger(): |
There was a problem hiding this comment.
I think this fix is a bit dangerous because it won't fail. Intestead it will try to find the second option. I am going to fix this by just making wandb a dependency
edyoshikun
left a comment
There was a problem hiding this comment.
I added the changes. review and test @ieivanov if this works for your issue.
There was a problem hiding this comment.
Pull request overview
This PR is intended to address viscy-utils CLI crashes on base installs caused by defaulting trainer.logger to WandbLogger while wandb is not installed. The current change set resolves the crash by making wandb a core dependency (rather than selecting a non-wandb default logger at runtime as described in the PR summary).
Changes:
- Add
wandbtopackages/viscy-utilscoredependencies. - Remove
wandbfromoptional-dependencies.eval. - Remove
wandbfrom thetestdependency group.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Yup, that works too, thank you! |
torch.multiprocessing fork() of the multi-threaded pytest parent aborts on macOS once the Metal/MPS Objective-C runtime is initialized: objc[...]: +[MPSGraphObject initialize] may have been in progress in another thread when fork() was called. ... Crashing instead. This is a hard SIGABRT/SIGSEGV in the fork child, not a flake — it reproduces deterministically. The tests already skip on Windows (no fork start_method); mirror that with a Darwin skip. The Linux CI runner still exercises these real-fork DDP paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Why the macOS DDP tests are now skippedThe macOS (and fail-fast-canceled Windows) Test Data jobs were failing on 3 parametrizations of The real cause (reproduced deterministically on macOS): This is the macOS Objective-C / Metal (MPS) fork-safety abort. The test intentionally uses This isn't caused by this PR's logic. The PR only moves Fix: the test already skips on Windows ( |
edyoshikun
left a comment
There was a problem hiding this comment.
I added the changes. review and test @ieivanov if this works for your issue.
Summary
VisCyCLI.add_arguments_to_parserunconditionally set the defaulttrainer.loggerto aWandbLogger. Butwandbis only an optional dependency (theevalextra /testgroup), not a core one. So on a base install, every trainer-building subcommand —predict,preprocess,export,precompute,convert_to_anndata— crashed during class instantiation with:Fix
Pick the default logger at runtime:
WandbLoggerwhenwandbis importable (unchanged behavior for users with theevalextra),TensorBoardLogger(tensorboardis already a core dependency), so the CLI works on a base install.before_instantiate_classes→_configure_wandb_loggeralready no-ops when the resolved logger isn't aWandbLogger(it checksclass_path), so the TensorBoard fallback is safe.Tests
Added unit tests for the new
_default_loggerhelper (monkeypatchingimportlib.util.find_spec) covering both branches. Fulltest_cli.pypasses;ruff check/ruff formatclean.Closes #471