예제 #1
0
 def test_get_logger_custom_name(self):
     logger1 = get_logger("test.module")
     self.assertEqual("test.module", logger1.name)
예제 #2
0
import sys
import time
from typing import Dict, List, Optional

from torchelastic.tsm.driver.api import (
    Application,
    AppState,
    DescribeAppResponse,
    RunMode,
    Scheduler,
    is_terminal,
    macros,
)
from torchelastic.utils.logging import get_logger

log = get_logger()


class ImageFetcher(abc.ABC):
    """
    Downloads and sets up an image onto the localhost. This is only needed for
    ``LocalhostScheduler`` since typically real schedulers will do this
    on-behalf of the user.
    """
    @abc.abstractmethod
    def fetch(self, image: str) -> str:
        """
        Pulls the given image and returns a path to the pulled image on
        the local host.
        """
        raise NotImplementedError()
예제 #3
0
 def test_get_logger_none(self):
     logger1 = get_logger(None)
     self.assertEqual(__name__, logger1.name)
예제 #4
0
 def test_get_logger(self):
     logger1 = get_logger()
     self.assertEqual(__name__, logger1.name)
예제 #5
0
 def test_get_logger_different(self):
     logger1 = get_logger("name1")
     logger2 = get_logger("name2")
     self.assertNotEqual(logger1.name, logger2.name)
예제 #6
0
 def test_get_logger_same(self):
     logger1 = get_logger(__name__)
     logger2 = get_logger(__name__)
     self.assertEqual(1, len(logger1.handlers))
     self.assertEqual(logger1, logger2)
예제 #7
0
#!/usr/bin/env python3

# 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.

import unittest

import torchelastic.utils.logging as logging

log = logging.get_logger()


class LoggingTest(unittest.TestCase):
    def test_logger_name(self):
        self.assertEqual("torchelastic.utils.test.logging_test", log.name)

    def test_derive_module_name(self):
        module_name = logging._derive_module_name(depth=1)
        self.assertEqual("torchelastic.utils.test.logging_test", module_name)