Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
282 commits
Select commit Hold shift + click to select a range
80f0a10
Merge branch 'yscope-dev-utils' into python_lint
sitaowang1998 Aug 4, 2025
3186a42
Add mypy and merge lint and test requirements.txt
sitaowang1998 Aug 4, 2025
0925938
Fix mysql connection type
sitaowang1998 Aug 4, 2025
6936a9b
Fix socket name type
sitaowang1998 Aug 4, 2025
7407090
Fix return type from db cursor
sitaowang1998 Aug 4, 2025
6a95b24
Fix db cursor return type
sitaowang1998 Aug 4, 2025
f29dcba
Fix mypy import untyped
sitaowang1998 Aug 4, 2025
453f209
Fix mypy and Popen
sitaowang1998 Aug 5, 2025
d1011c7
Fix generator type hint
sitaowang1998 Aug 5, 2025
a7dc642
Fix mypy
sitaowang1998 Aug 5, 2025
a7d92c2
Fix ruff
sitaowang1998 Aug 5, 2025
1c6213b
Simply socket return types.
sitaowang1998 Aug 5, 2025
0f13d07
Merge branch 'main' into python_lint
sitaowang1998 Aug 5, 2025
14d6326
Merge branch 'python_lint' into mypy_lint
sitaowang1998 Aug 5, 2025
55a727a
Add tombi lint tasks
sitaowang1998 Aug 5, 2025
c98fea1
Rename cpp build tasks
sitaowang1998 Aug 5, 2025
ef64454
Merge branch 'main' into mypy_lint
sitaowang1998 Aug 5, 2025
09ba8ad
Merge branch 'main' into tombi
sitaowang1998 Aug 5, 2025
4e7237e
Add basic python structure
sitaowang1998 Aug 5, 2025
1f944d0
Fix code structure
sitaowang1998 Aug 5, 2025
68992fc
Fix ruff lint
sitaowang1998 Aug 5, 2025
1127b22
Extend lint tasks to python directory
sitaowang1998 Aug 5, 2025
4c51c91
Add python build tasks
sitaowang1998 Aug 5, 2025
56878b2
Merge branch 'main' into mypy_lint
sitaowang1998 Aug 5, 2025
bb428c9
Merge branch 'mypy_lint' into tombi
sitaowang1998 Aug 5, 2025
944bd5e
Merge branch 'tombi' into build-task
sitaowang1998 Aug 5, 2025
d75bc15
Merge branch 'build-task' into python_structure
sitaowang1998 Aug 5, 2025
4b7eca2
Merge branch 'main' into tombi
sitaowang1998 Aug 5, 2025
8ddbda7
Merge branch 'tombi' into build-task
sitaowang1998 Aug 5, 2025
0d998ec
Merge branch 'build-task' into python_structure
sitaowang1998 Aug 5, 2025
6004d64
Fix yaml lint error
sitaowang1998 Aug 5, 2025
bcab5db
Fix tombi lint
sitaowang1998 Aug 5, 2025
a50d25a
Remove wrong mypy config
sitaowang1998 Aug 5, 2025
fbebb96
Fix typo and format file
sitaowang1998 Aug 5, 2025
0322bd5
Use typed msgpack and remove mypy config for msgpack from pyproject
sitaowang1998 Aug 6, 2025
2a08155
Update uv lock
sitaowang1998 Aug 6, 2025
dd29c23
Add task module
sitaowang1998 Aug 6, 2025
570cf2f
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 6, 2025
9b2a175
Add data and improve type alias
sitaowang1998 Aug 6, 2025
32afe0a
Add task graph and reformat files
sitaowang1998 Aug 6, 2025
0b62f73
Merge branch 'main' into tombi
sitaowang1998 Aug 6, 2025
7384158
Merge branch 'main' into build-task
sitaowang1998 Aug 6, 2025
70ef90a
Merge branch 'main' into python_structure
sitaowang1998 Aug 6, 2025
1aae0cb
Merge branch 'main' into python_task
sitaowang1998 Aug 6, 2025
2f9b4a0
Fix typo
sitaowang1998 Aug 6, 2025
4e080ac
Fix set remove key error
sitaowang1998 Aug 6, 2025
b09515c
Increase min version of tombi
sitaowang1998 Aug 6, 2025
bad9675
Merge branch 'tombi' into build-task
sitaowang1998 Aug 6, 2025
e009ff4
Merge branch 'tombi' into python_structure
sitaowang1998 Aug 6, 2025
f11a3b6
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 6, 2025
a0407a7
Merge branch 'main' into tombi
sitaowang1998 Aug 6, 2025
aa9a8de
Merge branch 'tombi' into build-task
sitaowang1998 Aug 6, 2025
3c7e794
Merge branch 'tombi' into python_structure
sitaowang1998 Aug 6, 2025
ca4ec29
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 6, 2025
b4d6576
Add uv in README
sitaowang1998 Aug 6, 2025
23f31cd
Merge branch 'main' into build-task
sitaowang1998 Aug 6, 2025
0167ac0
Merge branch 'build-task' into python_structure
sitaowang1998 Aug 6, 2025
5a9cb76
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 6, 2025
f447614
Fix redenduncy caused by merge
sitaowang1998 Aug 6, 2025
a84de83
Merge branch 'build-task' into python_structure
sitaowang1998 Aug 6, 2025
f94460f
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 6, 2025
2d1b6fc
Merge branch 'main' into python_structure
sitaowang1998 Aug 7, 2025
5a35122
Merge branch 'main' into python_task
sitaowang1998 Aug 7, 2025
061d101
Merge branch 'main' into python_structure
sitaowang1998 Aug 7, 2025
451a80e
Merge branch 'main' into python_task
sitaowang1998 Aug 7, 2025
de149ee
Add integral types
sitaowang1998 Aug 7, 2025
d332dbe
Revert "Add integral types"
sitaowang1998 Aug 7, 2025
80b6772
Add package export control for type
sitaowang1998 Aug 7, 2025
f2ebaa6
Add floating point type
sitaowang1998 Aug 8, 2025
8c27b16
Restructure under src/spider
sitaowang1998 Aug 8, 2025
1b7ab77
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 8, 2025
b7f1884
Merge branch 'python_structure' into python_type
sitaowang1998 Aug 8, 2025
a7aa6b0
Re-export spider.type under spider
sitaowang1998 Aug 8, 2025
95b98c8
Merge branch 'main' into python_structure
sitaowang1998 Aug 8, 2025
e7b119c
Merge branch 'main' into python_task
sitaowang1998 Aug 8, 2025
8ffbd03
Fix import path
sitaowang1998 Aug 8, 2025
5765acf
Add tdl types; Allow no docstring for override function
sitaowang1998 Aug 8, 2025
427dd6b
Merge branch 'main' into python_structure
sitaowang1998 Aug 8, 2025
a9c9e57
Merge branch 'main' into python_task
sitaowang1998 Aug 8, 2025
213d2fc
Add type conversion to tdl type
sitaowang1998 Aug 8, 2025
a1a86f3
Add to_tdl_str
sitaowang1998 Aug 8, 2025
97af71b
Add to_tdl_type_str to type package export
sitaowang1998 Aug 8, 2025
74f31e2
Add pytest and basic test structure
sitaowang1998 Aug 8, 2025
7d95706
Add python test tasks
sitaowang1998 Aug 8, 2025
96b5324
Rename some cpp tests and add python tests to GH workflow and doc
sitaowang1998 Aug 8, 2025
14ea6fb
Don't create __pycache__ when running pytest
sitaowang1998 Aug 8, 2025
854cd11
Fix missing link
sitaowang1998 Aug 8, 2025
5565c9e
Merge branch 'python_structure' of github.com:sitaowang1998/spider in…
sitaowang1998 Aug 8, 2025
a9791e5
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 8, 2025
2504429
Merge branch 'python_structure' into python_test_setup
sitaowang1998 Aug 8, 2025
7ea4928
Use task env
sitaowang1998 Aug 8, 2025
01dd0c6
Fix task executor path
sitaowang1998 Aug 8, 2025
c6ccce6
Merge branch 'python_structure' into python_task
sitaowang1998 Aug 8, 2025
4cec09b
Merge branch 'python_structure' into python_test_setup
sitaowang1998 Aug 8, 2025
e022404
Merge branch 'main' into python_structure
sitaowang1998 Aug 8, 2025
8894b90
Merge branch 'main' into python_test_setup
sitaowang1998 Aug 8, 2025
01c9c64
Merge branch 'main' into python_task
sitaowang1998 Aug 8, 2025
7753153
Merge branch 'main' into python_structure
sitaowang1998 Aug 9, 2025
dd59915
Merge branch 'main' into python_test_setup
sitaowang1998 Aug 9, 2025
b86d47c
Merge branch 'main' into python_task
sitaowang1998 Aug 9, 2025
ac1d4ee
Merge branch 'python_structure' into python_type
sitaowang1998 Aug 9, 2025
0d38c43
Merge branch 'python_test_setup' into python_type
sitaowang1998 Aug 9, 2025
438f6e7
Remove unnecessary __init__.py files
sitaowang1998 Aug 9, 2025
2caad5d
Merge branch 'python_structure' into python_test_setup
sitaowang1998 Aug 9, 2025
c6815ce
Merge branch 'python_test_setup' into python_type
sitaowang1998 Aug 9, 2025
61e0651
Fix bugs
sitaowang1998 Aug 9, 2025
8b13abd
Add some type convertion tests
sitaowang1998 Aug 9, 2025
50b2b25
Bug fix
sitaowang1998 Aug 9, 2025
519dcd8
Merge branch 'python_test_setup' into python_type
sitaowang1998 Aug 9, 2025
8e2786b
Add more tests
sitaowang1998 Aug 9, 2025
41d5de2
Add parsing of tdl type string
sitaowang1998 Aug 9, 2025
0a377f5
Add tests and fix parser
sitaowang1998 Aug 9, 2025
a8c8641
Fix pytest
sitaowang1998 Aug 9, 2025
9fabc44
Merge branch 'python_test_setup' into python_type
sitaowang1998 Aug 9, 2025
ade589b
Merge branch 'python_type' into python_type_parse
sitaowang1998 Aug 9, 2025
0b18170
Satisfy linter
sitaowang1998 Aug 9, 2025
0bfbdb5
Fix comment
sitaowang1998 Aug 9, 2025
e558f67
Improve code according to coderabbit
sitaowang1998 Aug 9, 2025
73e8f0c
Merge branch 'python_type' into python_type_parse
sitaowang1998 Aug 9, 2025
6b58ff0
Move functions to util
sitaowang1998 Aug 9, 2025
90ab334
Unwarp the type node to get TdlType
sitaowang1998 Aug 10, 2025
49acaee
Catch and rethrow lark error
sitaowang1998 Aug 10, 2025
09d3fd0
Merge branch 'python_type' into python_client_task
sitaowang1998 Aug 10, 2025
ae2a935
Add reset id
sitaowang1998 Aug 10, 2025
008c6fb
Export core
sitaowang1998 Aug 10, 2025
cd60dc6
Merge branch 'python_task' into python_client_task
sitaowang1998 Aug 10, 2025
720265f
Add client task graph
sitaowang1998 Aug 10, 2025
ebe64c6
Add client taskgraph to spider export
sitaowang1998 Aug 10, 2025
404cf3b
Excempt _impl from private access check
sitaowang1998 Aug 10, 2025
3f9fe04
Add basic TaskFunction defintion
sitaowang1998 Aug 10, 2025
4d10f88
"Add default values for tasks"
sitaowang1998 Aug 10, 2025
fe4121f
Merge branch 'python_task' into python_client_task
sitaowang1998 Aug 10, 2025
f3ac001
Fix task IO type and add create_task from function
sitaowang1998 Aug 10, 2025
95b7773
Add client task group
sitaowang1998 Aug 10, 2025
a72e4a6
Add task graph chain
sitaowang1998 Aug 11, 2025
f289e5a
Reset ids after chain
sitaowang1998 Aug 11, 2025
2e829bc
Add export
sitaowang1998 Aug 11, 2025
ec6802d
Export TaskContext
sitaowang1998 Aug 11, 2025
3685dd7
Add unit tests
sitaowang1998 Aug 11, 2025
2862f01
Fix tuple check
sitaowang1998 Aug 11, 2025
03af08d
Fix size check in chain
sitaowang1998 Aug 11, 2025
c3dda18
Fix chain dependencies
sitaowang1998 Aug 11, 2025
2a1f33e
Fix id collision
sitaowang1998 Aug 11, 2025
0e4452c
Add more tests and more fixes
sitaowang1998 Aug 11, 2025
3705ef3
Satisfy ruff
sitaowang1998 Aug 11, 2025
fb8938a
Satisfy mypy
sitaowang1998 Aug 11, 2025
9ed09be
Bug fix
sitaowang1998 Aug 11, 2025
ef827a3
Remove unnecessary reset_ids
sitaowang1998 Aug 11, 2025
220a2b0
Fix task input id reset
sitaowang1998 Aug 11, 2025
56f7866
Fix comment grammar
sitaowang1998 Aug 11, 2025
638d577
Fix tuple check
sitaowang1998 Aug 11, 2025
2bcc4a4
Add guard for function with no argument
sitaowang1998 Aug 11, 2025
aa1723e
Disallow varargs in task function
sitaowang1998 Aug 11, 2025
2469008
Disallow variable tuple return in task function
sitaowang1998 Aug 11, 2025
082476d
Use identity check for Parameter.empty sentinel
sitaowang1998 Aug 11, 2025
72239f7
Fix error msg for ruff
sitaowang1998 Aug 11, 2025
e13acec
Make create_task private
sitaowang1998 Aug 11, 2025
84a6256
Split create_task into multiple functions
sitaowang1998 Aug 11, 2025
c45eb0d
Add storage cursor
sitaowang1998 Aug 12, 2025
1a27b45
Add storage connection interface
sitaowang1998 Aug 12, 2025
b505e06
Use functionality as storage interface
sitaowang1998 Aug 12, 2025
44067ab
Add jdbc url
sitaowang1998 Aug 12, 2025
c81719b
Add mariadb connection
sitaowang1998 Aug 12, 2025
899189e
Add submit job sql
sitaowang1998 Aug 12, 2025
ba1fd69
Add driver id
sitaowang1998 Aug 12, 2025
fe4b24b
Add export of driver id
sitaowang1998 Aug 12, 2025
8c0125a
Add submit job db function
sitaowang1998 Aug 12, 2025
beb4b5f
Add tests for mariadb
sitaowang1998 Aug 12, 2025
ff8bb01
Fix jdbc url
sitaowang1998 Aug 12, 2025
43de342
Add mariadb test
sitaowang1998 Aug 12, 2025
6b06a30
Split python tests into storage and non-storage
sitaowang1998 Aug 12, 2025
8faa0c6
Add more complex graph
sitaowang1998 Aug 12, 2025
fe904b0
Bug fix
sitaowang1998 Aug 12, 2025
2f1c430
Merge branch 'python_client_task' into python-job-submission
sitaowang1998 Aug 12, 2025
e1b1ac3
Bug fix
sitaowang1998 Aug 12, 2025
2b5405a
Bug fix
sitaowang1998 Aug 12, 2025
3938934
Bug fix
sitaowang1998 Aug 12, 2025
eebcab7
Fix docstring typo
sitaowang1998 Aug 12, 2025
5e2175a
Fix dict get default value
sitaowang1998 Aug 12, 2025
bff3a95
Reformat pyporject.toml
sitaowang1998 Aug 12, 2025
e0fd981
Use not list instead of len(list) > 0
sitaowang1998 Aug 12, 2025
22e4547
Add client job submission
sitaowang1998 Aug 13, 2025
e50e892
Export driver
sitaowang1998 Aug 13, 2025
573f01c
Add job submission unit test and fix bugs
sitaowang1998 Aug 13, 2025
5a999ff
Set zip to strict
sitaowang1998 Aug 13, 2025
8cbebc9
Remove unnecessary zip check
sitaowang1998 Aug 13, 2025
2b29782
Remove msgpack exception in docstring
sitaowang1998 Aug 13, 2025
44129a6
Fix ruff
sitaowang1998 Aug 13, 2025
41cdb3e
Add core job
sitaowang1998 Aug 14, 2025
a36ac49
Fix docstring
sitaowang1998 Aug 14, 2025
f89ebc6
Export JobStatus in core
sitaowang1998 Aug 14, 2025
bd43d58
Add get job status
sitaowang1998 Aug 14, 2025
7c2d239
Merge branch 'python_type_parse' into py-job-status
sitaowang1998 Aug 14, 2025
d3f3eb1
Export tdl parse function
sitaowang1998 Aug 14, 2025
08649c9
Merge branch 'python_type_parse' into py-job-status
sitaowang1998 Aug 14, 2025
9a6fb16
Add get result storage function
sitaowang1998 Aug 14, 2025
4b755a4
Fix test var name
sitaowang1998 Aug 14, 2025
b36071a
Merge branch 'python-client-job' into py-job-status
sitaowang1998 Aug 14, 2025
af124fd
Add unit tests for getting status
sitaowang1998 Aug 14, 2025
2410829
Fix lint
sitaowang1998 Aug 14, 2025
97fcd36
Bug fix
sitaowang1998 Aug 14, 2025
3019cb6
Check for job existence
sitaowang1998 Aug 14, 2025
1a12604
Bug fix
sitaowang1998 Aug 14, 2025
cf28065
Add core.Data in task I/O
sitaowang1998 Aug 14, 2025
936fbf9
Use core data in client data
sitaowang1998 Aug 14, 2025
ab1c8b0
Add more fields to data
sitaowang1998 Aug 14, 2025
3822892
Add create driver data interface
sitaowang1998 Aug 15, 2025
8cd9c08
Add storage function to get data
sitaowang1998 Aug 15, 2025
77cd6ed
Add mariadb insert driver data
sitaowang1998 Aug 15, 2025
c58eb8b
Add storage driver creation; Add tests for data; Bug fixes
sitaowang1998 Aug 15, 2025
7aefb7b
Add client data, driver and job
sitaowang1998 Aug 15, 2025
710f42d
Export job
sitaowang1998 Aug 15, 2025
5f915cd
Add data tests and bug fixes
sitaowang1998 Aug 15, 2025
87606a1
Update get job result interface
sitaowang1998 Aug 15, 2025
2eb9a09
Add tests for getting results of a running job
sitaowang1998 Aug 15, 2025
2c36da4
Merge branch 'py-job-status' into py-data
sitaowang1998 Aug 15, 2025
9c7012d
Merge branch 'py-data' into py-client
sitaowang1998 Aug 15, 2025
f234241
Do not deserialize value in getting result
sitaowang1998 Aug 15, 2025
2e4c5c6
Merge branch 'py-job-status' into py-data
sitaowang1998 Aug 15, 2025
7dc0295
Merge branch 'py-data' into py-client
sitaowang1998 Aug 15, 2025
25d7012
Fix type annotation
sitaowang1998 Aug 15, 2025
e75accd
Merge branch 'py-job-status' into py-data
sitaowang1998 Aug 15, 2025
020c53f
Merge branch 'py-data' into py-client
sitaowang1998 Aug 15, 2025
563a337
Add job tests and fix client get results
sitaowang1998 Aug 15, 2025
4765d5d
Add missing commit
sitaowang1998 Aug 15, 2025
f45b8ef
Merge branch 'py-job-status' into py-data
sitaowang1998 Aug 15, 2025
ce16f23
Merge branch 'py-job-status' into py-client
sitaowang1998 Aug 15, 2025
0cd522c
Bug fix
sitaowang1998 Aug 15, 2025
dfac709
Fix docstring
sitaowang1998 Aug 15, 2025
4d7fc44
Add create task data
sitaowang1998 Aug 18, 2025
8eef082
Add unit test for creating data with no driver id
sitaowang1998 Aug 18, 2025
add2774
Merge branch 'py-data' into py-client
sitaowang1998 Aug 18, 2025
f185246
Merge branch 'py-client' into py-taskcontext
sitaowang1998 Aug 18, 2025
e2f7a38
Add task context impl
sitaowang1998 Aug 18, 2025
8a383c5
Add argument parsing
sitaowang1998 Aug 18, 2025
e78e4c4
Fix argparse
sitaowang1998 Aug 18, 2025
168683b
Fix ruff
sitaowang1998 Aug 18, 2025
be731cb
Add task executor message
sitaowang1998 Aug 19, 2025
34a314b
WIP
sitaowang1998 Aug 19, 2025
6e0dc17
Add arg parse. WIP
sitaowang1998 Aug 20, 2025
5581183
Add msgpack class serde
sitaowang1998 Aug 20, 2025
42bbda0
Expand the decoder to accept genric
sitaowang1998 Aug 21, 2025
9c07b88
Fix job deserialize
sitaowang1998 Aug 21, 2025
a53920a
Use strict zip
sitaowang1998 Aug 21, 2025
5314e50
Add nested list test
sitaowang1998 Aug 21, 2025
19279fd
Merge branch 'py-client' into py-taskcontext
sitaowang1998 Aug 21, 2025
3d4bee2
Merge branch 'py-taskcontext' into py-taskexecutor
sitaowang1998 Aug 21, 2025
e2c4610
Add task executor
sitaowang1998 Aug 21, 2025
0cb8e6f
Fix mypy
sitaowang1998 Aug 21, 2025
4d59367
Fix ruff
sitaowang1998 Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/code-linting-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
python --version
tar --version
task --version
uv --version

