DatasetJob · Python
Process a URL file into bounded, validated, resumable dataset shards.
In this guide
Purpose and lifecycle
The recommended API for large research and directory datasets. Define one row’s meaning, required fields and identity before scaling.
Records remain in Rust and on disk. run returns a report, not all records. Use one active writer per output directory and keep input, configuration, state and committed shards consistent.
A completed resume does not retry already committed failed URLs. Make a new job with corrected input for those failures. Cancellation requires a new instance for resume.
Definition and availability
Source snapshot: 1.0.0-alpha.3. Package export. Declared in source; this is not a runtime test result.
Signatures and source locations are generated from the SDK wrappers. Clean snapshots link to the recorded commit. Modified snapshots link to main, which may differ; file hashes identify the local inputs.
class DatasetJobUsage example
Use a matching source build. Where a snippet uses page, obtain it with the Page example first. Example URLs illustrate API shape; they are not promised datasets.
from crawlingo import DatasetJob
job = DatasetJob({
"urls_file": "urls.txt", "output_dir": "datasets/research",
"fields": [{"name": "title", "selector": "h1", "required": True}],
"format": "jsonl", "concurrency": 8,
})
report = job.run()
print(report["records_written"], report["pages_failed"])Members
| Member | Kind | Return / value type | Source status |
|---|---|---|---|
| __init__ | method | Not annotated; see behavior notes | Present in source |
| run | method | dict | Present in source |
| run_async | method | dict | Present in source |
| cancel | method | None | Present in source |
__init__()
Validate configuration and allocate the job handle. Network requests begin at run, not construction.
Returns / value: Not annotated; see behavior notes.
def __init__(self, config: dict, session: Optional[Session]=None)| Parameter | Type | Required / default | Meaning |
|---|---|---|---|
| config | dict | Required | Configuration object; see the linked job or pagination reference. |
| session | Optional[Session] | Default: None | Shared request state. Omit only where the signature provides a default. |
run()
Run or resume the job and return JobReport. Rust/Node are asynchronous; Python run blocks and releases the GIL for native work.
Returns / value: dict.
def run(self) -> dictrun_async()
Await the Python job in an executor. Task cancellation requests native cancellation and waits for cleanup before re-raising CancelledError.
Returns / value: dict.
async def run_async(self) -> dictcancel()
Request cooperative cancellation. Await the active run before releasing its volume or starting a replacement job. The uncommitted batch may be replayed.
Returns / value: None.
def cancel(self) -> NoneErrors and operational limits
Construction rejects invalid configuration. Job-level storage, checkpoint and configuration failures reject/raise; individual failed pages and rows are counted and written to error shards. complete=true does not mean every page succeeded.
Source availability, package publication and runtime validation are separate facts. These pages describe the source snapshot, not a claim that all platforms or every API path have passed production acceptance.