in cli/readme.py [0:0]
def write_readme(jobs, endpoints, resources, assets, scripts, schedules):
# read in prefix.md and suffix.md
with open("prefix.md", "r") as f:
prefix = f.read()
with open("suffix.md", "r") as f:
suffix = f.read()
# define markdown tables
jobs_table = "\n**Jobs** ([jobs](jobs))\n\npath|status|description\n-|-|-\n"
endpoints_table = (
"\n**Endpoints** ([endpoints](endpoints))\n\npath|status|description\n-|-|-\n"
)
resources_table = (
"\n**Resources** ([resources](resources))\n\npath|status|description\n-|-|-\n"
)
assets_table = "\n**Assets** ([assets](assets))\n\npath|status|description\n-|-|-\n"
scripts_table = "\n**Scripts**\n\npath|status|\n-|-\n"
schedules_table = "\n**Schedules**\n\npath|status|\n-|-\n"
# process jobs
for job in jobs:
# build entries for tutorial table
posix_job = job.replace(os.sep, "/")
job_name = posix_job.replace("/", "-")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-{job_name}.yml)"
description = "*no description*"
try:
with open(f"{job}.yml", "r") as f:
for line in f.readlines():
if "description: " in str(line):
description = line.split(": ")[-1].strip()
break
except:
pass
# add row to tutorial table
row = f"[{posix_job}.yml]({posix_job}.yml)|{status}|{description}\n"
jobs_table += row
# process endpoints
for endpoint in endpoints:
# build entries for tutorial table
posix_endpoint = endpoint.replace(os.sep, "/")
endpoint_name = posix_endpoint.replace("/", "-")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-{endpoint_name}.yml)"
description = "*no description*"
try:
with open(f"{endpoint}.yml", "r") as f:
for line in f.readlines():
if "description: " in str(line):
description = line.split(": ")[-1].strip()
break
except:
pass
# add row to tutorial table
row = f"[{posix_endpoint}.yml]({posix_endpoint}.yml)|{status}|{description}\n"
endpoints_table += row
# process resources
for resource in resources:
# build entries for tutorial table
posix_resource = resource.replace(os.sep, "/")
resource_name = posix_resource.replace("/", "-")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-{resource_name}.yml)"
description = "*no description*"
try:
with open(f"{resource}.yml", "r") as f:
for line in f.readlines():
if "description: " in str(line):
description = line.split(": ")[-1].strip()
break
except:
pass
# add row to tutorial table
row = f"[{posix_resource}.yml]({posix_resource}.yml)|{status}|{description}\n"
resources_table += row
# process assets
for asset in assets:
# build entries for tutorial table
posix_asset = asset.replace(os.sep, "/")
asset_name = posix_asset.replace("/", "-")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-{asset_name}.yml)"
description = "*no description*"
try:
with open(f"{asset}.yml", "r") as f:
for line in f.readlines():
if "description: " in str(line):
description = line.split(": ")[-1].strip()
break
except:
pass
# add row to tutorial table
row = f"[{posix_asset}.yml]({posix_asset}.yml)|{status}|{description}\n"
assets_table += row
# process scripts
for script in scripts:
# build entries for tutorial table
posix_script = script.replace(os.sep, "/")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-scripts-{script}.yml)"
link = f"https://scripts.microsoft.com/azure/machine-learning/{script}"
# add row to tutorial table
row = f"[{posix_script}.sh]({posix_script}.sh)|{status}\n"
scripts_table += row
# process schedules
for schedule in schedules:
# build entries for tutorial table
posix_schedule = schedule.replace(os.sep, "/")
status = f"[](https://github.com/Azure/azureml-examples/actions/workflows/cli-schedules-{posix_schedule}.yml)"
link = (
f"https://schedules.microsoft.com/azure/machine-learning/{posix_schedule}"
)
# add row to tutorial table
row = f"[{posix_schedule}.yml]({posix_schedule}.yml)|{status}\n"
schedules_table += row
# write README.md
print("writing README.md...")
with open("README.md", "w") as f:
f.write(
prefix
+ scripts_table
+ jobs_table
+ endpoints_table
+ resources_table
+ assets_table
+ schedules_table
+ suffix
)
print("Finished writing README.md...")