Exemplo n.º 1
0
 def process_response(response: Response, latest_log_id: int) -> int:
     for log in response.json():
         check_gt(log["id"], latest_log_id)
         latest_log_id = log["id"]
         print("{} [{}]: {}".format(log["time"], log["level"],
                                    log["message"]))
     return latest_log_id
Exemplo n.º 2
0
    def __init__(self, batch_sampler: torch.utils.data.BatchSampler,
                 num_replicas: int, rank: int) -> None:
        check_gt(rank, -1, "rank must be non-negative")
        check_gt(num_replicas, 0, "num_replicas must be positive")
        check_lt(rank, num_replicas, "rank must be less than num_replicas")

        self.batch_sampler = batch_sampler
        self.num_replicas = num_replicas
        self.rank = rank
Exemplo n.º 3
0
    def process_response(logs: Any, latest_log_id: int) -> Tuple[int, bool]:
        changes = False
        for log in logs:
            check_gt(log.id, latest_log_id)
            latest_log_id = log.id
            msg = api.decode_bytes(log.message)
            print(msg, end="")
            changes = True

        return latest_log_id, changes
Exemplo n.º 4
0
 def __init__(self,
              storage_id: str,
              resources: Dict[str, int],
              labels: Optional[Dict[str, str]] = None) -> None:
     check_gt(len(storage_id), 0, "Invalid storage ID")
     if labels is None:
         labels = {}
     self.storage_id = storage_id
     self.resources = resources
     self.labels = labels
Exemplo n.º 5
0
 def __init__(
     self,
     storage_id: str,
     resources: Dict[str, int],
     framework: Optional[str] = None,
     format: Optional[str] = None,
 ) -> None:
     check_gt(len(storage_id), 0, "Invalid storage ID")
     self.storage_id = storage_id
     self.resources = resources
     self.framework = framework
     self.format = format
Exemplo n.º 6
0
 def __init__(
     self,
     host_path: str,
     container_path: str = "/determined_shared_fs",
     storage_path: Optional[str] = None,
     propagation: str = "rprivate",
 ) -> None:
     super().__init__(
         _full_storage_dir(host_path, container_path, storage_path))
     check_type(host_path, str, "`host_path` must be a str.")
     check_true(os.path.isabs(host_path),
                "`host_path` must be an absolute path.")
     check_type(container_path, str, "`container_path` must be a str.")
     check_true(os.path.isabs(container_path),
                "`container_path` must be an absolute path.")
     check_type(propagation, str, "`propagation` must be a str.")
     check_gt(len(host_path), 0, "`host_path` must be non-empty.")
     check_gt(len(container_path), 0, "`container_path` must be non-empty.")
     self.host_path = host_path
     self.container_path = container_path
     self.propagation = propagation
Exemplo n.º 7
0
 def __init__(self, base_path: str) -> None:
     check_type(base_path, str)
     check_gt(len(base_path), 0)
     self._base_path = base_path