Creating Pypi Library

I’ve been utilizing nbdev to generate webpages from GitHub repositories. However, nbdev’s main function is to produce Python libraries for distribution via conda and pip. I’ve developed a Python library named NbdevAuto for this purpose.
Author

Benedict Thekkel

Published

April 22, 2024

NbdevAuto

https://bthek1.github.io/nbdevAuto/functions.html

This automation library was created for the perpose of speed up common daily task.

Like for example, after pip install nbdevAuto. The cli command upload will automatically:

  • nbdev_clean
  • nbdev_export
  • git add .
  • git push.
!pip list | grep nbdevAuto
nbdevAuto                           0.0.112     /home/ben/BENEDICT_Only/Benedict_Projects/Benedict_ML/nbdevAuto

cli commands created

!h
create_cfast              create mamba env cfast
everything                prep, gacp, release, reinstall
gacp                      git add, commit and push to github
gitrelease                release to git
h                         Show help for all console scripts
piprelease                release to pypi
prep                      Export, test, and clean notebooks, and render README if needed
reinstall                 runs pip install -e .
release                   release to github and pip
update                    prep, then reinstall
upload                    prep, then gacp

Also, the library contains function to simplify download images for the internet for image classification deep learning like:

from nbdevAuto.functions import *
download_pic?
Signature:
download_pic(
    image: str,
    n_images: int = 1,
    name: str = '',
    folder: str = '',
    show_progress: bool = False,
    recreate: bool = False,
)
Docstring: Downloads the image into the folder provided and displays it
File:      ~/BENEDICT_Only/Benedict_Projects/Benedict_ML/nbdevAuto/nbdevAuto/functions.py
Type:      function
download_pic('bird',
             n_images = 1,
             folder = './Data',
             show_progress=False,
             recreate = True)

create_data_folder?
Signature:
create_data_folder(
    folder_path: str,
    searches: tuple,
    before: str = '',
    after: str = '',
    amount: int = 200,
    recreate: bool = False,
    show_progress: bool = False,
)
Docstring: generate image data
File:      ~/BENEDICT_Only/Benedict_Projects/Benedict_ML/nbdevAuto/nbdevAuto/functions.py
Type:      function

For downloading kaggle files

kaggle_competition_download??
Signature: kaggle_competition_download(name: str, folderpath: str = './Data')
Source:   
def kaggle_competition_download(name:str, folderpath:str = './Data'):
    'download competition files from kaggle'
    import os
    import shutil
    from pathlib import Path
    
    iskaggle = os.environ.get('KAGGLE_KERNEL_RUN_TYPE', '')
    if iskaggle: path = Path(f'../input/{name}')
    else:
        path = Path(f'{folderpath}/{name}')
        if path.exists():print("file exists")
        else:
            import zipfile,kaggle
            kaggle.api.competition_download_cli(competition = name, path = path)
            zipfile.ZipFile(f'{path}/{name}.zip').extractall(path)
File:      ~/BENEDICT_Only/Benedict_Projects/Benedict_ML/nbdevAuto/nbdevAuto/functions.py
Type:      function
Back to top