feat: dont delete code

This commit is contained in:
Florian Hönicke
2023-04-13 22:42:05 +02:00
parent 51687424ba
commit f87c28dad0
2 changed files with 9 additions and 14 deletions

View File

@@ -7,7 +7,7 @@ from src.constants import FILE_AND_TAG_PAIRS
from src.jina_cloud import push_executor, process_error_message
from src.prompt_tasks import general_guidelines, executor_file_task, chain_of_thought_creation, test_executor_file_task, \
chain_of_thought_optimization, requirements_file_task, docker_file_task, not_allowed
from src.utils.io import create_folder_if_not_exist, persist_file
from src.utils.io import persist_file
from src.utils.string_tools import print_colored
@@ -70,7 +70,7 @@ class ExecutorFactory:
is_chain_of_thought=False,
):
EXECUTOR_FOLDER_v1 = self.get_executor_path(output_path, executor_name, package, num_approach, 1)
create_folder_if_not_exist(EXECUTOR_FOLDER_v1)
os.makedirs(EXECUTOR_FOLDER_v1)
print_colored('', '############# Executor #############', 'red')
user_query = (
@@ -170,20 +170,20 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul
def get_executor_path(self, output_path, executor_name, package, num_approach, version):
package_path = '_'.join(package)
return os.path.join(output_path, executor_name, f'{num_approach}_package_path', f'v{version}')
return os.path.join(output_path, executor_name, f'{num_approach}_{package_path}', f'v{version}')
def debug_executor(self, output_path, executor_name, package, description, test):
def debug_executor(self, output_path, executor_name, num_approach, packages, description, test):
MAX_DEBUGGING_ITERATIONS = 10
error_before = ''
for i in range(1, MAX_DEBUGGING_ITERATIONS):
print('Debugging iteration', i)
print('Trying to build the microservice. Might take a while...')
previous_executor_path = self.get_executor_path(output_path, executor_name, package, num_approach, i)
next_executor_path = self.get_executor_path(output_path, executor_name, package, num_approach, i + 1)
previous_executor_path = self.get_executor_path(output_path, executor_name, packages, num_approach, i)
next_executor_path = self.get_executor_path(output_path, executor_name, packages, num_approach, i + 1)
log_hubble = push_executor(previous_executor_path)
error = process_error_message(log_hubble)
if error:
create_folder_if_not_exist(next_executor_path)
os.makedirs(next_executor_path)
file_name_to_content = self.get_all_executor_files_with_content(previous_executor_path)
all_files_string = self.files_to_string(file_name_to_content)
user_query = (
@@ -224,7 +224,7 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul
break
if i == MAX_DEBUGGING_ITERATIONS - 1:
raise self.MaxDebugTimeReachedException('Could not debug the executor.')
return self.get_executor_path(output_path, executor_name, package, num_approach, i)
return self.get_executor_path(output_path, executor_name, packages, num_approach, i)
class MaxDebugTimeReachedException(BaseException):
pass
@@ -289,7 +289,7 @@ package2,package3,...
for num_approach, packages in enumerate(packages_list):
try:
self.create_executor(description, test, output_path, executor_name, packages, num_approach)
executor_path = self.debug_executor(output_path, executor_name, packages, description, test)
executor_path = self.debug_executor(output_path, executor_name, num_approach, packages, description, test)
host = jina_cloud.deploy_flow(executor_name, executor_path)
self.create_playground(executor_name, executor_path, host)
except self.MaxDebugTimeReachedException:

View File

@@ -6,11 +6,6 @@ from typing import Generator
import sys
from contextlib import contextmanager
def create_folder_if_not_exist(folder_path):
try:
os.makedirs(folder_path)
except FileExistsError:
pass
def persist_file(file_content, file_path):
with open(file_path, 'w') as f: