onnx-pytorch icon indicating copy to clipboard operation
onnx-pytorch copied to clipboard

Mistake in `output_dir` and `overwrite` parameters validation

Open Aivean opened this issue 3 years ago • 1 comments

This assert only lets in the following combination of parameter values:

  • output_dir must exist and overwrite=False

https://github.com/fumihwh/onnx-pytorch/blob/2902b4d7cfb0470e2a91e29595ba2dfb8dcee50f/onnx_pytorch/code_gen.py#L317-L319

From the context is seems that other combinations of parameter values should also be valid, such as:

  • output_dir doesn't exist an overwrite is whatever
  • output_dir exist and overwrite=True

I think the fix is to change the clause to:

assert not os.path.exists(
     output_dir 
 ) or overwrite, f"{output_dir} is not empty and overwrite is not True." 

Aivean avatar Jul 05 '21 22:07 Aivean

@Aivean Sorry for late reply. Some PR will resolve this issue.

fumihwh avatar Aug 16 '21 08:08 fumihwh