Skip to content
Merged
Show file tree
Hide file tree
Changes from 243 commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
d2ac198
Update yscope-dev-utils
sitaowang1998 Jul 15, 2025
cc8a097
Use boost install task
sitaowang1998 Jul 15, 2025
7f68bdc
Update install task variable names
sitaowang1998 Jul 15, 2025
2394649
Set CMP0074 to NEW to find boost
sitaowang1998 Jul 15, 2025
6ff3e33
Add uv to install script
sitaowang1998 Jul 15, 2025
7ae8a78
Fix cpp-lint root paths
sitaowang1998 Jul 15, 2025
56502f9
Fix clang-tidy file pattern
sitaowang1998 Jul 15, 2025
6f6becf
Limit build parallelism
sitaowang1998 Jul 17, 2025
a74523d
Bug fix
sitaowang1998 Jul 17, 2025
2345d22
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 Jul 17, 2025
77ee494
Bug fix
sitaowang1998 Jul 17, 2025
38b86c8
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 Jul 17, 2025
3698339
Bug fix
sitaowang1998 Jul 17, 2025
369e9f1
Rename variables to mirror CLP core
sitaowang1998 Aug 4, 2025
90aa5a2
Rename variables to mirror clp core
sitaowang1998 Aug 4, 2025
1769c95
Merge branch 'dep-concurrency' of github.com:sitaowang1998/spider int…
sitaowang1998 Aug 4, 2025
edaa834
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 Aug 4, 2025
7faac8f
Revert "Merge branch 'dep-concurrency' of github.com:sitaowang1998/sp…
sitaowang1998 Aug 4, 2025
f494a90
Add comment for deps parallelism default value
sitaowang1998 Aug 4, 2025
eb01bb2
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 Aug 4, 2025
ff2fe1c
Update yscope-dev-utils
sitaowang1998 Aug 4, 2025
d476e42
Merge branch 'main' into yscope-dev-utils
sitaowang1998 Aug 4, 2025
850126d
Merge branch 'yscope-dev-utils' into python_lint
sitaowang1998 Aug 4, 2025
65841a0
Add latest python lint config files
sitaowang1998 Aug 4, 2025
8564fc2
Update ruff lint tasks
sitaowang1998 Aug 4, 2025
a6e7d29
Fix ruff lint
sitaowang1998 Aug 4, 2025
573b448
Fix ruff lint
sitaowang1998 Aug 4, 2025
6ad72c3
Bug fix
sitaowang1998 Aug 4, 2025
ba7c6e5
Fix ruff
sitaowang1998 Aug 4, 2025
209acb1
Fix ruff
sitaowang1998 Aug 4, 2025
406b514
Reformat files
sitaowang1998 Aug 4, 2025
66892f5
Remove .inc from cpp linting
sitaowang1998 Aug 4, 2025
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
a8c8641
Fix pytest
sitaowang1998 Aug 9, 2025
9fabc44
Merge branch 'python_test_setup' into python_type
sitaowang1998 Aug 9, 2025
e558f67
Improve code according to coderabbit
sitaowang1998 Aug 9, 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
75793de
Bug fix
sitaowang1998 Aug 12, 2025
72a0920
Bug fix
sitaowang1998 Aug 12, 2025
2b5405a
Bug fix
sitaowang1998 Aug 12, 2025
fecdc68
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
08ce667
Restructure code to perpare for merge
sitaowang1998 Aug 24, 2025
4dc9623
Merge branch 'main' into python_client_task
sitaowang1998 Aug 24, 2025
ff76756
Style improvement
sitaowang1998 Aug 24, 2025
b9607ae
Use index instead of uuid to identify task in graph
sitaowang1998 Aug 25, 2025
75c8b76
Rename files
sitaowang1998 Aug 25, 2025
b95af57
Restructure to prepare for merge
sitaowang1998 Aug 25, 2025
e81c509
Merge branch 'python_client_task_index' into python-job-submission
sitaowang1998 Aug 25, 2025
d19fda2
Use updated task graph structure
sitaowang1998 Aug 26, 2025
afa7898
Bug fix
sitaowang1998 Aug 26, 2025
8e98c1e
Fix task input refs
sitaowang1998 Aug 26, 2025
fe306bc
Add test for task input output ref size
sitaowang1998 Aug 26, 2025
d0fb7e2
Avoid deep copy tasks
sitaowang1998 Aug 26, 2025
6fe936d
Fix chain task input output refs
sitaowang1998 Aug 26, 2025
82dab16
Merge branch 'main' into python_client_task
sitaowang1998 Aug 26, 2025
5ef3520
Add spider-py unit test tasks
sitaowang1998 Aug 26, 2025
395d46c
Add spider-py unit test tasks
sitaowang1998 Aug 26, 2025
b879134
Revert "Add spider-py unit test tasks"
sitaowang1998 Aug 26, 2025
1d6e28e
Merge branch 'python_client_task' into python-job-submission
sitaowang1998 Aug 26, 2025
7d41718
Merge branch 'main' into python-job-submission
sitaowang1998 Sep 3, 2025
67d3709
Fix ruff check
sitaowang1998 Sep 3, 2025
ef342cd
Fix task style based on review
sitaowang1998 Sep 4, 2025
69adf5a
Remove unpack for InputOutputRef
sitaowang1998 Sep 4, 2025
582abf6
Move sql parameter generation into separate functions
sitaowang1998 Sep 4, 2025
ec2d1d4
Apply suggestions from code review
sitaowang1998 Sep 4, 2025
413b3c8
Rename helper functions and move them after the public funciton
sitaowang1998 Sep 4, 2025
5f8ae0e
Update readme to add storage unit tests
sitaowang1998 Sep 4, 2025
9d19fff
Fix typo
sitaowang1998 Sep 4, 2025
6795c29
Format README.
LinZhihao-723 Sep 4, 2025
5b3dd17
Apply suggestions from code review
sitaowang1998 Sep 4, 2025
d0c3049
Rename functions
sitaowang1998 Sep 4, 2025
383373f
Add docstring and type annotation
sitaowang1998 Sep 4, 2025
86b318e
Initialize the ids explicitly
sitaowang1998 Sep 4, 2025
961018a
Merge branch 'python-job-submission' of github.com:sitaowang1998/spid…
sitaowang1998 Sep 4, 2025
890b620
Fix jdbc url docstring
sitaowang1998 Sep 4, 2025
6384fbb
USer urlparse to parse jdbc urls
sitaowang1998 Sep 4, 2025
2e91ced
Bug fix
sitaowang1998 Sep 4, 2025
67a55ef
Add detailed instruction on how to set up tables
sitaowang1998 Sep 4, 2025
4ffec6d
Apply code review
sitaowang1998 Sep 4, 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
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: what's the plan for the storage tests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean storage tests in GH workflows?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Are we planning to add this to our workflows?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were talks about it, but no concrete plans. I don't think this is very hard to implement, but we do need to sync the test jdbc url across C++ and Python as they are different right now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I think we should set it up ASAP. Let's prioritize this after ur're done with compression integration.

Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:

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