- name: "Install project dependencies "
timeout-minutes: 10
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
python --version
tar --version
task --version
uv --version

- name: "Install project dependencies "
timeout-minutes: 10
Expand All @@ -55,3 +56,5 @@ jobs:
run: "task deps:lib_install"

- run: "task test:non-storage-unit-tests"

- run: "task test:python-non-storage-tests"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Follow the steps below to develop and contribute to the project.
## Requirements
* Python 3.10 or higher
* [Task] 3.40.0 or higher
* [uv] 0.7.0 or higher

## Set up
Run dependency installation task:
Expand Down Expand Up @@ -67,3 +68,4 @@ in the table below.

[spider-docs]: https://docs.yscope.com/spider/main/
[Task]: https://taskfile.dev
[uv]: https://docs.astral.sh/uv/
4 changes: 4 additions & 0 deletions build-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ tasks:
deps: [":config-cmake-project"]
cmds:
- "cmake --build {{.G_BUILD_SPIDER_DIR}} --target clean --parallel {{numCPU}}"

py-build:
cmds:
- "uv build --directory {{.G_SRC_PYTHON_DIR}} -o {{.G_BUILD_PYTHON_DIR}}"
19 changes: 11 additions & 8 deletions docs/src/dev-docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ require this storage backend.

You can use the following tasks to run the set of unit tests that's appropriate.

