Skip to content

Commit 8902d2b

Browse files
--postpone-jobs flag (#146)
1 parent 03ea5e6 commit 8902d2b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
### Added
66

77
* Human-readable `CHANGELOG.md` 🕺
8-
* `--forbid-reindexing` option added to `dipdup run` command. If this flag is set, DipDup will raise `ReindexingRequiredError` when reindexing is triggered for any reason. A database won't be truncated. To continue indexing with existing database run `UPDATE dipdup_schema SET reindex = NULL;`
8+
* Two new options added to `dipdup run` command:
9+
* `--forbid-reindexing` – raise `ReindexingRequiredError` instead of truncating database when reindexing is triggered for any reason. To continue indexing with existing database run `UPDATE dipdup_schema SET reindex = NULL;`
10+
* `--postpone-jobs` – job scheduler won't start until all indexes are synchronized.
911

1012
### Changed
1113

src/dipdup/cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,24 @@ async def cli(ctx, config: List[str], env_file: List[str], logging_config: str):
136136
@cli.command(help='Run indexing')
137137
@click.option('--reindex', is_flag=True, help='Drop database and start indexing from scratch')
138138
@click.option('--oneshot', is_flag=True, help='Synchronize indexes wia REST and exit without starting WS connection')
139+
@click.option('--postpone-jobs', is_flag=True, help='Do not start job scheduler until all indexes are synchronized')
139140
@click.option('--forbid-reindexing', is_flag=True, help='Raise exception instead of truncating database when reindexing is triggered')
140141
@click.pass_context
141142
@cli_wrapper
142-
async def run(ctx, reindex: bool, oneshot: bool, forbid_reindexing: bool) -> None:
143+
async def run(
144+
ctx,
145+
reindex: bool,
146+
oneshot: bool,
147+
postpone_jobs: bool,
148+
forbid_reindexing: bool,
149+
) -> None:
143150
config: DipDupConfig = ctx.obj.config
144151
config.initialize()
145152
set_decimal_context(config.package)
146153
if forbid_reindexing:
147154
context.forbid_reindexing = True
148155
dipdup = DipDup(config)
149-
await dipdup.run(reindex, oneshot)
156+
await dipdup.run(reindex, oneshot, postpone_jobs)
150157

151158

152159
@cli.command(help='Generate missing callbacks and types')

src/dipdup/dipdup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ async def init(self, overwrite_types: bool = True) -> None:
225225
async def docker_init(self, image: str, tag: str, env_file: str) -> None:
226226
await self._codegen.docker_init(image, tag, env_file)
227227

228-
async def run(self, reindex: bool, oneshot: bool) -> None:
228+
async def run(self, reindex: bool, oneshot: bool, postpone_jobs: bool) -> None:
229229
"""Run indexing process"""
230230
tasks: Set[Task] = set()
231231
async with AsyncExitStack() as stack:
@@ -242,6 +242,8 @@ async def run(self, reindex: bool, oneshot: bool) -> None:
242242
start_scheduler_event: Optional[Event] = None
243243
if not oneshot:
244244
start_scheduler_event = await self._set_up_scheduler(stack, tasks)
245+
if not postpone_jobs:
246+
start_scheduler_event.set()
245247
spawn_datasources_event = await self._spawn_datasources(tasks)
246248

247249
for name in self._config.indexes:

0 commit comments

Comments
 (0)