#2418 replace os.path by pathlib.Path#2461
Conversation
vfdev-5
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR @yuta0821 ! Great work ! I left few comments to improve the code. As there is a lot of modified files, it can take time to review everything. A solution to that could be splitting the PR into mutiple ones, but not required...
@yuta0821 this is OK due to the fact that mlflow uses URI for |
|
@vfdev-5 |
|
@yuta0821 could you please resolve conflicting files |
Thank you for your reply and a lot of comments that helps me very much.
I would appreciate it if you could confirm. |
@yuta0821 you can run all tests with |
…b.com/yuta0821/ignite into feature/#2418_replace_os_path_by_Path
@vfdev-5 Thank you for your advise. I modified some codes to be match with your suggested change. |
|
@yuta0821 sorry I tried to improve type hints but I have to come back to what you did. Sorry for the noise. I restart the CI and if it is successful I think we can merge this PR EDIT: I'll fix the issues reported by the CI and move forward this PR |
Thank you for your try to improve type hints very much.
If there is anything I can do for this PR, please let me know. |
…b.com/yuta0821/ignite into feature/#2418_replace_os_path_by_Path
|
Thanks for the fix @yuta0821 |
|
@vfdev-5 |
|
Hope you enjoyed and learnt while contributing :) |
Fixes #2418
Description:
Environment
In order to construct the test environment, I used docker image
continuumio/miniconda3and install necessary dependencies, following CONTRIBUTING.md.Update code
os.path.exists(folder), os.path.join(a, b), os.makedirs(folder)byPath(folder).exists(), Path(a) / b, Path.mkdir(folder, parents=True), respectively.strtoUnion[str, Path]and make all folder/file-like attributes asPathobjects.filename: str->filename: Union[str, Path]assert isinstance(fname, str)->assert isinstance(fname, str) or isinstance(fname, Path)Test the code
pytest --tx 4*popen//python=python --cov ignite --cov-report term-missing --cov-report xml -vvv tests "${skip_distrib_opt[@]}"I got an error due to this replacement in two test files.
/opt/conda/envs/pytorch-ignite-dev/lib/python3.8/urllib/parse.py:111: in _decode_args return tuple(x.decode(encoding, errors) if x else '' for x in args)=>
AttributeError: 'PosixPath' object has no attribute 'decode'mlflow_logger = MLflowLogger(tracking_uri=Path(dirname) / "mlruns")with MLflowLogger(Path(dirname) / "mlruns") as mlflow_logger:with MLflowLogger(Path(dirname) / "mlruns") as mlflow_logger:mlf_logger = _test_setup_logging(I think it would be better to use the original code using
os.pathwithout this replacement for the part that causes the error.Code Format
In order to check code style, I ran the following commands.
isort . --settings setup.cfgblack . --config pyproject.tomlCheck list: