Skip to content

Commit

Permalink
Add online ingestor dry run mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
YooSunYoung committed Nov 4, 2024
1 parent c81ac41 commit 87e9bbd
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/scicat_online_ingestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,19 @@ def main() -> None:
]
if config.ingestion.file_handling.message_to_file:
cmd += ["-m", done_writing_message_file_path]
proc = subprocess.Popen(cmd) # noqa: S603
# save info about the background process
offline_ingestors[job_id] = {
"proc": proc,
"message": message,
}

# if background process is successful
# check if we need to commit the individual message
if config.kafka.individual_message_commit:
_individual_message_commit(offline_ingestors, consumer, logger)
if config.ingestion.dry_run:
logger.info("Dry run mode enabled. Skipping background ingestor.")
logger.info("Command that would have been run: \n\n%s\n\n", cmd)
else:
logger.info("Running background ingestor with command: %s", cmd)
proc = subprocess.Popen(cmd) # noqa: S603
# save info about the background process
offline_ingestors[job_id] = {"proc": proc, "message": message}

# if background process is successful
# check if we need to commit the individual message
if config.kafka.individual_message_commit:
_individual_message_commit(offline_ingestors, consumer, logger)


if __name__ == "__main__":
Expand Down

0 comments on commit 87e9bbd

Please sign in to comment.