| Task | Description |
|-------------------------------|-------------------------------------------------------------------|
| `test:all` | Runs all unit tests. |
| `test:non-storage-unit-tests` | Runs all unit tests which don't require a storage backend to run. |
| `test:storage-unit-tests` | Runs all unit tests which require a storage backend to run. |
| Task | Description |
|---------------------------------|-----------------------------------------------------------------------|
| `test:cpp-all` | Runs all C++ unit tests. |
| `test:non-storage-unit-tests` | Runs all C++ unit tests which don't require a storage backend to run. |
| `test:storage-unit-tests` | Runs all C++ unit tests which require a storage backend to run. |
| `test:python-tests` | Runs all Python tests. |
| `test:python-non-storage-tests` | Runs all Python tests which don't require a storage backend to run. |
| `test:python-storage-tests` | Runs all Python tests which require a storage backend to run. |

If any tests show error messages for the connection function below, revisit the
[setup section](#set-up-mysql-as-storage-backend) and verify that `cStorageUrl` was set correctly.
Expand All @@ -52,9 +55,9 @@ pull requests, and daily. Currently, it only runs unit tests that don't require

You can use the following tasks to run integration tests.

| Task | Description |
|-------------------------------|-------------------------------------------------------------------|
| `test:integration` | Runs all integration tests. |
| Task | Description |
|------------------------|---------------------------------|
| `test:cpp-integration` | Runs all C++ integration tests. |


[gh-workflow-unit-tests]: https://github.com/y-scope/spider/blob/main/.github/workflows/unit-tests.yaml
5 changes: 5 additions & 0 deletions lint-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ tasks:
mypy "{{.ITEM}}"
ruff check {{.RUFF_CHECK_FLAGS}} "{{.ITEM}}"
ruff format {{.RUFF_FORMAT_FLAGS}} "{{.ITEM}}"
- cmd: |-
cd "{{.G_SRC_PYTHON_DIR}}"
uv run mypy .
uv run ruff check {{.RUFF_CHECK_FLAGS}}
uv run ruff format {{.RUFF_FORMAT_FLAGS}}

yml:
aliases:
Expand Down
1 change: 1 addition & 0 deletions python/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
Empty file added python/README.md
Empty file.
89 changes: 89 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[project]
name = "spider"
version = "0.0.1"
description = "Spider is a distributed task execution framework"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"lark>=1.2.2",
"mariadb>=1.1.13",
"msgpack-types>=0.5.0",
]

