Skip to content

Commit

Permalink
Merge pull request #106 from traP-jp/feat/#105-python-as-judge-procedure
Browse files Browse the repository at this point in the history
✨ implemented python library as judge procedure schema
  • Loading branch information
comavius authored Feb 16, 2025
2 parents 4ba3324 + 9e81992 commit 9852ddc
Show file tree
Hide file tree
Showing 38 changed files with 1,104 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ Cargo.lock
*.pdb

# .env
.env
.env

# .venv
.venv
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.8
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ tonic = "0.12.3"
tonic-types = "0.12.3"
tonic-web = "0.12.3"
tonic-build = "0.12.3"
pyo3 = { version = "0.23.4", features = ["extension-module"] }
pyo3-stub-gen = "0.7.0"


[workspace]
Expand All @@ -31,5 +33,6 @@ members = [
"writerutil",
"grpc_schema",
"judge_core",
"traopy",
]
resolver = "2"
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "traojudge-judge-workspace"
version = "0.1.0"
description = "Rye workspace for traO-Judge-judge repository"
dependencies = []
readme = "README.md"
requires-python = ">= 3.8"

[tool.rye]
managed = true
dev-dependencies = []

[tool.rye.workspace]
members = ["traopy/example", "traopy"]

[tool.setuptools.packages.find]
include = ["traopy"]
79 changes: 79 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
-e file:traopy
-e file:traopy/example
asttokens==3.0.0
# via stack-data
comm==0.2.2
# via ipykernel
debugpy==1.8.12
# via ipykernel
decorator==5.1.1
# via ipython
executing==2.2.0
# via stack-data
ipykernel==6.29.5
# via traopy-example
ipython==8.32.0
# via ipykernel
jedi==0.19.2
# via ipython
jupyter-client==8.6.3
# via ipykernel
jupyter-core==5.7.2
# via ipykernel
# via jupyter-client
matplotlib-inline==0.1.7
# via ipykernel
# via ipython
nest-asyncio==1.6.0
# via ipykernel
packaging==24.2
# via ipykernel
parso==0.8.4
# via jedi
pexpect==4.9.0
# via ipython
platformdirs==4.3.6
# via jupyter-core
prompt-toolkit==3.0.50
# via ipython
psutil==7.0.0
# via ipykernel
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
# via stack-data
pygments==2.19.1
# via ipython
python-dateutil==2.9.0.post0
# via jupyter-client
pyzmq==26.2.1
# via ipykernel
# via jupyter-client
six==1.17.0
# via python-dateutil
stack-data==0.6.3
# via ipython
tornado==6.4.2
# via ipykernel
# via jupyter-client
traitlets==5.14.3
# via comm
# via ipykernel
# via ipython
# via jupyter-client
# via jupyter-core
# via matplotlib-inline
wcwidth==0.2.13
# via prompt-toolkit
79 changes: 79 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
-e file:traopy
-e file:traopy/example
asttokens==3.0.0
# via stack-data
comm==0.2.2
# via ipykernel
debugpy==1.8.12
# via ipykernel
decorator==5.1.1
# via ipython
executing==2.2.0
# via stack-data
ipykernel==6.29.5
# via traopy-example
ipython==8.32.0
# via ipykernel
jedi==0.19.2
# via ipython
jupyter-client==8.6.3
# via ipykernel
jupyter-core==5.7.2
# via ipykernel
# via jupyter-client
matplotlib-inline==0.1.7
# via ipykernel
# via ipython
nest-asyncio==1.6.0
# via ipykernel
packaging==24.2
# via ipykernel
parso==0.8.4
# via jedi
pexpect==4.9.0
# via ipython
platformdirs==4.3.6
# via jupyter-core
prompt-toolkit==3.0.50
# via ipython
psutil==7.0.0
# via ipykernel
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.3
# via stack-data
pygments==2.19.1
# via ipython
python-dateutil==2.9.0.post0
# via jupyter-client
pyzmq==26.2.1
# via ipykernel
# via jupyter-client
six==1.17.0
# via python-dateutil
stack-data==0.6.3
# via ipython
tornado==6.4.2
# via ipykernel
# via jupyter-client
traitlets==5.14.3
# via comm
# via ipykernel
# via ipython
# via jupyter-client
# via jupyter-core
# via matplotlib-inline
wcwidth==0.2.13
# via prompt-toolkit
17 changes: 17 additions & 0 deletions traopy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# python generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Rust
target/

# venv
.venv

python/traopy/*
!python/traopy/__init__.py
!python/traopy/lowlevel.pyi
!python/traopy/py.typed
1 change: 1 addition & 0 deletions traopy/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.8
21 changes: 21 additions & 0 deletions traopy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "traopy"
version = "0.1.0"
edition = "2021"

[lib]
name = "traopy"
crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { workspace = true }
pyo3-stub-gen = { workspace = true }
uuid = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
judge_core = { path = "../judge_core" }

[features]
abi3 = ["pyo3/abi3-py37", "generate-import-lib"]
generate-import-lib = ["pyo3/generate-import-lib"]
3 changes: 3 additions & 0 deletions traopy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# traopy

Describe your project here.
10 changes: 10 additions & 0 deletions traopy/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# python generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info

# venv
.venv
1 change: 1 addition & 0 deletions traopy/example/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.8
3 changes: 3 additions & 0 deletions traopy/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# simple-judge

Describe your project here.
1 change: 1 addition & 0 deletions traopy/example/problems/addition/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
judge_procedure.json
24 changes: 24 additions & 0 deletions traopy/example/problems/addition/judge_procedure_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resources": {
"output": { "TextFile": { "name": "output", "content": "3\n" } },
"actual": { "OnetimeTextFile": { "name": "actual" } },
"input": { "TextFile": { "name": "input", "content": "1 2\n" } }
},
"executions": {
"test": {
"name": "test",
"script_name": "script",
"depends_on": [
{ "ref_to": "input", "envvar_name": "INPUT" },
{ "ref_to": "output", "envvar_name": "OUTPUT" },
{ "ref_to": "actual", "envvar_name": "ACTUAL" }
]
}
},
"scripts": {
"script": {
"content": "import os\n\noutput_file = os.getenv('output')\nactual_output_file = os.getenv('actual')\n\nif output_file and actual_output_file:\n with open(output_file, 'r', encoding='utf-8') as f:\n output_text = f.read()\n\n with open(actual_output_file, 'r', encoding='utf-8') as f:\n actual_output = f.read()\n\n if output_text == actual_output:\n print(\"Test Passed\")\n else:\n print(\"Test Failed\")\nelse:\n print(\"Input and output files not found\")\n",
"name": "script"
}
}
}
Loading

0 comments on commit 9852ddc

Please sign in to comment.