Skip to content

[FEATURE] better error message about SWANLAB_LOG_DIR must be an existing path #239

@ShaohonChen

Description

@ShaohonChen

🤩 Features description [Please make everyone to understand it]

When I specify the 'logdir' for swanlab in my training code, swanlab does not correctly provide me with the command to view the logs in the training log, as shown in the following code and its corresponding output."

code:

 swanlab.init(
      experiment_name=str(cfg.log.exp_name),
      description="Honor inpaint model experiment",
      config=None,
      logdir=cfg.log.save_dir,
  )

output:

...
[2024-01-20 19:07:44,367][SwanLab][INFO] - Run data will be saved locally in 
/home/XXX/projects/HonorInpaint/experiments/baseline_2024-01-20_19-07-43
[SwanLab-INFO]:        Experiment_name: baseline_2024-01-20_19-07-43
[2024-01-20 19:07:44,367][SwanLab][INFO] - Experiment_name: baseline_2024-01-20_19-07-43
[SwanLab-INFO]:        Run `swanlab watch` to view SwanLab Experiment Dashboard
[2024-01-20 19:07:44,368][SwanLab][INFO] - Run `swanlab watch` to view SwanLab Experiment Dashboard
...

When I follow the output and use the swanlab watch command to view the logs, an error occurs, and the error message is as follows:

...
  File "/home/XXX/miniconda3/envs/inpaint/lib/python3.11/site-packages/swanlab/cli/main.py", line 64, in watch
    from ..server import app
  File "/home/XXX/miniconda3/envs/inpaint/lib/python3.11/site-packages/swanlab/server/__init__.py", line 14, in <module>
    init_env()
  File "/home/XXX/miniconda3/envs/inpaint/lib/python3.11/site-packages/swanlab/env.py", line 135, in init_env
    func(env)
  File "/home/XXX/miniconda3/envs/inpaint/lib/python3.11/site-packages/swanlab/env.py", line 52, in get_swanlog_dir
    raise ValueError('SWANLAB_LOG_DIR must be an existing path, now is "{path}"'.format(path=path))
ValueError: SWANLAB_LOG_DIR must be an existing path, now is "/home/XXX/projects/PROJECTNAME/swanlog"

I understand that this is caused by not correctly setting the log path, but I wish for a clearer error message to guide me in setting up the 'swanlab watch' command correctly when I forget to set the log path. Likes:

The log file was not found in the default path '/home/XXX/projects/PROJECTNAME/swanlog'. Please use the 'swanlab watch -d {LOG PATH}' command to specify the location of the log path."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions