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

Improve polling and logging #86

Closed
wants to merge 25 commits into from
Closed

Conversation

deldesir
Copy link
Collaborator

@deldesir deldesir commented Jan 3, 2024

This PR has following changes:
- Enhanced logging.
- Added more detailed error handling for database operations and subprocess execution.
- Wrapped database operations in a try-except block for better error handling.
- Ensured consistent progress updates.

Tested on Ubuntu 24.04 (10.8.0.70)

@deldesir deldesir added the enhancement New feature or request label Jan 3, 2024
@deldesir deldesir self-assigned this Jan 3, 2024
Comment on lines 48 to 68
if "creating" in line:
self.progress += 0.025
log.info("Download progress: %s", self.progress)
if "Running ANALYZE" in line:
self.progress = 0
line = p.stdout.readline()
if "extracting" in line:
self.message = "Downloading media..."
self.progress += 0.077
elif "downloading" in line:
self.progress += 0.077
elif "download" in line:
self.progress += 0.077
elif "merging" in line:
self.progress += 0.077
elif "adding" in line:
self.progress += 0.075
break
else:
self.progress += 0.077
log.info("Download progress: %s", self.progress)
Copy link
Member

@holta holta Jan 3, 2024

Choose a reason for hiding this comment

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

These lines need more explaining:

  • How were the 8 numbers chosen?
  • Why is 0.077 used 5 times, and 0.075 used once?
  • Why is a break statement now needed with "adding", unlike in the past?
  • Does 0.075 do anything at all, if it breaks out of the while loop, and is overwritten soon after (on Line 102) with self.progress = 1
  • Can the solitary test for "creating" (on Line 48) possibly be made a part of the if-elif-elif-elif-elif-else structure further below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored it and got rid of pattern matching. The logging will be more aligned with #68. However it builds on a customization made to xklb's underlying yt_dlp code, in which I use progress hooks.

Copy link
Member

Choose a reason for hiding this comment

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

builds on a customization made to xklb's underlying yt_dlp code

What xklb or yt-dlp code are you talking about, to help others understand?

in which I use progress hooks

What line number in your code? (Thanks!)

Copy link
Collaborator Author

@deldesir deldesir Jan 4, 2024

Choose a reason for hiding this comment

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

I am talking about this changes:
deldesir/library@f923477

Copy link
Member

@holta holta Jan 4, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I am talking about this changes: chapmanjacobd/[email protected]:library:main

@deldesir please clarify:

AI² = Articulate Assumptions, Intentions & Intuition

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No need to customize xklb. IIAB install instructions remain the same.

@deldesir deldesir marked this pull request as draft January 3, 2024 12:45
This will build upon progress hooks
xklb can be too verbose
@holta
Copy link
Member

holta commented Jan 3, 2024

Is this revised PR tested? (Thanks!)

holta

This comment was marked as duplicate.

@deldesir
Copy link
Collaborator Author

deldesir commented Jan 4, 2024

Is this revised PR tested? (Thanks!)

It's being actively tested on 10.8.0.70. An example test is to try to download this video https://www.youtube.com/watch?v=r2wBcCIlMGw. It will fail, but thanks to enhanced logging we now know why it fails. The error is read from the database too, as suggested by @chapmanjacobd

@deldesir deldesir requested a review from holta January 4, 2024 06:24
@deldesir deldesir marked this pull request as ready for review January 4, 2024 06:25
@holta
Copy link
Member

holta commented Jan 4, 2024

@codewiz is this logging design solid?

Or getting closer?

Show errors in tasks view
@deldesir deldesir marked this pull request as draft January 4, 2024 12:08
@deldesir deldesir marked this pull request as ready for review January 4, 2024 12:21
@holta
Copy link
Member

holta commented Jan 5, 2024

@deldesir please help explain this PR to everyone (AI²).

As well as answering the questions from 27h, 17h and 10h ago — allowing @EMG70 and others to understand what's happening here and test:

Thanks!

@holta
Copy link
Member

holta commented Jan 5, 2024

Just FYI @EMG70 is busy today — but he would like guidance on how to test this PR #86 over the wkd &/or beyond.

Alongside the just merged:

@deldesir
Copy link
Collaborator Author

deldesir commented Jan 6, 2024

QUESTION: Why are commits 322046c and e52ae66 reducing logging verbosity?

Many bugs are very urgently in need of more detailed (or at least most illustrative) logging — rather than less!

Just a few examples here:

* ["Download to IIAB" of Vimeo video ("Staff Pick" URL or regular URL) does not download [and 1 YouTube video too, then 2 YouTube videos worked] #78](https://github.com/iiab/calibre-web/issues/78)

* ["Download to IIAB" worked 5 out of 15 tries (trying to d/l individual YouTube videos) — "Tasks" view screenshots show the 10 failures #84](https://github.com/iiab/calibre-web/issues/84)

* ["Download to IIAB" failures must be shown in "Tasks" view with explanation [e.g. "Media check failed (will try again later)" "Failed reading header" with .mhtml] #85](https://github.com/iiab/calibre-web/issues/85)

I was testing log levels and wanted to find the optimal one to capture efficiently progress information. I will keep lb dl log level to -vv because it's the minimum to set to make this functional.

Summary of this PR:

  • Meaningful errors are logged both in /var/log/calibre-web.log and in the tasks' message column.
  • Download progress information is captured using a temporary polling file - Capturing with "Named Pipe (FIFO)" failed.
  • Messages and progress are reported dynamically in the tasks' view.

NB. A new related PR will be shipped to add a "retry" button in tasks' "actions column.

@holta
Copy link
Member

holta commented Jan 9, 2024

Just FYI I'm not in favor of this PR auto-closing these 3 issues:

(The above 3 issues are certainly related, but they were carefully written up to address larger issues like systemd's journalctl logging that will certainly be needed later, but those things are likely far above and beyond this current PR #86, which needs to remain tightly focused.)

@holta
Copy link
Member

holta commented Jan 9, 2024

FYI @deldesir 955716e was an accidentally destructive commit, reversing several commits from earlier today.

@holta
Copy link
Member

holta commented Jan 9, 2024

Positive: While I don't yet understand this PR's core assumptions...

(it definitely needs more AI² = Articulate Assumptions, Intentions & Intuition)

...the good news is that today it's starting to converge — to become progressively more Clearly Explained + Cleanly Understandable.

deldesir and others added 4 commits January 9, 2024 07:07
Add "format options" instructions to test large size videos.

Co-authored-by: A Holt <[email protected]>
@holta
Copy link
Member

holta commented Jan 10, 2024

FYI this PR #86 inspired...

The goal (as explained there) is smaller PR's and smaller (sometimes even Artisanal?!) ideas:

TDD momentum = Architectural Humility + Collaboration Authenticity

🪜

https://en.wikipedia.org/wiki/A_journey_of_a_thousand_miles_begins_with_a_single_step

@holta
Copy link
Member

holta commented Jan 11, 2024

@holta
Copy link
Member

holta commented Jan 14, 2024

Progress continues:

@holta
Copy link
Member

holta commented May 2, 2024

@deldesir should this PR be closed?

(If so, please explain what is replacing and why, Thanks!)

@deldesir
Copy link
Collaborator Author

deldesir commented May 2, 2024

Yes. It was abandoned in favor of smaller PRs. Already merged #87 was the first one spinned off it.

@holta holta closed this May 2, 2024
@deldesir deldesir deleted the deldesir-polling branch July 1, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants