Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update remove_existing_renders to only delete qhub related files/directories #800

Merged
merged 6 commits into from
Sep 24, 2021

Conversation

iameskild
Copy link
Member

Closes #767

The approach taken will only remove files/directories found in the deletable_dirs list. In the linked issue, the acceptance criteria specifies removing all os.remove and shutil.rmtree logic so my current solution employs Path object methods (which essentially do the same thing).

I have also added a verbosity flag (currently set to 0 - none) if and when we would like to output the list of files/directories being deleted.

All feedback is welcome :)


for deletable_dir in deletable_dirs:
deletable_dir = dest_repo_dir / deletable_dir
if deletable_dir.exists():
Copy link
Member

Choose a reason for hiding this comment

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

Ah. Sorry I shouldn't have mentioned that os.remove and shutil.rmtree shouldn't be used. I meant that more generally that long term i'd like to minimize the number of times that we make this call! Since it's a scary operation.

I'm fine with using shutil.rmtree here and I think that will dramatically reduce the code here.T his should remove all the walking in the code.

Also deletable_dirs should include .gitlab-ci.yml.

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it! Thanks for the feedback. And I agree, using shutil.rmtree would be preferred.

Copy link
Member

@costrouc costrouc left a comment

Choose a reason for hiding this comment

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

Thanks @iameskild this looks great to me and worked when I tested it locally.

@costrouc costrouc merged commit bc80e7c into nebari-dev:main Sep 24, 2021
@iameskild iameskild deleted the GH767_EE branch September 27, 2021 05:17
leej3 added a commit that referenced this pull request Nov 25, 2021
leej3 added a commit that referenced this pull request Nov 25, 2021
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.

[bug] Running QHub within home directory will delete files in home directory
2 participants