Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offline command #99

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/scicat_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class FileHandlingOptions:
@dataclass(kw_only=True)
class IngestionOptions:
dry_run: bool = False
offline_ingestor_executable: str = "background_ingestor"
offline_ingestor_executable: str | list[str]= "background_ingestor"
schemas_directory: str = "schemas"
check_if_dataset_exists_by_pid: bool = True
check_if_dataset_exists_by_metadata: bool = True
Expand Down
19 changes: 11 additions & 8 deletions src/scicat_online_ingestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@


def dump_message_to_file_if_needed(
*,
logger: logging.Logger,
message_file_path: pathlib.Path,
file_handling_options: FileHandlingOptions,
message: WritingFinished,
*,
logger: logging.Logger,
message_file_path: pathlib.Path,
file_handling_options: FileHandlingOptions,
message: WritingFinished,
) -> None:
"""Dump the message to a file according to the configuration."""
if not file_handling_options.message_to_file:
Expand Down Expand Up @@ -93,6 +93,10 @@ def build_online_config(logger: logging.Logger | None = None) -> OnlineIngestorC
)


def _pre_executable_offline_ingestor(offline_ingestor: str | list[str]) -> list[str]:
return [offline_ingestor] if isinstance(offline_ingestor, str) else offline_ingestor


def main() -> None:
"""Main entry point of the app."""
tmp_config = build_online_config()
Expand All @@ -103,7 +107,7 @@ def main() -> None:
logger.info('Starting the Scicat online Ingestor with the following configuration:')
logger.info(config.to_dict())

with handle_daemon_loop_exceptions(logger=logger):
with ((handle_daemon_loop_exceptions(logger=logger))):
# Kafka consumer
if (consumer := build_consumer(config.kafka, logger)) is None:
raise RuntimeError("Failed to build the Kafka consumer")
Expand Down Expand Up @@ -135,8 +139,7 @@ def main() -> None:
--done-writing-message-file message_file_path
# optional depending on the message_saving_options.message_output
"""
cmd = [
config.ingestion.offline_ingestor_executable,
cmd = _pre_executable_offline_ingestor(config.ingestion.offline_ingestor_executable) + [
"-c",
config.config_file,
"--nexus-file",
Expand Down