Skip to content

feat: Add Python task executor. - #205

Closed
sitaowang1998 wants to merge 282 commits into
y-scope:mainfrom
sitaowang1998:py-taskexecutor
Closed

feat: Add Python task executor.#205
sitaowang1998 wants to merge 282 commits into
y-scope:mainfrom
sitaowang1998:py-taskexecutor

Conversation

@sitaowang1998

@sitaowang1998 sitaowang1998 commented Aug 21, 2025

Copy link
Copy Markdown
Collaborator

Description

As title.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • GitHub workflows pass.

Summary by CodeRabbit

  • New Features
    • Introduces a Python SDK for building and composing tasks, submitting jobs, handling results, and working with typed data.
    • Adds a Python task executor CLI (spider_task_executor).
    • Provides a MariaDB-backed storage implementation.
    • Adds Python packaging, typing, linting, and testing configuration.
  • Documentation
    • Updates testing docs to add Python test tasks and clarify C++ test naming.
    • Updates requirements to include uv.
  • Tests
    • Adds comprehensive Python unit and integration tests.
  • Chores
    • Adds Python build/lint/test tasks and variables.
    • CI logs uv version and runs Python non-storage tests.

@sitaowang1998
sitaowang1998 requested a review from a team as a code owner August 21, 2025 01:48
@coderabbitai

coderabbitai Bot commented Aug 21, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a Python client/runtime to Spider with core models, type system, storage interface and MariaDB backend, task executor CLI, and utilities. Introduces Python packaging/config, tests, and task/CI updates (uv integration, Python build/lint/test tasks). Documentation is updated to reflect new Python test tasks and requirements.

Changes

