Batch#

Directory scan and the batch loop (error isolation, circuit breaker, summary).

exception remote_compression.batch.BatchAborted[source]#

Too many consecutive failures: the batch stops instead of burning CPU.

class remote_compression.batch.BatchSummary(done: int = 0, conform: int = 0, tracked: int = 0, failed: int = 0, not_profitable: int = 0, dry_run: int = 0, bytes_before: int = 0, bytes_after: int = 0, keep_files_seen: int = 0)[source]#

Counters of a batch run.

done, conform, tracked, failed, not_profitable, dry_run

Files per outcome (tracked = skipped through the failure log).

Type:

int

bytes_before, bytes_after

Cumulated sizes of successfully compressed files.

Type:

int

keep_files_seen#

Legacy .keep files crossed during the scan.

Type:

int

bump(result)[source]#

Account for one FileResult.

remote_compression.batch.LEGACY_KEEP = '.keep'#

Legacy per-directory tracking files from rcomp < 0.2 (dill format, unused).

remote_compression.batch.MAX_CONSECUTIVE_FAILURES = 5#

Consecutive failures beyond which the batch aborts (something is systemic).

remote_compression.batch.find_keep_files(target)[source]#
Returns:

All legacy .keep files under target.

Return type:

list of Path

remote_compression.batch.run_batch(target, settings, dry_run=False, retry_failed=False, no_progress=False, tracker=None, host=None)[source]#

Compress every relevant video under target.

Parameters:
  • target (Path or str) – Video file or directory.

  • settings (Settings) – Resolved settings.

  • dry_run (bool) – Show the work without doing it: no ffmpeg, no SSH connection, no write.

  • retry_failed (bool) – Ignore the failure log and retry those files.

  • no_progress (bool) – Disable the tqdm bars.

  • tracker (Tracker, optional) – Injected failure log (defaults to the user-wide one).

  • host (optional) – Injected execution host (defaults to open_host() on the settings). Entered as a context manager either way.

Returns:

Also logged at the end, including on interruption.

Return type:

BatchSummary

Raises:

BatchAborted – After MAX_CONSECUTIVE_FAILURES consecutive failures.

remote_compression.batch.scan(target, extensions)[source]#

List the videos to consider.

Parameters:
  • target (Path or str) – A video file, or a directory walked recursively (deterministic order).

  • extensions (frozenset of str) – Extensions to keep (compared lower-case, so .MP4 files count).

Returns:

  • list of Path – Video files; ori_* backups and comp_* leftovers are skipped.

  • int – Number of legacy .keep files crossed (see rcomp cleanup).