Skip to main content

Module scan

Module scan 

Source
Expand description

Scanning a DAG root: the files it holds, and its content hash.

A root is scanned recursively, following symbolic links (git-sync switches a link to each new checkout), skipping what .schedrignore files exclude (gitignore syntax, in any directory), .git and __pycache__ directories and *.pyc files. Every other file counts for the content hash, not only .py files, since tasks read SQL, configuration and other files next to their DAG files; only .py files mentioning schedr are parsed (see archive/PROJECT.md, DAG code delivery and Code versions and change detection; decision 305).

Structs§

Captured
A root’s code, copied by capture: its content hash and the read-only copy.
Snapshot
The files of a root at one moment. Two snapshots are equal when the root resolves to the same directory and every file has the same path, size and modification time.
Stamp
What a file looked like when scanned: enough to notice that it changed.

Enums§

ScanError
A failure to scan or hash a root.

Constants§

DAG_FILE_MARK
What a .py file must contain to be parsed (decision 305).
HASH_PREFIX
The prefix of content hashes, naming the algorithm.
IGNORE_FILE
The name of ignore files.
SKIPPED_DIRS
Directories never scanned.

Functions§

capture
Copies a snapshot’s files into store and hashes the bytes copied (decision 102): parse jobs and tasks import from the copy, so the code that runs is the code hashed, whatever happens to the root afterwards (git-sync deleting a checkout, an edit in place). A followed link is copied as its target’s contents; the copy is read-only (executable bits kept), so no task changes another’s code by accident. The hash is the same as content_hash’s.
content_hash
The content hash of a snapshot’s files: sha256: and the hex digest of each file’s path, length and bytes, in path order. It depends only on the files’ paths and contents, so every worker with the same code gets the same hash.
mentions_schedr
Whether path contains DAG_FILE_MARK, in its bytes, whatever its encoding. A file that can’t be read counts as mentioning it: the parser then reports why, under its timeout, instead of its DAGs quietly counting as removed. So does what isn’t a regular file (opening a FIFO would wait for a writer, with no timeout here).
remove_capture
Removes a copy made by capture, read-only as it is: first renamed to a temporary name, so a removal cut short never leaves a partial copy under its hash’s name (which a later capture of that hash would use as it is).
remove_tree
Removes a folder that may hold read-only copies of code (a local run’s, B181).
scan
Scans a root.
split_dag_files
files (relative to dir) split into those to parse and those that don’t mention schedr (decision 305).