Automate

Automate
!pip list | grep fast
fastai                    2.7.15
fastAIcourse              0.0.170        /home/ben/BENEDICT_Only/DL/FastAI_course
fastbook                  0.0.29
fastcore                  1.5.45
fastdownload              0.0.7
fastjsonschema            2.19.1
fastprogress              1.0.3

Upload Automation


source

prep

 prep (p:int=2)

Export, test, and clean notebooks, and render README if needed

Type Default Details
p int 2 Increment Part
Exported source
from fastcore.script import *

@call_parse
def prep(
    p:int = 2, # Increment Part
):
    "Export, test, and clean notebooks, and render README if needed"

    import nbdev.test, nbdev.clean, nbdev.quarto, nbdev.release
    nbdev.release.nbdev_bump_version(p)
    
    nbdev.quarto.nbdev_export.__wrapped__()
    print(f'### nbdev_export finished ###')
    nbdev.test.nbdev_test.__wrapped__(
        n_workers = 8,  # Number of workers
        timing = True,  # Time each notebook to see which are slow
    )
    print(f'### nbdev_test finished ###')
    nbdev.clean.nbdev_clean.__wrapped__()
    print(f'### nbdev_clean finished ###')
    nbdev.quarto.refresh_quarto_yml()
    print(f'### refresh_quarto_yml finished ###')
    nbdev.quarto.nbdev_readme.__wrapped__(chk_time=True)
    print(f'### nbdev_readme finished ###')

source

gacp

 gacp (m:str='')

git add, commit and push to github

Type Default Details
m str Commit message
Exported source
@call_parse
def gacp(
    m:str = '', # Commit message
):
    "git add, commit and push to github"
    
    import subprocess
    subprocess.run(["git", "add", "."])
    print(f'### git added ###')
    status = subprocess.check_output(["git", "status", "-s"]).decode('utf-8')
    print(f'### git status: "{status}" ###')

    if m != '':
        subprocess.run(["git", "commit", "-m", f'{m}'])
        print(f'### git commited "{m}"###')
    else:
        subprocess.run(["git", "commit", "-m", f'{status}'])
        print(f'### git commited status ###')
    subprocess.run(["git", "push"])
    print(f'### git pushed ###')

source

status

 status ()

git status

Exported source
def status():
    "git status"
    import subprocess
    subprocess.run(["git", "status"])

source

upload

 upload (m:str='', p:int=2)

prep, then gacp

Type Default Details
m str Commit message
p int 2 Increment part
Exported source
@call_parse
def upload(    
    m:str = '', # Commit message
    p:int = 2, #Increment part
):
    "prep, then gacp"
    prep(p)
    gacp(m)

source

reinstall

 reinstall ()

runs pip install -e .

Exported source
def reinstall():
    "runs pip install -e ."
    import subprocess
    subprocess.run(["pip", "install", "-e", "."])

source

update

 update ()

prep, then reinstall

Exported source
def update():
    "prep, then reinstall"
    prep()
    reinstall()

Release Automation


source

release_git

 release_git ()

release to git

Exported source
def release_git():
    "release to git"
    import nbdev.release
    nbdev.release.nbdev_bump_version(1)
    nbdev.release.release_git()

source

release_pypi

 release_pypi ()

release to pypi

Exported source
def release_pypi():
    "release to pypi"
    import nbdev.release
    nbdev.release.release_pypi()

source

release

 release ()

release to github and pip

Exported source
def release():
    "release to github and pip"
    release_git()
    release_pypi()

Help funtion

console_help?
Object `console_help` not found.

source

help_output

 help_output ()

Show help for all console scripts

Exported source
def help_output():
    "Show help for all console scripts"
    from fastcore.xtras import console_help
    console_help('nbdevAuto')

Single Command


source

everything

 everything ()

prep, gacp, release, reinstall

Exported source
def everything():
    "prep, gacp, release, reinstall"
    upload()
    update()
    release()

Auto create conda env


source

create_env

 create_env (n:str='fast')

create conda env for AI

Type Default Details
n str fast Name of the environment
Exported source
@call_parse
def create_env(
    n:str = 'fast', #Name of the environment 
):
    "create conda env for AI"
    from pathlib import Path
    import subprocess
    
    subprocess.run(["conda", "create", "-n", f"{n}", "python"])
    subprocess.run(["conda", "init"])
    subprocess.run(["conda", "activate", f"{n}"], shell=True)
    # subprocess.run(["pip", "install", "fastai", "fastcore"])

source

hello

 hello ()
Exported source
def hello():
    import argparse
    parser = argparse.ArgumentParser(description='My CLI function.')
    parser.add_argument('-n', '--name', type=str, help='Name of the environment', default='fast')
    args = parser.parse_args()
    
    print(f'Hello, {args.name}!')
hello()
usage: ipykernel_launcher.py [-h] name
ipykernel_launcher.py: error: unrecognized arguments: -f
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

Submit

import nbdev.test, nbdev.clean, nbdev.quarto
nbdev.quarto.nbdev_export.__wrapped__()
!cd .. && update
Old version: 0.0.140
New version: 0.0.141
### nbdev_export finished ###
Success.
01_Automate.ipynb: 0 secs
00_Functions.ipynb: 0 secs
02_PDF_reader.ipynb: 0 secs
index.ipynb: 0 secs
### nbdev_test finished ###
### nbdev_clean finished ###
### refresh_quarto_yml finished ###
### nbdev_readme finished ###
Obtaining file:///home/ben/BENEDICT_Only/Auto/nbdevAuto
  Preparing metadata (setup.py) ... done
Requirement already satisfied: graphviz in /home/ben/miniconda3/envs/pfast/lib/python3.12/site-packages (from nbdevAuto==0.0.141) (0.20.3)
Installing collected packages: nbdevAuto
  Attempting uninstall: nbdevAuto
    Found existing installation: nbdevAuto 0.0.140
    Uninstalling nbdevAuto-0.0.140:
      Successfully uninstalled nbdevAuto-0.0.140
  Running setup.py develop for nbdevAuto
Successfully installed nbdevAuto-0.0.141
!h
create_env                create conda env for AI
everything                prep, gacp, release, reinstall
gacp                      git add, commit and push to github
gitrelease                release to git
h                         Show help for all console scripts
hello                     None
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
status                    git status
update                    prep, then reinstall
upload                    prep, then gacp

Requirements

requirements = fastdownload>=0.0.5,<2 fastcore>=1.5.29,<1.6 torchvision matplotlib pandas requests pyyaml fastprogress>=0.2.4 pillow>6.0.0 scikit-learn scipy spacy<4 packaging fastbook twine conda_requirements = pytorch>=1.7,<2.1 dev_requirements = ipywidgets pytorch-lightning pytorch-ignite transformers sentencepiece tensorboard pydicom catalyst flask_compress captum>=0.3 flask wandb kornia scikit-image neptune-client comet_ml albumentations opencv-python pyarrow catalyst ninja timm>=0.6.2.dev accelerate>=0.10.0

Back to top