Browse Source

!325 Add a python script for create sig-info yaml

Merge pull request !325 from jxl/master
pull/326/MERGE
i-robot Gitee 2 years ago
parent
commit
e622fbce9a
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 215 additions and 1 deletions
  1. +4
    -0
      sigs/README.md
  2. +4
    -0
      sigs/README_en.md
  3. +129
    -0
      sigs/create_sig_info_template.py
  4. +1
    -1
      sigs/security/OWNERS
  5. +77
    -0
      sigs/security/sig-info.yaml

+ 4
- 0
sigs/README.md View File

@@ -42,3 +42,7 @@ SIG的全称是Special Interest Groups,即“特别兴趣小组”。MindSpore
当你和你的朋友有了非常好的技术idea,并且希望更多的人参与到你们的探索中,那么你就可以申请成立一个新的SIG了,点击下面的链接即可查看申请流程。

[申请流程](https://gitee.com/mindspore/community/blob/master/sigs/dx/docs/How%20to%20build%20a%20SIG%20or%20WG_cn.md)

## 创建描述SIG的yaml文件

为了将您创建的SIG在MindSpore官网展示,需要使用该目录下的create_sig_info_template.py创建一个yaml文件来描述SIG的相关信息,yaml文件的格式说明可以[参考这里](https://gitee.com/openeuler/community/blob/master/sig/README.md)。

+ 4
- 0
sigs/README_en.md View File

@@ -51,3 +51,7 @@ the steering committee. The chair facilitates the discussion and helps
synthesize proposals and decisions.

[Propose now!](https://gitee.com/mindspore/community/blob/master/sigs/dx/docs/How%20to%20build%20a%20SIG%20or%20WG_cn.md)

## Create a yaml file for description your SIG

To display the SIG you created on MindSpore's official website, you need to use create_sig_info_template.py to create a yaml file to describe SIG related information. The format of the yaml file can be referred [here](https://gitee.com/openeuler/community/blob/master/sig/README.md).

+ 129
- 0
sigs/create_sig_info_template.py View File

@@ -0,0 +1,129 @@
import os

import yaml
import sys


def load_yaml(file_path):
"""
load yaml
:param file_path: yaml file path
:return: content of yaml
"""
with open(file_path, encoding="utf-8") as fp:
try:
content = yaml.load(fp.read(), Loader=yaml.Loader)
except yaml.MarkedYAMLError as e:
print(e)
sys.exit(1)
return content


def get_sig_owners_path(sig_name):
cur_path = os.popen("pwd").read().replace("\n", "")
sig_path = os.path.join(cur_path, sig_name)
if not os.path.exists(sig_path):
print("%s is not exist" % sig_path)
sys.exit(1)
owners_path = os.path.join(sig_path, "OWNERS")
return sig_path, owners_path


def make_template_file_data_and_write(sig_name, sig_path, owners_path):
content = {}
content["name"] = sig_name
content["description"] = "TO_BE_CLARIFIED"
content["created_on"] = "2019-12-31"
content["mailing_list"] = "TO_BE_CLARIFIED"
content["meeting_url"] = "TO_BE_CLARIFIED"
content["mature_level"] = "startup"
content["mentors"] = [{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED", "email": "TO_BE_CLARIFIED"}]

# if sig_info.yaml exists
if os.path.exists(os.path.join(sig_path, "sig-info.yaml")):
sig_info_content = load_yaml(os.path.join(sig_path, "sig-info.yaml"))
content["description"] = sig_info_content.get("description") if sig_info_content.get("description") else "TO_BE_CLARIFIED"
content["meeting_url"] = sig_info_content.get("meeting_url") if sig_info_content.get("meeting_url") else "TO_BE_CLARIFIED"
content["mailing_list"] = sig_info_content.get("mailing_list") if sig_info_content.get("mailing_list") else "TO_BE_CLARIFIED"

mts_in_sig_info = []
for i in sig_info_content.get("maintainers"):
mts_in_sig_info.append(i["gitee_id"])

v = []
for m in decode_owners(owners_path):
if m in mts_in_sig_info:
for mr in sig_info_content.get("maintainers"):
if m == mr["gitee_id"]:
v.append({
"gitee_id": m, "name": mr.get("name") if mr.get("name") else "TO_BE_CLARIFIED",
"organization": mr.get("organization") if mr.get("organization") else "TO_BE_CLARIFIED",
"email": mr.get("email") if mr.get("email") else "TO_BE_CLARIFIED",
})
else:
v.append({"gitee_id": m, "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED",
"email": "TO_BE_CLARIFIED"})

if len(v) == 0:
content["maintainers"] = [
{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED",
"email": "TO_BE_CLARIFIED"}]
else:
content["maintainers"] = v

else:
v = []
for m in decode_owners(owners_path):
v.append({"gitee_id": m, "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED",
"email": "TO_BE_CLARIFIED"})

if len(v) == 0:
content["maintainers"] = [
{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED",
"email": "TO_BE_CLARIFIED"}]
else:
content["maintainers"] = v

repos = []
for root, dirs, files in os.walk(sig_path):
if len(dirs) == 0:
if len(files) == 0:
break
for f in files:
if root.count("/") > 2 and f.endswith(".yaml"):
repos.append(root.split("/")[-2] + '/' + f.split(".yaml")[0])
else:
continue
if len(repos) == 0:
content["repositories"] = [{"repo": ["example/repos1", "example/repos2"], "committers": [{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED", "email": "TO_BE_CLARIFIED"}],
"contributors": [{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED", "email": "TO_BE_CLARIFIED"}],}, {"repo": ["example/repos1", "example/repos2"],}, ]
else:
content["repositories"] = [{"repo": repos, "committers": [{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED", "email": "TO_BE_CLARIFIED"}],
"contributors": [{"gitee_id": "--xxx--", "name": "TO_BE_CLARIFIED", "organization": "TO_BE_CLARIFIED", "email": "TO_BE_CLARIFIED"}], }]
write_yaml_to_sig(sig_path, content)


def decode_owners(owners_path):
if os.path.exists(owners_path):
c = load_yaml(owners_path)
return c["maintainers"]
else:
return []


def write_yaml_to_sig(dst_path, data):
file_path = os.path.join(dst_path, "sig-info.yaml")
with open(file_path, 'w', encoding="utf-8") as f:
yaml.dump(data, f, Dumper=yaml.Dumper, sort_keys=False)


# you can use "python3 create_single_siginfo.py sig_name(example: security)" to auto make a sig_info.yaml for a sig,
# make sure you trigger this command after you enter the "community/sigs" directory
if __name__ == '__main__':
if len(sys.argv) != 2:
print('Required 1 parameters! The sig_name need to be transferred in sequence.')
sys.exit(1)
sig = sys.argv[1]
s_path, o_path = get_sig_owners_path(sig)
make_template_file_data_and_write(sig, s_path, o_path)


+ 1
- 1
sigs/security/OWNERS View File

@@ -1,4 +1,4 @@
approvers:
maintainers:
- jxlang910
- emmmmtang
- zhidanliu


+ 77
- 0
sigs/security/sig-info.yaml View File

@@ -0,0 +1,77 @@
name: security
description: Trusted AI SIG focus on models and data trust technology in the field of artificial intelligence, including model robustness and interpretability, privacy computing, model security deployment, and so on. Our goal is to build a secure and trusted AI computing framework.
created_on: '2019-12-31'
mailing_list: NA
meeting_url: https://etherpad.mindspore.cn/p/meetings-Security
mature_level: startup
mentors:
- gitee_id: jxlang910
name: Mr. JIn
organization: Huawei
email: jinxiulang@huawei.com
- gitee_id: emmmmtang
name: Mr. Tang
organization: Huawei
email: tangcong9@huawei.com
maintainers:
- gitee_id: jxlang910
name: Mr. JIn
organization: Huawei
email: jinxiulang@huawei.com
- gitee_id: emmmmtang
name: Mr. Tang
organization: Huawei
email: tangcong9@huawei.com
- gitee_id: Mr_GerhardtHu_Fox
name: Mr. Hu
organization: Northeast University
email: 780308144@qq.com
repositories:
- repo:
- mindspore/mindarmour
committers:
- gitee_id: jxlang910
name: Mr. JIn
organization: Huawei
email: jinxiulang@huawei.com
- gitee_id: emmmmtang
name: Mr. Tang
organization: Huawei
email: tangcong9@huawei.com
- gitee_id: ZhidanLiu
name: Miss Liu
organization: Huawei
email: liuzhidan5@huawei.com
- gitee_id: pkuliuliu
name: Mr. Liu
organization: Huawei
email: NA
contributors:
- gitee_id: liu_luobin
name: Mr. Liu
organization: Huawei
email: NA
- gitee_id: limingjun1
name: Mr. Li
organization: Zhejiang University of Technology
email: NA
- gitee_id: hu2175
name: Rice Zhang
organization: Zhejiang University
email: 8623924@qq.com
- gitee_id: qmckw
name: Kewei
organization: Huazhong University of Science and Technology
email: 2512235663@qq.com
- repo:
- mindspore/mindspore
committers:
- gitee_id: jxlang910
name: Mr. JIn
organization: Huawei
email: jinxiulang@huawei.com
contributors:
- gitee_id: shazi4399
name: Mr. Zhang
organization: Beijing University of Posts and Telecommunications
email: NA

Loading…
Cancel
Save