[project.scripts]
spider_task_executor = "spider.task_executor.task_executor:main"

[dependency-groups]
dev = [
"mypy>=1.12.0",
"pytest>=8.4.1",
"ruff>=0.4.4",
]

[build-system]
requires = ["hatchling>=1.18.0"]
build-backend = "hatchling.build"

[tool.mypy]
strict = true
# Additional output
pretty = true
show_error_code_links = true
show_error_context = true

[[tool.mypy.overrides]]
module = ["mariadb.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
markers = [
"integration: mark test as an integration test",
"storage: mark unit tests needing storage",
]
testpaths = ["tests"]

[tool.ruff]
line-length = 100

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 100

[tool.ruff.lint]
select = ["ALL"]
extend-select = ["PT"]
ignore = [
"COM812", # Redundant and conflicts with ruff format
"D203", # No blank line before docstrings (D211)
"D205", # Breaks if summary is larger than one line due to wrapping or if no summary exists
"D212", # Enforce docstring summary line on the next line after quotes (D213)
"D400", # First line of docstrings may not end in period
"D401", # Docstrings should be written in present tense (not imperative)
"D415", # First line of docstrings may not end in a period, question mark, or exclamation point
"FA102", # Allow use of PEP 604 union in type annotations
"FBT", # Allow bool positional parameters since other value positions are allowed
"FIX002", # Allow todo statements
"PERF401", # Allow for loops when creating lists
"PERF403", # Allow for loops when creating dicts
"S311", # Allow usage of `random` package
"SIM102", # Allow collapsible if statements for readability
"TD002", # Author unnecessary for todo statement
"TD003", # Issue link unnecessary for todo statement
"UP015", # Explicit open modes are helpful
]
isort.order-by-type = false

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"INP001", # Allow implicit namespace package for tests
"PLR2004", # Allow use of magic value
"S101", # Allow use of `assert` (security warning)
"S603", # Allow use of `subprocess.Popen` (security warning)
"T201", # Allow use of `print` (testing)
]

