Skip to content

process.py

QuietStdOut

Context for suppressing standard output

Source code in workflow_deeplabcut/process.py
 7
 8
 9
10
11
12
13
14
15
16
class QuietStdOut:
    """Context for suppressing standard output"""

    def __enter__(self):
        self._original_stdout = sys.stdout
        sys.stdout = open(os.devnull, "w")

    def __exit__(self, exc_type, exc_val, exc_tb):
        sys.stdout.close()
        sys.stdout = self._original_stdout

run(verbose=True, display_progress=True, reserve_jobs=False, suppress_errors=False)

Run all make methods from element-deeplabcut

Parameters:

Name Type Description Default
verbose bool

Print which table is in being populated. Default True.

True
display_progress bool

tqdm progress bar. Defaults to True.

True
reserve_jobs bool

Reserves job to populate in asynchronous fashion. Defaults to False.

False
suppress_errors bool

Suppress errors that would halt execution. Defaults to False.

False
Source code in workflow_deeplabcut/process.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def run(
    verbose: bool = True,
    display_progress: bool = True,
    reserve_jobs: bool = False,
    suppress_errors: bool = False,
):
    """Run all `make` methods from element-deeplabcut

    Args:
        verbose (bool, optional): Print which table is in being populated. Default True.
        display_progress (bool, optional): tqdm progress bar. Defaults to True.
        reserve_jobs (bool, optional): Reserves job to populate in asynchronous fashion.
            Defaults to False.
        suppress_errors (bool, optional): Suppress errors that would halt execution.
            Defaults to False.
    """
    populate_settings = {
        "display_progress": display_progress,
        "reserve_jobs": reserve_jobs,
        "suppress_errors": suppress_errors,
    }

    tables = [
        train.ModelTraining(),
        model.RecordingInfo(),
        model.ModelEvaluation(),
        model.PoseEstimation(),
    ]

    with nullcontext() if verbose else QuietStdOut():
        for table in tables:
            print(f"\n---- Populating {table.table_name} ----")
            table.populate(**populate_settings)