ObsidianToAnki / Obsidian_to_Anki

Script to add flashcards from text/markdown files to Anki
GNU General Public License v3.0
1.48k stars 131 forks source link

Only working the first time when Anki open #77

Closed BrayanDSO closed 3 years ago

BrayanDSO commented 3 years ago

I open Anki and run the script and it works well. If I try to run it again, it keeps stuck at "Removing Empty notes..." The only way to run it again is to close the script, close Anki and start them again

ddfonseca commented 3 years ago

Why don't you explain in more detail? Where is the attached file that make this? Are you using which version of python? OS? etc..

BrayanDSO commented 3 years ago

With some tests I discovered this is related to #76. The first run it stucks at the final, at the "Replacing tags..." prompt. The notes are created correctly, but I have to force close the task. The later runs stuck at the "Remove empty files" prompt. Probably it's a problem with AnkiConnect communication

ddfonseca commented 3 years ago

Hmm, maybe, this script still need to handle with some errors

tedblizzard commented 3 years ago

It would be good to have update output such as how many files and cards it is processing and what stage the script is in. If this script would work it is a game-changer for Obsidian. I am using Obsidian only in experimental mode. I use RemNote for the core notetaking app because it has SRS. But I am already an Anki user. What can be done to help move this script forward?

ddfonseca commented 3 years ago

What can be done to help move this script forward?

For me, the script works just fine. I'm using it with Obsidian for the core notetaking app. It's been amazing!

BrayanDSO commented 3 years ago

For me, the script works just fine. I'm using it with Obsidian for the core notetaking app. It's been amazing!

Same for me

Raagaception commented 3 years ago

Try out v2.2.2 It's got no bugs, I'm using that until the author updates the script to a working version.

Pseudonium commented 3 years ago

Yes, I should really see if I can add some better error-handling to the script...

@Raagaception What issues were you having?

Raagaception commented 3 years ago

@Pseudonium It works completely fine now, I think it's an issue where people who've been using the older version of the code (without ID comments) try to use the newer script, they get an error maybe? I'm able to use the latest version with no issues since quite a few weeks. Thanks a ton 👍

Pseudonium commented 3 years ago

This might be to do with the volume of the requests the script is giving.

Essentially, each request to AnkiConnect has some base time requirement. If I sent a single "addNote" request for every note in the database, it'd probably take hours!

So what I do is package many small requests into a big request. I do this at the file-level, then at the directory-level, then at the app-level (three tiers!). So overall the script maybe sends about 5 HTTP requests total - it's just that they're very, very big!

Unfortunately, AnkiConnect doesn't provide a way of tracking current progress through a request, so I can't really give an indication of that in the script. They're just big requests! What I can do, though, is a suggestion in pull request #94, which might speed up requests for large amounts of files.

I should also probably get around to doing some better print statements for the script at some point. But for now, I'll close this issue.

Pseudonium commented 3 years ago

As an example, I personally have about 2.9k cards added with the script, and each execution now takes around 10 minutes!