U-Time icon indicating copy to clipboard operation
U-Time copied to clipboard

Error in ut init

Open sindrijonsson opened this issue 3 years ago • 1 comments

Hi, I ran into an error when running through the demo in the README

ut init --name demo --model usleep_demo Traceback (most recent call last): File "\Anaconda3\envs\u-sleep\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "\Anaconda3\envs\u-sleep\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "\Anaconda3\envs\u-sleep\Scripts\ut.exe_main.py", line 7, in File "\Anaconda3\envs\u-sleep\lib\site-packages\utime\bin\ut.py", line 103, in entry_func mod.entry_func(script_args + help_agrs) File "\Anaconda3\envs\u-sleep\lib\site-packages\utime\bin\init.py", line 134, in entry_func run(parser.parse_args(args)) File "\Anaconda3\envs\u-sleep\lib\site-packages\utime\bin\init.py", line 128, in run init_project_folder(default_folder, args.model, out_folder, data_dir) File "\Anaconda3\envs\u-sleep\lib\site-packages\utime\bin\init.py", line 104, in init_project_folder copy_yaml_and_set_data_dirs(in_file_path, out_file_path, data_dir) File "\Anaconda3\envs\u-sleep\lib\site-packages\utime\bin\init.py", line 71, in copy_yaml_and_set_data_dirs hparams.save_current(out_path) File "\Anaconda3\envs\u-sleep\lib\site-packages\yamlhparams\yaml_hparams.py", line 152, in save_current with open(out_path, "w") as out_f: FileNotFoundError: [Errno 2] No such file or directory: 'C:\dataset_configurations\dcsm.yaml'

The issue is occurring in generating the out_file_path in init.py because when the sub directory dataset_configurations is derived there is a backslash "" at the beginning of the string, so os.path.join ignores the first entry.

I was able to fix the issue by editing the line 101 in init.py sub_dir = dir_path.replace(hparams_in_dir, "").strip("/").strip('\\')

sindrijonsson avatar Sep 26 '22 20:09 sindrijonsson

Happened to me on Windows but not on Linux, the fix does the job well.

Shubhamcl avatar Apr 20 '23 13:04 Shubhamcl