in sdk/python/readme.py [0:0]
def write_readme(notebooks, pipeline_folder=None):
prefix = "prefix.md"
suffix = "suffix.md"
readme_file = "README.md"
if pipeline_folder:
prefix = os.path.join(pipeline_folder, prefix)
suffix = os.path.join(pipeline_folder, suffix)
readme_file = os.path.join(pipeline_folder, readme_file)
if BRANCH == "":
branch = "main"
else:
branch = BRANCH
# read in prefix.md and suffix.md
with open(prefix, "r") as f:
prefix = f.read()
with open(suffix, "r") as f:
suffix = f.read()
# define markdown tables
notebook_table = f"Test Status is for branch - **_{branch}_**\n|Area|Sub-Area|Notebook|Description|Status|\n|--|--|--|--|--|\n"
for notebook in notebooks:
# get notebook name
name = notebook.split(os.sep)[-1].replace(".ipynb", "")
area = notebook.split(os.sep)[0]
sub_area = notebook.split(os.sep)[1]
folder = os.path.dirname(notebook)
classification = folder.replace(os.sep, "-")
try:
# read in notebook
with open(notebook, "r", encoding="utf-8") as f:
data = json.load(f)
description = "*no description*"
try:
if data["metadata"]["description"] is not None:
description = data["metadata"]["description"]["description"]
except BaseException:
pass
except BaseException:
print("Could not load", notebook)
pass
if any(excluded in notebook for excluded in NOT_TESTED_NOTEBOOKS):
description += " - _This sample is excluded from automated tests_"
if any(excluded in notebook for excluded in NOT_SCHEDULED_NOTEBOOKS):
description += " - _This sample is only tested on demand_"
if pipeline_folder:
notebook = os.path.relpath(notebook, pipeline_folder)
# write workflow file
notebook_table += (
write_readme_row(
branch,
notebook.replace(os.sep, "/"),
name,
classification,
area,
sub_area,
description,
)
+ "\n"
)
print("writing README.md...")
with open(readme_file, "w") as f:
f.write(prefix + notebook_table + suffix)
print("finished writing README.md")