taylormitchell / ankify_roam

A command-line tool which brings flashcards created in Roam to Anki.
MIT License
36 stars 6 forks source link

[[Bug]] Some cloze cards are failing to import? #38

Closed Etyre closed 2 years ago

Etyre commented 2 years ago

When I run ankify roam, I'm getting the error message bellow.

From going through and looking at the individual blocks...

Any thoughts / suggestions?

2021-12-06 08:49:35,565 - INFO - Setting up Ankifier
2021-12-06 08:49:38,663 - INFO - Loading Roam Graph
2021-12-06 08:50:00,624 - INFO - Fetching blocks to ankify
2021-12-06 08:50:00,940 - INFO - Ankifying 520 blocks
2021-12-06 08:51:58,571 - ERROR - Failed ankifying <Block(uid='Cd9cwEhyr', string='sin(θ) is ...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:51:58,669 - ERROR - Failed ankifying <Block(uid='nNKkUDUUP', string='sin(θ) is ...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:39,619 - ERROR - Failed ankifying <Block(uid='ftOpDJaz7', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:40,206 - ERROR - Failed ankifying <Block(uid='EmR0zLCeV', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:44,669 - ERROR - Failed ankifying <Block(uid='WCfXhdjRj', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:51,807 - ERROR - Failed ankifying <Block(uid='xI_w3JKSC', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:53,426 - ERROR - Failed ankifying <Block(uid='OBg1F2jof', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:52:54,009 - ERROR - Failed ankifying <Block(uid='FFMKiKxfX', string='If a funct...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:53:01,810 - ERROR - Failed ankifying <Block(uid='nOwj0CbLQ', string='The first ...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:53:02,876 - ERROR - Failed ankifying <Block(uid='OlmEvvMLL', string='The second...')> during upload to anki
Traceback (most recent call last):
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/ankifiers.py", line 83, in ankify
    anki.add_note(anki_note)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 52, in add_note
    return _invoke("addNote", note=anki_dict)
  File "/Users/elityre/Library/Python/3.8/lib/python/site-packages/ankify_roam/anki.py", line 37, in _invoke
    raise GenericResponseError(response['error'])
ankify_roam.anki.GenericResponseError: cannot create note for unknown reason
2021-12-06 08:55:28,934 - INFO - Added 17 new notes and updated 493 existing notes
taylormitchell commented 2 years ago

@Etyre Could you export the page as json and send it to me? Or create a new page with a couple blocks on it which produce the error and export that

Etyre commented 2 years ago

Sure. I can't attach a JSON file to a issue-message in GitHub, so I just emailed you.

Let me know if you figure anything out!

Etyre commented 2 years ago

An update: I think that all of these blocks include a cloze deletion and most (but not all of them) include a greek letter, either θ, α, or π.

Etyre commented 2 years ago

Update on this: I as near as I can tell, cloze deletions blocks, in general, have stopped importing for me.

Looking at my decks and which blocks cause the errors, I don't think that any of my cloze deletion cards have been imported almost a year. (The last ones that I can definitely pinpoint are from July 2021).

Do you have any idea what's up with that? Or a suggestion about what I should do to troubleshoot here?

taylormitchell commented 2 years ago

Very strange! I haven't had any issues with cloze deletions on my end. I remember trying to replicate this shortly after you'd reported the issue and wasn't able to. I'll try again later this week with the export you provided already on the latest version and see if I have any luck

Etyre commented 2 years ago

Any updates on this?

I have a growing pile of cloze deletion cards that fail to import every time I run ankify_roam, and I don't have any guesses about what might be going wrong.

taylormitchell commented 2 years ago

I think I found the problem. I was able to replicate using the "Calculus for the Forgetful.json" you'd sent me previously and fix on my end. Looks like the "Roam Cloze" note type created using ankify_roam init-models had an issue.

If you can confirm the fix works before I deploy to master, that'd be great. If I don't hear back in a few days I'll go ahead deploy. Here are the steps to check the fix:

Let me know if it works!

Etyre commented 2 years ago

Sorry for the delay. I must have missed this my email. (I'll keep an eye out going forward).

When I go look at "Roam Cloze" in "Note Types", it looks like there are 155 notes of that category. (Which makes sense to me. I made a lot of cloze cards before that stopped working.)

I'm hesitant to delete the note type for fear of deleting those cards.

I could still follow these other steps though, if that seems likely to help.

Etyre commented 2 years ago

Follow up on this?

taylormitchell commented 2 years ago

Hey sorry, this fell off my radar.

Here's a modified version of the steps above which will keep the existing cloze notes you have:

If this doesn't work, or you're still worried about breaking something, let me know and let's hop on a call to do it together.

Etyre commented 2 years ago

I'm wanting to try this on a different computer than my main one, so that if I mess it up I don't delete a bunch of my cards. Waiting until I have access to another machine.

Etyre commented 2 years ago

I finally got my hands on a backup computer, and some time away from work.

Unfortunately, when I run ankify_roam init-models, I get the following error message.

(base) atlasfellowship@Claires-MBP-4 ~ % ankify_roam init-models
Traceback (most recent call last):
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/http/client.py", line 946, in connect
    self.sock = self._create_connection(
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/socket.py", line 844, in create_connection
    raise err
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/socket.py", line 832, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/atlasfellowship/opt/anaconda3/bin/ankify_roam", line 8, in <module>
    sys.exit(main())
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/site-packages/ankify_roam/cli.py", line 141, in main
    func(**args)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/site-packages/ankify_roam/cli.py", line 28, in init_models
    models = add_default_models(overwrite=overwrite)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/site-packages/ankify_roam/default_models.py", line 274, in add_default_models
    modelNames = anki.get_model_names()
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/site-packages/ankify_roam/anki.py", line 122, in get_model_names
    return _invoke("modelNames")
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/site-packages/ankify_roam/anki.py", line 24, in _invoke
    response = json.load(urllib.request.urlopen(request))
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/Users/atlasfellowship/opt/anaconda3/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>
(base) atlasfellowship@Claires-MBP-4 ~ % 
Etyre commented 2 years ago

Ah. That was because I needed to install Anki connect, though.

Etyre commented 2 years ago

Ok. As near as I can tell, that worked. All 79 close cards that have been piling up, failing to import are now in my deck.

Woo!

Thank you so much for your help. I'm looking forward to going back to relying heavily on cloze cards.

The updated version of Ankify_roam did cause a new problem, of a sort, but that's unrelated, so I'll make a new thread for it.

taylormitchell commented 2 years ago

Awesome and no problem! Sorry it took so long, but I'm glad it's finally working for you :D