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

[Enhancement] Avoid blocking UI while adding existing repo #1643

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DaffyTheDuck
Copy link

Description

Related Issue

Closes #1306

Motivation and Context

When adding a existing repository the UI freezes, this change might solve this issue

How Has This Been Tested?

I've tested this by adding a repository which is used to crash the UI

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@DaffyTheDuck
Copy link
Author

Hi! @real-yfprojects , is this right ? like the UI is not freezing now, but after reverting back to the old changes I cant reproduce the issue anymore, I've tried editing the settings.db and even deleted the testing version. Any clue what I did wrong ?

@real-yfprojects
Copy link
Collaborator

the UI is not freezing now, but after reverting back to the old changes I cant reproduce the issue anymore

I don't know what you were experiencing before, but this looks good. What happens when you close the dialog, the main window, quit vorta or try to edit anything inside vorta?

@DaffyTheDuck
Copy link
Author

the UI is not freezing now, but after reverting back to the old changes I cant reproduce the issue anymore

I don't know what you were experiencing before, but this looks good. What happens when you close the dialog, the main window, quit vorta or try to edit anything inside vorta?

Hi! Actually that was my mistake 😓 , I was running vorta from the backup repo and reverted the changes in main repo 😓

But is this the required solution ? like are there more changes required ?

@DaffyTheDuck DaffyTheDuck changed the title [Enhancement] Better status message when adding existing repo [Enhancement] Avoid blocking UI while adding existing repo Mar 13, 2023
@real-yfprojects
Copy link
Collaborator

But is this the required solution ? like are there more changes required ?

As I said. This is the right approach. What happens when you close the dialog, the main window or quit vorta?

@DaffyTheDuck DaffyTheDuck force-pushed the issue/1306 branch 2 times, most recently from 005e97f to b250143 Compare March 14, 2023 17:13
@DaffyTheDuck
Copy link
Author

Hi! this seems to work on my machine! waiting for your review 😄

also I've had a question about migrations, how can I perform the migrations 🤔

@real-yfprojects
Copy link
Collaborator

@m3nu What was your Intention with the PR, would you consider it fine when the GUI stays responsive but you still can't do anything else while borg is running?

@m3nu
Copy link
Contributor

m3nu commented Mar 14, 2023

This code was written long ago. It didn't seem important to do, anything else, while adding a repo. No specific consideration.

@DaffyTheDuck
Copy link
Author

This code was written long ago. It didn't seem important to do, anything else, while adding a repo. No specific consideration.

But as per the current GUI, you can not do anything until you close the dialog displayed 🤔

@real-yfprojects
Copy link
Collaborator

also I've had a question about migrations, how can I perform the migrations thinking

Which migrations? Usually vorta migrates its database automatically.

@DaffyTheDuck
Copy link
Author

also I've had a question about migrations, how can I perform the migrations thinking

Which migrations? Usually vorta migrates its database automatically.

Oh, okay, means whenever I run vorta it applies the migrations ?

@real-yfprojects
Copy link
Collaborator

Yes, if needed.

@DaffyTheDuck DaffyTheDuck force-pushed the issue/1306 branch 2 times, most recently from 96f9671 to 85e9d09 Compare March 15, 2023 17:36
@DaffyTheDuck
Copy link
Author

Is this right ?
pip_freezeeeeee

src/vorta/views/repo_add_dialog.py Outdated Show resolved Hide resolved
src/vorta/views/repo_add_dialog.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@real-yfprojects real-yfprojects left a comment

Choose a reason for hiding this comment

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

Is this right?

Besides some minor problems this is right.

thread.result.connect(self.run_result)
self.thread = thread # Needs to be connected to self for tests to work.
self.thread.run()
job = BorgInfoRepoJob(params['cmd'], params)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be queued in the default queue rather than the repo specific queue.

Copy link
Author

Choose a reason for hiding this comment

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

But I guess the BorgInfoRepoJob is used to validate existing repo right ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that's right. You have to pass an extra argument iirc.

Copy link
Author

@DaffyTheDuck DaffyTheDuck Mar 21, 2023

Choose a reason for hiding this comment

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

Yes, that's right. You have to pass an extra argument iirc.

Hi! sorry for being inactive, I was sick 😅

I see the BorgJob accepting 3 params, 2 are already there, the third one should be sending value default by default since it is not provided 🤔 I was wondering how it's deciding about queue (this question might sound dumb but 😅 )

image

image

is this the default value we are talking about 🤔 , because jobs like backup are added to 1 I guess

Copy link
Collaborator

Choose a reason for hiding this comment

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

See this line:

