fix double logging in extension, dont get apps with name or status null and update package_repo.py script

This commit is contained in:
LeonOstrez
2023-10-01 14:43:28 +01:00
parent ddf613d0ab
commit d4b2c63e45
3 changed files with 42 additions and 19 deletions

View File

@@ -51,7 +51,7 @@ TABLES = [
]
def get_created_apps():
return [model_to_dict(app) for app in App.select()]
return [model_to_dict(app) for app in App.select().where((App.name.is_null(False)) & (App.status.is_null(False)))]
def get_created_apps_with_steps():

View File

@@ -187,7 +187,7 @@ class AgentConvo:
if self.log_to_user:
if self.agent.project.checkpoints['last_development_step'] is not None:
print(yellow("\nDev step ") + yellow_bold(str(self.agent.project.checkpoints['last_development_step'])) + '\n', end='')
print(f"\n{content}\n")
print(f"\n{content}\n", type='local')
logger.info(f"{print_msg}: {content}\n")
def to_playground(self):

View File

@@ -5,31 +5,54 @@ import zipfile
def main():
# Define the base directory (one level up from /scripts)
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Define paths based on base directory
env_path = os.path.join(base_dir, "pilot", ".env")
tmp_env_path = os.path.join("/tmp", ".env")
repo_path = os.path.abspath(base_dir)
# Check if .env exists
if os.path.exists(env_path):
# Step 1: Move .env to /tmp/x
shutil.move(env_path, tmp_env_path)
# Files to exclude from the repo temporarily while packaging
files_to_exclude = [
"pilot/.env",
"pilot/gpt-pilot"
]
# Step 2: Package the repository using Python's zipfile module
# Step 1: Move excluded files to /tmp
tmp_excluded_paths = []
for file in files_to_exclude:
source_path = os.path.join(repo_path, file)
if os.path.exists(source_path):
tmp_path = os.path.join("/tmp", os.path.basename(file))
shutil.move(source_path, tmp_path)
tmp_excluded_paths.append((tmp_path, source_path))
# Items to package
items_to_package = [
"pilot",
"scripts",
"Dockerfile",
"docker-compose.yml",
"LICENSE",
"README.md",
"requirements.txt"
]
# Step 2: Package the specified items using Python's zipfile module
parent_directory = os.path.dirname(base_dir)
archive_path = os.path.join(parent_directory, "gpt-pilot-packaged.zip")
with zipfile.ZipFile(archive_path, 'w', zipfile.ZIP_DEFLATED) as archive:
for root, _, files in os.walk(repo_path):
for file in files:
file_path = os.path.join(root, file)
archive_path = os.path.relpath(file_path, repo_path)
archive.write(file_path, archive_path)
for item in items_to_package:
item_path = os.path.join(repo_path, item)
if os.path.isfile(item_path):
archive.write(item_path, item)
elif os.path.isdir(item_path):
for root, _, files in os.walk(item_path):
for file in files:
file_path = os.path.join(root, file)
archive_path = os.path.relpath(file_path, repo_path)
archive.write(file_path, archive_path)
# Step 3: Move the .env file back, if it existed initially
if os.path.exists(tmp_env_path):
shutil.move(tmp_env_path, env_path)
# Step 3: Move the excluded files back
for tmp_path, orig_path in tmp_excluded_paths:
if os.path.exists(tmp_path):
shutil.move(tmp_path, orig_path)
if __name__ == "__main__":
main()