def remove_pixelserver_from_notebook(file_path):
    """
    Remove pixelserver tracking from a notebook. If the pixcelserver signature found in
    the notebook, the pixelserver cell will be removed from the notebook file. File will
    be modified only when the pixelserver signature is found in it.

    Args:
        file_path (str): The notebook file path.
    """

    with open(file_path, encoding='utf-8') as fd:
        raw_json = json.load(fd)

        if 'cells' not in raw_json:
            return
        
        cells = raw_json['cells']
        pixel_cells = []

        for idx, cell in enumerate(cells):
            if cell['cell_type'] != 'markdown':
                continue
            
            source = cell['source']
            for row in source:
                if row.startswith(SIGNATURE):
                    pixel_cells.append(idx)
                    print("Found pixelserver in file: \"{}\", cell {}".format(file_path, idx))
        
        for cell_id in pixel_cells[::-1]:
            cells.pop(cell_id)

    if pixel_cells:
        with open(file_path, 'w', encoding='utf-8') as fd:
            json.dump(raw_json, fd, indent=1)

    Remove pixelserver tracking from a notebook. If the pixcelserver signature found in
    the notebook, the pixelserver cell will be removed from the notebook file. File will
    be modified only when the pixelserver signature is found in it.

    Args:
        file_path (str): The notebook file path.
    
tools/remove_pixelserver.py