langfield / ki

version control for Anki collections
https://langfield.github.io/ki/
GNU Affero General Public License v3.0
70 stars 3 forks source link

Upload deck to github #124

Closed AkimfromParis closed 1 year ago

AkimfromParis commented 1 year ago

Hey guys,

I want to upload one particular deck (not my full collection) to my GitHub in order to work in a collaborative way. Should I use git commands or do you have particular ki commands?

Thx!

langfield commented 1 year ago

@AkimParis Yes, there is a script for this. See here. It hasn't been used in a while, so I may need to spruce it up for you a bit. Let me know how you fair, and I'll fix any problems you run into! 😁

Basically, you run this script and then just git push within the particular deck, and it should work!

AkimfromParis commented 1 year ago

I am sorry but I am confused about the syntax...

git-submodule push DeckName https://github.com/name/XYZ.git or git push DeckName https://github.com/name/XYZ.git

Thx!

langfield commented 1 year ago

Try this:

python3 ./<path_to_script>/submodule.py --kirepo <path_to_ki_repository> --deck <deck_name> --remote git@github.com:name/xyz.git

Make sure you give it the correct location of the submodule.py script, which I linked above. Also make sure to use the proper path separators for your operating system.

Note that this will create a remote pointing to the URL given, but it will not push to that remote. You must do that yourself.

langfield commented 1 year ago

@AkimParis Any luck?

AkimfromParis commented 1 year ago

I couldn't find the submodule.py... Did you change something?!

langfield commented 1 year ago

Hi, there is a link to the script above. Here it is!

AkimfromParis commented 1 year ago

Sorry dude but I don't have a submodule.py in my local KI folder...

langfield commented 1 year ago

Hi @AkimParis, sorry for the misunderstanding. You are not supposed to have such a script anywhere inside the repository. The script is available at the link I provided. You must either clone this project to get the script, or download it directly at that link. It is not installed anywhere on your $PATH by default.

AkimfromParis commented 1 year ago

Alright, I clone the submodule and pip install git-filter-repo... It seems to work. I got a small problem identifying the path of the kirepo and the deck.

It's the paths: ki -> C:\Users\Name\anaconda3\Lib\site-packages\ki ... decks -> C:\Users\Name\collection

Error: ki.types.NotKiRepoError: fatal: not a ki repository (or any parent up to mount point /) Stopping at filesystem boundary.

Almost there... : )

langfield commented 1 year ago

Hi! In the example I gave you, the --kirepo argument is the path to your collection repository, called a kirepo/ki repository because it is created by ki, but I understand the confusion. It is not the path to your local clone or installation of this project itself. The --deck argument is the path to the specific deck you want to host on Github.

If you cloned your collection into your home directory at collection/, and the deck you want to upload is collection/Default/a/, then from your home directory, you would run:

python3 ./<path_to_script>/submodule.py --kirepo collection --deck Default/a/ --remote git@github.com:name/xyz.git

Try running python3 submodule.py --help if you're having trouble!

AkimfromParis commented 1 year ago

Sorry, I don't use Git a lot at work, so I am confused. Ok, I understand better now.

My full CLI to share my deck on my GitHub: python C:\Users\Kikim\anaconda3\Lib\site-packages\ki\submodule.py --kirepo collection --deck c:/users/kikim/collection/Vocabulary-JAP-AI-NLP-CV-AkimfromParis --remote git@github.com/AkimParis/anki_jap_ai_vocabulary.git

And I got the following answer: Operating on 'C:\Users\Kikim\AppData\Local\Temp\tmpgp0kr6bc\submodule-143551385322c4974405cf0de1bc7135b285f7a8' Error: --path-rename expects one colon in its argument: .

I believe something is going on with git-filter-repo....

langfield commented 1 year ago

Try passing a relative path to the deck:

python C:\Users\Kikim\anaconda3\Lib\site-packages\ki\submodule.py --kirepo collection --deck Vocabulary-JAP-AI-NLP-CV-AkimfromParis --remote [git@github.com](mailto:git@github.com)/AkimParis/anki_jap_ai_vocabulary.git

See the help text for this script:

(anki) user@computer:~/pkgs/pyki$ python3 submodule.py --help
usage: submodule.py [-h] --kirepo KIREPO --deck DECK --remote REMOTE

optional arguments:
  -h, --help       show this help message and exit
  --kirepo KIREPO  Path (relative or absolute) to a ki repo containing the subdeck which is to be
                   converted into a submodule. This is the directory that is created when you run
                   `ki clone`, and is usually called `collection`. It should contain a `.ki`
                   subdirectory.

  --deck DECK      Relative path from the root of the ki repo to the subdeck which is to be
                   converted into a submodule.

  --remote REMOTE  A git remote URL. This could be one of the following.

                   SSH remote of the form:     `git@github.com:user/submodule.git`
                   HTTPS remote of the form:   `https://github.com/user/submodule.git`

                   In the above examples, you should replace `user` with the relevant username,
                   and `submodule` with the relelvant repo name. If you are using a hosted git
                   server other than `github.com`, then you should replace `github.com` with the
                   relevant URL.
AkimfromParis commented 1 year ago

Ok, I switched from SSH to HTTPS. And it worked...

It's more than 400 flashcards in Japanese for vocabulary about machine learning (from statistics to deep learning models). Now, I will ask Japanese developers for help on Qiita. Hopefully, they will help with this deck. ; )

langfield commented 1 year ago

Glad it's working for you! 😄