From 51f2e4b096174bf01a81ce0568463298a0a21c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6nicke?= Date: Wed, 3 May 2023 09:53:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix:=20file=20name=20(#?= =?UTF-8?q?76)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🛠️ fix: file name * 🛠️ fix: file name * 🛠️ fix: file name * 🛠️ fix: common libs --- src/constants.py | 2 +- src/options/generate/generator.py | 6 +++--- src/options/generate/static_files/microservice/Dockerfile | 2 +- .../microservice/{microservice.py => jina_wrapper.py} | 2 +- src/options/generate/templates_user.py | 5 +++-- 5 files changed, 9 insertions(+), 8 deletions(-) rename src/options/generate/static_files/microservice/{microservice.py => jina_wrapper.py} (92%) diff --git a/src/constants.py b/src/constants.py index 3119882..08833b4 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,5 +1,5 @@ EXECUTOR_FILE_NAME = '__init__.py' -IMPLEMENTATION_FILE_NAME = 'implementation.py' +IMPLEMENTATION_FILE_NAME = 'microservice.py' TEST_EXECUTOR_FILE_NAME = 'test_microservice.py' REQUIREMENTS_FILE_NAME = 'requirements.txt' DOCKER_FILE_NAME = 'Dockerfile' diff --git a/src/options/generate/generator.py b/src/options/generate/generator.py index f59a1a6..7467d5e 100644 --- a/src/options/generate/generator.py +++ b/src/options/generate/generator.py @@ -145,13 +145,13 @@ metas: num_approach, 1) os.makedirs(MICROSERVICE_FOLDER_v1) - with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'microservice.py'), 'r') as f: + with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'jina_wrapper.py'), 'r', encoding='utf-8') as f: microservice_executor_boilerplate = f.read() microservice_executor_code = microservice_executor_boilerplate.replace('class GPTDeployExecutor(Executor):', f'class {microservice_name}(Executor):') persist_file(microservice_executor_code, os.path.join(MICROSERVICE_FOLDER_v1, EXECUTOR_FILE_NAME)) - with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'apis.py'), 'r') as f: + with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'apis.py'), 'r', encoding='utf-8') as f: persist_file(f.read(), os.path.join(MICROSERVICE_FOLDER_v1, 'apis.py')) microservice_content = self.generate_and_persist_file( @@ -221,7 +221,7 @@ metas: @staticmethod def read_docker_template(): - with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'Dockerfile'), 'r') as f: + with open(os.path.join(os.path.dirname(__file__), 'static_files', 'microservice', 'Dockerfile'), 'r', encoding='utf-8') as f: return f.read() def parse_result_fn_dockerfile(self, content_raw: str): diff --git a/src/options/generate/static_files/microservice/Dockerfile b/src/options/generate/static_files/microservice/Dockerfile index 15e5434..29805eb 100644 --- a/src/options/generate/static_files/microservice/Dockerfile +++ b/src/options/generate/static_files/microservice/Dockerfile @@ -2,7 +2,7 @@ FROM jinaai/jina:3.14.1-py39-standard # update pip RUN pip install --upgrade pip -RUN apt-get update && apt-get install --no-install-recommends -y {{apt_get_packages}} && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install --no-install-recommends -y ffmpeg build-essential pkg-config {{apt_get_packages}} && apt-get clean && rm -rf /var/lib/apt/lists/* ## install requirements for the executor COPY requirements.txt . diff --git a/src/options/generate/static_files/microservice/microservice.py b/src/options/generate/static_files/microservice/jina_wrapper.py similarity index 92% rename from src/options/generate/static_files/microservice/microservice.py rename to src/options/generate/static_files/microservice/jina_wrapper.py index d80ae22..2c3391a 100644 --- a/src/options/generate/static_files/microservice/microservice.py +++ b/src/options/generate/static_files/microservice/jina_wrapper.py @@ -1,7 +1,7 @@ from jina import Executor, requests as jina_requests, DocumentArray import json -from .implementation import func +from .microservice import func class GPTDeployExecutor(Executor): diff --git a/src/options/generate/templates_user.py b/src/options/generate/templates_user.py index 340a76e..13b6114 100644 --- a/src/options/generate/templates_user.py +++ b/src/options/generate/templates_user.py @@ -87,7 +87,8 @@ If you listed gpt_3_5_turbo earlier, you must use it. gpt_3_5_turbo is the best ''' + template_generate_possible_packages_output_format_string) -template_code_wrapping_string = '''The code will go into {file_name_purpose}. Make sure to wrap the code into ``` marks even if you only output code: +template_code_wrapping_string = '''The code will go into {file_name_purpose}. +Note that you must obey the double asterisk and tripple backtick syntax from like this: **{file_name}** ```{tag_name} ...code... @@ -145,7 +146,7 @@ Start the test with an extensive comment about the test case. If gpt_3_5_turbo i The test must start with the following import: ``` -from .implementation import func +from .microservice import func ``` ''' + not_allowed_function_string + ''' The test must not open local files.