Giter Site home page Giter Site logo

Comments (12)

klieret avatar klieret commented on June 8, 2024 1

I'd say this looks like it's working, so I'll close this issue, but feel free to write more or re-open if anything should arise :)

from ankipandas.

klieret avatar klieret commented on June 8, 2024

Thanks a lot for letting me know!

Hmm, that's strange. Perhaps that's a similar error to #36 and has to do with changes introduced by the Anki 2.1.26/2.1.28beta.

What Anki version are you using? And are you running this on a completely empty collection or are there already some cards/notes/models?

And could you run the following snippet:

import ankipandas
from ankipandas.raw import get_info

col = ankipandas.Collection()
model_info = get_info(col.db)["models"]
print(type(model_info))
print(model_info)

and send me the output?

This would help me to track down what's happening there.

(I'm on holidays though, so I might be a bit slow to reply)

from ankipandas.

brownbat avatar brownbat commented on June 8, 2024

I've only tried building the latest build of Anki on my VM, so I've used the collection with v.1.3.1+ here. It's not an empty or new deck, it was exported from a deck originally used in Anki 2.1.26.

Looks like models is getting an empty string, not sure why.

thomas@thomas-VirtualBox:~/PycharmProjects/anki$ python3

Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ankipandas
>>> from ankipandas.raw import get_info
>>> col = ankipandas.Collection()
INFO: Searching for database. This might take some time. You can speed this up by specifying a search path or directly entering the path to your database.
WARNING: The search will stop at the first hit, so please verify that the result is correct (for example in case there might be morethan one Anki installations)
INFO: Loaded db from /home/thomas/.local/share/Anki2/User 1/collection.anki2
>>> model_info = get_info(col.db)["models"]
>>> print(type(model_info))
<class 'str'>
>>> print(model_info)

>>> 

That's a one line gap there, doesn't appear to contain a space or anything. After that, to confirm the collection has something in it, I ran col.cards just to be sure, here's the first line:

>>> col.cards
                         nid  cord        cmod  cusn  ... cleft codue  cdeck  codeck
cid                                                   ...                           
1589630886942  1589220255215     2  1597756833    -1  ...     0     0 
...

No rush for my benefit. I think you're right on my other comment, I need some other way to generate a set of test decks, maybe genanki.

Good luck with this one, let me know if there's anything else I can do to help test.

from ankipandas.

klieret avatar klieret commented on June 8, 2024

Ah, I've updated to the newest stable release and see what's going on there. Basically the way anki saved the configuration in the database has changed slightly, but it should be possible to adapt.

from ankipandas.

klieret avatar klieret commented on June 8, 2024

The new version of ankipandas should now support the new db format.

If you want, you could help by testing if it works for you.

To update ankipandas, do

pip3 install --user --upgrade ankipandas

from ankipandas.

brownbat avatar brownbat commented on June 8, 2024

col.notes now works like a charm.

Your earlier testing recommendations don't survive, but maybe you know that already.

>>> get_info(col.db)
{1: {'crt': 1597392000, 'mod': 1598225343106, 'scm': 1598220616405, 'ver': 15, 'dty': 0, 'usn': 0, 'ls': 0, 'conf': '', 'models': '', 'decks': '', 'dconf': '', 'tags': ''}}

So I have to subscript that get_info call with [1]["models"] instead of just "models", and it ends up empty.

But col.notes and col.cards have integers in nmod and cmod, and col.notes has strings in nmodel that track to my note types, so there are models floating around in there. Maybe that means everything's working as expected.

from ankipandas.

brownbat avatar brownbat commented on June 8, 2024

Output on col.cards and col.notes, for the curious.

>>> col.cards
                         nid  cord        cmod  cusn     ctype cqueue   cdue  civl  cfactor  creps  clapses  cleft  codue                             cdeck                          codeck
cid                                                                                                                                                                                        
1589630886942  1589220255215     2  1597756833    -1  learning    new    718     0     2500      0        0      0      0    Korean3 Transcription1 Vocab                                
1589630886944  1589220255216     2  1597756833    -1  learning    new   2046     0     2500      0        0      0      0    Korean3 Transcription1 Vocab                                
1589630886946  1589220255217     2  1597756833    -1  learning    new   1459     0     2500      0        0      0      0    Korean3 Transcription1 Vocab                                
1589630886950  1589220255220     2  1597756832    -1   relearn    due -99971    32     2900      3        0      0     19                   Filtered Deck 1  Korean3 Transcription1 Vocab
1589630886952  1589220255221     2  1597756833    -1  learning    new    965     0     2500      0        0      0      0    Korean3 Transcription1 Vocab                                
...                      ...   ...         ...   ...       ...    ...    ...   ...      ...    ...      ...    ...    ...                               ...                             ...
1597361145241  1597361136294     2  1597756833    -1  learning    new   1729     0        0      0        0      0      0  Korean3 Transcription2 Phrases                                
1597361145244  1597361136295     2  1597756833    -1  learning    new    691     0        0      0        0      0      0  Korean3 Transcription2 Phrases                                
1597361145247  1597361136296     2  1597756833    -1  learning    new   2983     0        0      0        0      0      0  Korean3 Transcription2 Phrases                                
1597361145250  1597361136297     2  1597756833    -1  learning    new   2513     0        0      0        0      0      0  Korean3 Transcription2 Phrases                                
1597361145253  1597361136298     2  1597756833    -1  learning    new   1061     0        0      0        0      0      0  Korean3 Transcription2 Phrases                                

[5330 rows x 15 columns]
>>> col.notes
                    nguid        nmod  nusn                  ntags                                              nflds       nmodel
nid                                                                                                                               
1589220255215  u>q;4An(mn  1595335887    -1             [modified]  [한국, Korea, The formal name of the country is ...   HTSK Vocab
1589220255216  gx^T0_ayJs  1595335887    -1             [modified]  [도시, city, , 대도시 = a large city<br>신도시 = a new...   HTSK Vocab
1589220255217  Aua_I=*8L(  1595335887    -1  [duplicate, modified]  [이름, name, , 이름이 뭐예요? = What is your name?<br>...   HTSK Vocab
1589220255220  sB5I5CNw:t  1595335887    -1  [duplicate, modified]  [남자, man, , 잘생긴 남자 = handsome man<br>강한 남자 = s...   HTSK Vocab
1589220255221  Hd>]fb:J&@  1595335887    -1  [duplicate, modified]  [여자, woman, , 예쁜 여자 = pretty girl<br>아름다운 여자 =...   HTSK Vocab
...                   ...         ...   ...                    ...                                                ...          ...
1597361136294  Or~GRLb0h4  1597361133    -1                     []                      [웃음, laughter, a smile, , , ]  HTSK Usages
1597361136295  P~hT^`}adj  1597361133    -1                     []            [웃게 해 주다, to make somebody laugh, , , ]  HTSK Usages
1597361136296  xVwInN0/GS  1597361133    -1                     []                            [건강에 좋다, healthy, , , ]  HTSK Usages
1597361136297  O[y=E>>ogO  1597361133    -1                     []                     [건강 검진, health check up, , , ]  HTSK Usages
1597361136298  FYBq5<JyXC  1597361133    -1                     []                           [현재까지는, until now, , , ]  HTSK Usages

[5330 rows x 6 columns]
>>> get_info(col.db)

from ankipandas.

klieret avatar klieret commented on June 8, 2024

col.notes now works like a charm.

Your earlier testing recommendations don't survive, but maybe you know that already.

>>> get_info(col.db)
{1: {'crt': 1597392000, 'mod': 1598225343106, 'scm': 1598220616405, 'ver': 15, 'dty': 0, 'usn': 0, 'ls': 0, 'conf': '', 'models': '', 'decks': '', 'dconf': '', 'tags': ''}}

So I have to subscript that get_info call with [1]["models"] instead of just "models", and it ends up empty.

But col.notes and col.cards have integers in nmod and cmod, and col.notes has strings in nmodel that track to my note types, so there are models floating around in there. Maybe that means everything's working as expected.

Right, you now need to use ankipandas.raw.get_model_info to retrieve the information.

Perhaps get_info should be renamed to get_collection_info as it now only includes the kind of "global" information. This is a change that was introduced in anki.

from ankipandas.

klieret avatar klieret commented on June 8, 2024

@allcontributors please add @brownbat for bug

from ankipandas.

allcontributors avatar allcontributors commented on June 8, 2024

@klieret

I've put up a pull request to add @brownbat! 🎉

from ankipandas.

klieret avatar klieret commented on June 8, 2024

hmm that didn't work as intended. @allcontributors please add @brownbat for bug

from ankipandas.

allcontributors avatar allcontributors commented on June 8, 2024

@klieret

I've put up a pull request to add @brownbat! 🎉

from ankipandas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.