ChronaxisUser manual中文
On this pageMembersBatchRunnerBatchRunner.__init__BatchRunner.runSource locations

chronaxis.BatchRunner

Import this object from chronaxis. This page covers directly public members and necessary construction/context protocols. See the Chinese implementation reference for internals. Return to the public API index. Check required parameters, defaults, returns, and exceptions before calling.

Members

BatchRunner

Execute independent jobs with a bounded pool of spawn workers. Continuous files within each job retain their original order.

python
BatchRunner(process_count=1, *, fail_fast=False, backend=None)

BatchRunner.__init__

Configure scheduling without starting workers or reading business data.

python
BatchRunner.__init__(process_count=1, *, fail_fast=False, backend=None)
Name Type Required Default Purpose, choices, and effect
process_count int No 1 Positional or keyword. Positive maximum analysis-worker count. Fewer jobs need fewer workers; empty batches start none. Excludes scheduler and CAN reader subprocesses.
fail_fast bool No False Keyword-only. False continues later jobs after failure; True stops new dispatch after observing failure and waits for started jobs to finish cleanup.
backend str | None No None Keyword-only. auto selects from each job's plan; reference or numpy fixes its numerical implementation. None uses each plan's setting.

The initializer returns None; calling BatchRunner(...) creates the instance. Invalid types, ranges, or backends are rejected. Specific errors include ValueError (“process_count需要正原生int。”: requires a positive native int) and TypeError (“fail_fast需要bool。”: requires bool).

BatchRunner.run

Run independent jobs and return a report in declaration order.

python
BatchRunner.run(jobs, output_dir, *, cancel_event=None, device_label='pending') -> BatchReport
Name Type Required Default Purpose, choices, and effect
jobs tuple Yes No default Positional or keyword. BatchJob tuple, for example load_batch_plan("batch.yaml").jobs; each includes an independent identity and plan.
output_dir str | Path Yes No default Positional or keyword. Reusable batch directory. Job subdirectories use the batch timestamp; existing results are preserved.
cancel_event threading.Event | None No None Keyword-only. Another thread can call set() to stop new dispatch; running jobs continue to finish cleanup. None disables this cancellation signal.
device_label str No 'pending' Keyword-only. Verified source-device label, such as home/work, or pending when unknown. It does not affect calculations or infer the device from paths.

Returns BatchReport; its close() retries failed cleanup in child processes. Declaration/path errors are rejected before creating workers. Worker-scheduler or other infrastructure errors propagate after cleanup, with batch_report when a report was created. If worker construction is interrupted and cleanup still needs recovery, the original KeyboardInterrupt propagates with batch_worker_cleanup_owner; that unfinished worker may not belong to a report job. Retain both the report and any recovery object, and retry their close methods after resolving the resource fault. Ctrl+C whose cleanup completed follows the normal cancelled-report path.

Specific errors: TypeError if jobs is not a BatchJob tuple (“批量任务需要BatchJob tuple。”); ValueError for duplicate or case-colliding IDs (“批量job_id不能重复,大小写冲突也拒绝。”); TypeError for a non-threading.Event cancellation signal (“cancel_event需要threading.Event。”); ValueError for an empty/nontext device label (“device_label需要非空文本。”).

Side effects: starts at most process_count workers and publishes each job independently. Cancellation prevents dispatch only for jobs not yet dispatched.

Source locations

Chronaxis user manual · Offline edition