Skip to content

Commit f8283ee

Browse files
authored
Merge pull request #152 from traP-jp/docs/#145-traopy-docstrings
📝 add docs for traopy
2 parents 33abe8d + 6c28210 commit f8283ee

File tree

10 files changed

+92
-0
lines changed

10 files changed

+92
-0
lines changed

pylib/traopy/python/traopy/lowlevel.pyi

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,113 @@ import typing
88
from enum import Enum, auto
99

1010
class Dependency:
11+
r"""
12+
Dependency object to refer to previous output.
13+
14+
Path to the output will be provided as an environment variable named `envvar_name`.
15+
"""
1116
def __new__(cls,ref_to:Output, envvar_name:builtins.str): ...
1217
...
1318

1419
class EmptyDirectory:
20+
r"""
21+
Empty directory object to be placed in the execution environment.
22+
"""
1523
def __new__(cls,name:builtins.str): ...
1624
...
1725

1826
class Execution:
27+
r"""
28+
Execution object to be executed
29+
30+
Script will be run with paths as environment variables specified in `depends_on`.
31+
"""
1932
def __new__(cls,name:builtins.str, script:ScriptOutput, depends_on:typing.Sequence[Dependency]): ...
2033
...
2134

2235
class LocalJudge:
36+
r"""
37+
LocalJudge object to run provided procedures in your local environment.
38+
"""
2339
def __new__(cls,temp_dir:builtins.str | os.PathLike | pathlib.Path): ...
2440
def run(self, builder:ProcedureBuilder, runtime_text_contents:typing.Mapping[builtins.str, builtins.str]) -> builtins.str:
41+
r"""
42+
Run the provided procedure in your local environment.
43+
"""
2544
...
2645

2746

2847
class Output:
48+
r"""
49+
Output object of each job.
50+
51+
Executions can depend on Output by passing Output object to `depends_on` field of Execution.
52+
"""
2953
...
3054

3155
class ProcedureBuilder:
56+
r"""
57+
ProcedureBuilder object to build a procedure.
58+
"""
3259
def __new__(cls,): ...
3360
def add_resource(self, resource:ResourceKind) -> Output:
61+
r"""
62+
Add a resource to the procedure.
63+
"""
3464
...
3565

3666
def add_script(self, script:Text) -> ScriptOutput:
67+
r"""
68+
Add a script to the procedure.
69+
"""
3770
...
3871

3972
def add_execution(self, execution:Execution) -> Output:
73+
r"""
74+
Add an execution to the procedure.
75+
"""
4076
...
4177

4278
def write_to(self, path:builtins.str | os.PathLike | pathlib.Path) -> None:
79+
r"""
80+
Export the procedure to a json file.
81+
"""
4382
...
4483

4584

4685
class RuntimeText:
86+
r"""
87+
RuntimeText object to be placed in the execution environment.
88+
89+
`label`s have corresponding types of resources determined in judge-run time.
90+
| label | description |
91+
| --- | --- |
92+
| `source` | Submission source code |
93+
| `time_limit` | Time limit(optional) |
94+
| `memory_limit` | Memory limit(optional) |
95+
| `language` | Language of the submission(optional) |
96+
"""
4797
def __new__(cls,name:builtins.str, label:builtins.str): ...
4898
...
4999

50100
class ScriptOutput:
51101
...
52102

53103
class Text:
104+
r"""
105+
Text object to be placed in the execution environment.
106+
107+
Contents of Text must be static.
108+
"""
54109
def __new__(cls,name:builtins.str, path:builtins.str | os.PathLike | pathlib.Path): ...
55110
...
56111

57112
class ResourceKind(Enum):
113+
r"""
114+
Resource object to be placed in the execution environment.
115+
116+
EmptyDirectory is an directory and TextFile and RuntimeTextFile are files.
117+
"""
58118
EmptyDirectory = auto()
59119
RuntimeTextFile = auto()
60120
TextFile = auto()

pylib/traopy/src/local_judge.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use pyo3_stub_gen::derive::*;
1111
use std::collections::HashMap;
1212
use std::path::PathBuf;
1313

14+
/// LocalJudge object to run provided procedures in your local environment.
1415
#[gen_stub_pyclass]
1516
#[pyclass]
1617
pub struct LocalJudge {
@@ -31,6 +32,7 @@ impl LocalJudge {
3132
}
3233
}
3334

