Skip to content

Added the ability to commit changes with nb #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion nbs/save_nb.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,21 @@ def last_saved():
if elapsed < 1: print('Correct conversion!')
else: print(f'Total elapsed time {elapsed:.0f} s')
print(strftime("%d-%m-%Y %H:%M:%S", gmtime()))
return int(elapsed)
return int(elapsed)

# Cell
from git import Repo # needs gitpython
from nbdev.export import Config as nb_Config
from nbdev.export import *

def git_add(fname, commit_msg='.'):
repo = Repo(nb_Config().nbs_path.parent)
notebook2script(fname)
nb = read_nb(fname)
default = find_default_export(nb['cells'])
py = [os.path.join(nb_Config().lib_path,*default.split('.'))+'.py',
os.path.join(nb_Config().nbs_path,fname)
]
repo.index.add(py)
repo.index.commit(commit_msg)
return py
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ license = apache2
status = 2

# Optional. Same format as setuptools requirements
requirements = sktime pyunpack fastai2 psutil nbdev
requirements = sktime pyunpack fastai2 psutil nbdev gitpython
# Optional. Same format as setuptools console_scripts
# console_scripts =

Expand Down