management/render_processing.py
def add_tag_based_on_content(input_file: Path, tag: str, content: str):
    """
    not all notebook editors are good with tags, but papermill uses it
    to find the parameters cell.
    This injects tag to the file based on the content of a cell
    """
    with open(input_file) as f:
        nb = json.load(f)

    change = False
    for n, cell in enumerate(nb["cells"]):
        if cell["cell_type"] == "code":
            if cell["source"] and content in "".join(cell["source"]):
                tags = cell["metadata"].get("Tags", [])
                if tag not in tags:
                    tags.append("parameters")
                    change = True
                nb["cells"][n]["metadata"]["tags"] = tags

    if change:
        with open(input_file, "w") as f:
            json.dump(nb, f)

    not all notebook editors are good with tags, but papermill uses it
    to find the parameters cell.
    This injects tag to the file based on the content of a cell
    
not all notebook editors are good with tags, but papermill uses it
to find the parameters cell.
This injects tag to the file based on the content of a cell
not all notebook editors are good with tags but papermill uses it to find the parameters cell . This injects tag to the file based on the content of a cell
def add_tag_based_on_content(input_file: Path, tag: str, content: str):
    with open(input_file) as f:
        nb = json.load(f)
    change = False
    for n, cell in enumerate(nb["cells"]):
        if cell["cell_type"] == "code":
            if cell["source"] and content in "".join(cell["source"]):
                tags = cell["metadata"].get("Tags", [])
                if tag not in tags:
                    tags.append("parameters")
                    change = True
                nb["cells"][n]["metadata"]["tags"] = tags
    if change:
        with open(input_file, "w") as f:
            json.dump(nb, f)
def add_tag_based_on_content ( input_file : Path , tag : str , content : str ) : with open ( input_file ) as f : nb = json . load ( f ) change = False for n , cell in enumerate ( nb [ "cells" ] ) : if cell [ "cell_type" ] == "code" : if cell [ "source" ] and content in "" . join ( cell [ "source" ] ) : tags = cell [ "metadata" ] . get ( "Tags" , [ ] ) if tag not in tags : tags . append ( "parameters" ) change = True nb [ "cells" ] [ n ] [ "metadata" ] [ "tags" ] = tags if change : with open ( input_file , "w" ) as f : json . dump ( nb , f )
not all notebook editors are good with tags, but papermill uses it
to find the parameters cell.
not all notebook editors are good with tags but papermill uses it to find the parameters cell .
"""
    not all notebook editors are good with tags, but papermill uses it
    to find the parameters cell.
    This injects tag to the file based on the content of a cell
    """
input_file
Path
tag
str
content
str