Fix docker volume mounts (#3710)

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
Co-authored-by: Nicholas Tindle <nick@ntindle.com>
This commit is contained in:
Peter Petermann
2023-05-03 01:08:15 +02:00
committed by GitHub
parent b0c6ed999c
commit 479c7468b4
5 changed files with 23 additions and 13 deletions

View File

@@ -36,5 +36,7 @@ RUN sed -i '/Items below this point will not be included in the Docker Image/,$d
pip install --no-cache-dir -r requirements.txt
WORKDIR /app
ONBUILD COPY autogpt/ ./autogpt
ONBUILD COPY scripts/ ./scripts
FROM autogpt-${BUILD_TYPE} AS auto-gpt

View File

@@ -109,10 +109,12 @@ def get_current_git_branch() -> str:
def get_latest_bulletin() -> tuple[str, bool]:
exists = os.path.exists("CURRENT_BULLETIN.md")
exists = os.path.exists("data/CURRENT_BULLETIN.md")
current_bulletin = ""
if exists:
current_bulletin = open("CURRENT_BULLETIN.md", "r", encoding="utf-8").read()
current_bulletin = open(
"data/CURRENT_BULLETIN.md", "r", encoding="utf-8"
).read()
new_bulletin = get_bulletin_from_web()
is_new_news = new_bulletin != "" and new_bulletin != current_bulletin
@@ -125,7 +127,7 @@ def get_latest_bulletin() -> tuple[str, bool]:
)
if new_bulletin and is_new_news:
open("CURRENT_BULLETIN.md", "w", encoding="utf-8").write(new_bulletin)
open("data/CURRENT_BULLETIN.md", "w", encoding="utf-8").write(new_bulletin)
current_bulletin = f"{Fore.RED}::NEW BULLETIN::{Fore.RESET}\n\n{new_bulletin}"
return f"{news_header}\n{current_bulletin}", is_new_news

0
data/.keep Normal file
View File

View File

@@ -54,9 +54,15 @@ Get your OpenAI API key from: [https://platform.openai.com/account/api-keys](htt
environment:
MEMORY_BACKEND: ${MEMORY_BACKEND:-redis}
REDIS_HOST: ${REDIS_HOST:-redis}
volumes:
- ./:/app
profiles: ["exclude-from-up"]
volumes:
- ./auto_gpt_workspace:/app/auto_gpt_workspace
- ./data:/app/data
## allow auto-gpt to write logs to disk
- ./logs:/app/logs
## uncomment following lines if you have / want to make use of these files
#- ./azure.yaml:/app/azure.yaml
#- ./ai_settings.yaml:/app/ai_settings.yaml
redis:
image: "redis/redis-stack-server:latest"

View File

@@ -85,8 +85,8 @@ def test_get_bulletin_from_web_exception(mock_get):
def test_get_latest_bulletin_no_file():
if os.path.exists("CURRENT_BULLETIN.md"):
os.remove("CURRENT_BULLETIN.md")
if os.path.exists("data/CURRENT_BULLETIN.md"):
os.remove("data/CURRENT_BULLETIN.md")
bulletin, is_new = get_latest_bulletin()
assert is_new
@@ -94,7 +94,7 @@ def test_get_latest_bulletin_no_file():
def test_get_latest_bulletin_with_file():
expected_content = "Test bulletin"
with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
with open("data/CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
f.write(expected_content)
with patch("autogpt.utils.get_bulletin_from_web", return_value=""):
@@ -102,11 +102,11 @@ def test_get_latest_bulletin_with_file():
assert expected_content in bulletin
assert is_new == False
os.remove("CURRENT_BULLETIN.md")
os.remove("data/CURRENT_BULLETIN.md")
def test_get_latest_bulletin_with_new_bulletin():
with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
with open("data/CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
f.write("Old bulletin")
expected_content = "New bulletin from web"
@@ -116,12 +116,12 @@ def test_get_latest_bulletin_with_new_bulletin():
assert expected_content in bulletin
assert is_new
os.remove("CURRENT_BULLETIN.md")
os.remove("data/CURRENT_BULLETIN.md")
def test_get_latest_bulletin_new_bulletin_same_as_old_bulletin():
expected_content = "Current bulletin"
with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
with open("data/CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
f.write(expected_content)
with patch("autogpt.utils.get_bulletin_from_web", return_value=expected_content):
@@ -129,7 +129,7 @@ def test_get_latest_bulletin_new_bulletin_same_as_old_bulletin():
assert expected_content in bulletin
assert is_new == False
os.remove("CURRENT_BULLETIN.md")
os.remove("data/CURRENT_BULLETIN.md")
@skip_in_ci