Skip to content

Commit e4693d5

Browse files
committed
Conditionally disable local reindexing
1 parent 893f55c commit e4693d5

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

scripts/reindex.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,22 @@
4747
parser.add_argument('--local',
4848
default=False,
4949
action='store_true',
50-
help='Do not offload the listing of subgraphs to the indexer Lambda function. When this option is '
51-
'used, this script queries the repository without partitioning, and the indexer notification '
52-
'endpoint is invoked for each subgraph individually and concurrently using worker threads. '
53-
'This is magnitudes slower than remote (i.e. partitioned) indexing. If this option is not '
54-
'used (the default), the set of subgraphs matching the query is partitioned using the '
55-
'partition prefix length configured for each of the catalog sources being reindexed. Each '
56-
'query partition is processed independently and remotely by the indexer lambda. The index '
57-
'Lambda function queries the repository for each partition and queues a notification for each '
58-
'matching subgraph in the partition.')
50+
help=(
51+
'' if config.enable_bundle_notifications else '**DISABLED** '
52+
) + (
53+
'Do not offload the listing of subgraphs to the indexer Lambda function. When '
54+
'this option is used, this script queries the repository without partitioning, '
55+
'and the indexer notification endpoint is invoked for each subgraph '
56+
'individually and concurrently using worker threads. This is magnitudes slower '
57+
'than remote (i.e. partitioned) indexing. If this option is not used (the '
58+
'default), the set of subgraphs matching the query is partitioned using the '
59+
'partition prefix length configured for each of the catalog sources being '
60+
'reindexed. Each query partition is processed independently and remotely by '
61+
'the indexer lambda. The index Lambda function queries the repository for each '
62+
'partition and queues a notification for each matching subgraph in the '
63+
'partition.'
64+
)
65+
)
5966
parser.add_argument('--catalogs',
6067
nargs='+',
6168
metavar='NAME',
@@ -134,6 +141,10 @@ def main(argv: list[str]):
134141
every_source = '*' in source_globs
135142
sources_by_catalog = azul.sources_by_catalog(args.catalogs)
136143

144+
if not config.enable_bundle_notifications and args.local:
145+
parser.error('Local reindexing is not available while bundle '
146+
'notifications are disabled.')
147+
137148
if not every_source:
138149
if args.local:
139150
parser.error('Cannot specify sources when performing a local reindex')

src/azul/azulclient.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def mirror_source_message(self,
128128
)
129129

130130
def local_reindex(self, catalog: CatalogName, prefix: str) -> int:
131+
if not config.enable_bundle_notifications:
132+
raise AzulClientError('Bundle notifications are disabled')
131133
service = self.index_repository_service
132134
notifications: JSONs = [
133135
# Notifications sent organically by DSS had a different structure,
@@ -148,6 +150,8 @@ def index(self,
148150
notifications: Iterable[JSON],
149151
delete: bool = False
150152
):
153+
if not config.enable_bundle_notifications:
154+
raise AzulClientError('Bundle notifications are disabled')
151155
errors = defaultdict[int, int](int)
152156
missing = []
153157
indexed = 0

0 commit comments

Comments
 (0)