Remove overrides decorator

This commit is contained in:
afik.cohen 2024-05-06 19:37:08 -07:00
parent dc559c456b
commit 146aa1205c
5 changed files with 33 additions and 89 deletions

View file

@ -4,6 +4,8 @@
<option name="alwaysUseGlobalRuff" value="true" /> <option name="alwaysUseGlobalRuff" value="true" />
<option name="globalRuffExecutablePath" value="$USER_HOME$/miniforge3/envs/aiservice/bin/ruff" /> <option name="globalRuffExecutablePath" value="$USER_HOME$/miniforge3/envs/aiservice/bin/ruff" />
<option name="globalRuffLspExecutablePath" value="$USER_HOME$/miniforge3/envs/aiservice/bin/ruff-lsp" /> <option name="globalRuffLspExecutablePath" value="$USER_HOME$/miniforge3/envs/aiservice/bin/ruff-lsp" />
<option name="projectRuffExecutablePath" value="$USER_HOME$/miniforge3/envs/codeflash311/bin/ruff" />
<option name="projectRuffLspExecutablePath" value="$USER_HOME$/miniforge3/envs/codeflash311/bin/ruff-lsp" />
<option name="ruffConfigPath" value="$PROJECT_DIR$/django/aiservice/pyproject.toml" /> <option name="ruffConfigPath" value="$PROJECT_DIR$/django/aiservice/pyproject.toml" />
<option name="runRuffOnSave" value="true" /> <option name="runRuffOnSave" value="true" />
<option name="useRuffFormat" value="true" /> <option name="useRuffFormat" value="true" />

View file

@ -5,12 +5,21 @@
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="$USER_HOME$/mambaforge/envs/codeflash311/bin/python" /> <option name="SDK_HOME" value="$USER_HOME$/mambaforge/envs/codeflash311/bin/python" />
<option name="SDK_NAME" value="codeflash311" />
<option name="WORKING_DIRECTORY" value="" /> <option name="WORKING_DIRECTORY" value="" />
<option name="IS_MODULE_SDK" value="false" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<EXTENSION ID="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</EXTENSION>
<option name="_new_keywords" value="&quot;&quot;" /> <option name="_new_keywords" value="&quot;&quot;" />
<option name="_new_parameters" value="&quot;&quot;" /> <option name="_new_parameters" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" /> <option name="_new_additionalArguments" value="&quot;&quot;" />

View file

@ -5,7 +5,6 @@ import platform
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
import requests import requests
from overrides import overrides
from pydantic.dataclasses import dataclass from pydantic.dataclasses import dataclass
from pydantic.json import pydantic_encoder from pydantic.json import pydantic_encoder
@ -222,6 +221,5 @@ class AiServiceClient:
class LocalAiServiceClient(AiServiceClient): class LocalAiServiceClient(AiServiceClient):
@overrides
def get_aiservice_base_url(self) -> str: def get_aiservice_base_url(self) -> str:
return "http://localhost:8000/" return "http://localhost:8000/"

View file

@ -2,16 +2,6 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [
{
"data": {
"text/plain": "True"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"import optimizer.optimizer_mistral as opt\n", "import optimizer.optimizer_mistral as opt\n",
"from dotenv import load_dotenv\n", "from dotenv import load_dotenv\n",
@ -26,7 +16,8 @@
} }
}, },
"id": "1aca8c639f7c0f59", "id": "1aca8c639f7c0f59",
"execution_count": 9 "execution_count": 9,
"outputs": []
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
@ -38,39 +29,6 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI code\n",
"The given Python function `mutinator` appends a zero to the input list and returns the new length of the list. This function is already quite efficient because both `list.append` and `len` operations are O(1) in Python. However, the function could be slightly 'optimized' by directly using the increment operation on the length, but it's important to note that such 'optimization' wouldn't typically result in a noticeable performance improvement. \n",
"\n",
"Here's the function with a minor change to eliminate the use of `append`:\n",
"\n",
"```python\n",
"def mutinator(mylist):\n",
" return len(mylist) + 1\n",
"```\n",
"\n",
"This version assumes that mutating the input list is not essential since the only observable effect from outside the function is the returned length. The original list remains unchanged - if the mutation is required, the original version should be retained.\n",
"\n",
"It is important to note that such optimizations are often marginal and can potentially introduce bugs if the function's behavior is expected to mutate the list. Always profile before and after such changes to ensure there is a real performance benefit.\n",
"\n",
"Mistral code\n",
"Sure, I can help with that. The function you've provided appends a 0 to the end of a list and then returns the length of the list. This operation is already quite fast in Python, but if we're dealing with a very large list, appending an element to the end of it might take some time due to the way Python lists are implemented.\n",
"\n",
"However, since we know that appending an element to a list increases its length by 1, we can avoid the append operation altogether and just return the length of the list plus 1. Here's the optimized function:\n",
"\n",
"```python\n",
"def mutinator_optimized(mylist):\n",
" return len(mylist) + 1\n",
"```\n",
"\n",
"This function will return the same value as the original function, but it won't modify the input list. If it's important for the list to be modified, then the original function is already as efficient as it can be.\n"
]
}
],
"source": [ "source": [
"code0 = \"\"\"def sorter(arr):\n", "code0 = \"\"\"def sorter(arr):\n",
" for i in range(len(arr)):\n", " for i in range(len(arr)):\n",
@ -137,11 +95,11 @@
} }
}, },
"id": "e6f0f53319d68837", "id": "e6f0f53319d68837",
"execution_count": 10 "execution_count": 10,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -151,7 +109,8 @@
} }
}, },
"id": "d65fcf3dbed8c36f", "id": "d65fcf3dbed8c36f",
"execution_count": 10 "execution_count": 10,
"outputs": []
} }
], ],
"metadata": { "metadata": {

View file

@ -2,31 +2,6 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"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"
]
}
],
"source": [ "source": [
"from testgen.instrumentation.instrument_test_source import instrument_test_source\n", "from testgen.instrumentation.instrument_test_source import instrument_test_source\n",
"from aiservice.models.functions_to_optimize import FunctionToOptimize\n", "from aiservice.models.functions_to_optimize import FunctionToOptimize\n",
@ -56,11 +31,11 @@
} }
}, },
"id": "8d108492763a25a5", "id": "8d108492763a25a5",
"execution_count": 5 "execution_count": 5,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -70,7 +45,8 @@
} }
}, },
"id": "694116ed54c4af6a", "id": "694116ed54c4af6a",
"execution_count": 4 "execution_count": 4,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -83,12 +59,11 @@
"start_time": "2024-02-29T07:11:56.812619Z" "start_time": "2024-02-29T07:11:56.812619Z"
} }
}, },
"outputs": [], "source": [],
"source": [] "outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -98,11 +73,11 @@
} }
}, },
"id": "80fefa4a71d32347", "id": "80fefa4a71d32347",
"execution_count": 4 "execution_count": 4,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -112,11 +87,11 @@
} }
}, },
"id": "3cb5881311ca16e2", "id": "3cb5881311ca16e2",
"execution_count": 4 "execution_count": 4,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -126,11 +101,11 @@
} }
}, },
"id": "639c96f42318a856", "id": "639c96f42318a856",
"execution_count": 4 "execution_count": 4,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"outputs": [],
"source": [], "source": [],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
@ -140,7 +115,8 @@
} }
}, },
"id": "12baa8a023eafc26", "id": "12baa8a023eafc26",
"execution_count": 4 "execution_count": 4,
"outputs": []
} }
], ],
"metadata": { "metadata": {