from __future__ import annotations

import gc
import os
import random
import time
from concurrent.futures import ThreadPoolExecutor
from unittest.mock import Mock, patch

import numpy as np
import pytest
import supervision as sv
from fastapi import BackgroundTasks
from inference.core.cache.base import BaseCache
from inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2 import \
    maybe_register_datapoint_at_roboflow
from inference.core.workflows.execution_engine.entities.base import (
    ImageParentMetadata, WorkflowImageData)


def codeflash_wrap(codeflash_wrapped, codeflash_test_module_name, codeflash_test_class_name, codeflash_test_name, codeflash_function_name, codeflash_line_id, codeflash_loop_index, *args, **kwargs):
    test_id = f'{codeflash_test_module_name}:{codeflash_test_class_name}:{codeflash_test_name}:{codeflash_line_id}:{codeflash_loop_index}'
    if not hasattr(codeflash_wrap, 'index'):
        codeflash_wrap.index = {}
    if test_id in codeflash_wrap.index:
        codeflash_wrap.index[test_id] += 1
    else:
        codeflash_wrap.index[test_id] = 0
    codeflash_test_index = codeflash_wrap.index[test_id]
    invocation_id = f'{codeflash_line_id}_{codeflash_test_index}'
    test_stdout_tag = f"{codeflash_test_module_name}:{(codeflash_test_class_name + '.' if codeflash_test_class_name else '')}{codeflash_test_name}:{codeflash_function_name}:{codeflash_loop_index}:{invocation_id}"
    print(f'!$######{test_stdout_tag}######$!')
    exception = None
    gc.disable()
    try:
        counter = time.perf_counter_ns()
        return_value = codeflash_wrapped(*args, **kwargs)
        codeflash_duration = time.perf_counter_ns() - counter
    except Exception as e:
        codeflash_duration = time.perf_counter_ns() - counter
        exception = e
    gc.enable()
    print(f'!######{test_stdout_tag}:{codeflash_duration}######!')
    if exception:
        raise exception
    return return_value

def create_workflow_image_data(numpy_image=None):
    """Create a real WorkflowImageData instance with default or provided numpy image."""
    if numpy_image is None:
        numpy_image = np.zeros((100, 100, 3), dtype=np.uint8)
    parent_metadata = ImageParentMetadata(parent_id='test_image_id')
    return WorkflowImageData(parent_metadata=parent_metadata, numpy_image=numpy_image)

def create_mock_cache():
    """Create a mock cache for testing."""
    mock_cache = Mock(spec=BaseCache)
    mock_cache.get = Mock(return_value=None)
    mock_cache.set = Mock()
    return mock_cache

def test_basic_registration_with_100_percent_probability():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that registration is called when data_percentage is 100.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (True, 'Registration successful')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_basic_registration_with_100_percent_probability', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=['tag1'], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        codeflash_output = codeflash_return_value
        result = codeflash_output

def test_skip_registration_with_0_percent_probability():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that registration is skipped when data_percentage is 0.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (True, 'Registration successful')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_skip_registration_with_0_percent_probability', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=0.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        codeflash_output = codeflash_return_value
        result = codeflash_output

