refactor: adjust structure

This commit is contained in:
Florian Hönicke
2023-03-18 20:05:52 +01:00
parent d84cc8ee04
commit 47aa456e88
10 changed files with 221 additions and 131 deletions

47
src/prompt_tasks.py Normal file
View File

@@ -0,0 +1,47 @@
from src.constants import EXECUTOR_FILE_NAME, REQUIREMENTS_FILE_NAME, TEST_EXECUTOR_FILE_NAME, DOCKER_FILE_NAME, \
DOCKER_FILE_TAG
general_guidelines = (
"The code you write is production ready. "
"Every file starts with comments describing what the code is doing before the first import. "
"Comments can only be written between tags. "
"Start from top-level and then fully implement all methods."
)
def _task(task, tag_name, file_name=None):
return task + f"{f'The code will go into {file_name}. ' if tag_name else ''}. Wrap the code in the string $$$start_{tag_name}$$$...$$$end_{tag_name}$$$ "
def executor_name_task():
return _task("Write the executor name. "
"The executor name only consists of lower case and upper case letters.", 'executor_name'
)
def executor_file_task():
return _task("Write the executor code.", 'executor', EXECUTOR_FILE_NAME)
def requirements_file_task():
return _task("Write the content of the requirements.txt file. Make sure to include pytest.", 'requirements',
REQUIREMENTS_FILE_NAME)
def test_executor_file_task():
return _task(
"Write a small unit test for the executor. "
"Start the test with an extensive comment about the test case. "
"Never do relative imports.", 'test_executor', TEST_EXECUTOR_FILE_NAME)
def docker_file_task():
return _task(
"Write the Dockerfile that defines the environment with all necessary dependencies that the executor uses. "
"The Dockerfile runs the test during the build process. "
"It is important to make sure that all libs are installed that are required by the python packages."
"The base image of the Dockerfile is FROM jinaai/jina:3.14.2-dev18-py310-standard. "
'The entrypoint is ENTRYPOINT ["jina", "executor", "--uses", "config.yml"] '
"The Dockerfile runs the test during the build process. "
, DOCKER_FILE_TAG, DOCKER_FILE_NAME)