Skip to content

Commit

Permalink
Merge pull request microsoft#154 from john0isaac/improve-workflow
Browse files Browse the repository at this point in the history
Improve workflow
  • Loading branch information
leestott authored Nov 9, 2023
2 parents aa7e119 + 5fa2dcd commit 67a0fe8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
61 changes: 36 additions & 25 deletions .github/markdown_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def main() -> None:
file_path = os.path.join(
in_arg.dir,
lesson_folder_name,
lesson_file_name )
lesson_file_name)
if in_arg.dir == lesson_folder_name:
file_path = os.path.join(lesson_folder_name, lesson_file_name)
if "check_broken_paths" in in_arg.func:
formatted_output = check_broken_links(file_path, "path" , "broken")
if formatted_output:
Expand Down Expand Up @@ -50,29 +52,36 @@ def get_lessons_paths(root_path: str) -> dict:
Return: formatted dictionary with directories as key and an array of files as values
"""
lessons = {}

# add root path to the dictionary
lessons[root_path] = []
pass_list = ['CODE_OF_CONDUCT.md', 'CONTRIBUTING.md', 'SECURITY.md']
# get lessons folders
for item in os.listdir(root_path):
if os.path.isdir(os.path.join(root_path, item)):
lessons[item] = []

# get lesson exercises (md, ipynb files)
for lesson, _ in lessons.items():
for item in os.listdir(os.path.join(root_path, lesson)):
# check for translations directories
if os.path.isdir(os.path.join(root_path, lesson, item)):
for sub_item in os.listdir(os.path.join(root_path, lesson, item)):
if os.path.isdir(os.path.join(root_path, lesson, item, sub_item)):
for sub_item2 in os.listdir(os.path.join(root_path, lesson, item, sub_item)):
# check for .md and .ipynb files and store them
if sub_item2.lower().endswith(('.md', '.ipynb')):
lessons[lesson].append(os.path.join(item, sub_item, sub_item2))
# check for .md and .ipynb files and store them
elif sub_item.lower().endswith(('.md', '.ipynb')):
lessons[lesson].append(os.path.join(item, sub_item))
# check for .md and .ipynb files and store them
elif item.lower().endswith(('.md', '.ipynb')):
lessons[lesson].append(item)
if lesson != root_path:
for item in os.listdir(os.path.join(root_path, lesson)):
# check for translations directories
if os.path.isdir(os.path.join(root_path, lesson, item)):
for sub_item in os.listdir(os.path.join(root_path, lesson, item)):
if os.path.isdir(os.path.join(root_path, lesson, item, sub_item)):
for sub_item2 in os.listdir(os.path.join(root_path, lesson, item, sub_item)):
# check for .md and .ipynb files and store them
if sub_item2.lower().endswith(('.md', '.ipynb')) and sub_item2 not in pass_list:
lessons[lesson].append(os.path.join(item, sub_item, sub_item2))
# check for .md and .ipynb files and store them
elif sub_item.lower().endswith(('.md', '.ipynb')) and sub_item not in pass_list:
lessons[lesson].append(os.path.join(item, sub_item))
# check for .md and .ipynb files and store them
elif item.lower().endswith(('.md', '.ipynb')) and item not in pass_list:
lessons[lesson].append(item)
# get .md and .ipynb in root directory
for item in os.listdir(root_path):
if item.lower().endswith(('.md', '.ipynb')) and item not in pass_list:
lessons[root_path].append(item)

# check to remove folders that don't have .md files in them
lessons = {key: values for key, values in lessons.items() if len(values) > 0}
Expand All @@ -95,24 +104,24 @@ def check_broken_links(file_path : str, link_type : str , check_type: str) -> st
formatted_output = f" FILE '{file_path}'\n"
if link_type == "path":
paths = get_paths_from_links(all_links)
if check_type == "broken":
if check_type == "broken" and len(paths) > 0:
broken_path = check_paths_exists(file_path, paths)
if len (broken_path) > 0:
formatted_output += f' has the following broken relative paths {broken_path}\n'
return formatted_output
elif check_type == "tracking":
elif check_type == "tracking" and len(paths) > 0:
tracking_id_paths = check_url_tracking(paths)
if len(tracking_id_paths) > 0:
formatted_output += f' has the following paths with no tracking id {tracking_id_paths}\n'
return formatted_output
elif link_type == "url":
urls = get_urls_from_links(all_links)
if check_type == "tracking":
if check_type == "tracking" and len(urls) > 0:
tracking_id_urls = check_url_tracking(urls)
if len(tracking_id_urls) > 0:
formatted_output += f' has the following links with no tracking id {tracking_id_urls}\n'
return formatted_output
elif check_type == "locale":
elif check_type == "locale" and len(urls) > 0:
country_locale_urls = check_url_locale(urls)
if len(country_locale_urls) > 0:
formatted_output += f' has the following links with country locale {country_locale_urls}\n'
Expand All @@ -125,20 +134,22 @@ def get_links_from_file(file_path: str) -> list:
all_links = []
with open(file_path, 'r', encoding="utf-8") as file:
data = file.read()
link_pattern = re.compile(r'\[.*\]\((.*?)\)')
link_pattern = re.compile(r'\]\((.*?)\)| \)')
matches = re.finditer(link_pattern, data)
for matched_group in matches:
all_links.append(matched_group.group(1))
if matched_group.group(1):
all_links.append(matched_group.group(1))
return all_links

def get_urls_from_links(all_links: list) -> list:
"""function to get an array of urls from a list"""
urls = []
url_pattern = re.compile(r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)')

allowed_list = ['github.com', 'microsoft.com', 'visualstudio.com', 'aka.ms', 'azure.com']
for link in all_links:
matches = re.findall(url_pattern, link)
if matches:

if matches and any(allowed in link.lower() for allowed in allowed_list):
urls.append(link)
return urls

Expand Down
4 changes: 2 additions & 2 deletions 00-course-setup/translations/cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

### 1. Fork this Repo

[Fork 这个完整的 repo](https://github.com/microsoft/generative-ai-for-beginners/fork) 到你自己的 GitHub 账号下以便您能完成代码的修改和完成相关的挑战. 您也可以 [给该 repo star (🌟)](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars?WT.mc_id=academic-105485-koreyst) 让您更容易找到它和相关的 Repo.
[Fork 这个完整的 repo](https://github.com/microsoft/generative-ai-for-beginners/fork?WT.mc_id=academic-105485-koreyst) 到你自己的 GitHub 账号下以便您能完成代码的修改和完成相关的挑战. 您也可以 [给该 repo star (🌟)](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars?WT.mc_id=academic-105485-koreyst) 让您更容易找到它和相关的 Repo.

### 2. 创建 GitHub Codespaces

Expand Down Expand Up @@ -88,7 +88,7 @@ jupyterhub

## 贡献该内容

本课程是一项开源计划。 如果您发现需要改进的地方或问题,请创建 [Pull Request](https://github.com/microsoft/generative-ai-for-beginners/pulls) 或记录 [Github 问题](https://github.com/microsoft/generative-ai-for-beginners/issues?WT.mc_id=academic-105485-koreyst)
本课程是一项开源计划。 如果您发现需要改进的地方或问题,请创建 [Pull Request](https://github.com/microsoft/generative-ai-for-beginners/pulls?WT.mc_id=academic-105485-koreyst) 或记录 [Github 问题](https://github.com/microsoft/generative-ai-for-beginners/issues?WT.mc_id=academic-105485-koreyst)

课程项目团队将跟踪所有贡献,为开源做出贡献是在生成人工智能领域建立职业生涯的绝佳方式。

Expand Down
4 changes: 2 additions & 2 deletions translation/cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## 🌱 如何开始

首先,将 [整个repo fork ](https://github.com/microsoft/generative-ai-for-beginners/fork) 到您自己的 GitHub 帐户,以便能够更改任何代码并完成相关学习。 您还可以[(🌟)该 Fork](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars?WT.mc_id=academic-105485-koreyst)以便稍后更容易地找到它!
首先,将 [整个repo fork ](https://github.com/microsoft/generative-ai-for-beginners/fork?WT.mc_id=academic-105485-koreyst) 到您自己的 GitHub 帐户,以便能够更改任何代码并完成相关学习。 您还可以[(🌟)该 Fork](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars?WT.mc_id=academic-105485-koreyst)以便稍后更容易地找到它!

前往[课程学习环境设置](../../00-course-setup/translations/cn/README.md?WT.mc_id=academic-105485-koreyst) 找到最适合您的设置指南!

Expand All @@ -48,7 +48,7 @@
| | 课程链接 | 相关教学内容 | 学习目标 |
| :---: | :------------------------------------: | :---------------------------------------------------------: | ----------------------------------------------------------- |
| 00 | [课程介绍和学习环境设置](../../00-course-setup/translations/cn/README.md?WT.mc_id=academic-105485-koreyst) | 学习环境配置和课程结构 | 在学习本课程的同时帮助您取得成功 |
| 01 | [生成式人工智能和 LLMs 介绍](../../01-introduction-to-genai//translations/cn/README.md?WT.mc_id=academic-105485-koreyst) | **知识点**: 生成式人工智能以及我们如何适应当前的技术格局 | 了解什么是生成式人工智能 以及 LLMs 的工作原理。 |
| 01 | [生成式人工智能和 LLMs 介绍](../../01-introduction-to-genai/translations/cn/README.md?WT.mc_id=academic-105485-koreyst) | **知识点**: 生成式人工智能以及我们如何适应当前的技术格局 | 了解什么是生成式人工智能 以及 LLMs 的工作原理。 |
| 02 | [探索和比较不同的 LLMs](../../02-exploring-and-comparing-different-llms/translations/cn/README.md?WT.mc_id=academic-105485-koreyst) | **知识点**: 测试、迭代和比较不同的 LLMs 模型 | 为您的应用场景选择正确的模型 |
| 03 | [负责任地使用生成式人工智能](../../03-using-generative-ai-responsibly/translations/cn/README.md?WT.mc_id=academic-105485-koreyst)| **知识点:** 了解基础模型的局限性和人工智能背后的风险 | 了解如何负责任地构建生成式人工智能应用程序
| 04 | [提示工程基础](../../04-prompt-engineering-fundamentals/translations/cn/README.md?WT.mc_id=academic-105485-koreyst) | **代码/知识点:** 提示工程最佳实践| 了解提示结构和用法|
Expand Down

0 comments on commit 67a0fe8

Please sign in to comment.