def test_return_value_when_skipped():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test the return value when registration is skipped due to sampling.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_return_value_when_skipped', 'maybe_register_datapoint_at_roboflow', '3', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=0.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_passes_all_parameters_to_register_datapoint():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all parameters are correctly passed to register_datapoint_at_roboflow.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    prediction = sv.Detections.empty()
    tags = ['tag1', 'tag2']
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (True, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_passes_all_parameters_to_register_datapoint', 'maybe_register_datapoint_at_roboflow', '5_1', codeflash_loop_index, image=image, prediction=prediction, target_project='my_project', usage_quota_name='my_quota', data_percentage=100.0, persist_predictions=True, minutely_usage_limit=5, hourly_usage_limit=50, daily_usage_limit=500, max_image_size=(800, 600), compression_level=85, registration_tags=tags, fire_and_forget=True, labeling_batch_prefix='batch_prefix', new_labeling_batch_frequency='weekly', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='my_api_key', image_name='custom_name')
        mock_register.assert_called_once()
        call_kwargs = mock_register.call_args[1]

def test_with_sv_detections_prediction():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that function handles sv.Detections objects as predictions.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    detections = sv.Detections.empty()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_with_sv_detections_prediction', 'maybe_register_datapoint_at_roboflow', '4_1', codeflash_loop_index, image=image, prediction=detections, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=True, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        codeflash_output = codeflash_return_value
        result = codeflash_output
        call_kwargs = mock_register.call_args[1]

def test_with_dict_prediction():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that function handles dict objects as predictions.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    dict_prediction = {'class': 'person', 'confidence': 0.95}
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_with_dict_prediction', 'maybe_register_datapoint_at_roboflow', '4_1', codeflash_loop_index, image=image, prediction=dict_prediction, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=True, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        codeflash_output = codeflash_return_value
        result = codeflash_output
        call_kwargs = mock_register.call_args[1]

def test_with_none_prediction():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that function handles None as prediction.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_with_none_prediction', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        codeflash_output = codeflash_return_value
        result = codeflash_output
        call_kwargs = mock_register.call_args[1]

def test_probability_normalization_at_boundary_50_percent():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test probability normalization with 50% data_percentage.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    call_count = 0
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        random.seed(42)
        for i in range(100):
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_probability_normalization_at_boundary_50_percent', 'maybe_register_datapoint_at_roboflow', '4_2_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=50.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_count = mock_register.call_count

def test_very_small_probability():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with very small probability (0.001%).'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        random.seed(42)
        for i in range(100):
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_very_small_probability', 'maybe_register_datapoint_at_roboflow', '3_2_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=0.001, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_probability_99_99_percent():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with very high probability (99.99%).'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        random.seed(42)
        for i in range(100):
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_probability_99_99_percent', 'maybe_register_datapoint_at_roboflow', '3_2_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=99.99, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_empty_registration_tags():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with empty registration tags list.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_empty_registration_tags', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_many_registration_tags():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with many registration tags.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    many_tags = [f'tag_{i}' for i in range(100)]
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_registration_tags', 'maybe_register_datapoint_at_roboflow', '4_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=many_tags, fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_empty_string_image_name():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with empty string as image_name.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_empty_string_image_name', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key', image_name='')
        call_kwargs = mock_register.call_args[1]

def test_none_image_name():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with None as image_name.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_none_image_name', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key', image_name=None)
        call_kwargs = mock_register.call_args[1]

def test_with_background_tasks():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with BackgroundTasks provided.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    background_tasks = BackgroundTasks()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_with_background_tasks', 'maybe_register_datapoint_at_roboflow', '4_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=True, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=background_tasks, thread_pool_executor=None, api_key='test_key')

def test_with_thread_pool_executor():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with ThreadPoolExecutor provided.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    thread_pool_executor = ThreadPoolExecutor(max_workers=2)
    try:
        with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
            mock_register.return_value = (False, 'Success')
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_with_thread_pool_executor', 'maybe_register_datapoint_at_roboflow', '4_0_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=True, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=thread_pool_executor, api_key='test_key')
    finally:
        thread_pool_executor.shutdown(wait=False)

def test_min_max_image_size():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with minimum image size (1x1).'
    small_image = np.zeros((1, 1, 3), dtype=np.uint8)
    image = create_workflow_image_data(numpy_image=small_image)
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_min_max_image_size', 'maybe_register_datapoint_at_roboflow', '4_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(1, 1), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_large_max_image_size():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with very large max image size.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_large_max_image_size', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(4096, 4096), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_compression_level_0():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with compression level 0 (no compression).'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_compression_level_0', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=0, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_compression_level_100():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with maximum compression level 100.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_compression_level_100', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=100, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_all_batch_frequency_options():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with all available batch creation frequency options.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    frequencies = ['never', 'daily', 'weekly', 'monthly']
    for frequency in frequencies:
        with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
            mock_register.return_value = (False, 'Success')
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_all_batch_frequency_options', 'maybe_register_datapoint_at_roboflow', '4_0_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency=frequency, cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
            call_kwargs = mock_register.call_args[1]

def test_special_characters_in_strings():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with special characters in string parameters.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    special_project = 'project@#$%^&*()'
    special_quota = 'quota_!@#$%'
    special_prefix = 'prefix/\\|<>?:";'
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_special_characters_in_strings', 'maybe_register_datapoint_at_roboflow', '6_1', codeflash_loop_index, image=image, prediction=None, target_project=special_project, usage_quota_name=special_quota, data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix=special_prefix, new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_zero_limits():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with all usage limits set to 0.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_zero_limits', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=0, hourly_usage_limit=0, daily_usage_limit=0, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_very_large_limits():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with very large usage limits.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_very_large_limits', 'maybe_register_datapoint_at_roboflow', '3_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=1000000, hourly_usage_limit=10000000, daily_usage_limit=100000000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
        call_kwargs = mock_register.call_args[1]

