Skip to content

makedirs: fix mode flag is being ignored starting from Python 3.7#2790

Merged
efiop merged 6 commits into
treeverse:masterfrom
shcheklein:fix-2789
Nov 19, 2019
Merged

makedirs: fix mode flag is being ignored starting from Python 3.7#2790
efiop merged 6 commits into
treeverse:masterfrom
shcheklein:fix-2789

Conversation

@shcheklein
Copy link
Copy Markdown
Contributor

Fixes #2789

  • ❗ Have you followed the guidelines in the Contributing to DVC list?

  • 📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.

  • ❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addresses. Please review them carefully and fix those that actually improve code or fix bugs.

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

@shcheklein
Copy link
Copy Markdown
Contributor Author

shcheklein commented Nov 13, 2019

  • probably would be great add some tests for this

@shcheklein shcheklein requested a review from efiop November 13, 2019 22:15
@shcheklein shcheklein requested review from a user and pared and removed request for efiop November 14, 2019 01:04
Comment thread dvc/utils/__init__.py
@pared
Copy link
Copy Markdown
Contributor

pared commented Nov 14, 2019

One comment, also test for 2.7 fails. I tried to reproduce it on my computer, and it seems to fail only for first test run. Maybe something is not unset? Though its done in finally, so I am confused.

Copy link
Copy Markdown
Contributor

@pared pared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment

@shcheklein
Copy link
Copy Markdown
Contributor Author

also test for 2.7 fails

👀

@shcheklein shcheklein requested a review from pared November 14, 2019 22:59
Comment thread dvc/utils/compat.py
@shcheklein shcheklein requested a review from pared November 15, 2019 15:50
Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me; just adding that mode flag still works on >=3.7 but it doesn't affect anymore intermediate directories.

@shcheklein
Copy link
Copy Markdown
Contributor Author

@MrOutis yep! thanks

just adding that mode flag still works on >=3.7 but it doesn't affect anymore intermediate directories.

yep, #2789 (comment)

@shcheklein shcheklein requested a review from efiop November 18, 2019 16:42
Copy link
Copy Markdown
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see two comments up above.

Comment thread dvc/utils/__init__.py
return

umask = os.umask(0)
umask = os.umask(0o777 - mode)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put a comment explaining what is going on :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread tests/func/test_utils.py
def test_makedirs_permissions():
dir_mode = 0o755
intermediate_dir = "тестовая-директория"
test_dir = os.path.join(intermediate_dir, "data")
Copy link
Copy Markdown
Contributor

@efiop efiop Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are creating this directory in the project's root, which is not nice. Please use tmpdir fixture or something like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, simplified using tmpdir

@shcheklein shcheklein requested a review from efiop November 19, 2019 08:33
Copy link
Copy Markdown
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@efiop efiop merged commit 689dd95 into treeverse:master Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

permissions are not set right for directories DVC creates

3 participants