Skip to content

Commit

Permalink
allowing str or list as offline command
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrosx committed Dec 12, 2024
1 parent 84a387a commit a50458e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
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

0 comments on commit a50458e

Please sign in to comment.