import os
import shutil
from fastcore.all import *
= '/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms'
base_path = '/Users/cck/writings/fractal-llms-nbs/nbs' dest_path
def is_lesson(o):
return "/fractal-llms/0" in str(o)
# files relevant to the lessons
= [
file_formats ".ipynb",
".jpg",
".png",
".gif",
".jpeg",
".svg",
".txt",
".md",
]
def is_lesson_content(o):
return Path(o).suffix in file_formats
# point to the base notebook repo
= Path(base_path)
bp # find all notebook folders in order
= bp.ls().sorted()
bp = bp.filter(is_lesson); lessons
lessons
lessons
(#8) [Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/00-Overview'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/01-env'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/02-nbdev'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/03-hf-nlp-models'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/05-rag'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/06-text-data'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/07-fine-tuning')]
for lesson in lessons:
# make a new home for the notebooks
= lesson.name
name = Path(dest_path)/name
new_lesson =True)
new_lesson.mkdir(exist_ok
# copy over the content
for o in lesson.ls().filter(is_lesson_content):
if o.suffix == ".ipynb":
= f'{name}.ipynb'
fid_name else:
= o.name
fid_name /fid_name) shutil.copy(o, new_lesson
-4].ls().filter(is_lesson_content) lessons[
(#5) [Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama/llama_description.png'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama/llama-cpp-logo.png'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama/llama_model_support.png'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama/mistral_quantized.png'),Path('/Users/cck/writings/chaski/nbs/blog/posts/fractal-llms/04-llama/index.ipynb')]
o.name
'00-Overview'