Cohort / File(s) Change summary
CI workflows
.github/workflows/code-linting-checks.yaml, .github/workflows/unit-tests.yaml
Log uv version in tool versions; unit-tests adds a Python non-storage tests step after existing non-storage unit tests.
Docs
README.md, docs/src/dev-docs/testing.md
Add uv requirement and link; update testing docs: split/rename C++ tasks, add Python test task docs.
Task config
build-tasks.yaml, lint-tasks.yaml, taskfile.yaml, test-tasks.yaml
Add py-build using uv; extend py lint with uv-run mypy/ruff over package dir; define Python src/build vars; rename C++ test tasks and add Python test tasks (all/non-storage/storage) with uv run pytest.
Python project setup
python/.python-version, python/pyproject.toml
Pin Python 3.13; add package config for spider (deps, scripts, mypy/pytest/ruff configs, entrypoint spider_task_executor).
Client API
python/src/spider/__init__.py, python/src/spider/client/*
New Python client: Data wrapper, Driver (submit_jobs/create_data), Job (status/results via storage), TaskContext, TaskGraph composition (group/chain), and package exports.
Core models
python/src/spider/core/*
Add core dataclasses/types for Data, DriverId, Job/JobStatus, Task/TaskState and helpers, TaskGraph (add/merge/chain/reset IDs); package exports.
Type system
python/src/spider/type/*
Add TDL type system (types, parse, convert), bounded int and float wrappers, utils for class name/lookup; package exports.
Storage
python/src/spider/storage/*
Define Storage interface and errors; JDBC URL parser; MariaDBStorage implementation (jobs, tasks, data CRUD, status/results); package exports.
Task executor
python/src/spider/task_executor/__init__.py, python/src/spider/task_executor/task_executor.py, python/src/spider/task_executor/task_executor_message.py
Add Python task executor CLI: parse pipes/messages, load function, fetch inputs (incl. Data), execute, return results; message enums/parsing helpers.
Utilities
python/src/spider/utils/__init__.py, python/src/spider/utils/msgpack_serde.py
Add msgpack-like encoder/decoder for dataclasses/collections and package exports.
Tests — client
python/tests/client/*
Tests for Data, Driver submit_jobs error paths, Job status/results, and TaskGraph composition/chaining/failures.
Tests — storage
python/tests/storage/*
Tests for JDBC URL parsing and MariaDBStorage operations (job submit/status/results, data CRUD/error).
Tests — type/utils
python/tests/type/*, python/tests/utils/test_msgpack_serde.py
Tests for TDL parse→native, native→TDL conversion (incl. errors), and msgpack serde round-trips (primitives, collections, dataclasses).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Client as Client (Driver)
  participant Storage as MariaDBStorage
  participant Core as Core Models

  User->>Client: submit_jobs(graphs, args)
  Client->>Client: Validate graphs/args sizes
  Client->>Core: Map inputs (Data IDs or packed values)
  Client->>Storage: submit_jobs(driver_id, core_graphs)
  Storage->>Storage: Insert jobs/tasks/deps/IO rows
  Storage-->>Client: [core.Job...]
  Client-->>User: [Job...]

  User->>Client: job.get_status()
  alt Cached non-Running
    Client-->>User: status
  else Running
    Client->>Storage: get_job_status(job)
    Storage-->>Client: JobStatus
    Client-->>User: status
  end

  User->>Client: job.get_results()
  alt Results cached
    Client-->>User: results
  else Not cached
    Client->>Storage: get_job_results(job)
    Storage-->>Client: [TaskOutput] | None
    Client->>Client: Convert outputs (values/Data)
    Client-->>User: results | None
  end
Loading
sequenceDiagram
  autonumber
  actor Worker as Executor Process
  participant Exec as task_executor.main()
  participant Storage as MariaDBStorage
  participant Target as User Function
  participant Pipes as Input/Output Pipes

  Worker->>Exec: CLI args (--func, --storage_url, --task_id, pipes)
  Exec->>Storage: connect(parse_jdbc_url)
  Exec->>Pipes: receive_message()
  Exec->>Exec: get_request_body() → [args...]
  Exec->>Exec: import target function
  Exec->>Exec: inspect signature
  Exec->>Storage: fetch Data by ID (for Data params)
  Exec->>Exec: msgpack decode other args
  Exec->>Target: call(ctx, *args)
  Target-->>Exec: result | tuple[result...]
  Exec->>Exec: pack results (Data bytes or msgpack)
  Exec->>Pipes: write header + payload (ResponseType.Result)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested reviewers

  • LinZhihao-723
  • davidlion

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 930cf97 and 4d59367.

⛔ Files ignored due to path filters (1)
  • python/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (48)
  • .github/workflows/code-linting-checks.yaml (1 hunks)
  • .github/workflows/unit-tests.yaml (2 hunks)
  • README.md (2 hunks)
  • build-tasks.yaml (1 hunks)
  • docs/src/dev-docs/testing.md (2 hunks)
  • lint-tasks.yaml (1 hunks)
  • python/.python-version (1 hunks)
  • python/pyproject.toml (1 hunks)
  • python/src/spider/__init__.py (1 hunks)
  • python/src/spider/client/__init__.py (1 hunks)
  • python/src/spider/client/data.py (1 hunks)
  • python/src/spider/client/driver.py (1 hunks)
  • python/src/spider/client/job.py (1 hunks)
  • python/src/spider/client/task.py (1 hunks)
  • python/src/spider/client/task_context.py (1 hunks)
  • python/src/spider/client/taskgraph.py (1 hunks)
  • python/src/spider/core/__init__.py (1 hunks)
  • python/src/spider/core/data.py (1 hunks)
  • python/src/spider/core/driver.py (1 hunks)
  • python/src/spider/core/job.py (1 hunks)
  • python/src/spider/core/task.py (1 hunks)
  • python/src/spider/core/taskgraph.py (1 hunks)
  • python/src/spider/storage/__init__.py (1 hunks)
  • python/src/spider/storage/jdbc_url.py (1 hunks)
  • python/src/spider/storage/mariadb_storage.py (1 hunks)
  • python/src/spider/storage/storage.py (1 hunks)
  • python/src/spider/task_executor/__init__.py (1 hunks)
  • python/src/spider/task_executor/task_executor.py (1 hunks)
  • python/src/spider/task_executor/task_executor_message.py (1 hunks)
  • python/src/spider/type/__init__.py (1 hunks)
  • python/src/spider/type/tdl_convert.py (1 hunks)
  • python/src/spider/type/tdl_parse.py (1 hunks)
  • python/src/spider/type/tdl_type.py (1 hunks)
  • python/src/spider/type/type.py (1 hunks)
  • python/src/spider/type/utils.py (1 hunks)
  • python/src/spider/utils/__init__.py (1 hunks)
  • python/src/spider/utils/msgpack_serde.py (1 hunks)
  • python/tests/client/test_data.py (1 hunks)
  • python/tests/client/test_driver.py (1 hunks)
  • python/tests/client/test_job.py (1 hunks)
  • python/tests/client/test_task_graph.py (1 hunks)
  • python/tests/storage/test_jdbc_url.py (1 hunks)
  • python/tests/storage/test_mariadb.py (1 hunks)
  • python/tests/type/test_to_native.py (1 hunks)
  • python/tests/type/test_to_tdl.py (1 hunks)
  • python/tests/utils/test_msgpack_serde.py (1 hunks)
  • taskfile.yaml (1 hunks)
  • test-tasks.yaml (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant