Skip to content

Safe migration from nbdev 1 for a slightly modified setup #998

@Rahuketu86

Description

@Rahuketu86

I am looking for some guidance and clarification on migrating a repository created with nbdev 1 and customized for additional workflow steps. I have followed the instructions on nbdev1 migration tutorial but have identified some issues with which I need some help.

My setup consists of a remote ubuntu server. I usually work on jupyterlab which is exposed over the host IP 0.0.0.0 and prespecified port. In addition to regular nbdev generated docs I also have a jupyterbook folder where I maintained a recipe kind of documentation which could include more things not part of regular library setup.

Issues :

  1. _docs folder is not automatically created with nbdev_preview. In order for preview to work I needed to manually create a folder and then run nbdev_preview [ This explicit step is missing in tutorial]
  2. sidebar is not created in newly generated doc. What is needed to explicitly create the same?
    My generated site looks like this

image

Old site looked like this
image

  1. I am unable to explicitly set host as 0.0.0.0 in nbdev_preview. It would be nice to have that option available in terminal command
  2. After checking nbdev_template repository my guess is (3) can be solved by introducing a custom _quarto.yml. How do I do the same safely without conflicting with settings.ini.[ Which is preferred in event of conflict.

My current settings.ini is as follows :-

[DEFAULT]
# All sections below are required unless otherwise specified
host = github
lib_name = aiking
# For Enterprise Git add variable repo_name and company name
# repo_name = analytics
# company_name = nike

user = rahuketu86
description = A library for checking data quality issues
keywords = Data Quality, Anomaly Detection, outlier, Fastai 
author = Rahul Saraf
author_email = rahuketu86@gmail.com
copyright = Rahul Saraf
branch = master
version = 0.0.1
min_python = 3.6
audience = Developers
language = English
# Set to True if you want to create a more fancy sidebar.json than the default
custom_sidebar = True
# Add licenses and see current list in `setup.py`
license = apache2
# From 1-7: Planning Pre-Alpha Alpha Beta Production Mature Inactive
status = 2

# Optional. Same format as setuptools requirements
# requirements = 
requirements = fastcore fastai>=2.3 seaborn plotnine altair plotly dash jupyter-dash xlrd>=1.2.0 openpyxl pyarrow sqlalchemy hvplot datashader dask[complete] sklearn pyod torch torchvision python-dotenv kaggle  fastdot opencv-python scikit-image imutils moviepy lifelines beautifulsoup4 rich[jupyter] nltk emoji trax 
# azure-cognitiveservices-search-imagesearch
# selenium

dev_requirements = GitPython jupyter-book sphinx-click sphinx_inline_tabs sphinxext-rediraffe~=0.2.3 wandb nbdev<2.0.0 jupyterlab-myst
# Optional. Same format as setuptools console_scripts
# console_scripts = 
# Optional. Same format as setuptools dependency-links
# dep_links = 

###
# You probably won't need to change anything under here,
#   unless you have some special requirements
###

# Change to, e.g. "nbs", to put your notebooks in nbs dir instead of repo root
nbs_path = nbs
doc_path = docs

# Whether to look for library notebooks recursively in the `nbs_path` dir
recursive = False

# Anything shown as '%(...)s' is substituted with that setting automatically
# doc_host =  https://%(user)s.github.io
#For Enterprise Git pages use:  
#doc_host = https://pages.github.%(company_name)s.com.  
url = https://aiking.zealmaker.com
doc_host = https://aiking.zealmaker.com

#doc_baseurl = /%(lib_name)s/
doc_baseurl = /
# For Enterprise Github pages docs use:
# doc_baseurl = /%(repo_name)s/%(lib_name)s/

git_url = https://github.com/%(user)s/%(lib_name)s/tree/%(branch)s/
# For Enterprise Github use:
#git_url = https://github.%(company_name)s.com/%(repo_name)s/%(lib_name)s/tree/%(branch)s/



lib_path = %(lib_name)s
title = %(lib_name)s

#Optional advanced parameters
#Monospace docstings: adds <pre> tags around the doc strings, preserving newlines/indentation.
#monospace_docstrings = False
#Test flags: introduce here the test flags you want to use separated by |
#tst_flags = 
tst_flags = slow|cpp|cuda|ignore
#Custom sidebar: customize sidebar.json yourself for advanced sidebars (False/True)
#custom_sidebar = 
#Cell spacing: if you want cell blocks in code separated by more than one new line
#cell_spacing = 
#Custom jekyll styles: if you want more jekyll styles than tip/important/warning, set them here
jekyll_styles = note,warning,tip,important

and Makefile is as follows

.ONESHELL:
SHELL := /bin/bash
SRC = $(wildcard nbs/*.ipynb)

all: aiking docs mybook

soft: aiking docs

aiking: $(SRC)
	nbdev_build_lib
	touch aiking

sync:
	nbdev_update_lib

docs_serve: docs
	cd docs && bundle exec jekyll serve --host 0.0.0.0

docs: $(SRC)
	nbdev_build_docs
	touch docs

test:
	nbdev_test_nbs

release: pypi conda_release
	nbdev_bump_version

conda_release:
	fastrelease_conda_package

pypi: dist
	twine upload --repository pypi dist/*

dist: clean
	python setup.py sdist bdist_wheel

clean:
	rm -rf dist

mybook:
	echo "Building Book"
	jupyter-book build book/

jl:
	echo "Running Jupyter"
	jupyter lab --ip 0.0.0.0 --port 9000 --no-browser &
  1. How do I safely introduce steps in GitHub workflow/ deploy the website to netlify? [ I can still follow the old way of reading the repo folder]. But having played with the quarto publishing framework. I think it would be easier to use the same. Current workflow with composite action seems comprehensive enough but any guidance for the same is appreciated
    My present action looks like the following:-
name: CI
on: [push, pull_request]

concurrency:
  group: main
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-python@v1
      with:
        python-version: '3.7'
        architecture: 'x64'
    - name: Install the library
      run: |
        sudo apt install -y graphviz
        # pip install nbdev jupyter
        pip install -e .[dev]
    - name: Read all notebooks
      run: |
        nbdev_read_nbs
    - name: Check if all notebooks are cleaned
      run: |
        echo "Check we are starting with clean git checkout"
        if [ -n "$(git status -uno -s)" ]; then echo "git status is not clean"; false; fi
        echo "Trying to strip out notebooks"
        nbdev_clean_nbs
        echo "Check that strip out was unnecessary"
        git status -s # display the status to see which nbs need cleaning up
        if [ -n "$(git status -uno -s)" ]; then echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_git_hooks"; false; fi
    - name: Check if there is no diff library/notebooks
      run: |
        if [ -n "$(nbdev_diff_nbs)" ]; then echo -e "!!! Detected difference between the notebooks and the library"; false; fi
    - name: Run tests
      run: |
        nbdev_test_nbs

    # - name: Install dependencies for book
    #   run: |
    #     # pip uninstall nbdev -y
    #     # pip install -r requirements.txt
    #     pip install -e .[dev]
    - name: Build the book
      run: |
        jupyter-book build book
    # Push the book's HTML to github-pages
    - name: GitHub Pages action
      uses: peaceiris/actions-gh-pages@v3.6.1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: book/_build/html

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions