mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-22 22:25:10 +08:00
Make torchelastic publicly importable by raising error on import etcd lazily, [BE task, row 7](https://docs.google.com/spreadsheets/d/1TtATnLJf1rVXaBQd3X3yYqm9xNN9BIWG7QqRgrFiRRI/edit?gid=1748512924#gid=1748512924) Pull Request resolved: https://github.com/pytorch/pytorch/pull/145396 Approved by: https://github.com/albanD ghstack dependencies: #145387
76 lines
2.0 KiB
Python
76 lines
2.0 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the BSD-style license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
from typing import Any, Optional
|
|
|
|
|
|
"""
|
|
This file is not meant to be used directly. It serves as a stub to allow
|
|
other files to be safely imported without requiring the installation of
|
|
the 'etcd' library. The classes and methods here raise exceptions to
|
|
indicate that the real 'etcd' module is needed.
|
|
"""
|
|
|
|
|
|
class EtcdStubError(ImportError):
|
|
"""Custom exception to indicate that the real etcd module is required."""
|
|
|
|
def __init__(self) -> None:
|
|
super().__init__("The 'etcd' module is required but not installed.")
|
|
|
|
|
|
class EtcdAlreadyExist(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdCompareFailed(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdKeyNotFound(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdWatchTimedOut(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdEventIndexCleared(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdException(Exception):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class EtcdResult:
|
|
def __init__(self) -> None:
|
|
raise EtcdStubError
|
|
|
|
|
|
class Client:
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise EtcdStubError
|
|
|
|
def read(self, key: str) -> None:
|
|
raise EtcdStubError
|
|
|
|
def write(
|
|
self, key: str, value: Any, ttl: Optional[int] = None, **kwargs: Any
|
|
) -> None:
|
|
raise EtcdStubError
|
|
|
|
def test_and_set(
|
|
self, key: str, value: Any, prev_value: Any, ttl: Optional[int] = None
|
|
) -> None:
|
|
raise EtcdStubError
|