diff --git a/compiler/quilt/test/test_cli.py b/compiler/quilt/test/test_cli.py index 44baefd21da..07b30ded693 100644 --- a/compiler/quilt/test/test_cli.py +++ b/compiler/quilt/test/test_cli.py @@ -148,6 +148,7 @@ [0, 'check', '--env'], [0, 'check', 0], [0, 'config'], + [0, 'config', 0], [0, 'delete'], [0, 'delete', 0], [0, 'export'], @@ -616,7 +617,7 @@ def test_cli_command_config(self): cmd = ['config'] result = self.execute_with_checks(cmd, funcname='config') - assert not result['kwargs'] + assert result['kwargs']['team'] is None def test_cli_command_login(self): """Ensures the 'login' command calls a specific API""" diff --git a/compiler/quilt/tools/command.py b/compiler/quilt/tools/command.py index 120bb9701f3..2f298925b5a 100644 --- a/compiler/quilt/tools/command.py +++ b/compiler/quilt/tools/command.py @@ -34,7 +34,7 @@ generate_contents, get_or_create_package, BuildException, load_yaml) from .compat import pathlib from .const import DEFAULT_BUILDFILE, DTIMEF, QuiltException, SYSTEM_METADATA, TargetType -from .core import (LATEST_TAG, GroupNode, RootNode, decode_node, encode_node, +from .core import (LATEST_TAG, GroupNode, decode_node, encode_node, find_object_hashes, hash_contents) from .data_transfer import download_fragments, upload_fragments from .store import PackageStore, StoreException @@ -131,7 +131,12 @@ def _save_auth(cfg): def get_registry_url(team): if team is not None: - return "https://%s-registry.team.quiltdata.com" % team + # Check config + cfg = _load_config() + if team and cfg.get('team_id') == team and cfg.get('team_registry_url'): + return cfg['team_registry_url'] + else: + return "https://%s-registry.team.quiltdata.com" % team global _registry_url if _registry_url is not None: @@ -148,9 +153,20 @@ def get_registry_url(team): _registry_url = url or DEFAULT_REGISTRY_URL return _registry_url -def config(): - answer = input("Please enter the URL for your custom Quilt registry (ask your administrator),\n" - "or leave this line blank to use the default registry: ") +def config(team=None): + if team is None: + message = "Please enter the URL for your custom Quilt registry " \ + "(ask your administrator),\n" \ + "or leave this line blank to use the default registry: " + else: + _check_team_id(team) + message = "Please enter the URL for the Quilt Team registry [%s] " \ + "(ask your administrator),\n" \ + "or leave this line blank to use the default: " % team + answer = input(message) + + # When saving the config, store '' instead of the actual URL in case we ever change it. + cfg = _load_config() if answer: url = urlparse(answer.rstrip('/')) if (url.scheme not in ['http', 'https'] or not url.netloc or @@ -158,11 +174,14 @@ def config(): raise CommandException("Invalid URL: %s" % answer) canonical_url = urlunparse(url) else: - # When saving the config, store '' instead of the actual URL in case we ever change it. canonical_url = '' - - cfg = _load_config() - cfg['registry_url'] = canonical_url + + if team: + cfg['team_registry_url'] = canonical_url + cfg['team_id'] = team + else: + cfg['registry_url'] = canonical_url + cfg['team_id'] = '' _save_config(cfg) # Clear the cached URL. @@ -360,7 +379,7 @@ def _check_team_exists(team): if team is None: return - hostname = '%s-registry.team.quiltdata.com' % team + hostname = urlparse(get_registry_url(team)).hostname try: socket.gethostbyname(hostname) except IOError: @@ -542,7 +561,8 @@ def _build_internal(package, path, dry_run, env, build_file): assert not dry_run # TODO? build_from_node(package, nodes.GroupNode({})) else: - raise ValueError("Expected a GroupNode, path, git URL, DataFrame, ndarray, or None, but got %r" % path) + raise ValueError("Expected a GroupNode, path, git URL, DataFrame, ndarray, or None, " \ + "but got %r" % path) def build_from_node(package, node): diff --git a/compiler/quilt/tools/main.py b/compiler/quilt/tools/main.py index 85cc4254c40..d9533de7ae0 100644 --- a/compiler/quilt/tools/main.py +++ b/compiler/quilt/tools/main.py @@ -127,6 +127,7 @@ def check_hash(group, hashstr): # quilt config shorthelp = "Configure Quilt" config_p = subparsers.add_parser("config", description=shorthelp, help=shorthelp) + config_p.add_argument("team", type=str, nargs='?', help="Specify team to configure") config_p.set_defaults(func=command.config) # quilt delete diff --git a/compiler/setup.py b/compiler/setup.py index 4a734e59a70..d778d1a46b3 100644 --- a/compiler/setup.py +++ b/compiler/setup.py @@ -66,8 +66,8 @@ def readme(): 'tests': [ 'funcsigs; python_version<"3.4"', # stdlib backport 'mock; python_version<"3.3"', - 'pytest', - 'pytest-cov', + 'pytest==3.3.2', + 'pytest-cov==2.4.0', 'responses>=0.7.0', ], 'torchvision': [