提交 43a7ce8a 编辑于 作者: Administrator's avatar Administrator
浏览文件

chore: update readme

上级 04c3cc3c
加载中
加载中
加载中
加载中
+7 −5
原始行号 差异行号 差异行
@@ -15,11 +15,12 @@
要从命令行使用该脚本,请切换到该脚本所在目录,用 Python 运行该脚本:

```bash
python submit.py [-h] [-s SERVER] [-k TICKET] [result_path]
python submit.py [-h] [-s SERVER] [-c CONTEST] [-k TICKET] [result_path]
```

* `[result_path]`: 提交的结果文件路径。如果未指定,默认使用当前目录下的 `result.jsonl`
* `[result_path]`提交的结果文件路径。如果未指定,默认使用当前目录下的 `result.jsonl`
* `-s, --server`:指定评测服务器的 URL。如果未提供,将使用脚本中定义的 `JUDGE_SERVER` 变量。
* `-c, --contest`:比赛标识。如果未提供,将使用脚本中定义的 `CONTEST` 变量。
* `-k, --ticket`:团队标识。如果未提供,将使用脚本中定义的 `TICKET` 变量。

## 编程方式提交
@@ -45,13 +46,14 @@ python submit.py [-h] [-s SERVER] [-k TICKET] [result_path]
        # 根据需要添加更多项
    ]

    submission_id = submit(data, judge_server='http://judge.aiops-challenge.com', ticket='YOUR_TEAM_TICKET')
    submission_id = submit(data, judge_server='http://judge.aiops-challenge.com', contest='YOUR_CONTEST_ID', ticket='YOUR_TEAM_TICKET')
    if submission_id:
        print("提交成功!提交 ID: ", submission_id)
    else:
        print("提交失败")
    ```
    
    http://judge.aiops-challenge.com 为评测服务器地址
    在此示例中,请将 `YOUR_CONTEST_ID` 替换为您参加的**比赛ID**,将 `YOUR_TEAM_TICKET` 替换为您的**团队ID**。
    *  **比赛ID** 在比赛的URL中获得,比如"赛道一(Qwen1.5-14B):基于检索增强的运维知识问答挑战赛"的URL为https://competition.aiops-challenge.com/home/competition/1771009908746010681 ,比赛ID为1771009908746010681
    *  **团队ID**需要在参加比赛并组队后能获得,具体在比赛详情页-> 团队 -> 团队ID,为一串数字标识。 
    YOUR_TEAM_TICKET 为团队的ID 
+17 −9
原始行号 差异行号 差异行
@@ -5,24 +5,31 @@ import argparse
from urllib import request, error


# 提交答案服务域名或IP, 将在赛前告知
JUDGE_SERVER = "http://judge.aiops-challenge.com"  # 评测服务地址
# 团队ID, 登陆账号后, 选择对应的比赛, 在团队页面中可以获得。如未注明团队ID,结果不计入成绩
TICKET = "TeamID" # 填团队ID信息
# 提交答案服务域名或IP
JUDGE_SERVER = "http://judge.aiops-challenge.com"
# 比赛ID,可通过比赛界面 URL 获取, 比如"赛道一(Qwen1.5-14B):基于检索增强的运维知识问答挑战赛"的URL为https://competition.aiops-challenge.com/home/competition/1771009908746010681 ,比赛ID为1771009908746010681
CONTEST = None
# 团队ID, 需要在参加比赛并组队后能获得,具体在比赛详情页-> 团队 -> 团队ID,为一串数字标识。 
TICKET = None


def submit(data, judge_server=None, ticket=None):
def submit(data, judge_server=None, contest=None, ticket=None):
    judge_server = judge_server or JUDGE_SERVER
    contest = contest or CONTEST
    ticket = ticket or TICKET
    
    if not judge_server or not ticket:
        missing = ["judge_server" if not judge_server else "", "ticket" if not ticket else ""]
    if not judge_server or not contest or not ticket:
        missing = [
            "judge_server" if not judge_server else "",
            "contest" if not contest else "",
            "ticket" if not ticket else "",
        ]
        missing = [m for m in missing if m]
        print("Required fields must be provided: %s" % ', '.join(missing))
        return None
    
    req_data = json.dumps({'data': data}).encode('utf-8')
    req = request.Request(judge_server, data=req_data, headers={'ticket': ticket, 'Content-Type': 'application/json'})
    req = request.Request(judge_server, data=req_data, headers={'ticket': ticket, 'contest': contest, 'Content-Type': 'application/json'})

    try:
        with request.urlopen(req) as response:
@@ -46,6 +53,7 @@ if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Submit to judge server")
    parser.add_argument('result_path', nargs='?', default='result.jsonl', help='Path to the submission file, default is result.jsonl')
    parser.add_argument('-s', '--server', help='Judge server URL, if not specified, the global JUDGE_SERVER variable will be used')
    parser.add_argument('-c', '--contest', help='Contest ID, if not specified, the global CONTEST variable will be used')
    parser.add_argument('-k', '--ticket', help='Submission ticket, if not specified, the global TICKET variable will be used')
    
    args = parser.parse_args()
@@ -57,7 +65,7 @@ if __name__ == "__main__":
        print(e)
        exit(1)

    submission_id = submit(data, judge_server=args.server, ticket=args.ticket)
    submission_id = submit(data, judge_server=args.server, contest=args.contest, ticket=args.ticket)
    if submission_id:
        print("Success! Your submission ID is %s." % submission_id)
        exit(0)