[tool.ruff.lint.flake8-self]
ignore-names = ["_from_impl", "_impl"]

[tool.ruff.lint.pydocstyle]
ignore-decorators = ["typing.override"]
22 changes: 22 additions & 0 deletions python/src/spider/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Spider package root."""

from spider.client import chain, Data, Driver, group, Job, TaskContext, TaskGraph
from spider.core import JobStatus
from spider.type import Double, Float, Int8, Int16, Int32, Int64

__all__ = [
"Data",
"Double",
"Driver",
"Float",
"Int8",
"Int16",
"Int32",
"Int64",
"Job",
"JobStatus",
"TaskContext",
"TaskGraph",
"chain",
"group",
]
17 changes: 17 additions & 0 deletions python/src/spider/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Spider python client."""

from .data import Data
from .driver import Driver
from .job import Job
from .task_context import TaskContext
from .taskgraph import chain, group, TaskGraph

__all__ = [
"Data",
"Driver",
"Job",
"TaskContext",
"TaskGraph",
"chain",
"group",
]
43 changes: 43 additions & 0 deletions python/src/spider/client/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Spider client Data module."""

from uuid import uuid4

from spider import core


class Data:
"""Represents a spider client data."""

def __init__(self, value: bytes) -> None:
"""Initialize the Data object with the given value."""
self._impl = core.Data(uuid4(), value)

@staticmethod
def _from_impl(impl: core.Data) -> "Data":
"""Creates a Data instance from an existing core.Data implementation."""
data = Data(impl.value)
data._impl = impl
return data

@property
def value(self) -> bytes:
"""Property to get the value of the data."""
return self._impl.value

@property
def hard_locality(self) -> bool:
"""Property to check if the data has hard locality."""
return self._impl.hard_locality

@hard_locality.setter
def hard_locality(self, value: bool) -> None:
"""Sets the hard locality for the data."""
self._impl.hard_locality = value

def get_localities(self) -> list[str]:
"""Gets the list of localities where the data is stored."""
return [locality.address for locality in self._impl.localities]

def add_locality(self, address: str) -> None:
"""Adds a new locality to the data."""
self._impl.localities.append(core.DataLocality(address))
74 changes: 74 additions & 0 deletions python/src/spider/client/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""Spider client driver module."""

