<jupyter_start><jupyter_text>Library imports<jupyter_code>import os
from nbdev import *
from nbdev.showdoc import *
from nbdev_colab import *
from pathlib import Path
from getpass import getpass
import urllib<jupyter_output><empty_output><jupyter_text>Command line template> A minimal template for a 'command line notebook' to manage an nbdev project in Google Colaboratory.    Clone a new repository to Google Drive<jupyter_code>clone_new_repo()
# after successful clone you should be in the cloned repo directory - check
!pwd
!ls
# verify the clone by printing out (and checking) settings.ini
! cat settings.ini<jupyter_output><empty_output><jupyter_text>If the repo cloned successfully, but either git user configuration or installing git hooks failed then use the following code to perform these tasks manually.<jupyter_code>!git config user.email "<github username>"
!git config user.name "<email>"
!nbdev_install_git_hooks<jupyter_output><empty_output><jupyter_text>Building and testing project files with nbdev<jupyter_code># check the CWD is the desired project directory
% cd /content/drive/My Drive/nbd_colab
!pwd
!ls
!nbdev_build_lib
!nbdev_build_docs
!nbdev_diff_nbs<jupyter_output><empty_output><jupyter_text>If nbdev_diff_nbs gives an output, run either notebook2script() or script2notebook() to fix the conflict.To keep the notebook code (most common)<jupyter_code># from nbdev.export import notebook2script
# notebook2script()<jupyter_output><empty_output><jupyter_text>or, to keep the script code:<jupyter_code># from nbdev.sync import script2notebook
# script2notebook()<jupyter_output><empty_output><jupyter_text>Run tests. Don't forget the optional `--flags` attribute if you want to overide test_flags.<jupyter_code>!nbdev_test_nbs<jupyter_output><empty_output><jupyter_text>Push to GitHub.<jupyter_code># check the CWD is the desired project directory
% cd /content/drive/My Drive/nbd_colab
!pwd
!ls
!git status
!git add -A
!git status
!git commit -am "commit msg"
!git push<jupyter_output><empty_output><jupyter_text>Occasionally we'll want to pull as well<jupyter_code># !git pull<jupyter_output><empty_output><jupyter_text>Upload package to PyPi To upload your library to PyPi as a package, there must be a valid _pypirc file in the user's home directory on Google drive (see nbdev docs to set this up)<jupyter_code>! pip install twine
# check the CWD is the desired project directory
% cd /content/drive/My Drive/nbd_colab
!pwd
!ls
! make release<jupyter_output><empty_output><jupyter_text>If 'make release' fails with 'file already exists' error, it is likely because of incompatible version numbers between the project repo and PyPi. Solve by bumping the repo version to match PyPi's. This can be done with the `nbdev_bump` or `nbdev_bump_version(part="Part of version to bump")` or by simply editing `settings.ini` to match the PyPi release number. To bumps the repo version number by 0.0.1<jupyter_code># !nbdev_bump<jupyter_output><empty_output><jupyter_text>or, to increment a part of the version number by 1<jupyter_code># !nbdev_bump_version(part="Part of version to bump")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07650621613006056, 'fraction_numerical': 0.0031877590054191903, 'mean_word_length': 6.944303797468354, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '586252', 'license': 'Apache-2.0', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1008, 'n_words': 342, 'path': '04_cltemplate.ipynb', 'repo_name': 'hallmx/nbd_colab', 'size': '3137'}