Stvad / CrowdAnki

Plugin for Anki SRS designed to facilitate cooperation on creation of notes and decks.
MIT License
536 stars 43 forks source link

Failed to import .json on Anki Version 2.1.29 #92

Closed hno2 closed 4 years ago

hno2 commented 4 years ago

Hey all,

I have trouble importing a json exported by CrowdAnki, and importing from disk. This error happens after clicking OK in the Import Settings when card personal fields are selected. No cards are imported after this message. I am not sure wether this is an error of Anki or of CrowdAnki. Anyway here is the error message.

Error Message ``` Error An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site. Debug info: Anki 2.1.29 (bbff62bf) Python 3.8.0 Qt 5.15.0 PyQt 5.15.0 Platform: Mac 10.15.5 Flags: frz=True ao=True sv=1 Add-ons, last update check: 2020-08-01 12:06:30 Add-ons possibly involved: ⁨CrowdAnki JSON exportimport Edit history Collaborate on deck creation⁩ Caught exception: Traceback (most recent call last): File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/anki/ui/action_vendor.py", line 31, in lambda: AnkiJsonImporter.import_deck(self.window.col, self.directory_vendor)) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 112, in import_deck AnkiJsonImporter.import_deck_from_path(collection, Path(directory_path)) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 101, in import_deck_from_path if importer.load_deck(directory_path): File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 39, in load_deck deck.save_to_collection(self.collection, import_config=import_config) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 131, in save_to_collection self.save_decks_and_notes(collection=collection, File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 154, in save_decks_and_notes note.save_to_collection(collection, self, model_map_cache, import_config=import_config) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/note.py", line 125, in save_to_collection self.anki_object.flush() File "anki/notes.py", line 67, in flush AssertionError ```

Can you give me a hint, wether this is a problem on my side, in the json or with CrowdAnki.

Thanks for your support!

hno2 commented 4 years ago

Just to confirm: This issue does not happen on Version 2.1.26 (70784154) but on Version 2.1.29.

ohare93 commented 4 years ago

Hi mate, sorry to hear that. I downloaded your deck json and can confirm I could import it several times with no issues. I selected none, some, and all fields as personal, with no issue whoops I wasn't on the latest version of Anki, and am having build issues getting it working. Will need some time to test it out properly. Hmm... :thinking: I did not try with the media though, could you attach a zip file here (as it seems difficult to download just one folder of a git repo)?

The area where the error happens is on flushing data in anki itself :thinking: Perhaps the issue is with your setup. Could you try some/all of these and try again:

hno2 commented 4 years ago

Thanks @ohare93 for your quick reply!

I was able to verify this (or similar) issue with a new profile and no other add-ons. (Please note that the base issue was seen on a clean install of Anki with only CrowdAnki installed). I did some try and error to find out when exactly the error happens and the error message seems to depend on the Deck Parts to Use Option and not on the personal field options.

Media and Notes selected Importing the .json (now with images as .zip attached) and selecting no personal field will lead to a Change Note Type Dialog. Here no matter what Note Type is selected will lead to this error. Please note that this error also happens when clicking Cancel.

Error Message Notes and Media selected (Change Note Type) ``` An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site. Debug info: Anki 2.1.29 (bbff62bf) Python 3.8.0 Qt 5.15.0 PyQt 5.15.0 Platform: Mac 10.15.5 Flags: frz=True ao=True sv=1 Add-ons, last update check: 2020-08-01 12:06:30 Add-ons possibly involved: ⁨CrowdAnki JSON exportimport Edit history Collaborate on deck creation⁩ Caught exception: Traceback (most recent call last): File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/anki/overrides/change_model_dialog.py", line 169, in accept self.collection.models.change(self.old_model, self.note_id_list, self.targetModel, field_map, templates_map) File "anki/models.py", line 412, in change AssertionError ```

Neither Media nor Notes selected If I deselect Notes and Media in the Import Dialog, no error happens, but no cards are imported.

Only Notes selected I get the immediately get the error message as described in original issue.

Error Message Only Notes selected ``` Error An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue on the add-on support site. Debug info: Anki 2.1.29 (bbff62bf) Python 3.8.0 Qt 5.15.0 PyQt 5.15.0 Platform: Mac 10.15.5 Flags: frz=True ao=True sv=1 Add-ons, last update check: 2020-08-01 12:06:30 Add-ons possibly involved: ⁨CrowdAnki JSON exportimport Edit history Collaborate on deck creation⁩ Caught exception: Traceback (most recent call last): File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/anki/ui/action_vendor.py", line 31, in lambda: AnkiJsonImporter.import_deck(self.window.col, self.directory_vendor)) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 112, in import_deck AnkiJsonImporter.import_deck_from_path(collection, Path(directory_path)) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 101, in import_deck_from_path if importer.load_deck(directory_path): File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/importer/anki_importer.py", line 39, in load_deck deck.save_to_collection(self.collection, import_config=import_config) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 131, in save_to_collection self.save_decks_and_notes(collection=collection, File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/deck.py", line 154, in save_decks_and_notes note.save_to_collection(collection, self, model_map_cache, import_config=import_config) File "/Users/username/Library/Application Support/Anki2/addons21/1788670778/representation/note.py", line 125, in save_to_collection self.anki_object.flush() File "anki/notes.py", line 67, in flush AssertionError ```

Only Media selected No error message but no import.

I hope this can help to debug this issue. Thanks in Advance!

Deep_Learning_for_CV.zip

motla commented 4 years ago

I confirm this issue!

ohare93 commented 4 years ago

Just had some time to have a look at this issue, but my failing Anki build is really hampering my debug attempts :disappointed: @Stvad have you looked into this? Seems like Anki 2.1.30 really broke a lot of add-ons.

A quick temporary fix is to reinstall the current stable release of Anki 2.1.26 https://apps.ankiweb.net/ and we can update here when 2.1.30 is fixed :sweat: @hno2 @motla