from collections.abc import Sequence
from uuid import uuid4

import msgpack

from spider import core
from spider.client.data import Data
from spider.client.job import Job
from spider.client.taskgraph import TaskGraph
from spider.storage import MariaDBStorage, parse_jdbc_url
from spider.type import to_tdl_type_str


class Driver:
"""Spider client driver class."""

def __init__(self, storage_url: str) -> None:
"""
Creates a new Spider client driver and connects to the storage.
:param storage_url: The URL of the storage to connect to.
:raises StorageError: If the storage cannot be connected to.
"""
self._driver_id = uuid4()
self._storage = MariaDBStorage(parse_jdbc_url(storage_url))
self._storage.create_driver(self._driver_id)

def submit_jobs(
self, graphs: Sequence[TaskGraph], args: Sequence[Sequence[object]]
) -> Sequence[Job]:
"""
Submits a list of jobs to the storage.
:param graphs: The list of task graphs to submit.
:param args: The arguments for each job.
:return: A sequence of Job objects representing the submitted jobs.
:raises StorageError: If the jobs cannot be submitted to the storage.
:raises ValueError: If the number of job inputs does not match the number of arguments.
:raises TypeError: If the arguments are not of the expected type.
"""
msg = "Number of job inputs does not match number of arguments"
if len(graphs) != len(args):
raise ValueError(msg)

if not graphs:
return []
for task_graph, task_args in zip(graphs, args, strict=True):
arg_index = 0
for task_id in task_graph._impl.input_tasks:
task = task_graph._impl.tasks[task_id]
for task_input in task.task_inputs:
if arg_index >= len(task_args):
raise ValueError(msg)
arg = task_args[arg_index]
if isinstance(arg, Data):
task_input.type = to_tdl_type_str(Data)
task_input.value = arg._impl.id
else:
task_input.type = to_tdl_type_str(type(arg))
task_input.value = core.TaskInputValue(msgpack.packb(arg))
arg_index += 1
if arg_index != len(task_args):
raise ValueError(msg)

jobs = self._storage.submit_jobs(self._driver_id, [graph._impl for graph in graphs])
return [Job(job, self._storage) for job in jobs]

def create_data(self, data: Data) -> None:
"""
Registers a Data object in the storage.
:param data: The Data object to register.
:raises StorageError: If the Data object cannot be registered in the storage.
"""
self._storage.create_driver_data(self._driver_id, data._impl)
Loading