35+
/// Run the provided procedure in your local environment.
3436
#[pyo3(name = "run")]
3537
async fn run(
3638
&self,

pylib/traopy/src/models/dependency.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use judge_core::procedure::writer_schema::Dependency;
33
use pyo3::prelude::*;
44
use pyo3_stub_gen::derive::*;
55

6+
/// Dependency object to refer to previous output.
7+
///
8+
/// Path to the output will be provided as an environment variable named `envvar_name`.
69
#[gen_stub_pyclass]
710
#[pyclass]
811
#[pyo3(name = "Dependency")]

pylib/traopy/src/models/empty_directory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use judge_core::procedure::writer_schema::EmptyDirectory;
22
use pyo3::prelude::*;
33
use pyo3_stub_gen::derive::*;
44

5+
/// Empty directory object to be placed in the execution environment.
56
#[gen_stub_pyclass]
67
#[pyclass]
78
#[pyo3(name = "EmptyDirectory")]

pylib/traopy/src/models/execution.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use judge_core::procedure::writer_schema::{Dependency, Execution};
33
use pyo3::prelude::*;
44
use pyo3_stub_gen::derive::*;
55

6+
/// Execution object to be executed
7+
///
8+
/// Script will be run with paths as environment variables specified in `depends_on`.
69
#[gen_stub_pyclass]
710
#[pyclass]
811
#[pyo3(name = "Execution")]

pylib/traopy/src/models/output.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use pyo3::prelude::*;
22
use pyo3_stub_gen::derive::*;
33

4+
/// Output object of each job.
5+
///
6+
/// Executions can depend on Output by passing Output object to `depends_on` field of Execution.
47
#[gen_stub_pyclass]
58
#[pyclass]
69
#[pyo3(name = "Output")]

pylib/traopy/src/models/resource_kind.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use judge_core::procedure::writer_schema::ResourceKind;
33
use pyo3::prelude::*;
44
use pyo3_stub_gen::derive::*;
55

6+
/// Resource object to be placed in the execution environment.
7+
///
8+
/// EmptyDirectory is an directory and TextFile and RuntimeTextFile are files.
69
#[gen_stub_pyclass_enum]
710
#[pyclass]
811
#[pyo3(name = "ResourceKind")]

pylib/traopy/src/models/runtime_text.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ use judge_core::procedure::writer_schema::RuntimeText;
22
use pyo3::prelude::*;
33
use pyo3_stub_gen::derive::*;
44

5+
/// RuntimeText object to be placed in the execution environment.
6+
///
7+
/// `label`s have corresponding types of resources determined in judge-run time.
8+
/// | label | description |
9+
/// | --- | --- |
10+
/// | `source` | Submission source code |
11+
/// | `time_limit` | Time limit(optional) |
12+
/// | `memory_limit` | Memory limit(optional) |
13+
/// | `language` | Language of the submission(optional) |
514
#[gen_stub_pyclass]
615
#[pyclass]
716
#[pyo3(name = "RuntimeText")]

pylib/traopy/src/models/text.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ use pyo3::prelude::*;
33
use pyo3_stub_gen::derive::*;
44
use std::path::PathBuf;
55

6+
/// Text object to be placed in the execution environment.
7+
///
8+
/// Contents of Text must be static.
69
#[gen_stub_pyclass]
710
#[pyclass]
811
#[pyo3(name = "Text")]

pylib/traopy/src/procedure_builder.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use pyo3::prelude::*;
55
use pyo3_stub_gen::derive::*;
66
use std::path::PathBuf;
77

8+
/// ProcedureBuilder object to build a procedure.
89
#[gen_stub_pyclass]
910
#[pyclass]
1011
#[pyo3(name = "ProcedureBuilder")]
@@ -23,6 +24,7 @@ impl PyProcedureBuilder {
2324
}
2425
}
2526

27+
/// Add a resource to the procedure.
2628
#[pyo3(name = "add_resource")]
2729
fn add_resource(&mut self, resource: resource_kind::PyResourceKind) -> output::PyOutput {
2830
let schema_resource = writer_schema::ResourceKind::from(resource);
@@ -31,6 +33,7 @@ impl PyProcedureBuilder {
3133
output
3234
}
3335

36+
/// Add a script to the procedure.
3437
#[pyo3(name = "add_script")]
3538
fn add_script(&mut self, script: text::PyText) -> output::PyScriptOutput {
3639
let schema_script = writer_schema::Text::from(script);
@@ -39,6 +42,7 @@ impl PyProcedureBuilder {
3942
output
4043
}
4144

45+
/// Add an execution to the procedure.
4246
#[pyo3(name = "add_execution")]
4347
fn add_execution(&mut self, execution: execution::PyExecution) -> output::PyOutput {
4448
let script_name = execution.script.name.clone();
@@ -56,6 +60,7 @@ impl PyProcedureBuilder {
5660
output
5761
}
5862

63+
/// Export the procedure to a json file.
5964
#[pyo3(name = "write_to")]
6065
fn write_to(&self, path: PathBuf) -> () {
6166
// output this instance as a json file

0 commit comments

Comments
 (0)