def test_many_sequential_calls_with_100_percent_probability():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test 1000 sequential calls with 100% probability.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for i in range(1000):
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_sequential_calls_with_100_percent_probability', 'maybe_register_datapoint_at_roboflow', '3_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_many_sequential_calls_with_0_percent_probability():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test 1000 sequential calls with 0% probability.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for i in range(1000):
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_sequential_calls_with_0_percent_probability', 'maybe_register_datapoint_at_roboflow', '3_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=0.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_many_different_images():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 1000 different WorkflowImageData instances.'
    images = []
    for i in range(1000):
        height = 50 + i % 200
        width = 50 + i * 2 % 200
        img_array = np.zeros((height, width, 3), dtype=np.uint8)
        images.append(create_workflow_image_data(numpy_image=img_array))
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for image in images:
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_different_images', 'maybe_register_datapoint_at_roboflow', '4_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_many_different_tag_combinations():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 100 different tag combinations (up to 1000 total tags).'
    tag_lists = []
    for i in range(100):
        num_tags = 1 + i % 11
        tags = [f'tag_{i}_{j}' for j in range(num_tags)]
        tag_lists.append(tags)
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for tags in tag_lists:
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_different_tag_combinations', 'maybe_register_datapoint_at_roboflow', '5_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=tags, fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_varying_probabilities_1000_iterations():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test statistical behavior with 1000 iterations at various probabilities.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    probabilities = [1, 5, 10, 25, 50, 75, 90, 95, 99]
    random.seed(123)
    for prob in probabilities:
        with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
            mock_register.return_value = (False, 'Success')
            for i in range(1000):
                codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_varying_probabilities_1000_iterations', 'maybe_register_datapoint_at_roboflow', '5_0_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=prob, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')
            expected = prob / 100 * 1000
            actual = mock_register.call_count
            tolerance = expected * 0.2

def test_many_different_project_names():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 500 different project names.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    project_names = [f'project_{i:03d}' for i in range(500)]
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for project_name in project_names:
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_different_project_names', 'maybe_register_datapoint_at_roboflow', '4_1_0', codeflash_loop_index, image=image, prediction=None, target_project=project_name, usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_many_different_quota_names():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 500 different quota names.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    quota_names = [f'quota_{i:03d}' for i in range(500)]
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for quota_name in quota_names:
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_different_quota_names', 'maybe_register_datapoint_at_roboflow', '4_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name=quota_name, data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_alternating_fire_and_forget_modes():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test 500 calls alternating between fire_and_forget True and False.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for i in range(500):
            fire_and_forget = i % 2 == 0
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_alternating_fire_and_forget_modes', 'maybe_register_datapoint_at_roboflow', '3_1_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=fire_and_forget, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_alternating_persist_predictions():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test 500 calls alternating persist_predictions between True and False.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for i in range(500):
            persist = i % 2 == 0
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_alternating_persist_predictions', 'maybe_register_datapoint_at_roboflow', '3_1_1', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=persist, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')

def test_many_different_image_names():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 500 different image_name values.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    image_names = [f'image_{i:04d}.jpg' for i in range(500)]
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for image_name in image_names:
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_many_different_image_names', 'maybe_register_datapoint_at_roboflow', '4_1_0', codeflash_loop_index, image=image, prediction=None, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=False, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key', image_name=image_name)

def test_large_predictions_list():
    random.seed(42)
    np.random.seed(42)
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test with 1000 sequential calls using different prediction objects.'
    image = create_workflow_image_data()
    cache = create_mock_cache()
    with patch('inference.core.workflows.core_steps.sinks.roboflow.dataset_upload.v2.register_datapoint_at_roboflow') as mock_register:
        mock_register.return_value = (False, 'Success')
        for i in range(1000):
            if i % 3 == 0:
                prediction = None
            elif i % 3 == 1:
                prediction = {'class': 'person', 'confidence': 0.95}
            else:
                prediction = sv.Detections.empty()
            codeflash_return_value = codeflash_wrap(maybe_register_datapoint_at_roboflow, 'tests.inference.unit_tests.test_maybe_register_datapoint_at_roboflow__unit_test_1', None, 'test_large_predictions_list', 'maybe_register_datapoint_at_roboflow', '3_1_1', codeflash_loop_index, image=image, prediction=prediction, target_project='test_project', usage_quota_name='test_quota', data_percentage=100.0, persist_predictions=True, minutely_usage_limit=10, hourly_usage_limit=100, daily_usage_limit=1000, max_image_size=(640, 640), compression_level=95, registration_tags=[], fire_and_forget=False, labeling_batch_prefix='batch', new_labeling_batch_frequency='daily', cache=cache, background_tasks=None, thread_pool_executor=None, api_key='test_key')