- run: "task test:spider-py-unit-tests"
- run: "task test:spider-py-non-storage-unit-tests"
14 changes: 8 additions & 6 deletions docs/src/dev-docs/testing.md
Comment thread
sitaowang1998 marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +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:cpp-unit-tests` | Runs all C++ unit tests. |
| `test:cpp-non-storage-unit-tests` | Runs all C++ unit tests which don't require a storage backend to run. |
| `test:cpp-storage-unit-tests` | Runs all C++ unit tests which require a storage backend to run. |
| `test:spider-py-unit-tests` | Runs all spider-py unit tests. |
| Task | Description |
|-----------------------------------------|-----------------------------------------------------------------------------|
| `test:cpp-unit-tests` | Runs all C++ unit tests. |
| `test:cpp-non-storage-unit-tests` | Runs all C++ unit tests which don't require a storage backend to run. |
| `test:cpp-storage-unit-tests` | Runs all C++ unit tests which require a storage backend to run. |
| `test:spider-py-unit-tests` | Runs all spider-py unit tests. |
| `test:spider-py-non-storage-unit-tests` | Runs all spider-py unit tests which don't require a storage backend to run. |
| `test:spider-py-storage-unit-tests` | Runs all spider-py unit 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 Down
48 changes: 47 additions & 1 deletion python/spider-py/README.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let's add a sentence to explain how to set up the DB. We don't have the scheduler ready as it's not the integration test.

Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,58 @@ directory at the Spider project root.

## Testing

To run all unit tests:
Unit tests are divided into two categories: storage and non-storage tests. Non-storage tests do not
require any external services, while storage tests require a MariaDB instance to be available.

### Non-Storage Unit Tests

To run all non-storage unit tests:

```shell
task test:spider-py-non-storage-unit-tests
```

### Setup MariaDB for Storage Unit Tests

To run storage unit tests, we need to create a MariaDB instance first.

```shell
docker run \
--detach \
--rm \
--name spider-storage \
--env MARIADB_USER=spider \
--env MARIADB_PASSWORD=password \
--env MARIADB_DATABASE=spider-storage \
--env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=true \
--publish 3306:3306 mariadb:latest
```

The database tables will be automatically created by the spawned spider scheduler.

You can choose to set up the database table manually by using the SQL script
`tools/scripts/storage/init_db.sql` from the project root.

### Storage Unit Tests

To run all storage unit tests:

```shell
task test:spider-py-storage-unit-tests
```

This requires a running MariaDB instance as described above.

### All Unit Tests

To run all unit tests (both storage and non-storage):

```shell
task test:spider-py-unit-tests
```

This requires a running MariaDB instance as described above.

## Linting

To run all linting checks:
Expand Down
8 changes: 8 additions & 0 deletions python/spider-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ 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 as needing external storage service",
]
testpaths = ["tests"]

[tool.ruff]
Expand Down
5 changes: 4 additions & 1 deletion python/spider-py/src/spider_py/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Spider core package."""

from .data import Data, DataId
from .driver import DriverId
from .task import (
Task,
TaskId,
Expand All @@ -13,11 +14,13 @@
TaskOutputValue,
TaskState,
)
from .task_graph import TaskGraph
from .task_graph import JobId, TaskGraph

__all__ = [
"Data",
"DataId",
"DriverId",
"JobId",
"Task",
"TaskGraph",
"TaskId",
Expand Down
5 changes: 5 additions & 0 deletions python/spider-py/src/spider_py/core/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Spider core Driver module."""

from uuid import UUID

DriverId = UUID
37 changes: 36 additions & 1 deletion python/spider-py/src/spider_py/core/task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Task module for Spider."""

from __future__ import annotations

from dataclasses import dataclass, field
from enum import IntEnum
from uuid import UUID, uuid4
Expand All @@ -26,7 +28,7 @@ class TaskInput:
"""Represents a task input"""

type: str
value: TaskInputData | TaskInputOutput | None
value: TaskInputData | TaskInputOutput | TaskInputValue | None


TaskOutputValue = bytes
Expand All @@ -51,6 +53,39 @@ class TaskState(IntEnum):
Failed = 4
Cancelled = 5

def __str__(self) -> str:
"""
Returns string representation of task state.
:return: The string representation of task state.
"""
return _StateToStrMap[self]

@staticmethod
def from_str(state_str: str) -> TaskState:
"""
Returns task state from string representation.
:param state_str: The string representation of task state.
:return: The task state from string representation.
:raises ValueError: If the state string is not recognized.
"""
state = _StrToStateMap.get(state_str)
if state is not None:
return state
msg = f"Invalid task state string: {state_str}"
raise ValueError(msg)


_StateToStrMap = {
TaskState.Pending: "pending",
TaskState.Ready: "ready",
TaskState.Running: "running",
TaskState.Succeeded: "success",
TaskState.Failed: "fail",
TaskState.Cancelled: "cancel",
Comment thread
sitaowang1998 marked this conversation as resolved.
Resolved
}

_StrToStateMap = {value: key for key, value in _StateToStrMap.items()}


@dataclass
class Task:
Expand Down
3 changes: 3 additions & 0 deletions python/spider-py/src/spider_py/core/task_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

from copy import deepcopy
from typing import TYPE_CHECKING
from uuid import UUID

if TYPE_CHECKING:
from spider_py.core.task import Task

JobId = UUID


class TaskGraph:
"""
Expand Down
13 changes: 13 additions & 0 deletions python/spider-py/src/spider_py/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Spider Storage package."""

from .jdbc_url import JdbcParameters, parse_jdbc_url
from .mariadb_storage import MariaDBStorage
from .storage import Storage, StorageError

__all__ = [
"JdbcParameters",
"MariaDBStorage",
"Storage",
"StorageError",
"parse_jdbc_url",
]
55 changes: 55 additions & 0 deletions python/spider-py/src/spider_py/storage/jdbc_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""JDBC URL module."""

import urllib.parse
from dataclasses import dataclass


@dataclass
class JdbcParameters:
"""JDBC url parameters."""

protocol: str
host: str
database: str
port: int | None = None
user: str | None = None
password: str | None = None


_JdbcPrefix = "jdbc:"


def parse_jdbc_url(url: str) -> JdbcParameters:
Comment thread
sitaowang1998 marked this conversation as resolved.
Resolved
"""
Parses a JDBC URL.
:param url:
:return: Parsed JDBC parameters.
Comment thread
sitaowang1998 marked this conversation as resolved.
Resolved
:raises ValueError: If the JDBC URL is invalid.
"""
protocol_prefix = ""
if url.startswith(_JdbcPrefix):
url = url.removeprefix(_JdbcPrefix)
protocol_prefix = _JdbcPrefix
parsed = urllib.parse.urlparse(url)
Comment thread
sitaowang1998 marked this conversation as resolved.
Resolved

msg = "Invalid JDBC URL: {}. Missing {}."
if not parsed.scheme:
raise ValueError(msg.format(url, "protocol"))
if not parsed.hostname:
raise ValueError(msg.format(url, "host"))
if not parsed.path or not parsed.path.lstrip("/"):
raise ValueError(msg.format(url, "database"))

database = parsed.path.lstrip("/")
query_params = urllib.parse.parse_qs(parsed.query)
user = query_params.get("user", [None])[0]
password = query_params.get("password", [None])[0]

return JdbcParameters(
protocol=protocol_prefix + parsed.scheme,
host=parsed.hostname,
port=parsed.port,
database=database,
user=user,
password=password,
)
Loading