job = BorgCreateJob(msg['cmd'], msg, profile.repo.id)

Copy link
Author

Choose a reason for hiding this comment

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

Hi! added the code, but is there any way to verify it that it is going in default queue since I'm unsure it's working properly :)

@@ -211,6 +214,11 @@ def password_listener(self):
self.passwordLabel.setText(translate('utils', msg))
return not bool(msg)

def cancel_job(self):
if self.job:
self.job.cancel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sadly this only cancelt the job if its already running. If the job manager hasn't picked up the job yet, that is the job still sits in the queue, it won't be cancelled.

Copy link
Author

Choose a reason for hiding this comment

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

Hi! I'm a bit confused testing this, any suggestion on how can I test this ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently there is no way to reproduce this with the GUI. So you can decide not to deal with it but instead write a code comment on the issue.

Copy link
Author

Choose a reason for hiding this comment

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

Currently there is no way to reproduce this with the GUI. So you can decide not to deal with it but instead write a code comment on the issue.

The code will be included in cancel_job method since it will check for both, if running or in queue, should I create a duplicate method for that and comment it ?

Copy link
Author

Choose a reason for hiding this comment

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

Hi! @real-yfprojects , Since this is not reproducible, I'm not sure that the code will work or not, then is it okay to push the code even it is commented ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can only decide after seeing the code.

@real-yfprojects
Copy link
Collaborator

I noticed that the cancel button no longer works.

@DaffyTheDuck
Copy link
Author

I noticed that the cancel button no longer works.

when we try to cancel (close) the add repo dialog without hitting the OK? I noticed that too, I added a try-except block for that in cancel_job 👍🏼 I'll push the code once the default queue change is done 😄

@DaffyTheDuck
Copy link
Author

I noticed that the cancel button no longer works.

The cancel button should work now 👍🏼

Copy link
Collaborator

@real-yfprojects real-yfprojects left a comment

Choose a reason for hiding this comment

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

You are n't setting a meaningful status message yet which was requested in #1306.

Comment on lines 217 to 218
if self.job:
self.job.cancel()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no self.job currently.

Copy link
Author

@DaffyTheDuck DaffyTheDuck Apr 8, 2023

Choose a reason for hiding this comment

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

There is no self.job currently.

Hm! The close() method is working!, but I also noticed that you have to cancel the job within a specific time gap it might vary from machine to machine i guess, but after that time gap it adds the repo anyways

Copy link
Author

Choose a reason for hiding this comment

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

You are n't setting a meaningful status message yet which was requested in #1306.

Screenshot from 2023-04-21 23-10-59

Done 👍🏼

src/vorta/views/repo_add_dialog.py Outdated Show resolved Hide resolved
src/vorta/views/repo_add_dialog.py Outdated Show resolved Hide resolved
src/vorta/views/repo_add_dialog.py Show resolved Hide resolved
- Avoids freezing UI when an existing repo is added

Closes borgbase#1306
@DaffyTheDuck
Copy link
Author

Hi! and sorry I was away leaving this PR open with no activity, I was actually having my Practical exams 😅

I've updated the code accordingly, waiting for your review @real-yfprojects 😄

@real-yfprojects
Copy link
Collaborator

Pls also show a status message while borg init/borg info is running.

@DaffyTheDuck
Copy link
Author

Pls also show a status message while borg init/borg info is running.

Sorry! did not get that exactly

@DaffyTheDuck
Copy link
Author

DaffyTheDuck commented Apr 22, 2023

Pls also show a status message while borg init/borg info is running.

Hi! Did you mean, while the app is backing up the data? l instead of messages like Received SIGTERM or ERROR: Connection closed by remote host it should show Cancelled Adding Repository ? Because it shows the Cancelled adding repository message in AddRepoDialog 🤔

@real-yfprojects
Copy link
Collaborator

real-yfprojects commented Apr 22, 2023

No it should show a message while the repository is accessed (verified) for the first time. Something like Adding repository or something more specific and preferably progress updates if available.

@DaffyTheDuck
Copy link
Author

Hi! @real-yfprojects, sorry, this is taking longer than expected, I'm completely engrossed in preparation of my upcoming semester exam from May 8th. I will be completing this in a slow pace till then.

Sorry for inconvenience :)

@real-yfprojects
Copy link
Collaborator

No worries.

@DaffyTheDuck DaffyTheDuck marked this pull request as draft June 15, 2023 09:46
@real-yfprojects real-yfprojects added the help wanted This issue is available, comment if you want to fix it label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted This issue is available, comment if you want to fix it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better status message when adding existing repo
3 participants