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 test_extract_pdf_with_pdfium_integration(): """ Integration test for the extract_pdf_with_pdfium function. Verifies that the PDFium-based extraction correctly processes a test PDF document and returns a DataFrame with the expected structure and content. """ # Get the test file path test...
Integration test for the extract_pdf_with_pdfium function. Verifies that the PDFium-based extraction correctly processes a test PDF document and returns a DataFrame with the expected structure and content.
test_extract_pdf_with_pdfium_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_extract.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_extract.py
Apache-2.0
def test_extract_pdf_with_nemoretriever_integration(): """ Integration test for the extract_pdf_with_nemoretriever function. Verifies that the NemoRetriever Parse extraction correctly processes a test PDF document and returns a DataFrame with the expected structure and content. """ # Get the te...
Integration test for the extract_pdf_with_nemoretriever function. Verifies that the NemoRetriever Parse extraction correctly processes a test PDF document and returns a DataFrame with the expected structure and content.
test_extract_pdf_with_nemoretriever_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_extract.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_extract.py
Apache-2.0
def test_extract_infographic_data_from_image_integration(): """ Integration test for the extract_infographic_data_from_image function. This test verifies that the infographic extraction pipeline correctly processes image data and augments the DataFrame with extracted information. """ # Build a ...
Integration test for the extract_infographic_data_from_image function. This test verifies that the infographic extraction pipeline correctly processes image data and augments the DataFrame with extracted information.
test_extract_infographic_data_from_image_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_extract.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_extract.py
Apache-2.0
def test_extract_table_data_from_image_integration(): """ Integration test for the extract_table_data_from_image function. This test verifies that the table extraction pipeline correctly processes image data and updates the DataFrame with extracted table content. """ # Get the test file path fr...
Integration test for the extract_table_data_from_image function. This test verifies that the table extraction pipeline correctly processes image data and updates the DataFrame with extracted table content.
test_extract_table_data_from_image_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_extract.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_extract.py
Apache-2.0
def test_extract_chart_data_from_image_integration(): """ Integration test for the extract_chart_data_from_image function. This test verifies that the chart extraction pipeline correctly processes image data and updates the DataFrame with extracted chart content. """ # At the beginning of the t...
Integration test for the extract_chart_data_from_image function. This test verifies that the chart extraction pipeline correctly processes image data and updates the DataFrame with extracted chart content.
test_extract_chart_data_from_image_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_extract.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_extract.py
Apache-2.0
def test_with_multiple_tuple_input(self, mock_internal, mock_build_df): """Test transform_image_create_vlm_caption with list of tuples input.""" # Setup file_paths = ["image1.png", "image2.png"] doc_types = [DocumentTypeEnum.PNG, DocumentTypeEnum.PNG] input_df = pd.DataFrame( ...
Test transform_image_create_vlm_caption with list of tuples input.
test_with_multiple_tuple_input
python
NVIDIA/nv-ingest
api/api_tests/interface/test_interface.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_interface.py
Apache-2.0
def test_with_list_of_strings_input(self, mock_internal, mock_build_df): """Test transform_text_split_and_tokenize with list of strings input.""" # Setup input_texts = ["Document one.", "Document two."] input_df = pd.DataFrame( { "source_name": ["text_0", "te...
Test transform_text_split_and_tokenize with list of strings input.
test_with_list_of_strings_input
python
NVIDIA/nv-ingest
api/api_tests/interface/test_interface.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_interface.py
Apache-2.0
def test_with_invalid_list_input(self): """Test transform_text_split_and_tokenize with list containing non-string items.""" # Should raise a ValueError with self.assertRaises(ValueError): transform_text_split_and_tokenize( inputs=["Text", 123, "More text"], # List wi...
Test transform_text_split_and_tokenize with list containing non-string items.
test_with_invalid_list_input
python
NVIDIA/nv-ingest
api/api_tests/interface/test_interface.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_interface.py
Apache-2.0
def create_image_row(source: str, content: str, width: int, height: int) -> Dict[str, Any]: """ Create a simulated image row dictionary for testing the image filter. Parameters ---------- source : str A unique identifier for the image (e.g., file name). content : str A string re...
Create a simulated image row dictionary for testing the image filter. Parameters ---------- source : str A unique identifier for the image (e.g., file name). content : str A string representing the image content (for hashing). width : int Simulated image width. heig...
create_image_row
python
NVIDIA/nv-ingest
api/api_tests/interface/test_mutate.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_mutate.py
Apache-2.0
def create_text_row(source: str, content: str) -> Dict[str, Any]: """ Create a simulated text row dictionary for testing the image filter. Parameters ---------- source : str A unique identifier for the text document. content : str The text content. Returns ------- D...
Create a simulated text row dictionary for testing the image filter. Parameters ---------- source : str A unique identifier for the text document. content : str The text content. Returns ------- Dict[str, Any] A dictionary representing a text row with metadata....
create_text_row
python
NVIDIA/nv-ingest
api/api_tests/interface/test_mutate.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_mutate.py
Apache-2.0
def test_deduplicate_images_integration(): """ Integration test for deduplicate_images. This test creates a DataFrame containing image and non-image rows to validate that duplicate images are removed based on content hashes, while non-image rows are preserved. Test Data: - Two image rows (...
Integration test for deduplicate_images. This test creates a DataFrame containing image and non-image rows to validate that duplicate images are removed based on content hashes, while non-image rows are preserved. Test Data: - Two image rows (document_type set to "image") with identical image...
test_deduplicate_images_integration
python
NVIDIA/nv-ingest
api/api_tests/interface/test_mutate.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_mutate.py
Apache-2.0
def test_transform_text_split_and_tokenize_integration_success(input_mode, monkeypatch): """ Parameterized integration test for transform_text_split_and_tokenize. This test verifies that text documents can be split and tokenized correctly when provided as: - A preconstructed pandas DataFrame. ...
Parameterized integration test for transform_text_split_and_tokenize. This test verifies that text documents can be split and tokenized correctly when provided as: - A preconstructed pandas DataFrame. - A single plain text string. - A list of plain text strings. When a plain text strin...
test_transform_text_split_and_tokenize_integration_success
python
NVIDIA/nv-ingest
api/api_tests/interface/test_transform.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/interface/test_transform.py
Apache-2.0
def test_enum_values(self): """Test that the enum contains the expected values.""" self.assertEqual(AccessLevelEnum.UNKNOWN, -1) self.assertEqual(AccessLevelEnum.LEVEL_1, 1) self.assertEqual(AccessLevelEnum.LEVEL_2, 2) self.assertEqual(AccessLevelEnum.LEVEL_3, 3)
Test that the enum contains the expected values.
test_enum_values
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_value_comparison(self): """Test that enum values can be compared with integers.""" self.assertTrue(AccessLevelEnum.LEVEL_1 < AccessLevelEnum.LEVEL_2) self.assertTrue(AccessLevelEnum.LEVEL_2 > AccessLevelEnum.LEVEL_1) self.assertTrue(AccessLevelEnum.LEVEL_3 > 2) self.asse...
Test that enum values can be compared with integers.
test_value_comparison
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_value_arithmetic(self): """Test that enum values can be used in arithmetic operations.""" self.assertEqual(AccessLevelEnum.LEVEL_1 + 1, 2) self.assertEqual(AccessLevelEnum.LEVEL_2 - 1, 1)
Test that enum values can be used in arithmetic operations.
test_value_arithmetic
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_string_operations(self): """Test that enum values can be used in string operations.""" self.assertTrue(ContentDescriptionEnum.PDF_TEXT.startswith("Unstructured")) self.assertTrue("table" in ContentDescriptionEnum.DOCX_TABLE.lower()) self.assertEqual(ContentDescriptionEnum.PPTX_I...
Test that enum values can be used in string operations.
test_string_operations
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_uniqueness(self): """Test that all enum values are unique.""" values = [e.value for e in ContentTypeEnum] self.assertEqual(len(values), len(set(values)), "Duplicate values found in ContentTypeEnum")
Test that all enum values are unique.
test_uniqueness
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_categories(self): """Test that we can group document types by category.""" image_formats = [ DocumentTypeEnum.BMP, DocumentTypeEnum.JPEG, DocumentTypeEnum.PNG, DocumentTypeEnum.SVG, DocumentTypeEnum.TIFF, ] document_for...
Test that we can group document types by category.
test_categories
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_member_access(self): """Test different ways to access enum members.""" # Direct access self.assertEqual(LanguageEnum.EN, "en") # Access via value self.assertEqual(LanguageEnum("en"), LanguageEnum.EN) # Access via name self.assertEqual(LanguageEnum["EN"]...
Test different ways to access enum members.
test_member_access
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_all_members(self): """Test that the enum contains all expected members.""" expected_members = {"ERROR", "SUCCESS"} actual_members = set(StatusEnum.__members__.keys()) self.assertEqual(expected_members, actual_members)
Test that the enum contains all expected members.
test_all_members
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_extract_related_tasks(self): """Test that extraction-related tasks contain 'extract' in their values.""" extract_tasks = [ TaskTypeEnum.EXTRACT, TaskTypeEnum.AUDIO_DATA_EXTRACT, TaskTypeEnum.TABLE_DATA_EXTRACT, TaskTypeEnum.CHART_DATA_EXTRACT, ...
Test that extraction-related tasks contain 'extract' in their values.
test_extract_related_tasks
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_hierarchical_types(self): """Test types that can be considered hierarchical.""" hierarchical_types = [ TextTypeEnum.DOCUMENT, TextTypeEnum.PAGE, TextTypeEnum.BLOCK, TextTypeEnum.LINE, TextTypeEnum.SPAN, ] # Check that ...
Test types that can be considered hierarchical.
test_hierarchical_types
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_all_enums_are_properly_defined(self): """Test that all enums are properly defined as Enum subclasses.""" enums = [ AccessLevelEnum, ContentDescriptionEnum, ContentTypeEnum, DocumentTypeEnum, LanguageEnum, StatusEnum, ...
Test that all enums are properly defined as Enum subclasses.
test_all_enums_are_properly_defined
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_enum_member_iteration(self): """Test that we can iterate through enum members.""" enums = [ AccessLevelEnum, ContentDescriptionEnum, ContentTypeEnum, DocumentTypeEnum, LanguageEnum, StatusEnum, TableFormatEnum, ...
Test that we can iterate through enum members.
test_enum_member_iteration
python
NVIDIA/nv-ingest
api/api_tests/internal/test_enums.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/test_enums.py
Apache-2.0
def test_extract_text_from_audio_internal_no_trace_info(self, mock_df_apply, mock_create_client): """Test extract_text_from_audio_internal with no trace info provided.""" # Setup test data mock_create_client.return_value = self.mock_audio_client # Create test DataFrame with a single row...
Test extract_text_from_audio_internal with no trace info provided.
test_extract_text_from_audio_internal_no_trace_info
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/audio/test_audio_extraction.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/audio/test_audio_extraction.py
Apache-2.0
def test_client_creation(self, mock_create_client): """Test that the audio inference client is created with correct parameters.""" # Setup mock return value mock_client = Mock() mock_create_client.return_value = mock_client # Test client creation with different parameters ...
Test that the audio inference client is created with correct parameters.
test_client_creation
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/audio/test_audio_extraction.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/audio/test_audio_extraction.py
Apache-2.0
def test_prepare_task_props_without_params(self): """Test _prepare_task_props with a config that has no params key.""" # Create a task config without params task_config_no_params = {"method": "python_docx"} # Call the function task_config, source_id = _prepare_task_props(task_co...
Test _prepare_task_props with a config that has no params key.
test_prepare_task_props_without_params
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/docx/test_docx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/docx/test_docx_extractor.py
Apache-2.0
def test_prepare_task_props_without_source_id(self): """Test _prepare_task_props with a row that has no source_id.""" # Create a row without source_id row_no_source = pd.Series({"content": self.sample_base64, "filename": "test_document.docx"}) # Call the function task_config, so...
Test _prepare_task_props with a row that has no source_id.
test_prepare_task_props_without_source_id
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/docx/test_docx_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/docx/test_docx_extractor.py
Apache-2.0
def test_empty_dataframe(self, mock_update_chart_metadata, mock_create_clients): """Test behavior with an empty DataFrame.""" # Create empty DataFrame df = pd.DataFrame() # Call the function result_df, result_trace = module_under_test.extract_chart_data_from_image_internal( ...
Test behavior with an empty DataFrame.
test_empty_dataframe
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_no_matching_rows(self, mock_update_chart_metadata, mock_create_clients): """Test behavior when no rows match the extraction criteria.""" # Configure _create_clients to return our mock clients mock_create_clients.return_value = (self.mock_yolox_client, self.mock_paddle_client) #...
Test behavior when no rows match the extraction criteria.
test_no_matching_rows
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_successful_extraction(self, mock_update_chart_metadata, mock_create_clients): """Test successful chart data extraction and DataFrame update.""" # Configure _create_clients to return our mock clients mock_create_clients.return_value = (self.mock_yolox_client, self.mock_paddle_client) ...
Test successful chart data extraction and DataFrame update.
test_successful_extraction
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_mixed_rows(self, mock_update_chart_metadata, mock_create_clients): """Test behavior with a mix of matching and non-matching rows.""" # Configure _create_clients to return our mock clients mock_create_clients.return_value = (self.mock_yolox_client, self.mock_paddle_client) # Con...
Test behavior with a mix of matching and non-matching rows.
test_mixed_rows
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_extraction_error(self, mock_update_chart_metadata, mock_create_clients): """Test behavior when an error occurs during extraction.""" # Configure _create_clients to return our mock clients mock_create_clients.return_value = (self.mock_yolox_client, self.mock_paddle_client) # Con...
Test behavior when an error occurs during extraction.
test_extraction_error
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_client_creation_error(self, mock_create_clients): """Test behavior when an error occurs during client creation.""" # Create DataFrame with a matching row df = pd.DataFrame( [ { "metadata": { "content": "base64_image...
Test behavior when an error occurs during client creation.
test_client_creation_error
python
NVIDIA/nv-ingest
api/api_tests/internal/extract/image/test_chart_extractor.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/internal/extract/image/test_chart_extractor.py
Apache-2.0
def test_get_metadata_regex_match(): """ Validate that get_metadata returns a dict of all matching metadata entries when a regex is provided. """ cm = IngestControlMessage() cm.set_metadata("alpha", 1) cm.set_metadata("beta", 2) cm.set_metadata("gamma", 3) # Use a regex to match keys tha...
Validate that get_metadata returns a dict of all matching metadata entries when a regex is provided.
test_get_metadata_regex_match
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message.py
Apache-2.0
def test_get_metadata_regex_no_match(): """ Validate that get_metadata returns the default value when a regex is provided but no keys match. """ cm = IngestControlMessage() cm.set_metadata("alpha", 1) cm.set_metadata("beta", 2) pattern = re.compile("z") # Return default as an empty dict ...
Validate that get_metadata returns the default value when a regex is provided but no keys match.
test_get_metadata_regex_no_match
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message.py
Apache-2.0
def test_has_metadata_regex_match(): """ Validate that has_metadata returns True if any metadata key matches the regex. """ cm = IngestControlMessage() cm.set_metadata("key1", "value1") cm.set_metadata("other", "value2") assert cm.has_metadata(re.compile("^key")) assert not cm.has_metada...
Validate that has_metadata returns True if any metadata key matches the regex.
test_has_metadata_regex_match
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message.py
Apache-2.0
def test_empty_control_message(): """ Validate that an IngestControlMessage with no tasks returns an empty list from get_tasks() and that has_task returns False for any task id. """ cm = IngestControlMessage() assert list(cm.get_tasks()) == [] assert not cm.has_task("nonexistent")
Validate that an IngestControlMessage with no tasks returns an empty list from get_tasks() and that has_task returns False for any task id.
test_empty_control_message
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message_task.py
Apache-2.0
def test_add_single_task(): """ Validate that adding a single ControlMessageTask stores the task correctly, making it retrievable via has_task and get_tasks. """ cm = IngestControlMessage() task = ControlMessageTask(type="Test Task", id="task1", properties={"key": "value"}) cm.add_task(task)...
Validate that adding a single ControlMessageTask stores the task correctly, making it retrievable via has_task and get_tasks.
test_add_single_task
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message_task.py
Apache-2.0
def test_add_duplicate_task(): """ Validate that adding a duplicate task (same id) raises a ValueError indicating that tasks must be unique. """ cm = IngestControlMessage() task = ControlMessageTask(type="Test Task", id="task1", properties={"key": "value"}) cm.add_task(task) duplicate_task =...
Validate that adding a duplicate task (same id) raises a ValueError indicating that tasks must be unique.
test_add_duplicate_task
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message_task.py
Apache-2.0
def test_multiple_tasks(): """ Validate that multiple tasks added to IngestControlMessage are stored and retrievable. Ensures that has_task returns True for all added tasks and that get_tasks returns the correct set of tasks. """ cm = IngestControlMessage() task_data = [ {"type": "Task A...
Validate that multiple tasks added to IngestControlMessage are stored and retrievable. Ensures that has_task returns True for all added tasks and that get_tasks returns the correct set of tasks.
test_multiple_tasks
python
NVIDIA/nv-ingest
api/api_tests/primitives/test_ingest_control_message_task.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/test_ingest_control_message_task.py
Apache-2.0
def test_basic_caching(self): """Test that the function result is cached.""" call_count = 0 @multiprocessing_cache(max_calls=10) def example_function(a, b): nonlocal call_count call_count += 1 return a + b # First call should execute the func...
Test that the function result is cached.
test_basic_caching
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_cache_invalidation(self): """Test that the cache is invalidated after max_calls.""" call_count = 0 @multiprocessing_cache(max_calls=3) def example_function(x): nonlocal call_count call_count += 1 return x * 2 # First set of calls ...
Test that the cache is invalidated after max_calls.
test_cache_invalidation
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_kwargs_handling(self): """Test that the function caches correctly with keyword arguments.""" call_count = 0 @multiprocessing_cache(max_calls=10) def example_function(a, b=2, c=3): nonlocal call_count call_count += 1 return a + b + c ...
Test that the function caches correctly with keyword arguments.
test_kwargs_handling
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_multiple_processes(self): """Test that the cache works across multiple processes.""" def worker_function(queue, value): @multiprocessing_cache(max_calls=10) def cached_func(x): # This sleep simulates some expensive computation time.sleep(...
Test that the cache works across multiple processes.
test_multiple_processes
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_different_function_caches(self): """Test that different functions have separate caches.""" call_count1 = 0 call_count2 = 0 @multiprocessing_cache(max_calls=10) def function1(x): nonlocal call_count1 call_count1 += 1 return x * 2 ...
Test that different functions have separate caches.
test_different_function_caches
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_hashable_arguments(self): """Test caching behavior with hashable arguments.""" call_count = 0 @multiprocessing_cache(max_calls=10) def example_function(a, b, c): nonlocal call_count call_count += 1 return a + b + c # Call with simple...
Test caching behavior with hashable arguments.
test_hashable_arguments
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_zero_max_calls(self): """Test behavior with max_calls=0 (should disable caching).""" call_count = 0 @multiprocessing_cache(max_calls=0) def example_function(x): nonlocal call_count call_count += 1 return x * 2 # Each call should exec...
Test behavior with max_calls=0 (should disable caching).
test_zero_max_calls
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_negative_max_calls(self): """Test behavior with negative max_calls (actually disables caching).""" call_count = 0 @multiprocessing_cache(max_calls=-1) def example_function(x): nonlocal call_count call_count += 1 return x * 2 # Multip...
Test behavior with negative max_calls (actually disables caching).
test_negative_max_calls
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_decorators.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_decorators.py
Apache-2.0
def test_preprocess_image_default_dimension(self): """Test image preprocessing with default max dimension.""" result, metadata = preprocess_image_for_paddle(self.sample_image) # Check that the result has the correct shape (channel, height, width) self.assertEqual(result.shape[0], 3) # ...
Test image preprocessing with default max dimension.
test_preprocess_image_default_dimension
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_helpers.py
Apache-2.0
def test_preprocess_image_custom_dimension(self): """Test image preprocessing with custom max dimension.""" custom_max_dim = 512 result, metadata = preprocess_image_for_paddle(self.sample_image, image_max_dimension=custom_max_dim) # Check that resize was called with the correct scale fa...
Test image preprocessing with custom max dimension.
test_preprocess_image_custom_dimension
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_helpers.py
Apache-2.0
def test_preprocess_image_tall_image(self): """Test preprocessing with a tall image (height > width).""" tall_image = np.zeros((300, 100, 3), dtype=np.uint8) result, metadata = preprocess_image_for_paddle(tall_image) # Scale factor should be based on max dimension (300) expected...
Test preprocessing with a tall image (height > width).
test_preprocess_image_tall_image
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_helpers.py
Apache-2.0
def test_query_metadata_empty_field(self, mock_get): """Test _query_metadata with empty field in response.""" # Setup mock response mock_response = MagicMock() mock_response.status_code = 200 mock_response.json.return_value = {"other_field": "value"} mock_get.return_value...
Test _query_metadata with empty field in response.
test_query_metadata_empty_field
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_helpers.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_helpers.py
Apache-2.0
def test_initialization(self): """Test the initialization of the model interface.""" # Test default initialization self.assertEqual(self.model_interface.model_name, "nvidia/nemoretriever-parse") # Test custom model name custom_model = NemoRetrieverParseModelInterface(model_name=...
Test the initialization of the model interface.
test_initialization
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_format_input_http_single_image(self): """Test format_input method with HTTP protocol and a single image.""" test_data = {"image": self.sample_image} formatted_batches, formatted_batch_data = self.model_interface.format_input( test_data, protocol="http", max_batch_size=1 ...
Test format_input method with HTTP protocol and a single image.
test_format_input_http_single_image
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_format_input_http_multiple_images(self): """Test format_input method with HTTP protocol and multiple images.""" test_data = {"images": self.sample_images} formatted_batches, formatted_batch_data = self.model_interface.format_input( test_data, protocol="http", max_batch_size=...
Test format_input method with HTTP protocol and multiple images.
test_format_input_http_multiple_images
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_format_input_grpc_protocol(self): """Test format_input method with gRPC protocol (should raise ValueError).""" test_data = {"image": self.sample_image} with self.assertRaises(ValueError) as context: self.model_interface.format_input(test_data, protocol="grpc", max_batch_size...
Test format_input method with gRPC protocol (should raise ValueError).
test_format_input_grpc_protocol
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_format_input_invalid_protocol(self): """Test format_input method with an invalid protocol.""" test_data = {"image": self.sample_image} with self.assertRaises(ValueError) as context: self.model_interface.format_input(test_data, protocol="invalid", max_batch_size=1) s...
Test format_input method with an invalid protocol.
test_format_input_invalid_protocol
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_parse_output_missing_choices(self): """Test parse_output method with a response missing the 'choices' key.""" mock_response = {} # Missing 'choices' key with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_response, protocol="http") ...
Test parse_output method with a response missing the 'choices' key.
test_parse_output_missing_choices
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_parse_output_empty_choices(self): """Test parse_output method with an empty 'choices' list.""" mock_response = {"choices": []} # Empty 'choices' list with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_response, protocol="http") ...
Test parse_output method with an empty 'choices' list.
test_parse_output_empty_choices
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_parse_output_grpc_protocol(self): """Test parse_output method with gRPC protocol (should raise ValueError).""" mock_response = {} with self.assertRaises(ValueError) as context: self.model_interface.parse_output(mock_response, protocol="grpc") self.assertTrue("gRPC ...
Test parse_output method with gRPC protocol (should raise ValueError).
test_parse_output_grpc_protocol
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_parse_output_invalid_protocol(self): """Test parse_output method with an invalid protocol.""" mock_response = {} with self.assertRaises(ValueError) as context: self.model_interface.parse_output(mock_response, protocol="invalid") self.assertTrue("Invalid protocol" i...
Test parse_output method with an invalid protocol.
test_parse_output_invalid_protocol
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_accepted_classes_consistency(self): """Test that the ACCEPTED_CLASSES set is correctly defined.""" # Verify that ACCEPTED_CLASSES is the union of the individual class sets expected_union = set().union(ACCEPTED_TEXT_CLASSES, ACCEPTED_TABLE_CLASSES, ACCEPTED_IMAGE_CLASSES) self.as...
Test that the ACCEPTED_CLASSES set is correctly defined.
test_accepted_classes_consistency
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_nemoretriever_parse.py
Apache-2.0
def test_format_input_grpc_single_image(self): """Test format_input method with gRPC protocol and a single image.""" # Set up test data with image_arrays and empty image_dims img_array = np.zeros((100, 200, 3), dtype=np.uint8) test_data = {"image_arrays": [img_array], "image_dims": []} ...
Test format_input method with gRPC protocol and a single image.
test_format_input_grpc_single_image
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_format_input_grpc_multiple_images(self): """Test format_input method with gRPC protocol and multiple images.""" # Set up test data with multiple image arrays and empty image_dims img_arrays = [np.zeros((100, 200, 3), dtype=np.uint8) for _ in range(3)] test_data = {"image_arrays"...
Test format_input method with gRPC protocol and multiple images.
test_format_input_grpc_multiple_images
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_parse_output_http_missing_data(self): """Test parse_output method with HTTP protocol and missing data.""" mock_response = {} # Missing 'data' key data = {"image_dims": [{}]} with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_res...
Test parse_output method with HTTP protocol and missing data.
test_parse_output_http_missing_data
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_parse_output_grpc_multiple_images(self): """Test parse_output method with gRPC protocol and multiple images.""" # Create a mock gRPC response for multiple images # Shape (3, 2) for a batch of 2 images mock_response = np.array( [ # Bounding boxes for 2...
Test parse_output method with gRPC protocol and multiple images.
test_parse_output_grpc_multiple_images
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_parse_output_grpc_single_item_response(self): """Test parse_output method with gRPC protocol and a response with shape (3,).""" # Create a mock gRPC response with shape (3,) for a single image mock_response = np.array( [ json.dumps([[0.1, 0.2], [0.3, 0.2], [0...
Test parse_output method with gRPC protocol and a response with shape (3,).
test_parse_output_grpc_single_item_response
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_parse_output_grpc_invalid_response_type(self): """Test parse_output method with gRPC protocol and an invalid response type.""" mock_response = "not a numpy array" data = {"image_dims": [{}]} with self.assertRaises(ValueError) as context: self.model_interface.parse_o...
Test parse_output method with gRPC protocol and an invalid response type.
test_parse_output_grpc_invalid_response_type
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_parse_output_grpc_invalid_response_shape(self): """Test parse_output method with gRPC protocol and an invalid response shape.""" # Create a response with an invalid shape (2, 3) instead of (3, n) mock_response = np.zeros((2, 3)) data = {"image_dims": [{}]} with self.ass...
Test parse_output method with gRPC protocol and an invalid response shape.
test_parse_output_grpc_invalid_response_shape
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_postprocess_paddle_response_nan_box(self): """Test _postprocess_paddle_response static method with 'nan' box.""" # Set up test data with one valid box and one 'nan' box bounding_boxes = [[[0.1, 0.2], [0.3, 0.2], [0.3, 0.4], [0.1, 0.4]], "nan"] # This should be skipped text_pred...
Test _postprocess_paddle_response static method with 'nan' box.
test_postprocess_paddle_response_nan_box
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_postprocess_paddle_response_no_dims(self): """Test _postprocess_paddle_response static method with no dims.""" bounding_boxes = [[[0.1, 0.2], [0.3, 0.2], [0.3, 0.4], [0.1, 0.4]]] text_predictions = ["Text 1"] with self.assertRaises(ValueError) as context: PaddleOCRM...
Test _postprocess_paddle_response static method with no dims.
test_postprocess_paddle_response_no_dims
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_paddle.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_paddle.py
Apache-2.0
def test_initialization(self): """Test initialization of ParakeetClient with various configurations.""" # Test with all parameters provided client = ParakeetClient( endpoint="test.endpoint:50051", auth_token="test_token", function_id="test_function_id", ...
Test initialization of ParakeetClient with various configurations.
test_initialization
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_initialization_auto_ssl(self): """Test automatic SSL detection based on function_id.""" # With function_id but no explicit use_ssl client = ParakeetClient(endpoint="grpc.nvcf.nvidia.com:443", function_id="test_function_id") self.assertTrue(client.use_ssl) # Without func...
Test automatic SSL detection based on function_id.
test_initialization_auto_ssl
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_infer_method(self, mock_process_response): """Test the infer method of ParakeetClient.""" # Create a client instance for this test client = ParakeetClient(endpoint="test.endpoint:50051", auth_token="test_token", function_id="test_function_id") # Reset the mocks to clear the ini...
Test the infer method of ParakeetClient.
test_infer_method
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_infer_method_with_none_response(self): """Test the infer method when transcribe returns None.""" # Create a client instance for this test client = ParakeetClient(endpoint="test.endpoint:50051", auth_token="test_token", function_id="test_function_id") # Reset the mocks to clear ...
Test the infer method when transcribe returns None.
test_infer_method_with_none_response
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_transcribe_method( self, mock_convert_to_mono, mock_add_endpoint_params, mock_add_speaker_diarization, mock_add_word_boosting, mock_recognition_config, ): """Test the transcribe method of ParakeetClient.""" # Create a client instance for this ...
Test the transcribe method of ParakeetClient.
test_transcribe_method
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_transcribe_method_with_custom_parameters(self): """Test the transcribe method with custom parameters.""" # Create a client instance for this test client = ParakeetClient(endpoint="test.endpoint:50051", auth_token="test_token", function_id="test_function_id") # Reset the mocks t...
Test the transcribe method with custom parameters.
test_transcribe_method_with_custom_parameters
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_transcribe_method_with_grpc_error(self): """Test the transcribe method when a gRPC error occurs.""" # Create a client instance for this test client = ParakeetClient(endpoint="test.endpoint:50051", auth_token="test_token", function_id="test_function_id") # Reset the mocks to cle...
Test the transcribe method when a gRPC error occurs.
test_transcribe_method_with_grpc_error
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_convert_to_mono_wav(self): """Test the convert_to_mono_wav function that uses librosa and scipy.""" # Mock librosa.load with patch(f"{MODULE_UNDER_TEST}.librosa.load") as mock_librosa_load, patch( f"{MODULE_UNDER_TEST}.wavfile.write" ) as mock_wavfile_write, patch(f"...
Test the convert_to_mono_wav function that uses librosa and scipy.
test_convert_to_mono_wav
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_process_transcription_response_empty_alternatives(self): """Test processing a response with empty alternatives.""" # Create a mock transcription response mock_response = MagicMock() # Set up result with empty alternatives mock_result = MagicMock() mock_result.al...
Test processing a response with empty alternatives.
test_process_transcription_response_empty_alternatives
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_create_audio_inference_client_with_grpc(self): """Test creating an audio inference client with gRPC.""" # Set up endpoints endpoints = ("grpc.endpoint:50051", "http.endpoint:8000") # Call the function with gRPC protocol client = create_audio_inference_client( ...
Test creating an audio inference client with gRPC.
test_create_audio_inference_client_with_grpc
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_create_audio_inference_client_with_http(self): """Test creating an audio inference client with HTTP (should raise error).""" # Set up endpoints endpoints = ("grpc.endpoint:50051", "http.endpoint:8000") # Call the function with HTTP protocol with self.assertRaises(ValueE...
Test creating an audio inference client with HTTP (should raise error).
test_create_audio_inference_client_with_http
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_create_audio_inference_client_default_protocol(self): """Test creating an audio inference client with default protocol detection.""" # Set up endpoints endpoints = ("grpc.endpoint:50051", "http.endpoint:8000") # Call the function without specifying protocol _ = create_a...
Test creating an audio inference client with default protocol detection.
test_create_audio_inference_client_default_protocol
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_create_audio_inference_client_empty_grpc_endpoint(self): """Test creating a client with empty gRPC endpoint.""" # Set up endpoints with empty gRPC endpoint endpoints = ("", "http.endpoint:8000") # Call the function without specifying protocol _ = create_audio_inference_...
Test creating a client with empty gRPC endpoint.
test_create_audio_inference_client_empty_grpc_endpoint
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_parakeet.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_parakeet.py
Apache-2.0
def test_parse_output_missing_data(self): """Test parse_output with missing data in response.""" # Mock response with missing data mock_response = {"some_other_key": "value"} with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_response, pr...
Test parse_output with missing data in response.
test_parse_output_missing_data
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_text_embedding.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_text_embedding.py
Apache-2.0
def test_parse_output_empty_data(self): """Test parse_output with empty data in response.""" # Mock response with empty data mock_response = {"data": []} with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_response, protocol="http") ...
Test parse_output with empty data in response.
test_parse_output_empty_data
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_text_embedding.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_text_embedding.py
Apache-2.0
def test_parse_output_missing_embedding(self): """Test parse_output with missing 'embedding' field in data items.""" # Mock response with missing embedding field mock_response = { "data": [ {"some_field": "value"}, {"embedding": [0.4, 0.5, 0.6]}, ...
Test parse_output with missing 'embedding' field in data items.
test_parse_output_missing_embedding
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_text_embedding.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_text_embedding.py
Apache-2.0
def test_parse_output_missing_choices(self): """Test parse_output with missing choices in response.""" # Mock response with missing choices mock_response = {"some_other_key": "value"} with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_res...
Test parse_output with missing choices in response.
test_parse_output_missing_choices
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_vlm.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_vlm.py
Apache-2.0
def test_parse_output_empty_choices(self): """Test parse_output with empty choices in response.""" # Mock response with empty choices mock_response = {"choices": []} with self.assertRaises(RuntimeError) as context: self.model_interface.parse_output(mock_response, protocol="h...
Test parse_output with empty choices in response.
test_parse_output_empty_choices
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_vlm.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_vlm.py
Apache-2.0
def test_parse_output_missing_message(self): """Test parse_output with missing message in choices.""" # Mock response with missing message field mock_response = { "choices": [ {"some_field": "value"}, {"message": {"content": "A dog playing in the park....
Test parse_output with missing message in choices.
test_parse_output_missing_message
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_vlm.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_vlm.py
Apache-2.0
def test_parse_output_missing_content(self): """Test parse_output with missing content in message.""" # Mock response with missing content field mock_response = { "choices": [ {"message": {"some_field": "value"}}, {"message": {"content": "A dog playing...
Test parse_output with missing content in message.
test_parse_output_missing_content
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_vlm.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_vlm.py
Apache-2.0
def test_prepare_data_non_numpy_images(self): """Test prepare_data_for_inference with non-numpy array images.""" # Create input data with non-numpy images input_data = {"images": ["image1", "image2"]} with self.assertRaises(ValueError) as context: self.model_interface.prepar...
Test prepare_data_for_inference with non-numpy array images.
test_prepare_data_non_numpy_images
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
Apache-2.0
def test_format_input_grpc_batching(self): """Test format_input with gRPC protocol and batching.""" # Create input data with more images than max_batch_size input_data = { "images": [self.image1, self.image2, self.image3], "original_image_shapes": [(100, 200, 3), (150, 25...
Test format_input with gRPC protocol and batching.
test_format_input_grpc_batching
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
Apache-2.0
def test_format_input_http_batching(self): """Test format_input with HTTP protocol and batching.""" # Create input data with more images than max_batch_size input_data = { "images": [self.image1, self.image2, self.image3], "original_image_shapes": [(100, 200, 3), (150, 25...
Test format_input with HTTP protocol and batching.
test_format_input_http_batching
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
Apache-2.0
def test_parse_output_http_multiple_images(self): """Test parse_output with HTTP protocol and multiple images.""" # Create a mock HTTP response with multiple images mock_response = { "data": [ { "bounding_boxes": { "person":...
Test parse_output with HTTP protocol and multiple images.
test_parse_output_http_multiple_images
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_base.py
Apache-2.0
def test_postprocess_annotations_numpy_array_conversion(self): """Test that postprocess_annotations correctly converts numpy arrays to lists.""" # Mock get_bbox_dict_yolox_graphic to return dict with numpy arrays self.mock_get_bbox_dict.return_value = { "logo": np.array([[10, 20, 30,...
Test that postprocess_annotations correctly converts numpy arrays to lists.
test_postprocess_annotations_numpy_array_conversion
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_graphic_elements.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_graphic_elements.py
Apache-2.0
def test_postprocess_annotations_non_numpy_values(self): """Test that postprocess_annotations correctly handles non-numpy values.""" # Mock get_bbox_dict_yolox_graphic to return dict with mixed types self.mock_get_bbox_dict.return_value = { "logo": [[10, 20, 30, 40, 0.9]], # Already...
Test that postprocess_annotations correctly handles non-numpy values.
test_postprocess_annotations_non_numpy_values
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_graphic_elements.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_graphic_elements.py
Apache-2.0
def test_default_initialization(self): """Test default initialization (should use v2 parameters).""" model = YoloxPageElementsModelInterface() # Check that v2 parameters are used by default self.assertEqual(model.num_classes, 4) self.assertEqual(model.final_score, {"table": 0.5,...
Test default initialization (should use v2 parameters).
test_default_initialization
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_page_elements.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_page_elements.py
Apache-2.0
def test_postprocess_annotations_title_preservation(self): """Test postprocess_annotations preserves title entries without filtering.""" # Create mock annotation dictionaries annotations = [ { "table": [], "chart": [], "title": [ ...
Test postprocess_annotations preserves title entries without filtering.
test_postprocess_annotations_title_preservation
python
NVIDIA/nv-ingest
api/api_tests/primitives/nim/model_interface/test_yolox_interface_page_elements.py
https://github.com/NVIDIA/nv-ingest/blob/master/api/api_tests/primitives/nim/model_interface/test_yolox_interface_page_elements.py
Apache-2.0