<commit_before>import pytest
import os

from pyhocon import ConfigFactory
from context import OptimizationWorker, test_model_dict

internal_config = ConfigFactory.parse_file('worker/internal/internal.conf')


@pytest.mark.skipif(not os.getenv('NUMBA_ENABLE_CUDASIM') == '1',
                    reason='CUDA Simulator is disabled, test_run_opt_on_cpu skipped because it would fail.')
def test_run_opt_on_cpu():
    worker = OptimizationWorker(conf=internal_config)
    worker.compile_model(test_model_dict)
    opt_result = worker.run({
        'initial_temp': 100.0,
        'max_steps': 1000,
        'thread_count': 100
    })<commit_msg>Added test for running optimization without deploying model<commit_after>import pytest
import os

from pyhocon import ConfigFactory
from context import OptimizationWorker, test_model_dict

internal_config = ConfigFactory.parse_file('worker/internal/internal.conf')


def test_run_opt_without_deploy():
    worker = OptimizationWorker(conf=internal_config)
    opt_result = worker.run({
        'initial_temp': 100.0,
        'max_steps': 1000,
        'thread_count': 100
    })

    opt_result_dict = opt_result.to_dict()

    assert type(opt_result_dict) is dict
    assert 'failure' in opt_result_dict
    assert opt_result_dict['values'] is None
    assert opt_result_dict['states'] is None


@pytest.mark.skipif(not os.getenv('NUMBA_ENABLE_CUDASIM') == '1',
                    reason='CUDA Simulator is disabled, test_run_opt_on_cpu skipped because it would fail.')
def test_run_opt_on_cpu():
    worker = OptimizationWorker(conf=internal_config)
    worker.compile_model(test_model_dict)
    opt_result = worker.run({
        'initial_temp': 100.0,
        'max_steps': 1000,
        'thread_count': 100
    })
{'fraction_non_alphanumeric': 0.09271899886234357, 'fraction_numerical': 0.019908987485779295, 'mean_word_length': 4.098550724637681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7453794', 'n_tokens_mistral': 576, 'n_tokens_neox': 541, 'n_words': 119}