code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def push_to_broker(
broker_client: MessageBrokerClientBase, response_channel: str, json_payloads: List[str], retry_count: int = 2
) -> None:
"""
Attempts to push a JSON payload to a message broker channel, retrying on failure up to a specified number of
attempts.
Parameters
----------
broke... |
Attempts to push a JSON payload to a message broker channel, retrying on failure up to a specified number of
attempts.
Parameters
----------
broker_client : MessageBrokerClient
The broker client used to push the data.
response_channel : str
The broker channel to which the data ... | push_to_broker | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | Apache-2.0 |
def handle_failure(
broker_client: MessageBrokerClientBase,
response_channel: str,
json_result_fragments: List[Dict[str, Any]],
e: Exception,
mdf_size: int,
) -> None:
"""
Handles failure scenarios by logging the error and pushing a failure message to a broker channel.
Parameters
--... |
Handles failure scenarios by logging the error and pushing a failure message to a broker channel.
Parameters
----------
broker_client : Any
A MessageBrokerClientBase instance.
response_channel : str
The broker channel to which the failure message will be sent.
json_result_fragm... | handle_failure | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | Apache-2.0 |
def process_and_forward(message: IngestControlMessage, broker_client: MessageBrokerClientBase) -> IngestControlMessage:
"""
Processes a message by extracting data, creating a JSON payload, and attempting to push it to the message broker.
Parameters
----------
message : IngestControlMessage
... |
Processes a message by extracting data, creating a JSON payload, and attempting to push it to the message broker.
Parameters
----------
message : IngestControlMessage
The message to process.
broker_client : MessageBrokerClientBase
The message broker client used for pushing data.
... | process_and_forward | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | Apache-2.0 |
def _message_broker_task_sink(builder: mrc.Builder) -> None:
"""
Configures and registers a processing node for message handling, including message broker task sinking.
Parameters
----------
builder : mrc.Builder
The modular processing chain builder to which the message broker task sink nod... |
Configures and registers a processing node for message handling, including message broker task sinking.
Parameters
----------
builder : mrc.Builder
The modular processing chain builder to which the message broker task sink node will be added.
Returns
-------
None
Notes
--... | _message_broker_task_sink | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/message_broker_task_sink.py | Apache-2.0 |
def _create_vdb_service(
service: str, is_service_serialized: bool, service_kwargs: dict, recreate: bool, resource_schemas: dict
):
"""
A function to used to instantiate a `VectorDBService` if a running VDB is available and a connection can be
established.
Parameters
----------
service : st... |
A function to used to instantiate a `VectorDBService` if a running VDB is available and a connection can be
established.
Parameters
----------
service : str
A string mapping to a supported `VectorDBService`.
is_service_serialized : bool
A flag to identify if the supplied servic... | _create_vdb_service | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def _extract_dataframe_from_control_message(
ctrl_msg: IngestControlMessage, filter_errors: bool
) -> Tuple[pd.DataFrame, Optional[str]]:
"""
Extracts a DataFrame from the control message and applies filtering to remove error messages.
Returns a tuple of the processed DataFrame and an optional resource ... |
Extracts a DataFrame from the control message and applies filtering to remove error messages.
Returns a tuple of the processed DataFrame and an optional resource name (always None in this case).
| _extract_dataframe_from_control_message | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def _update_accumulator_and_flush(
df: pd.DataFrame,
resource_name: Optional[str],
accumulator_dict: Dict[str, AccumulationStats],
batch_size: int,
write_time_interval: float,
service: VectorDBService,
resource_kwargs: dict,
ctrl_msg: IngestControlMessage,
default_resource_name: str,... |
Updates the accumulator for the given resource with the new DataFrame.
Flushes (inserts) data if the batch size or time interval criteria are met.
| _update_accumulator_and_flush | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def _finalize_vector_db_service(accumulator_dict: Dict[str, AccumulationStats], service: VectorDBService) -> None:
"""
Flushes any remaining accumulated data to the vector database and closes the service connection.
"""
for key, accum_stats in accumulator_dict.items():
try:
if accum_... |
Flushes any remaining accumulated data to the vector database and closes the service connection.
| _finalize_vector_db_service | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def _process_control_message_data(
ctrl_msg: IngestControlMessage,
service: VectorDBService,
accumulator_dict: Dict[str, AccumulationStats],
default_resource_name: str,
batch_size: int,
write_time_interval: float,
resource_kwargs: dict,
service_kwargs: dict,
filter_errors: bool,
) ->... |
Processes the control message for data ingestion. If bulk ingestion is enabled, delegates to the bulk ingest
function.
Otherwise, it extracts the DataFrame from the message and updates/flushed the accumulator accordingly.
| _process_control_message_data | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def _vdb_task_sink(builder: mrc.Builder):
"""
Receives incoming messages in IngestControlMessage format and writes data to a vector database.
The module configuration (validated using VdbTaskSinkSchema) should include various parameters
controlling resource creation, batching, write intervals, and retr... |
Receives incoming messages in IngestControlMessage format and writes data to a vector database.
The module configuration (validated using VdbTaskSinkSchema) should include various parameters
controlling resource creation, batching, write intervals, and retry intervals.
| _vdb_task_sink | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sinks/vdb_task_sink.py | Apache-2.0 |
def fetch_and_process_messages(client, validated_config: MessageBrokerTaskSourceSchema):
"""
Fetch messages from the message broker and process them.
Parameters
----------
client : MessageBrokerClientBase
The client used to interact with the message broker.
validated_config : MessageBro... |
Fetch messages from the message broker and process them.
Parameters
----------
client : MessageBrokerClientBase
The client used to interact with the message broker.
validated_config : MessageBrokerTaskSourceSchema
The validated configuration for the message broker.
Yields
... | fetch_and_process_messages | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | Apache-2.0 |
def process_message(job: Dict, ts_fetched: datetime) -> IngestControlMessage:
"""
Process a job and return an IngestControlMessage.
"""
control_message = IngestControlMessage()
job_id = None
try:
if logger.isEnabledFor(logging.DEBUG):
no_payload = copy.deepcopy(job)
... |
Process a job and return an IngestControlMessage.
| process_message | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | Apache-2.0 |
def _message_broker_task_source(builder: mrc.Builder):
"""
A module for receiving messages from a message broker, converting them into DataFrames,
and attaching job IDs to IngestControlMessages.
Parameters
----------
builder : mrc.Builder
The Morpheus pipeline builder object.
Raise... |
A module for receiving messages from a message broker, converting them into DataFrames,
and attaching job IDs to IngestControlMessages.
Parameters
----------
builder : mrc.Builder
The Morpheus pipeline builder object.
Raises
------
ValueError
If an unsupported client t... | _message_broker_task_source | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/sources/message_broker_task_source.py | Apache-2.0 |
def _storage_images(builder: mrc.Builder) -> None:
"""
A module for storing images or structured content in MinIO, updating the metadata
with storage URLs.
Parameters
----------
builder : mrc.Builder
The Morpheus pipeline builder object.
Raises
------
ValueError
If ... |
A module for storing images or structured content in MinIO, updating the metadata
with storage URLs.
Parameters
----------
builder : mrc.Builder
The Morpheus pipeline builder object.
Raises
------
ValueError
If storing extracted objects fails.
| _storage_images | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/storages/image_storage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/storages/image_storage.py | Apache-2.0 |
def _count_jobs_impl(message: IngestControlMessage, validated_config, stats) -> IngestControlMessage:
"""
Private helper function to count jobs.
Parameters
----------
message : IngestControlMessage
The IngestControlMessage instance to process.
validated_config : JobCounterSchema
... |
Private helper function to count jobs.
Parameters
----------
message : IngestControlMessage
The IngestControlMessage instance to process.
validated_config : JobCounterSchema
The validated configuration for the job counter.
stats : GlobalStats
The global statistics insta... | _count_jobs_impl | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/job_counter.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/job_counter.py | Apache-2.0 |
def _metrics_aggregation(builder: mrc.Builder) -> None:
"""
Module for collecting and exporting job statistics to OpenTelemetry
Parameters
----------
builder : mrc.Builder
The module configuration builder.
Returns
-------
None
"""
validated_config = fetch_and_validate_m... |
Module for collecting and exporting job statistics to OpenTelemetry
Parameters
----------
builder : mrc.Builder
The module configuration builder.
Returns
-------
None
| _metrics_aggregation | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_meter.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_meter.py | Apache-2.0 |
def _trace(builder: mrc.Builder) -> None:
"""
Module for collecting and exporting traces to OpenTelemetry.
Parameters
----------
builder : mrc.Builder
The module configuration builder.
Returns
-------
None
"""
validated_config = fetch_and_validate_module_config(builder,... |
Module for collecting and exporting traces to OpenTelemetry.
Parameters
----------
builder : mrc.Builder
The module configuration builder.
Returns
-------
None
| _trace | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_tracer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_tracer.py | Apache-2.0 |
def uuid_to_trace_id(uuid_str: str) -> str:
"""Convert a UUID-like format back to a 32-character OpenTelemetry trace ID."""
if not isinstance(uuid_str, str) or len(uuid_str) != 36:
raise ValueError("UUID must be a 36-character string with hyphens")
return uuid_str.replace("-", "") | Convert a UUID-like format back to a 32-character OpenTelemetry trace ID. | uuid_to_trace_id | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_tracer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/telemetry/otel_tracer.py | Apache-2.0 |
def _text_splitter(builder: mrc.Builder):
"""
A pipeline module that splits documents into smaller parts based on the specified criteria.
"""
validated_config = fetch_and_validate_module_config(builder, TextSplitterSchema)
@filter_by_task(["split"])
@traceable(MODULE_NAME)
@cm_skip_processi... |
A pipeline module that splits documents into smaller parts based on the specified criteria.
| _text_splitter | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/modules/transforms/text_splitter.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/modules/transforms/text_splitter.py | Apache-2.0 |
def generate_audio_extractor_stage(
c: Config,
stage_config: Dict[str, Any],
task: str = "audio_data_extract",
task_desc: str = "audio_data_extraction",
pe_count: int = 1,
):
"""
Generates a multiprocessing stage to perform audio data extraction.
Parameters
----------
c : Config... |
Generates a multiprocessing stage to perform audio data extraction.
Parameters
----------
c : Config
Morpheus global configuration object.
stage_config : Dict[str, Any]
Configuration parameters for the audio content extractor, passed as a dictionary
validated against the `... | generate_audio_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/audio_extraction_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/audio_extraction_stage.py | Apache-2.0 |
def generate_chart_extractor_stage(
c: Config,
extractor_config: Dict[str, Any],
task: str = "chart_data_extract",
task_desc: str = "chart_data_extraction",
pe_count: int = 1,
):
"""
Generates a multiprocessing stage to perform chart data extraction from PDF content.
Parameters
----... |
Generates a multiprocessing stage to perform chart data extraction from PDF content.
Parameters
----------
c : Config
Morpheus global configuration object.
extractor_config : Dict[str, Any]
Configuration parameters for the chart content extractor, passed as a dictionary
va... | generate_chart_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/chart_extraction_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/chart_extraction_stage.py | Apache-2.0 |
def generate_docx_extractor_stage(
c: Config,
extraction_config: dict,
task: str = "docx-extract",
task_desc: str = "docx_content_extractor",
pe_count: int = 8,
):
"""
Helper function to generate a multiprocessing stage to perform document content extraction.
Parameters
----------
... |
Helper function to generate a multiprocessing stage to perform document content extraction.
Parameters
----------
c : Config
Morpheus global configuration object.
extraction_config : dict
Configuration parameters for document content extractor.
task : str
The task name ... | generate_docx_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/docx_extractor_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/docx_extractor_stage.py | Apache-2.0 |
def generate_image_extractor_stage(
c: Config,
extraction_config: Dict[str, Any],
task: str = "extract",
task_desc: str = "image_content_extractor",
pe_count: int = 24,
):
"""
Helper function to generate a multiprocessing stage to perform image content extraction.
Parameters
-------... |
Helper function to generate a multiprocessing stage to perform image content extraction.
Parameters
----------
c : Config
Morpheus global configuration object.
extraction_config : dict
Configuration parameters for image content extractor.
task : str
The task name to mat... | generate_image_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/image_extractor_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/image_extractor_stage.py | Apache-2.0 |
def generate_infographic_extractor_stage(
c: Config,
extraction_config: Dict[str, Any],
task: str = "infographic_data_extract",
task_desc: str = "infographic_data_extraction",
pe_count: int = 1,
):
"""
Generates a multiprocessing stage to perform infographic data extraction from PDF content.... |
Generates a multiprocessing stage to perform infographic data extraction from PDF content.
Parameters
----------
c : Config
Morpheus global configuration object.
extraction_config : Dict[str, Any]
Configuration parameters for the infographic content extractor, passed as a dictiona... | generate_infographic_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/infographic_extraction_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/infographic_extraction_stage.py | Apache-2.0 |
def generate_pdf_extractor_stage(
c: Any,
extractor_config: Dict[str, Any],
task: str = "extract",
task_desc: str = "pdf_content_extractor",
pe_count: int = 24,
) -> Any:
"""
Generate a multiprocessing stage for PDF extraction.
This function validates the extractor configuration, create... |
Generate a multiprocessing stage for PDF extraction.
This function validates the extractor configuration, creates a partial function
wrapper to inject the validated configuration into the config dict, and returns
a MultiProcessingBaseStage for parallel PDF extraction.
Parameters
----------
... | generate_pdf_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/pdf_extractor_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/pdf_extractor_stage.py | Apache-2.0 |
def generate_pptx_extractor_stage(
c: Config,
extraction_config: dict,
task: str = "pptx-extract",
task_desc: str = "pptx_content_extractor",
pe_count: int = 8,
):
"""
Helper function to generate a multiprocessing stage to perform PPTX content extraction.
Parameters
----------
c... |
Helper function to generate a multiprocessing stage to perform PPTX content extraction.
Parameters
----------
c : Config
Morpheus global configuration object.
extraction_config : dict
Configuration parameters for PPTX content extractor.
task : str
The task name to match... | generate_pptx_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/pptx_extractor_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/pptx_extractor_stage.py | Apache-2.0 |
def generate_table_extractor_stage(
c: Config,
extraction_config: Dict[str, Any],
task: str = "table_data_extract",
task_desc: str = "table_data_extraction",
pe_count: int = 1,
):
"""
Generates a multiprocessing stage to perform table data extraction from PDF content.
Parameters
---... |
Generates a multiprocessing stage to perform table data extraction from PDF content.
Parameters
----------
c : Config
Morpheus global configuration object.
extraction_config : Dict[str, Any]
Configuration parameters for the table content extractor, passed as a dictionary
v... | generate_table_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/extractors/table_extraction_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/extractors/table_extraction_stage.py | Apache-2.0 |
def trace_message(ctrl_msg, task_desc):
"""
Adds tracing metadata to the control message.
Parameters
----------
ctrl_msg : IngestControlMessage
The control message to trace.
task_desc : str
Description of the task for tracing purposes.
"""
ts_fetched = datetime.now()
... |
Adds tracing metadata to the control message.
Parameters
----------
ctrl_msg : IngestControlMessage
The control message to trace.
task_desc : str
Description of the task for tracing purposes.
| trace_message | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def put_in_queue(ctrl_msg, pass_thru_recv_queue):
"""
Puts the control message into the pass-through receive queue.
Parameters
----------
ctrl_msg : IngestControlMessage
The control message to put in the queue.
pass_thru_recv_queue : queue.Queue
The queue to put the control mess... |
Puts the control message into the pass-through receive queue.
Parameters
----------
ctrl_msg : IngestControlMessage
The control message to put in the queue.
pass_thru_recv_queue : queue.Queue
The queue to put the control message into.
| put_in_queue | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def process_control_message(ctrl_msg, task, task_desc, ctrl_msg_ledger, send_queue):
"""
Processes the control message, extracting the DataFrame payload and task properties,
and puts the work package into the send queue.
Parameters
----------
ctrl_msg : IngestControlMessage
The control ... |
Processes the control message, extracting the DataFrame payload and task properties,
and puts the work package into the send queue.
Parameters
----------
ctrl_msg : IngestControlMessage
The control message to process.
task : str
The task name.
task_desc : str
Descri... | process_control_message | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def work_package_response_handler(
mp_context,
max_queue_size,
work_package_input_queue: mp.Queue,
sub: mrc.Subscriber,
cancellation_token: mp.Value,
process_fn: typing.Callable[[pd.DataFrame, dict], pd.DataFrame],
process_pool: ProcessWorkerPoolSingleton,
):
... |
Manages child threads and collects results, forwarding them to the subscriber.
Parameters
----------
mp_context : multiprocessing.context.BaseContext
Context for creating multiprocessing objects.
max_queue_size : int
Maximum size of the queues.
w... | work_package_response_handler | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def _build_forwarding_function(self):
"""
Constructs a forwarding function that traces and enqueues an IngestControlMessage.
"""
@nv_ingest_node_failure_context_manager(
annotation_id=self.task_desc,
raise_on_failure=False,
forward_func=partial(put_in... |
Constructs a forwarding function that traces and enqueues an IngestControlMessage.
| _build_forwarding_function | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def _build_reconstruction_function(self):
"""
Reconstructs the control message from the work package.
Returns a function that takes a work package and returns the reconstructed IngestControlMessage.
"""
def reconstruct_fn(work_package):
# Reconstructs the control me... |
Reconstructs the control message from the work package.
Returns a function that takes a work package and returns the reconstructed IngestControlMessage.
| _build_reconstruction_function | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def _build_merge_function(self):
"""
Adds tracing metadata to the control message and marks its completion.
"""
def merge_fn(ctrl_msg: IngestControlMessage):
do_trace_tagging = ctrl_msg.get_metadata("config::add_trace_tagging") is True
if do_trace_tagging:
... |
Adds tracing metadata to the control message and marks its completion.
| _build_merge_function | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def _pass_thru_source_fn(self):
"""
Continuously gets control messages from the pass-through receive queue.
Yields
------
IngestControlMessage
The control message from the queue.
"""
while True:
try:
ctrl_msg = self._pass_t... |
Continuously gets control messages from the pass-through receive queue.
Yields
------
IngestControlMessage
The control message from the queue.
| _pass_thru_source_fn | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def _build_single(self, builder: mrc.Builder, input_node: SegmentObject) -> SegmentObject:
"""
Builds the processing pipeline by creating nodes for different stages and connecting them.
Parameters
----------
builder : mrc.Builder
The builder object used to create and... |
Builds the processing pipeline by creating nodes for different stages and connecting them.
Parameters
----------
builder : mrc.Builder
The builder object used to create and connect nodes in the pipeline.
input_node : SegmentObject
The input node of the p... | _build_single | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
async def join(self):
"""
Stops all running threads and processes gracefully, waits for all threads to complete,
and calls the parent class's join method.
Notes
-----
This method sets the cancellation token to True to signal all running threads to stop.
It then j... |
Stops all running threads and processes gracefully, waits for all threads to complete,
and calls the parent class's join method.
Notes
-----
This method sets the cancellation token to True to signal all running threads to stop.
It then joins all threads to ensure they h... | join | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/meta/multiprocessing_stage.py | Apache-2.0 |
def dedup_image_stage(
df_ledger: pd.DataFrame, task_config: Dict[str, Any], mutate_config: ImageDedupSchema
) -> pd.DataFrame:
"""
Deduplicates images in the provided DataFrame based on the task properties.
This function processes a DataFrame containing images and applies a deduplication filter
ba... |
Deduplicates images in the provided DataFrame based on the task properties.
This function processes a DataFrame containing images and applies a deduplication filter
based on the `filter` parameter within the task properties. The deduplication is performed
by identifying and removing duplicate images, ... | dedup_image_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_dedup.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_dedup.py | Apache-2.0 |
def generate_dedup_stage(
c: Config,
deduplicate_image_config: Dict[str, Any],
task: str = "dedup",
task_desc: str = "dedup_images",
pe_count: int = 8,
) -> MultiProcessingBaseStage:
"""
Generates a deduplication processing stage for images using multiprocessing.
This function validates... |
Generates a deduplication processing stage for images using multiprocessing.
This function validates the deduplication configuration, wraps the `dedup_image_stage` function with the validated
configuration, and then generates a `MultiProcessingBaseStage` for executing the deduplication task.
Paramete... | generate_dedup_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_dedup.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_dedup.py | Apache-2.0 |
def image_filter_stage(
df_ledger: pd.DataFrame,
task_config: Dict[str, Any],
mutate_config: ImageFilterSchema,
execution_trace_log: Optional[List[Any]] = None,
) -> pd.DataFrame:
"""
Apply the image filtering stage to the ledger DataFrame.
This function extracts image filtering parameters ... |
Apply the image filtering stage to the ledger DataFrame.
This function extracts image filtering parameters from the provided task
configuration and delegates processing to the internal filter_images_internal
function.
Parameters
----------
df_ledger : pd.DataFrame
The ledger DataF... | image_filter_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_filter.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_filter.py | Apache-2.0 |
def generate_image_filter_stage(
c: Config,
image_filter_config: Dict[str, Any],
task: str = "filter",
task_desc: str = "image_filter",
pe_count: int = 8,
) -> MultiProcessingBaseStage:
"""
Generate an image filter stage with the specified configuration.
This function validates the imag... |
Generate an image filter stage with the specified configuration.
This function validates the image filter configuration and wraps the image_filter_stage
function to produce a multi-processing stage for filtering images.
Parameters
----------
c : Config
The global configuration object.... | generate_image_filter_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_filter.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/mutate/image_filter.py | Apache-2.0 |
def generate_embedding_storage_stage(
c: Config,
store_config: dict,
task: str = "store_embedding",
task_desc: str = "Store_embeddings_minio",
pe_count: int = 24,
):
"""
Helper function to generate a multiprocessing stage to perform pdf content extraction.
Parameters
----------
... |
Helper function to generate a multiprocessing stage to perform pdf content extraction.
Parameters
----------
c : Config
Morpheus global configuration object
embedding_storage_config : dict
Configuration parameters for embedding storage.
store_config : dict
Configuration... | generate_embedding_storage_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/store/embedding_storage_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/store/embedding_storage_stage.py | Apache-2.0 |
def generate_text_embed_extractor_stage(
c: Any,
transform_config: Dict[str, Any],
task: str = "embed",
task_desc: str = "text_embed_extraction",
pe_count: int = 1,
):
"""
Generates a multiprocessing stage to perform text embedding extraction from a pandas DataFrame.
Parameters
----... |
Generates a multiprocessing stage to perform text embedding extraction from a pandas DataFrame.
Parameters
----------
c : Any
Global configuration object.
transform_config : Dict[str, Any]
Configuration parameters for the text embedding extractor, validated against EmbedExtractions... | generate_text_embed_extractor_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/transforms/embed_text_stage.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/transforms/embed_text_stage.py | Apache-2.0 |
def generate_caption_extraction_stage(
c: Config,
transform_config: Dict[str, Any],
task: str = "caption",
task_desc: str = "caption_extraction",
pe_count: int = 8,
):
"""
Generates a caption extraction stage with the specified configuration.
Parameters
----------
c : Config
... |
Generates a caption extraction stage with the specified configuration.
Parameters
----------
c : Config
Morpheus global configuration object.
transform_config : dict
Configuration parameters for caption extraction.
task : str, optional
The task name to match for the sta... | generate_caption_extraction_stage | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/stages/transforms/image_caption_extraction.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/stages/transforms/image_caption_extraction.py | Apache-2.0 |
def fetch_and_validate_module_config(builder: mrc.Builder, schema_class):
"""
Validates the configuration of a module using a specified Pydantic schema class.
Parameters
----------
builder : object
The builder object used to access the current module's configuration.
schema_class : Pyda... |
Validates the configuration of a module using a specified Pydantic schema class.
Parameters
----------
builder : object
The builder object used to access the current module's configuration.
schema_class : Pydantic BaseModel
The schema class to be used for validating the module conf... | fetch_and_validate_module_config | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/modules/config_validator.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/modules/config_validator.py | Apache-2.0 |
def setup_logging(log_level):
"""
Configures logging based on the provided log level or the INGEST_LOG_LEVEL environment variable.
"""
# Check for INGEST_LOG_LEVEL environment variable
env_log_level = os.getenv("INGEST_LOG_LEVEL", log_level)
if env_log_level:
log_level = env_log_level
... |
Configures logging based on the provided log level or the INGEST_LOG_LEVEL environment variable.
| setup_logging | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/logging.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/logging.py | Apache-2.0 |
def _launch_pipeline(morpheus_pipeline_config: Any, ingest_config: Dict[str, Any]) -> float:
"""
Launches the pipeline setup and runs it synchronously.
This function initializes a pipeline with the provided configurations,
sets it up, and executes it. It measures and logs timing information
at each... |
Launches the pipeline setup and runs it synchronously.
This function initializes a pipeline with the provided configurations,
sets it up, and executes it. It measures and logs timing information
at each stage.
Parameters
----------
morpheus_pipeline_config : Config
The configurati... | _launch_pipeline | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def run_pipeline(morpheus_pipeline_config: Any, ingest_config: Dict[str, Any]) -> float:
"""
Runs the pipeline synchronously in the current process.
This is the primary entry point for executing a pipeline directly
in the current process.
Parameters
----------
morpheus_pipeline_config : Co... |
Runs the pipeline synchronously in the current process.
This is the primary entry point for executing a pipeline directly
in the current process.
Parameters
----------
morpheus_pipeline_config : Config
The configuration object for the Morpheus pipeline.
ingest_config : Dict[str, A... | run_pipeline | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def run_ingest_pipeline(
ingest_config_path: Optional[str] = None,
caption_batch_size: int = 8,
use_cpp: bool = False,
pipeline_batch_size: int = 256,
enable_monitor: bool = False,
feature_length: int = 512,
num_threads: Optional[int] = None,
model_max_batch_size: int = 256,
mode: st... |
Configures and runs the pipeline with the specified options.
This function serves as the main entry point for configuring and
executing a pipeline with user-defined settings.
Parameters
----------
ingest_config_path : str, optional
Path to the JSON configuration file.
caption_batc... | run_ingest_pipeline | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def _set_pdeathsig(sig: int = signal.SIGTERM) -> None:
"""
Sets the parent death signal so that if the parent process dies, the child
receives `sig`. This is Linux-specific.
This mechanism ensures that child processes are terminated when their
parent process is killed, preventing orphaned processes... |
Sets the parent death signal so that if the parent process dies, the child
receives `sig`. This is Linux-specific.
This mechanism ensures that child processes are terminated when their
parent process is killed, preventing orphaned processes.
Parameters
----------
sig : int
The sig... | _set_pdeathsig | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def _terminate_subprocess(process: Optional["subprocess.Popen"] = None) -> None:
"""
Terminates the pipeline subprocess and its entire process group.
Sends SIGTERM followed by SIGKILL if necessary.
This function provides a reliable way to clean up all related
processes when terminating the main pro... |
Terminates the pipeline subprocess and its entire process group.
Sends SIGTERM followed by SIGKILL if necessary.
This function provides a reliable way to clean up all related
processes when terminating the main process.
Parameters
----------
process : subprocess.Popen or None
The ... | _terminate_subprocess | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def is_port_in_use(port, host="127.0.0.1"):
"""
Checks if a given port is in use on the specified host with socket reuse settings.
Parameters:
port (int): The port number to check.
host (str): The host to check on. Default is '127.0.0.1'.
Returns:
bool: True if the port is in u... |
Checks if a given port is in use on the specified host with socket reuse settings.
Parameters:
port (int): The port number to check.
host (str): The host to check on. Default is '127.0.0.1'.
Returns:
bool: True if the port is in use, False otherwise.
| is_port_in_use | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def start_pipeline_subprocess(
config: PipelineCreationSchema, stdout: Optional[TextIO] = None, stderr: Optional[TextIO] = None
) -> "subprocess.Popen":
"""
Launches the pipeline in a subprocess and ensures that it terminates
if the parent process dies.
This function encapsulates all subprocess-rel... |
Launches the pipeline in a subprocess and ensures that it terminates
if the parent process dies.
This function encapsulates all subprocess-related setup,
including signal handling and `atexit` registration.
Parameters
----------
config : PipelineCreationSchema
Validated pipeline c... | start_pipeline_subprocess | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def combined_preexec_fn():
"""Setup function to run in the child process before exec()."""
# Start a new session to create a new process group
os.setsid()
# Set the parent death signal to SIGTERM
_set_pdeathsig(signal.SIGTERM)
# Set CPU affinity O... | Setup function to run in the child process before exec(). | combined_preexec_fn | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def _read_stream(stream: TextIO, prefix: str, output_stream: TextIO) -> None:
"""
Reads lines from a subprocess stream (stdout or stderr) and writes them
to the provided output stream with a prefix.
This function runs in a separate daemon thread to handle output
in a non-blocking way.
Paramete... |
Reads lines from a subprocess stream (stdout or stderr) and writes them
to the provided output stream with a prefix.
This function runs in a separate daemon thread to handle output
in a non-blocking way.
Parameters
----------
stream : TextIO
The stream object to read from (subproc... | _read_stream | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def subprocess_entrypoint() -> None:
"""
Entry point for the pipeline subprocess.
This function is called when a pipeline subprocess is started.
It configures logging and runs the ingest pipeline.
Raises
------
Exception
Any exception raised during pipeline execution will cause
... |
Entry point for the pipeline subprocess.
This function is called when a pipeline subprocess is started.
It configures logging and runs the ingest pipeline.
Raises
------
Exception
Any exception raised during pipeline execution will cause
the subprocess to exit with a non-zero ... | subprocess_entrypoint | python | NVIDIA/nv-ingest | src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/orchestration/morpheus/util/pipeline/pipeline_runners.py | Apache-2.0 |
def build_default_milvus_config(embedding_size: int = 1024) -> typing.Dict[str, typing.Any]:
"""
Builds the configuration for Milvus.
This function creates a dictionary configuration for a Milvus collection.
It includes the index configuration and the schema configuration, with
various fields like ... |
Builds the configuration for Milvus.
This function creates a dictionary configuration for a Milvus collection.
It includes the index configuration and the schema configuration, with
various fields like id, title, link, summary, page_content, and embedding.
Parameters
----------
embedding_... | build_default_milvus_config | python | NVIDIA/nv-ingest | src/nv_ingest/framework/schemas/framework_vdb_task_sink_schema.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/schemas/framework_vdb_task_sink_schema.py | Apache-2.0 |
def filter_by_task(
required_tasks: List[Union[str, Tuple[Any, ...]]],
forward_func: Optional[Callable[[Any], Any]] = None,
) -> Callable:
"""
Decorator that checks whether the first argument (an IngestControlMessage) contains any of the
required tasks. Each required task can be specified as a strin... |
Decorator that checks whether the first argument (an IngestControlMessage) contains any of the
required tasks. Each required task can be specified as a string (the task name) or as a tuple/list
with the task name as the first element and additional task properties as subsequent elements.
If the IngestC... | filter_by_task | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/flow_control/filter_by_task.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/flow_control/filter_by_task.py | Apache-2.0 |
def _is_subset(superset: Any, subset: Any) -> bool:
"""
Recursively checks whether 'subset' is contained within 'superset'. Supports dictionaries,
lists, strings (including regex patterns), and basic types.
Parameters
----------
superset : Any
The data structure (or value) that is expec... |
Recursively checks whether 'subset' is contained within 'superset'. Supports dictionaries,
lists, strings (including regex patterns), and basic types.
Parameters
----------
superset : Any
The data structure (or value) that is expected to contain the subset.
subset : Any
The dat... | _is_subset | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/flow_control/filter_by_task.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/flow_control/filter_by_task.py | Apache-2.0 |
def get_fetch_mode_from_env() -> "FetchMode":
"""
Retrieves the fetch mode from the environment variable FETCH_MODE.
Returns
-------
FetchMode
The fetch mode as specified by the environment variable, or NON_DESTRUCTIVE by default.
"""
mode_str: str = os.getenv("FETCH_MODE", "NON_DES... |
Retrieves the fetch mode from the environment variable FETCH_MODE.
Returns
-------
FetchMode
The fetch mode as specified by the environment variable, or NON_DESTRUCTIVE by default.
| get_fetch_mode_from_env | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
def get_instance() -> "RedisIngestService":
"""
Static access method implementing the Singleton pattern.
Returns
-------
RedisIngestService
The singleton instance of the RedisIngestService.
"""
if RedisIngestService.__shared_instance is None:
... |
Static access method implementing the Singleton pattern.
Returns
-------
RedisIngestService
The singleton instance of the RedisIngestService.
| get_instance | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
def __init__(
self,
redis_hostname: str,
redis_port: int,
redis_task_queue: str,
fetch_mode: "FetchMode",
result_data_ttl_seconds: Optional[int],
state_ttl_seconds: Optional[int],
cache_config: Optional[Dict[str, Any]],
use_ssl: bool,
) -> None... |
Initializes the service and the underlying RedisClient.
Parameters
----------
redis_hostname : str
Redis server hostname.
redis_port : int
Redis server port.
redis_task_queue : str
The Redis queue name for tasks.
fetch_mode : ... | __init__ | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def fetch_job(self, job_id: str) -> Optional[Dict]:
"""
Fetches the job result using the configured RedisClient fetch mode and timeout.
Executes the synchronous client call asynchronously.
Parameters
----------
job_id : str
The unique identifier of the ... |
Fetches the job result using the configured RedisClient fetch mode and timeout.
Executes the synchronous client call asynchronously.
Parameters
----------
job_id : str
The unique identifier of the job.
Returns
-------
dict or None
... | fetch_job | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def set_job_state(self, job_id: str, state: str) -> None:
"""
Sets the explicit state of a job and refreshes its TTL.
Parameters
----------
job_id : str
The unique identifier of the job.
state : str
The state to be assigned to the job.
... |
Sets the explicit state of a job and refreshes its TTL.
Parameters
----------
job_id : str
The unique identifier of the job.
state : str
The state to be assigned to the job.
Returns
-------
None
| set_job_state | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def get_job_state(self, job_id: str) -> Optional[str]:
"""
Retrieves the explicit state of a job.
Parameters
----------
job_id : str
The unique identifier of the job.
Returns
-------
str or None
The state of the job, or None... |
Retrieves the explicit state of a job.
Parameters
----------
job_id : str
The unique identifier of the job.
Returns
-------
str or None
The state of the job, or None if not found or upon error.
| get_job_state | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def set_processing_cache(self, job_id: str, jobs_data: List["ProcessingJob"]) -> None:
"""
Stores processing jobs data in a simple key-value cache.
Parameters
----------
job_id : str
The unique identifier of the job.
jobs_data : list of ProcessingJob
... |
Stores processing jobs data in a simple key-value cache.
Parameters
----------
job_id : str
The unique identifier of the job.
jobs_data : list of ProcessingJob
The processing job data to be cached.
Returns
-------
None
| set_processing_cache | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def get_processing_cache(self, job_id: str) -> List["ProcessingJob"]:
"""
Retrieves processing jobs data from the simple key-value cache.
Parameters
----------
job_id : str
The unique identifier of the job.
Returns
-------
list of Proce... |
Retrieves processing jobs data from the simple key-value cache.
Parameters
----------
job_id : str
The unique identifier of the job.
Returns
-------
list of ProcessingJob
A list of processing jobs, or an empty list if not found or upon e... | get_processing_cache | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def get_fetch_mode(self) -> "FetchMode":
"""
Returns the configured fetch mode for the service.
Returns
-------
FetchMode
The current fetch mode.
"""
return self._fetch_mode |
Returns the configured fetch mode for the service.
Returns
-------
FetchMode
The current fetch mode.
| get_fetch_mode | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/impl/ingest/redis_ingest_service.py | Apache-2.0 |
async def fetch_job(self, job_id: str):
"""Abstract method for fetching job from ingestion service based on job_id""" | Abstract method for fetching job from ingestion service based on job_id | fetch_job | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
async def set_processing_cache(self, job_id: str, jobs_data: List[ProcessingJob]) -> None:
"""Abstract method for setting processing cache""" | Abstract method for setting processing cache | set_processing_cache | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
async def get_processing_cache(self, job_id: str) -> List[ProcessingJob]:
"""Abstract method for getting processing cache""" | Abstract method for getting processing cache | get_processing_cache | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
async def set_job_state(self, job_id: str, state: str, ttl: int = 86400):
"""Abstract method for setting job state""" | Abstract method for setting job state | set_job_state | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
async def get_job_state(self, job_id: str) -> Optional[str]:
"""Abstract method for getting job state""" | Abstract method for getting job state | get_job_state | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
async def get_fetch_mode(self) -> FetchMode:
"""Abstract method for getting fetch mode""" | Abstract method for getting fetch mode | get_fetch_mode | python | NVIDIA/nv-ingest | src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/nv_ingest/framework/util/service/meta/ingest/ingest_service_meta.py | Apache-2.0 |
def extract_bboxes_and_content(data):
"""Extract bounding boxes and associated content from the deeply nested data structure."""
# Navigate the nested structure to get to the nearby_objects
nearby_objects = data["content_metadata"]["hierarchy"]["nearby_objects"]["text"]
bboxes = nearby_objects["bbox"]
... | Extract bounding boxes and associated content from the deeply nested data structure. | extract_bboxes_and_content | python | NVIDIA/nv-ingest | src/util/centroid_testing.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/centroid_testing.py | Apache-2.0 |
def fit_nearest_neighbors(centroids, n_neighbors=3):
"""Fit the NearestNeighbors model to the centroids."""
centroids_array = np.array(centroids)
nbrs = NearestNeighbors(n_neighbors=n_neighbors, algorithm="auto", metric="euclidean")
nbrs.fit(centroids_array)
return nbrs | Fit the NearestNeighbors model to the centroids. | fit_nearest_neighbors | python | NVIDIA/nv-ingest | src/util/centroid_testing.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/centroid_testing.py | Apache-2.0 |
def find_nearest_neighbors(nbrs, new_bbox, content):
"""Find the nearest neighbors for a new bounding box and return associated content."""
new_centroid = np.array(
[(new_bbox[0] + (new_bbox[2] - new_bbox[0]) / 2, new_bbox[1] + (new_bbox[3] - new_bbox[1]) / 2)]
)
new_centroid_reshaped = new_cent... | Find the nearest neighbors for a new bounding box and return associated content. | find_nearest_neighbors | python | NVIDIA/nv-ingest | src/util/centroid_testing.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/centroid_testing.py | Apache-2.0 |
def format_size(size_in_bytes):
"""
Formats a size in bytes into a human-readable string with a maximum of three digits.
Parameters:
----------
size_in_bytes : int
The size in bytes to format.
Returns:
-------
str
The formatted size string with appropriate size suffix.
... |
Formats a size in bytes into a human-readable string with a maximum of three digits.
Parameters:
----------
size_in_bytes : int
The size in bytes to format.
Returns:
-------
str
The formatted size string with appropriate size suffix.
| format_size | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def parse_size(size):
"""Parse the size string with optional suffix (KB, MB) into bytes."""
units = {"KB": 1024, "MB": 1024**2, "GB": 1024**3}
if size.isdigit():
return int(size)
unit = size[-2:].upper()
number = size[:-2]
if unit in units and number.isdigit():
return int(number)... | Parse the size string with optional suffix (KB, MB) into bytes. | parse_size | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def load_or_scan_files(source_directory, cache_file=None):
"""Load file list from cache or scan the source directory."""
if cache_file and os.path.exists(cache_file):
with open(cache_file, "r") as f:
return json.load(f)
file_list = defaultdict(list)
all_files = [os.path.join(root, f... | Load file list from cache or scan the source directory. | load_or_scan_files | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def sample_files(file_list, samples, total_size_bytes, with_replacement=True):
"""
Samples files to meet a target total size, respecting the specified proportions for each
file type, and allows for sampling with or without replacement.
Parameters
----------
file_list : dict
A dictionary... |
Samples files to meet a target total size, respecting the specified proportions for each
file type, and allows for sampling with or without replacement.
Parameters
----------
file_list : dict
A dictionary mapping file types to lists of file paths.
samples : dict
A dictionary ma... | sample_files | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def process_samples(sample_options):
"""
Converts a list of 'key=value' strings from the --sample option into a dictionary,
mapping file extensions to their corresponding proportions for sampling.
Parameters
----------
sample_options : tuple of str
A tuple containing strings, each in th... |
Converts a list of 'key=value' strings from the --sample option into a dictionary,
mapping file extensions to their corresponding proportions for sampling.
Parameters
----------
sample_options : tuple of str
A tuple containing strings, each in the format 'key=value', where 'key'
is... | process_samples | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def validate_output_file(output_file_path):
"""
Validates the output file by calculating and logging the total bytes for each file type
identified in the sampled files listed within the specified JSON file, and checks if the
actual proportions match the expected proportions within a 5% tolerance.
""... |
Validates the output file by calculating and logging the total bytes for each file type
identified in the sampled files listed within the specified JSON file, and checks if the
actual proportions match the expected proportions within a 5% tolerance.
| validate_output_file | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def main(
source_directory,
size,
sample,
cache_file,
output_file,
validate_output,
log_level,
with_replacement,
):
"""
Samples files from a source directory based on specified proportions and total size,
optionally caches the file list, outputs a sampled file list, and valid... |
Samples files from a source directory based on specified proportions and total size,
optionally caches the file list, outputs a sampled file list, and validates output.
Parameters
----------
source_directory : str
The directory to scan for files to sample.
size : str
The total ... | main | python | NVIDIA/nv-ingest | src/util/gen_dataset.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/gen_dataset.py | Apache-2.0 |
def main(file_path: str) -> None:
"""
Command-line entry point for the image viewer application.
Loads images from a JSON file and starts the image viewer application.
Parameters
----------
file_path : str
Path to the JSON file containing the images.
"""
images: List[Image.Imag... |
Command-line entry point for the image viewer application.
Loads images from a JSON file and starts the image viewer application.
Parameters
----------
file_path : str
Path to the JSON file containing the images.
| main | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def keep_aspect_ratio_resize(image: Image.Image, max_size: Tuple[int, int]) -> Image.Image:
"""
Resize an image to fit within max_size while preserving its aspect ratio.
Parameters
----------
image : Image.Image
The input PIL Image.
max_size : Tuple[int, int]
A tuple (max_width,... |
Resize an image to fit within max_size while preserving its aspect ratio.
Parameters
----------
image : Image.Image
The input PIL Image.
max_size : Tuple[int, int]
A tuple (max_width, max_height) specifying the maximum size.
Returns
-------
Image.Image
The resi... | keep_aspect_ratio_resize | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def __init__(
self,
images: List[Image.Image],
initial_window_size: Tuple[int, int] = (1024, 768),
initial_thumb_size: Tuple[int, int] = (256, 256),
) -> None:
"""
Initialize the ImageViewerApp.
Parameters
----------
images : List[Image.Image]... |
Initialize the ImageViewerApp.
Parameters
----------
images : List[Image.Image]
List of original PIL Images to display.
initial_window_size : Tuple[int, int], optional
Initial window dimensions (width, height), by default (1024, 768).
initial_thu... | __init__ | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def center_window(self) -> None:
"""
Center the application window on the screen.
"""
self.root.update_idletasks()
screen_width = self.root.winfo_screenwidth()
screen_height = self.root.winfo_screenheight()
x = (screen_width // 2) - (self.window_width // 2)
... |
Center the application window on the screen.
| center_window | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def on_mouse_release(self, event: tk.Event) -> None:
"""
Handle mouse release events to detect window size changes and update pagination.
Parameters
----------
event : tk.Event
The Tkinter event object.
"""
new_width = self.root.winfo_width()
... |
Handle mouse release events to detect window size changes and update pagination.
Parameters
----------
event : tk.Event
The Tkinter event object.
| on_mouse_release | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def update_pagination(self) -> None:
"""
Update pagination parameters based on the current window size and regenerate thumbnails.
"""
desired_images_per_row: int = 4
max_thumb_width: int = max((self.window_width - 50) // desired_images_per_row, 50)
max_thumb_height: int =... |
Update pagination parameters based on the current window size and regenerate thumbnails.
| update_pagination | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def update_images(self) -> None:
"""
Update the scrollable frame with the current page of thumbnail images.
"""
# Destroy existing frames.
for frame in self.frames:
frame.destroy()
self.frames = []
start: int = self.page * self.images_per_page
... |
Update the scrollable frame with the current page of thumbnail images.
| update_images | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def show_full_size(self, index: int) -> None:
"""
Open a new window to display the full-size image.
Parameters
----------
index : int
The index of the image in the original image list.
"""
full_win = tk.Toplevel(self.root)
full_win.title("Full... |
Open a new window to display the full-size image.
Parameters
----------
index : int
The index of the image in the original image list.
| show_full_size | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def prev_page(self) -> None:
"""
Navigate to the previous page of images.
"""
if self.page > 0:
self.page -= 1
self.update_images() |
Navigate to the previous page of images.
| prev_page | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def next_page(self) -> None:
"""
Navigate to the next page of images.
"""
if (self.page + 1) * self.images_per_page < len(self.images):
self.page += 1
self.update_images() |
Navigate to the next page of images.
| next_page | python | NVIDIA/nv-ingest | src/util/image_viewer.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_viewer.py | Apache-2.0 |
def convert_model(
ckpt_path,
device,
dynamic_batching,
engine_path,
generate_onnx,
generate_triton_config,
generate_trt,
input_size,
max_batch_size,
max_queue_delay,
memory_pool_limit,
model_class_name,
model_io_config,
model_name,
model_script_path,
onnx... |
Convert a PyTorch model to ONNX and then to TensorRT engine, and set up Triton Inference Server model repository.
| convert_model | python | NVIDIA/nv-ingest | src/util/trt_converters.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/trt_converters.py | Apache-2.0 |
def extract_and_print_results(results):
"""
Extract and print the results from the Triton server response.
"""
try:
text = " ".join([output[0].decode("utf-8") for output in results.as_numpy("output")])
logger.info(text)
logger.info(json.loads(text))
except Exception as e:
... |
Extract and print the results from the Triton server response.
| extract_and_print_results | python | NVIDIA/nv-ingest | src/util/image_model_validation/cached.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_model_validation/cached.py | Apache-2.0 |
def resize_image(image, target_img_size):
"""
Resize and pad an image to the target image size.
"""
w, h, _ = np.array(image).shape
if target_img_size is not None: # Resize + Pad
r = min(target_img_size[0] / w, target_img_size[1] / h)
image = cv2.resize(
image,
... |
Resize and pad an image to the target image size.
| resize_image | python | NVIDIA/nv-ingest | src/util/image_model_validation/util.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_model_validation/util.py | Apache-2.0 |
def load_and_preprocess_image(image_path, target_img_size):
"""
Load and preprocess an image from the specified path, resizing and padding it to the target size.
"""
image = cv2.imread(image_path)
if image is None:
raise ValueError(f"Failed to load image from path: {image_path}")
# Resi... |
Load and preprocess an image from the specified path, resizing and padding it to the target size.
| load_and_preprocess_image | python | NVIDIA/nv-ingest | src/util/image_model_validation/util.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_model_validation/util.py | Apache-2.0 |
def validate_output(output_data, expected_batch_size):
"""
Validate the size of the output data.
"""
if len(output_data) != expected_batch_size:
raise ValueError(f"Output size {len(output_data)} does not match expected batch size {expected_batch_size}.")
print(f"Output size is valid: {len(ou... |
Validate the size of the output data.
| validate_output | python | NVIDIA/nv-ingest | src/util/image_model_validation/util.py | https://github.com/NVIDIA/nv-ingest/blob/master/src/util/image_model_validation/util.py | Apache-2.0 |
def canonicalize_markdown_table(table_string):
"""Converts a markdown table string to a canonical format.
This function takes a string potentially containing a Markdown table
(which might have inconsistent spacing, tabs, asterisks for formatting,
and a separator line) and transforms it into a standardi... | Converts a markdown table string to a canonical format.
This function takes a string potentially containing a Markdown table
(which might have inconsistent spacing, tabs, asterisks for formatting,
and a separator line) and transforms it into a standardized format.
The canonical format ensures:
-... | canonicalize_markdown_table | python | NVIDIA/nv-ingest | tests/integration/utilities_for_test.py | https://github.com/NVIDIA/nv-ingest/blob/master/tests/integration/utilities_for_test.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.