-
Notifications
You must be signed in to change notification settings - Fork 12
feat(spider-py): Add storage functions to get job status and results. #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
232 commits
Select commit
Hold shift + click to select a range
d2ac198
Update yscope-dev-utils
sitaowang1998 cc8a097
Use boost install task
sitaowang1998 7f68bdc
Update install task variable names
sitaowang1998 2394649
Set CMP0074 to NEW to find boost
sitaowang1998 6ff3e33
Add uv to install script
sitaowang1998 7ae8a78
Fix cpp-lint root paths
sitaowang1998 56502f9
Fix clang-tidy file pattern
sitaowang1998 6f6becf
Limit build parallelism
sitaowang1998 a74523d
Bug fix
sitaowang1998 2345d22
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 77ee494
Bug fix
sitaowang1998 38b86c8
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 3698339
Bug fix
sitaowang1998 369e9f1
Rename variables to mirror CLP core
sitaowang1998 90aa5a2
Rename variables to mirror clp core
sitaowang1998 1769c95
Merge branch 'dep-concurrency' of github.com:sitaowang1998/spider int…
sitaowang1998 edaa834
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 7faac8f
Revert "Merge branch 'dep-concurrency' of github.com:sitaowang1998/sp…
sitaowang1998 f494a90
Add comment for deps parallelism default value
sitaowang1998 eb01bb2
Merge branch 'dep-concurrency' into yscope-dev-utils
sitaowang1998 ff2fe1c
Update yscope-dev-utils
sitaowang1998 d476e42
Merge branch 'main' into yscope-dev-utils
sitaowang1998 850126d
Merge branch 'yscope-dev-utils' into python_lint
sitaowang1998 65841a0
Add latest python lint config files
sitaowang1998 8564fc2
Update ruff lint tasks
sitaowang1998 a6e7d29
Fix ruff lint
sitaowang1998 573b448
Fix ruff lint
sitaowang1998 6ad72c3
Bug fix
sitaowang1998 ba7c6e5
Fix ruff
sitaowang1998 209acb1
Fix ruff
sitaowang1998 406b514
Reformat files
sitaowang1998 66892f5
Remove .inc from cpp linting
sitaowang1998 80f0a10
Merge branch 'yscope-dev-utils' into python_lint
sitaowang1998 3186a42
Add mypy and merge lint and test requirements.txt
sitaowang1998 0925938
Fix mysql connection type
sitaowang1998 6936a9b
Fix socket name type
sitaowang1998 7407090
Fix return type from db cursor
sitaowang1998 6a95b24
Fix db cursor return type
sitaowang1998 f29dcba
Fix mypy import untyped
sitaowang1998 453f209
Fix mypy and Popen
sitaowang1998 d1011c7
Fix generator type hint
sitaowang1998 a7dc642
Fix mypy
sitaowang1998 a7d92c2
Fix ruff
sitaowang1998 1c6213b
Simply socket return types.
sitaowang1998 0f13d07
Merge branch 'main' into python_lint
sitaowang1998 14d6326
Merge branch 'python_lint' into mypy_lint
sitaowang1998 55a727a
Add tombi lint tasks
sitaowang1998 c98fea1
Rename cpp build tasks
sitaowang1998 ef64454
Merge branch 'main' into mypy_lint
sitaowang1998 09ba8ad
Merge branch 'main' into tombi
sitaowang1998 4e7237e
Add basic python structure
sitaowang1998 1f944d0
Fix code structure
sitaowang1998 68992fc
Fix ruff lint
sitaowang1998 1127b22
Extend lint tasks to python directory
sitaowang1998 4c51c91
Add python build tasks
sitaowang1998 56878b2
Merge branch 'main' into mypy_lint
sitaowang1998 bb428c9
Merge branch 'mypy_lint' into tombi
sitaowang1998 944bd5e
Merge branch 'tombi' into build-task
sitaowang1998 d75bc15
Merge branch 'build-task' into python_structure
sitaowang1998 4b7eca2
Merge branch 'main' into tombi
sitaowang1998 8ddbda7
Merge branch 'tombi' into build-task
sitaowang1998 0d998ec
Merge branch 'build-task' into python_structure
sitaowang1998 6004d64
Fix yaml lint error
sitaowang1998 bcab5db
Fix tombi lint
sitaowang1998 a50d25a
Remove wrong mypy config
sitaowang1998 fbebb96
Fix typo and format file
sitaowang1998 0322bd5
Use typed msgpack and remove mypy config for msgpack from pyproject
sitaowang1998 2a08155
Update uv lock
sitaowang1998 dd29c23
Add task module
sitaowang1998 570cf2f
Merge branch 'python_structure' into python_task
sitaowang1998 9b2a175
Add data and improve type alias
sitaowang1998 32afe0a
Add task graph and reformat files
sitaowang1998 0b62f73
Merge branch 'main' into tombi
sitaowang1998 7384158
Merge branch 'main' into build-task
sitaowang1998 70ef90a
Merge branch 'main' into python_structure
sitaowang1998 1aae0cb
Merge branch 'main' into python_task
sitaowang1998 2f9b4a0
Fix typo
sitaowang1998 4e080ac
Fix set remove key error
sitaowang1998 b09515c
Increase min version of tombi
sitaowang1998 bad9675
Merge branch 'tombi' into build-task
sitaowang1998 e009ff4
Merge branch 'tombi' into python_structure
sitaowang1998 f11a3b6
Merge branch 'python_structure' into python_task
sitaowang1998 a0407a7
Merge branch 'main' into tombi
sitaowang1998 aa9a8de
Merge branch 'tombi' into build-task
sitaowang1998 3c7e794
Merge branch 'tombi' into python_structure
sitaowang1998 ca4ec29
Merge branch 'python_structure' into python_task
sitaowang1998 b4d6576
Add uv in README
sitaowang1998 23f31cd
Merge branch 'main' into build-task
sitaowang1998 0167ac0
Merge branch 'build-task' into python_structure
sitaowang1998 5a9cb76
Merge branch 'python_structure' into python_task
sitaowang1998 f447614
Fix redenduncy caused by merge
sitaowang1998 a84de83
Merge branch 'build-task' into python_structure
sitaowang1998 f94460f
Merge branch 'python_structure' into python_task
sitaowang1998 2d1b6fc
Merge branch 'main' into python_structure
sitaowang1998 5a35122
Merge branch 'main' into python_task
sitaowang1998 061d101
Merge branch 'main' into python_structure
sitaowang1998 451a80e
Merge branch 'main' into python_task
sitaowang1998 de149ee
Add integral types
sitaowang1998 d332dbe
Revert "Add integral types"
sitaowang1998 80b6772
Add package export control for type
sitaowang1998 f2ebaa6
Add floating point type
sitaowang1998 8c27b16
Restructure under src/spider
sitaowang1998 1b7ab77
Merge branch 'python_structure' into python_task
sitaowang1998 b7f1884
Merge branch 'python_structure' into python_type
sitaowang1998 a7aa6b0
Re-export spider.type under spider
sitaowang1998 95b98c8
Merge branch 'main' into python_structure
sitaowang1998 e7b119c
Merge branch 'main' into python_task
sitaowang1998 8ffbd03
Fix import path
sitaowang1998 5765acf
Add tdl types; Allow no docstring for override function
sitaowang1998 427dd6b
Merge branch 'main' into python_structure
sitaowang1998 a9c9e57
Merge branch 'main' into python_task
sitaowang1998 213d2fc
Add type conversion to tdl type
sitaowang1998 a1a86f3
Add to_tdl_str
sitaowang1998 97af71b
Add to_tdl_type_str to type package export
sitaowang1998 74f31e2
Add pytest and basic test structure
sitaowang1998 7d95706
Add python test tasks
sitaowang1998 96b5324
Rename some cpp tests and add python tests to GH workflow and doc
sitaowang1998 14ea6fb
Don't create __pycache__ when running pytest
sitaowang1998 854cd11
Fix missing link
sitaowang1998 5565c9e
Merge branch 'python_structure' of github.com:sitaowang1998/spider in…
sitaowang1998 a9791e5
Merge branch 'python_structure' into python_task
sitaowang1998 2504429
Merge branch 'python_structure' into python_test_setup
sitaowang1998 7ea4928
Use task env
sitaowang1998 01dd0c6
Fix task executor path
sitaowang1998 c6ccce6
Merge branch 'python_structure' into python_task
sitaowang1998 4cec09b
Merge branch 'python_structure' into python_test_setup
sitaowang1998 e022404
Merge branch 'main' into python_structure
sitaowang1998 8894b90
Merge branch 'main' into python_test_setup
sitaowang1998 01c9c64
Merge branch 'main' into python_task
sitaowang1998 7753153
Merge branch 'main' into python_structure
sitaowang1998 dd59915
Merge branch 'main' into python_test_setup
sitaowang1998 b86d47c
Merge branch 'main' into python_task
sitaowang1998 ac1d4ee
Merge branch 'python_structure' into python_type
sitaowang1998 0d38c43
Merge branch 'python_test_setup' into python_type
sitaowang1998 438f6e7
Remove unnecessary __init__.py files
sitaowang1998 2caad5d
Merge branch 'python_structure' into python_test_setup
sitaowang1998 c6815ce
Merge branch 'python_test_setup' into python_type
sitaowang1998 61e0651
Fix bugs
sitaowang1998 8b13abd
Add some type convertion tests
sitaowang1998 50b2b25
Bug fix
sitaowang1998 519dcd8
Merge branch 'python_test_setup' into python_type
sitaowang1998 8e2786b
Add more tests
sitaowang1998 41d5de2
Add parsing of tdl type string
sitaowang1998 0a377f5
Add tests and fix parser
sitaowang1998 a8c8641
Fix pytest
sitaowang1998 9fabc44
Merge branch 'python_test_setup' into python_type
sitaowang1998 ade589b
Merge branch 'python_type' into python_type_parse
sitaowang1998 0b18170
Satisfy linter
sitaowang1998 0bfbdb5
Fix comment
sitaowang1998 e558f67
Improve code according to coderabbit
sitaowang1998 73e8f0c
Merge branch 'python_type' into python_type_parse
sitaowang1998 6b58ff0
Move functions to util
sitaowang1998 90ab334
Unwarp the type node to get TdlType
sitaowang1998 49acaee
Catch and rethrow lark error
sitaowang1998 09d3fd0
Merge branch 'python_type' into python_client_task
sitaowang1998 ae2a935
Add reset id
sitaowang1998 008c6fb
Export core
sitaowang1998 cd60dc6
Merge branch 'python_task' into python_client_task
sitaowang1998 720265f
Add client task graph
sitaowang1998 ebe64c6
Add client taskgraph to spider export
sitaowang1998 404cf3b
Excempt _impl from private access check
sitaowang1998 3f9fe04
Add basic TaskFunction defintion
sitaowang1998 4d10f88
"Add default values for tasks"
sitaowang1998 fe4121f
Merge branch 'python_task' into python_client_task
sitaowang1998 f3ac001
Fix task IO type and add create_task from function
sitaowang1998 95b7773
Add client task group
sitaowang1998 a72e4a6
Add task graph chain
sitaowang1998 f289e5a
Reset ids after chain
sitaowang1998 2e829bc
Add export
sitaowang1998 ec6802d
Export TaskContext
sitaowang1998 3685dd7
Add unit tests
sitaowang1998 2862f01
Fix tuple check
sitaowang1998 03af08d
Fix size check in chain
sitaowang1998 c3dda18
Fix chain dependencies
sitaowang1998 2a1f33e
Fix id collision
sitaowang1998 0e4452c
Add more tests and more fixes
sitaowang1998 3705ef3
Satisfy ruff
sitaowang1998 fb8938a
Satisfy mypy
sitaowang1998 9ed09be
Bug fix
sitaowang1998 ef827a3
Remove unnecessary reset_ids
sitaowang1998 220a2b0
Fix task input id reset
sitaowang1998 56f7866
Fix comment grammar
sitaowang1998 638d577
Fix tuple check
sitaowang1998 2bcc4a4
Add guard for function with no argument
sitaowang1998 aa1723e
Disallow varargs in task function
sitaowang1998 2469008
Disallow variable tuple return in task function
sitaowang1998 082476d
Use identity check for Parameter.empty sentinel
sitaowang1998 72239f7
Fix error msg for ruff
sitaowang1998 e13acec
Make create_task private
sitaowang1998 84a6256
Split create_task into multiple functions
sitaowang1998 c45eb0d
Add storage cursor
sitaowang1998 1a27b45
Add storage connection interface
sitaowang1998 b505e06
Use functionality as storage interface
sitaowang1998 44067ab
Add jdbc url
sitaowang1998 c81719b
Add mariadb connection
sitaowang1998 899189e
Add submit job sql
sitaowang1998 ba1fd69
Add driver id
sitaowang1998 fe4b24b
Add export of driver id
sitaowang1998 8c0125a
Add submit job db function
sitaowang1998 beb4b5f
Add tests for mariadb
sitaowang1998 ff8bb01
Fix jdbc url
sitaowang1998 43de342
Add mariadb test
sitaowang1998 6b06a30
Split python tests into storage and non-storage
sitaowang1998 8faa0c6
Add more complex graph
sitaowang1998 fe904b0
Bug fix
sitaowang1998 2f1c430
Merge branch 'python_client_task' into python-job-submission
sitaowang1998 e1b1ac3
Bug fix
sitaowang1998 2b5405a
Bug fix
sitaowang1998 3938934
Bug fix
sitaowang1998 eebcab7
Fix docstring typo
sitaowang1998 5e2175a
Fix dict get default value
sitaowang1998 bff3a95
Reformat pyporject.toml
sitaowang1998 e0fd981
Use not list instead of len(list) > 0
sitaowang1998 22e4547
Add client job submission
sitaowang1998 e50e892
Export driver
sitaowang1998 573f01c
Add job submission unit test and fix bugs
sitaowang1998 5a999ff
Set zip to strict
sitaowang1998 8cbebc9
Remove unnecessary zip check
sitaowang1998 2b29782
Remove msgpack exception in docstring
sitaowang1998 44129a6
Fix ruff
sitaowang1998 41cdb3e
Add core job
sitaowang1998 a36ac49
Fix docstring
sitaowang1998 f89ebc6
Export JobStatus in core
sitaowang1998 bd43d58
Add get job status
sitaowang1998 7c2d239
Merge branch 'python_type_parse' into py-job-status
sitaowang1998 d3f3eb1
Export tdl parse function
sitaowang1998 08649c9
Merge branch 'python_type_parse' into py-job-status
sitaowang1998 9a6fb16
Add get result storage function
sitaowang1998 4b755a4
Fix test var name
sitaowang1998 b36071a
Merge branch 'python-client-job' into py-job-status
sitaowang1998 af124fd
Add unit tests for getting status
sitaowang1998 2410829
Fix lint
sitaowang1998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.13 |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = ["_impl"] | ||
|
|
||
| [tool.ruff.lint.pydocstyle] | ||
| ignore-decorators = ["typing.override"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| """Spider package root.""" | ||
|
|
||
| from spider.client import chain, Data, Driver, group, TaskContext, TaskGraph | ||
| from spider.type import Double, Float, Int8, Int16, Int32, Int64 | ||
|
|
||
| __all__ = [ | ||
| "Data", | ||
| "Double", | ||
| "Driver", | ||
| "Float", | ||
| "Int8", | ||
| "Int16", | ||
| "Int32", | ||
| "Int64", | ||
| "TaskContext", | ||
| "TaskGraph", | ||
| "chain", | ||
| "group", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """Spider python client.""" | ||
|
|
||
| from .data import Data | ||
| from .driver import Driver | ||
| from .task import TaskContext | ||
| from .taskgraph import chain, group, TaskGraph | ||
|
|
||
| __all__ = [ | ||
| "Data", | ||
| "Driver", | ||
| "TaskContext", | ||
| "TaskGraph", | ||
| "chain", | ||
| "group", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """Spider client Data module.""" | ||
|
|
||
| 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.data_id = core.DataId() | ||
| self.value = value | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """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)) | ||
|
|
||
| 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.data_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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| """Spider job module.""" | ||
|
|
||
| from spider import core | ||
| from spider.storage import Storage | ||
|
|
||
|
|
||
| class Job: | ||
| """Represents Spider job.""" | ||
|
|
||
| def __init__(self, job: core.Job, storage: Storage) -> None: | ||
| """ | ||
| Creates a new Spider job. | ||
| :param job: Core job object. | ||
| :param storage: The storage backend. | ||
| """ | ||
| self._impl = job | ||
| self.storage = storage |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataId is an alias for UUID, but calling
UUID()without arguments creates a new UUID each time. This should likely beuuid4()to generate a proper UUID.