def add_cells(notebook_path):
with open(notebook_path) as f:
root = notebook_path.split("/")[0]
cell_type = cell.get('cell_type')
sources = cell.get('source')
if cell_type == "markdown":
if source.startswith("<img") and no_markdown == 0:
if source.startswith("# ") and root in source:
if "https://app.naas.ai/user-redirect/naas/downloader" in source:
if "**Tags:**" in source:
tags = source[9:].strip()
if "**Author:**" in source:
author = source[11:].split("[")[-1].split("]")[0]
if source.startswith("## Input"):
if source.startswith("## Model"):
if source.startswith("## Output"):
print("Logo to be added")
if not check_author and check_tags:
print("Author to be added below tags")
cell_logo = {'cell_type': 'markdown',
'metadata': {'papermill': {}, 'tags': ["naas"]},
'source': '<img width="10%" alt="Naas" src="https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160"/>'}
new_cells.append(cell_logo)
cell_type = cell.get('cell_type')
source = cell.get('source')
if cell_type == "markdown":
if "**Tags:**" in source and add_author:
cell_author = {'cell_type': 'markdown',
'metadata': {'papermill': {}, 'tags': ["naas"]},
'source': '**Author:** [Unknown](https://www.linkedin.com/company/naas-ai/)'}
new_cells.append(cell_author)
if add_logo or add_author:
nb_new["cells"] = new_cells
with open(notebook_path, 'w') as f:
print(f"{notebook_path} saved in Naas.")
print("Nothing to be added in notebooks !")