Skip to content

Commit

Permalink
Fix metadata
Browse files Browse the repository at this point in the history
- comment out database deployment
  • Loading branch information
rexruan committed Aug 26, 2024
1 parent 466ddd3 commit 3b8e075
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SWEGRAM_BACKEND
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.5
1.0.6
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
- database

backend:
image: rex0046/swegram-backend:1.0.5 # Image needs to be built with network
image: rex0046/swegram-backend:1.0.6 # Image needs to be built with network
container_name: swegram-backend-fastapi
restart: always
environment:
Expand Down
17 changes: 8 additions & 9 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
deploy_all=false
deploy_backend=false
deploy_frontend=false
deploy_database=false
# deploy_database=false

print_usage() {
echo "Usage: $0 [-a] [-b] [-d] [-f] [-h]" >&2;
echo "options:
-a Deploy all containers
-b Deploy backend container
-d Deploy database container
-f Build and Deploy frontend container
-h this help message"
exit 1;
}

while getopts ":abdfh" OPTION; do
while getopts ":abfh" OPTION; do
case "$OPTION" in
a) deploy_all=true;;
b) deploy_backend=true;;
d) deploy_database=true;;
# d) deploy_database=true;;
f) deploy_frontend=true;;
h) print_usage;;
\?) echo "$0: Error: Invalid option: -${OPTARG}" >&2; exit 1;;
Expand All @@ -31,7 +30,7 @@ shift "$(($OPTIND -1))"

echo "all: $deploy_all"
echo "backend: $deploy_backend"
echo "database: $deploy_database"
# echo "database: $deploy_database"
echo "frontend: $deploy_frontend"

if $deploy_all; then
Expand Down Expand Up @@ -76,9 +75,9 @@ else
docker compose --profile frontend up -d --build
fi

if $deploy_database; then
docker compose --profile database down || true
docker compose --profile database up -d
fi
# if $deploy_database; then
# docker compose --profile database down || true
# docker compose --profile database up -d
# fi
fi

12 changes: 12 additions & 0 deletions server/lib/fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ def _update_metadata(metadata: Dict[str, Any], texts: List[Text]) -> Dict[str, A
value = 1
text_ids = [t.id for t in texts]
texts_with_metadata = set()
if not metadata:
for text in texts:
if text.labels:
for label, _value in text.labels.items():
if label not in metadata:
metadata[label] = {_value: [(text.id, text.filename)]}
elif _value not in metadata[label]:
metadata[label][_value] = [(text.id, text.filename)]
else:
metadata[label][_value].append((text.id, text.filename))

if metadata:
for label, value_dict in metadata.items():
has_values = [False] * len(value_dict.keys())
Expand All @@ -44,6 +55,7 @@ def _update_metadata(metadata: Dict[str, Any], texts: List[Text]) -> Dict[str, A

def fetch_data(metadata: Any, texts: List[Text]) -> Dict[str, Any]:
"""Reset data for frontend"""

return {
"text_ids": _fetch_text_ids_and_filenames(texts),
"selected_text_ids": _fetch_selected_text_ids(texts),
Expand Down

0 comments on commit 3b8e075

Please sign in to comment.