Skip to content
GitLab
探索
登录
注册
aiops-challenge
aiops-2024-submit
比较版本
ced7d8f91d0c10310c7c95323cc777529546fcd3 to 4c42072c560b0638b420d708bed5896b6a5fee32
源代码提交(6)
feat: history
· e5ebf68f
由
刘 玉河
创作于
6月 21, 2024
e5ebf68f
fix: remove submission_id check in get_history
· 42ee2262
由
刘 玉河
创作于
6月 21, 2024
42ee2262
add README
· 28faa40a
由
刘 玉河
创作于
6月 21, 2024
28faa40a
Merge remote-tracking branch 'origin/main' into feat_submission_status
· ab414062
由
刘 玉河
创作于
6月 21, 2024
ab414062
fix: re-add comment
· 05dea2fc
由
刘 玉河
创作于
6月 21, 2024
05dea2fc
Merge branch 'feat_submission_status' into 'main'
· 4c42072c
由
刘 玉河
创作于
6月 21, 2024
Feat submission history See merge request
!3
4c42072c
隐藏空白变更内容
行内
左右并排
README.md
浏览文件 @
4c42072c
...
@@ -23,6 +23,7 @@ python submit.py [-h] [-s SERVER] [-c CONTEST] [-k TICKET] [-i SUBMISSION_ID] [r
...
@@ -23,6 +23,7 @@ python submit.py [-h] [-s SERVER] [-c CONTEST] [-k TICKET] [-i SUBMISSION_ID] [r
*
`-c, --contest`
:比赛标识。如果未提供,将使用脚本中定义的
`CONTEST`
变量。
*
`-c, --contest`
:比赛标识。如果未提供,将使用脚本中定义的
`CONTEST`
变量。
*
`-k, --ticket`
:团队标识。如果未提供,将使用脚本中定义的
`TICKET`
变量。
*
`-k, --ticket`
:团队标识。如果未提供,将使用脚本中定义的
`TICKET`
变量。
*
`-i, --submission_id`
:提交ID,当指定这一参数时,该脚本将不会提交结果文件,而是会查询该提交ID的结果。
*
`-i, --submission_id`
:提交ID,当指定这一参数时,该脚本将不会提交结果文件,而是会查询该提交ID的结果。
*
`-H, --history`
:查询历史提交记录,当指定这一参数时,该脚本将不会提交结果文件,而是会查询给定赛道和团队的历史提交评测结果。
## 单次提交结果查询
## 单次提交结果查询
...
@@ -36,6 +37,14 @@ python submit.py -i <submission_id> -s <judge_server> -c <contest> -k <ticket>
...
@@ -36,6 +37,14 @@ python submit.py -i <submission_id> -s <judge_server> -c <contest> -k <ticket>
由于评测服务器可能需要一段时间来处理提交,因此您可能需要等待一段时间才能获得结果。
由于评测服务器可能需要一段时间来处理提交,因此您可能需要等待一段时间才能获得结果。
## 历史提交结果查询
示例:
```
bash
python submit.py
-H
-s
<judge_server>
-c
<contest>
-k
<ticket>
```
## 编程方式提交
## 编程方式提交
您还可以将
`submit`
函数导入到您的 Python 代码中,以便用编程方式提交数据。
您还可以将
`submit`
函数导入到您的 Python 代码中,以便用编程方式提交数据。
...
...
submit.py
100755 → 100644
浏览文件 @
4c42072c
...
@@ -51,6 +51,32 @@ def submit(data, judge_server=None, contest=None, ticket=None):
...
@@ -51,6 +51,32 @@ def submit(data, judge_server=None, contest=None, ticket=None):
print
(
e
.
reason
)
print
(
e
.
reason
)
return
None
return
None
def
get_history
(
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
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
=
request
.
Request
(
judge_server
+
"
/history/
"
,
headers
=
{
'
ticket
'
:
ticket
,
'
contest
'
:
contest
,
'
Content-Type
'
:
'
application/json
'
})
try
:
with
request
.
urlopen
(
req
)
as
response
:
response_body
=
response
.
read
().
decode
(
'
utf-8
'
)
history
=
json
.
loads
(
response_body
)
return
history
except
:
print
(
"
Failed to get submission history.
"
)
return
None
def
check_status
(
submission_id
,
judge_server
=
None
,
contest
=
None
,
ticket
=
None
):
def
check_status
(
submission_id
,
judge_server
=
None
,
contest
=
None
,
ticket
=
None
):
judge_server
=
judge_server
or
JUDGE_SERVER
judge_server
=
judge_server
or
JUDGE_SERVER
contest
=
contest
or
CONTEST
contest
=
contest
or
CONTEST
...
@@ -95,6 +121,7 @@ if __name__ == "__main__":
...
@@ -95,6 +121,7 @@ if __name__ == "__main__":
parser
.
add_argument
(
'
-c
'
,
'
--contest
'
,
help
=
'
Contest ID, if not specified, the global CONTEST 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
'
)
parser
.
add_argument
(
'
-k
'
,
'
--ticket
'
,
help
=
'
Submission ticket, if not specified, the global TICKET variable will be used
'
)
parser
.
add_argument
(
'
-i
'
,
'
--submission_id
'
,
help
=
'
Submission ID, specified if you want to check the submission status
'
,
default
=
None
)
parser
.
add_argument
(
'
-i
'
,
'
--submission_id
'
,
help
=
'
Submission ID, specified if you want to check the submission status
'
,
default
=
None
)
parser
.
add_argument
(
'
-H
'
,
'
--history
'
,
help
=
'
Get submission history
'
,
action
=
'
store_true
'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -117,9 +144,23 @@ if __name__ == "__main__":
...
@@ -117,9 +144,23 @@ if __name__ == "__main__":
else
:
else
:
print
(
"
Failed to check submission status.
"
)
print
(
"
Failed to check submission status.
"
)
exit
(
1
)
exit
(
1
)
elif
args
.
history
:
history
=
get_history
(
judge_server
=
args
.
server
,
contest
=
args
.
contest
,
ticket
=
args
.
ticket
)
if
history
:
print
(
"
=
"
*
16
)
for
submission
in
history
:
print
(
f
"
Submission
{
submission
[
'
submission_id
'
]
}
:
"
)
print
(
f
"
- Create time:
{
submission
[
'
create_time
'
]
}
"
)
print
(
f
"
- Judge time:
{
submission
[
'
judge_time
'
]
}
"
)
print
(
f
"
- Score:
{
submission
[
'
score
'
]
}
"
)
print
(
"
=
"
*
16
)
exit
(
0
)
else
:
print
(
"
Failed to get submission history.
"
)
exit
(
1
)
try
:
try
:
with
open
(
args
.
result_path
,
'
r
'
)
as
file
:
with
open
(
args
.
result_path
,
'
r
'
,
encoding
=
'
utf-8
'
)
as
file
:
data
=
[
json
.
loads
(
line
.
strip
())
for
line
in
file
if
line
.
strip
()]
data
=
[
json
.
loads
(
line
.
strip
())
for
line
in
file
if
line
.
strip
()]
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
...
...