codeflash-internal/experiments/remove_subprocess_mock.ipynb

168 lines
4.2 KiB
Text
Raw Normal View History

2024-01-30 01:31:30 +00:00
{
"cells": [
{
"cell_type": "code",
2024-02-29 11:18:12 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"import pickle\n",
"import os\n",
"def _log__test__values(values, duration, test_name):\n",
" iteration = os.environ[\"CODEFLASH_TEST_ITERATION\"]\n",
" with open(os.path.join('{codeflash_run_tmp_dir_client_side}', f'test_return_values_{iteration}.bin'), 'ab') as f:\n",
" return_bytes = pickle.dumps(values)\n",
" _test_name = f\"{test_name}\".encode(\"ascii\")\n",
" f.write(len(_test_name).to_bytes(4, byteorder='big'))\n",
" f.write(_test_name)\n",
" f.write(duration.to_bytes(8, byteorder='big'))\n",
" f.write(len(return_bytes).to_bytes(4, byteorder='big'))\n",
" f.write(return_bytes)\n",
"import inspect\n",
"import time\n",
"import gc\n",
"from code_to_optimize.impure import mutinator\n",
"[42]\n"
]
}
],
2024-01-30 01:31:30 +00:00
"source": [
2024-02-29 11:18:12 +00:00
"from testgen.instrumentation.instrument_test_source import instrument_test_source\n",
"from aiservice.models.functions_to_optimize import FunctionToOptimize\n",
"\n",
"\n",
"test_source = \"\"\"[42]\n",
"\"\"\"\n",
"function_to_optimize = FunctionToOptimize(\n",
" function_name=\"mutinator\",\n",
" file_path=\"/Users/renaud/repos/codeflash/cli/code_to_optimize/impure.py\",\n",
" parents=[],\n",
" starting_line=None,\n",
" ending_line=None,\n",
")\n",
"module_path = \"code_to_optimize.impure\"\n",
"test_module_path = \"code_to_optimize.tests.pytest.test_sorter__unit_test_0\"\n",
"instr_test = instrument_test_source(\n",
" test_source, function_to_optimize, [], module_path, test_module_path, 'pytest', 15)\n",
"\n",
"print(instr_test)"
2024-01-30 01:31:30 +00:00
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:12:25.515265Z",
"start_time": "2024-02-29T07:12:25.510325Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "8d108492763a25a5",
2024-02-29 11:18:12 +00:00
"execution_count": 5
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
"outputs": [],
2024-02-29 11:18:12 +00:00
"source": [],
2024-01-30 01:31:30 +00:00
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.826388Z",
"start_time": "2024-02-29T07:11:56.809516Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "694116ed54c4af6a",
2024-02-29 11:18:12 +00:00
"execution_count": 4
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
2024-02-29 11:18:12 +00:00
"execution_count": 4,
2024-01-30 01:31:30 +00:00
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.826672Z",
"start_time": "2024-02-29T07:11:56.812619Z"
2024-01-30 01:31:30 +00:00
}
},
"outputs": [],
2024-02-29 11:18:12 +00:00
"source": []
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
"outputs": [],
2024-02-29 11:18:12 +00:00
"source": [],
2024-01-30 01:31:30 +00:00
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.826732Z",
"start_time": "2024-02-29T07:11:56.815532Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "80fefa4a71d32347",
2024-02-29 11:18:12 +00:00
"execution_count": 4
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
2024-02-29 11:18:12 +00:00
"outputs": [],
"source": [],
2024-01-30 01:31:30 +00:00
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.827003Z",
"start_time": "2024-02-29T07:11:56.820078Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "3cb5881311ca16e2",
2024-02-29 11:18:12 +00:00
"execution_count": 4
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
2024-02-29 11:18:12 +00:00
"outputs": [],
"source": [],
2024-01-30 01:31:30 +00:00
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.830003Z",
"start_time": "2024-02-29T07:11:56.823116Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "639c96f42318a856",
2024-02-29 11:18:12 +00:00
"execution_count": 4
2024-01-30 01:31:30 +00:00
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
2024-02-29 11:18:12 +00:00
"end_time": "2024-02-29T07:11:56.830236Z",
"start_time": "2024-02-29T07:11:56.825068Z"
2024-01-30 01:31:30 +00:00
}
},
"id": "12baa8a023eafc26",
2024-02-29 11:18:12 +00:00
"execution_count": 4
2024-01-30 01:31:30 +00:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}