def __init__(self, processor_num: int = None, ): self.processor_num = cpu_count() if processor_num is None \ else min(processor_num, cpu_count()) LOGGER.debug('Building Pathos multi-processing pool with {} cores.'.format(self.processor_num)) self._pool = Pool(self.processor_num)
# -*- coding: utf-8 -*- import os import socket import getpass from ncc import LOGGER HOSTNAME = socket.gethostname() USERNAME = getpass.getuser() # register your hostname or username DEFAULT_DIR = '~/.ncc' DEFAULT_DIR = os.path.expanduser(DEFAULT_DIR) LIBS_DIR = os.path.join(os.path.dirname(__file__), 'tree-sitter-libs') LOGGER.debug('Host Name: {}; User Name: {}; Default data directory: {}'.format( HOSTNAME, USERNAME, DEFAULT_DIR)) __all__ = ( HOSTNAME, USERNAME, DEFAULT_DIR, LIBS_DIR, LOGGER, )
from botocore.exceptions import ClientError from filelock import FileLock from tqdm.auto import tqdm from ncc import LOGGER from ncc import __VERSION__ try: USE_TF = os.environ.get("USE_TF", "AUTO").upper() USE_TORCH = os.environ.get("USE_TORCH", "AUTO").upper() if USE_TORCH in ("1", "ON", "YES", "AUTO") and USE_TF not in ("1", "ON", "YES"): import torch _torch_available = True # pylint: disable=invalid-name LOGGER.debug("PyTorch version {} available.".format(torch.__version__)) else: LOGGER.info("Disabling PyTorch because USE_TF is set") _torch_available = False except ImportError: _torch_available = False # pylint: disable=invalid-name try: USE_TF = os.environ.get("USE_TF", "AUTO").upper() USE_TORCH = os.environ.get("USE_TORCH", "AUTO").upper() if USE_TF in ("1", "ON", "YES", "AUTO") and USE_TORCH not in ("1", "ON", "YES"): import tensorflow as tf assert hasattr(tf, "__version__") and int(tf.__version__[0]) >= 2