askap-vast / vast-post-processing

MIT License
0 stars 0 forks source link

vast_post_processing breaks due to inability to create log file #59

Closed ddobie closed 8 months ago

ddobie commented 8 months ago
(post-processing-ddobie-v2) ubuntu@vast-data:~/ddobie$ vast_post_processing --data-root=/data/VAST/vast-data/TILES/ --stokes=I --epoch=42
Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/bin/vast_post_processing", line 6, in <module>
    sys.exit(app())
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/site-packages/typer/main.py", line 532, in wrapper
    return callback(**use_params)  # type: ignore
  File "/mnt/home/ubuntu/ddobie/vast-post-processing/vast_post_processing/cli/vast_post_processing.py", line 95, in main
    core.run(
  File "/mnt/home/ubuntu/ddobie/vast-post-processing/vast_post_processing/core.py", line 722, in run
    main_logger = logutils.setup_logger(verbose=verbose, debug=debug)
  File "/mnt/home/ubuntu/ddobie/vast-post-processing/vast_post_processing/utils/logutils.py", line 58, in setup_logger
    main_logger = create_logger(
  File "/mnt/home/ubuntu/ddobie/vast-post-processing/vast_post_processing/utils/logutils.py", line 100, in create_logger
    handler = logging.FileHandler(filename=filename + ".log")
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/logging/__init__.py", line 1146, in __init__
    StreamHandler.__init__(self, self._open())
  File "/home/ubuntu/miniconda3/envs/post-processing-ddobie-v2/lib/python3.9/logging/__init__.py", line 1175, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding,
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/home/ubuntu/ddobie/vast-post-processing/vast_post_processing/data/full/2023-10-29T21:32:27+00:00.log'

Problem is here: https://github.com/askap-vast/vast-post-processing/blob/8cd5bebfd548b239aee3648e6fa1ca41dff74889/vast_post_processing/utils/logutils.py#L58-L60

There's no check to see if DATA_SUBDIRECTORIES[module] exists. Fix is just to create that directory if it doesn't already exist.