import re import time from concurrent import futures import click #import grpc import yaml from nvidia_deepops import Progress, utils from nvidia_deepops.docker import DockerClient, NGCRegistry, DGXRegistry from . import replicator_pb2 #from . import replicator_pb2_grpc log = utils.get_logger(__name__, level=logging.INFO) _ONE_DAY_IN_SECONDS = 60 * 60 * 24 class Replicator: def __init__(self, *, api_key, project, **optional_config): log.info("Initializing Replicator") self._config = optional_config self.project = project self.service = self.config("service") if len(api_key) == 40: self.nvcr = DGXRegistry(api_key) elif len(api_key) == 84: self.nvcr = NGCRegistry(api_key) else:
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import collections import base64 import logging import pprint import contexttimer import requests from nvidia_deepops import utils from nvidia_deepops.docker.registry.base import BaseRegistry log = utils.get_logger(__name__, level=logging.INFO) dev = utils.get_logger("devel", level=logging.ERROR) __all__ = ('NGCRegistry', ) class NGCRegistry(BaseRegistry): def __init__(self, api_key, nvcr_url='nvcr.io', nvcr_api_url=None, ngc_auth_url=None): self.api_key = api_key self.api_key_b64 = base64.b64encode( api_key.encode("utf-8")).decode("utf-8") self.url = nvcr_url
import traceback from click.testing import CliRunner from docker.errors import APIError from nvidia_deepops import utils # from nvidia_deepops import cli from nvidia_deepops.docker import (BaseClient, DockerClient, registry) BaseRegistry = registry.BaseRegistry # DockerRegistry = registry.DockerRegistry DGXRegistry = registry.DGXRegistry NGCRegistry = registry.NGCRegistry dev = utils.get_logger(__name__, level=logging.DEBUG) try: from .secrets import ngcpassword, dgxpassword HAS_SECRETS = True except Exception: HAS_SECRETS = False secrets = pytest.mark.skipif(not HAS_SECRETS, reason="No secrets.py file found") @pytest.fixture def response(): """Sample pytest fixture.