Skip to content

Commit c51b2ee

Browse files
committed
w
1 parent de1ddec commit c51b2ee

File tree

3 files changed

+32
-35
lines changed

3 files changed

+32
-35
lines changed

scripts/mirror.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import argparse
66
import logging
77
import sys
8-
from typing import (
9-
Iterable,
10-
)
118

129
from azul import (
1310
CatalogName,
@@ -20,9 +17,6 @@
2017
from azul.azulclient import (
2118
AzulClient,
2219
)
23-
from azul.indexer import (
24-
SourceRef,
25-
)
2620
from azul.logging import (
2721
configure_script_logging,
2822
)
@@ -44,28 +38,31 @@ def mirror_catalog(azul: AzulClient,
4438
source.spec: source
4539
for source in plugin.list_sources(authentication=None)
4640
}
47-
source_refs: Iterable[SourceRef]
48-
# When the user doesn't specify a source or provides "*" as a source glob,
49-
# we implicitly filter out managed-access sources. This lets us assert that
50-
# all sources matching the provided globs are public, without forcing the
51-
# user to manually specify every public source.
41+
source_specs = azul.matching_sources([catalog], source_globs)[catalog]
5242
if '*' in source_globs:
53-
source_refs = public_sources_by_spec.values()
43+
# When the user doesn't specify a source or provides "*" as a source glob,
44+
# we implicitly filter out managed-access sources. This lets us assert that
45+
# all sources matching the provided globs are public, without forcing the
46+
# user to manually specify every public source.
47+
source_specs = {
48+
spec: cfg
49+
for spec, cfg in source_specs.items()
50+
if spec in public_sources_by_spec
51+
}
52+
try:
53+
source_refs = {
54+
public_sources_by_spec[spec]: cfg
55+
for spec, cfg in source_specs.items()
56+
}
57+
except KeyError as e:
58+
assert False, R(
59+
'Cannot mirror managed-access source', e.args[0])
5460
else:
55-
source_specs = azul.matching_sources([catalog], source_globs)[catalog]
56-
try:
57-
source_refs = {
58-
public_sources_by_spec[spec]
59-
for spec in source_specs
60-
}
61-
except KeyError as e:
62-
assert False, R(
63-
'Cannot mirror managed-access source', e.args[0])
64-
azul.remote_mirror(catalog, source_refs)
65-
if wait:
66-
azul.wait_for_mirroring()
67-
assert azul.is_queue_empty(fail_queue), R(
68-
'There are messages in the fail queue', fail_queue)
61+
azul.remote_mirror(catalog, source_refs.items())
62+
if wait:
63+
azul.wait_for_mirroring()
64+
assert azul.is_queue_empty(fail_queue), R(
65+
'There are messages in the fail queue', fail_queue)
6966

7067

7168
def main(args):

src/azul/azulclient.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import fnmatch
2-
import logging
3-
import uuid
41
from collections import (
52
defaultdict,
63
)
@@ -14,15 +11,18 @@
1411
from enum import (
1512
auto,
1613
)
14+
import fnmatch
1715
from functools import (
1816
partial,
1917
)
20-
from itertools import starmap
18+
import logging
2119
from pprint import (
2220
PrettyPrinter,
2321
)
2422
from typing import (
25-
AbstractSet, )
23+
AbstractSet,
24+
)
25+
import uuid
2626

2727
import attrs
2828
import requests
@@ -248,7 +248,7 @@ def matching_sources(self,
248248
matched_globs.add(glob)
249249
log.debug('Source glob %r matched sources %r in catalog %r',
250250
glob, _matching_raw_specs, catalog)
251-
specs = {spec: cfg for spec, cfg in specs if str(spec) in matching_raw_specs}
251+
specs = {spec: cfg for spec, cfg in specs.items() if str(spec) in matching_raw_specs}
252252
result[catalog] = specs
253253
unmatched_globs = globs - matched_globs
254254
if unmatched_globs:

test/azul_test_case.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def catalog_config(cls) -> dict[CatalogName, Config.Catalog]:
456456
mirror_max_file_size=None,
457457
plugins=dict(metadata=config.Catalog.Plugin(name='hca'),
458458
repository=config.Catalog.Plugin(name='dss')),
459-
sources={str(cls.source.spec): {}})
459+
sources={str(cls.source.spec): {'mirror': True}})
460460
}
461461

462462

@@ -480,7 +480,7 @@ def _patch_tdr_service_url(cls):
480480

481481
@classmethod
482482
def _sources(cls):
483-
return {str(cls.source.spec): {}}
483+
return {str(cls.source.spec): {'mirror': True}}
484484

485485
@classmethod
486486
def _patch_source_cache(cls):
@@ -522,5 +522,5 @@ def catalog_config(cls) -> dict[CatalogName, Config.Catalog]:
522522
mirror_max_file_size=None,
523523
plugins=dict(metadata=config.Catalog.Plugin(name='anvil'),
524524
repository=config.Catalog.Plugin(name='tdr_anvil')),
525-
sources={str(cls.source.spec): {}})
525+
sources={str(cls.source.spec): {'mirror': True}})
526526
}

0 commit comments

Comments
 (0)