File size: 1,017 Bytes
bc90483 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed in accordance with
# the terms of the DINOv3 License Agreement.
import contextlib
from datetime import timedelta
from typing import Optional
from dinov3.configs import exit_job, setup_job
@contextlib.contextmanager
def job_context(
output_dir: Optional[str] = None,
distributed_enabled: bool = True,
logging_enabled: bool = True,
seed: Optional[int] = 0,
restrict_print_to_main_process: bool = True,
distributed_timeout: timedelta | None = None,
):
setup_job(
output_dir=output_dir,
distributed_enabled=distributed_enabled,
logging_enabled=logging_enabled,
seed=seed,
restrict_print_to_main_process=restrict_print_to_main_process,
distributed_timeout=distributed_timeout,
)
try:
yield
finally:
exit_job(distributed_enabled=distributed_enabled, logging_enabled=logging_enabled)
|