Skip to content

Commit 5ade1f2

Browse files
committed
Merge branch 'dev-sql-tables' into dev-frontend
2 parents e30823b + 72f54fe commit 5ade1f2

31 files changed

+1651
-661
lines changed

cmd/mb3dbtool/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func main() {
8383
}
8484
count, err = db.Count()
8585

86-
println("Database update was succesful. ", count, " records in database.")
86+
println("Database update was successful. ", count, " records in database.")
8787
}
8888

8989
func readDirectoryData(dir string) ([]*massbank.MassBank2, *massbank.MbMetaData, error) {

cmd/mb3server/src/api_default_service.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ func (s *DefaultApiService) GetRecord(ctx context.Context, accession string) (Im
7474

7575
record, err := GetRecord(accession)
7676
return Response(200, record), err
77-
78-
return Response(http.StatusNotImplemented, nil), errors.New("GetRecord method not implemented")
7977
}
8078

8179
// GetRecords - Get a list of records

compose/docker-compose.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
services:
2+
3+
postgres:
4+
image: docker.io/postgres:latest
5+
restart: always
6+
ports:
7+
- '${DB_PORT}:${DB_PORT}'
8+
environment:
9+
POSTGRES_PASSWORD: ${DB_PASSWORD}
10+
POSTGRES_USER: ${DB_USER}
11+
POSTGRES_DB: ${DB_NAME}
12+
healthcheck:
13+
test: ["CMD-SHELL", "pg_isready", "-d", "$$POSTGRES_DB","-U", "$$POSTGRES_USER"]
14+
interval: 30s
15+
timeout: 60s
16+
retries: 5
17+
start_period: 40s
18+
19+
mb3server:
20+
build: ../
21+
restart: always
22+
ports:
23+
- "${MB3_API_PORT}:${MB3_SERVER_PORT}"
24+
depends_on:
25+
postgres:
26+
condition: service_healthy
27+
environment:
28+
- DB_TYPE
29+
- DB_PORT
30+
- DB_PASSWORD
31+
- DB_HOST
32+
- DB_NAME
33+
- DB_CONN_STRING
34+
- MB3_SERVER_PORT
35+
- CDKDEPICT_URL
36+
37+
similarity-service-cosine:
38+
build: ../similarity-service-cosine
39+
restart: always
40+
ports:
41+
- "${SIMILARITY_SERVICE_COSINE_PORT}:8080"
42+
depends_on:
43+
mb3tool:
44+
condition: service_completed_successfully
45+
environment:
46+
- DB_PORT
47+
- DB_USER
48+
- DB_PASSWORD
49+
- DB_HOST
50+
- DB_NAME
51+
52+
mb3frontend:
53+
build:
54+
context: ..
55+
dockerfile: Dockerfile-frontend
56+
args:
57+
MB3_API_URL: "http://${MB3_API_HOST}:${MB3_API_PORT}"
58+
MB3_FRONTEND_BASE_URL: "${MB3_FRONTEND_BASE_URL}"
59+
restart: always
60+
ports:
61+
- "${MB3_FRONTEND_PORT}:3000"
62+
63+
mb3tool:
64+
build:
65+
context: ..
66+
dockerfile: Dockerfile-dbtool
67+
depends_on:
68+
postgres:
69+
condition: service_healthy
70+
environment:
71+
- DB_TYPE
72+
- DB_PORT
73+
- DB_USER
74+
- DB_PASSWORD
75+
- DB_HOST
76+
- DB_NAME
77+
- DB_CONN_STRING
78+
- MB_GIT_REPO
79+
- MB_GIT_BRANCH
80+
- MB_DATA_DIRECTORY
81+
- MB_DROP_ALL

compose/env.dist

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
############################
2+
# Massbank 3 configuration #
3+
############################
4+
5+
# --------------------
6+
# Server configuration
7+
# --------------------
8+
9+
# The port where the API is exposed for frontend and application usage
10+
MB3_API_PORT=8081
11+
12+
# The host where the frontend is running
13+
MB3_API_HOST=localhost
14+
15+
# The port used internally by the server
16+
MB3_SERVER_PORT=8080
17+
18+
19+
# ----------------------
20+
# Frontend configuration
21+
# ----------------------
22+
23+
# The Port where the frontend ist exposed
24+
MB3_FRONTEND_PORT=8080
25+
26+
# The base URL
27+
MB3_FRONTEND_BASE_URL=/massbank3/
28+
29+
# ----------------------
30+
# Database configuration
31+
# ----------------------
32+
33+
# The database type: "mongodb" or "postgres"
34+
DB_TYPE=postgres
35+
36+
# The port of the database
37+
DB_PORT=5432
38+
39+
# The database user name
40+
DB_USER=massbank3
41+
42+
# The database password
43+
DB_PASSWORD=massbank3password
44+
45+
# The database host name
46+
DB_HOST=localhost
47+
48+
# The name of the database
49+
DB_NAME=massbank3
50+
51+
# A connection string to connect with the database. If set to non empty string other "DB_..." environment variables will be ignored
52+
DB_CONN_STRING=""
53+
54+
# ------------------------------
55+
# Similarity microservice cosine
56+
# ------------------------------
57+
58+
# The port where the similarity service is exposed
59+
SIMILARITY_SERVICE_COSINE_PORT=8082
60+
61+
# The host where the similarity service is running
62+
SIMILARITY_SERVICE_COSINE_HOST=localhost
63+
64+
# ---------------------------
65+
# Massbank-data configuration
66+
# ---------------------------
67+
68+
# The repo where to load massbank data from
69+
MB_GIT_REPO="https://github.com/MassBank/MassBank-data"
70+
71+
# The git branch of the massbank data repo
72+
MB_GIT_BRANCH=main
73+
74+
# A directory where the massbank data is stored. If set, this will tried first before getting data from git.
75+
MB_DATA_DIRECTORY=""
76+
77+
# Set to true to clear the database before filling with new data, otherwise data is upserted.
78+
MB_DROP_ALL=true
79+

docker/docker-compose-database-only.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

docker/env.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ MB3_FRONTEND_BASE_URL=/massbank3/
3131
# ----------------------
3232

3333
# The database type: "mongodb" or "postgres"
34-
DB_TYPE=mongodb
34+
DB_TYPE=postgres
3535

3636
# The port of the database
37-
DB_PORT=27017
37+
DB_PORT=5432
3838

3939
# The database user name
4040
DB_USER=massbank3
@@ -43,7 +43,7 @@ DB_USER=massbank3
4343
DB_PASSWORD=massbank3password
4444

4545
# The database host name
46-
DB_HOST=mongodb
46+
DB_HOST=postgres
4747

4848
# The name of the database
4949
DB_NAME=massbank3

pkg/config/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package config
33
import (
44
"errors"
55
"flag"
6-
"github.com/MassBank/MassBank3/pkg/database"
76
"log"
87
"os"
98
"strconv"
9+
10+
"github.com/MassBank/MassBank3/pkg/database"
1011
)
1112

1213
type ToolConfig struct {
@@ -63,6 +64,10 @@ func GetToolConfig() ToolConfig {
6364
flag.Parse()
6465
if len(toolConfig.GitRepo) > 0 && len(toolConfig.DataDir) > 0 {
6566
println("Git repo and data directory are set. Using data directory as default and git repo as fallback.")
67+
} else if(len(toolConfig.GitRepo) > 0) {
68+
println("Git repo is set. Using git repo as data source.")
69+
} else if(len(toolConfig.DataDir) > 0) {
70+
println("Data directory is set. Using data directory as data source.")
6671
}
6772
return *toolConfig
6873
}

pkg/database/db_interface.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package database
22

33
import (
4-
"github.com/Code-Hex/dd"
5-
"github.com/MassBank/MassBank3/pkg/massbank"
64
"log"
75
"math"
6+
7+
"github.com/Code-Hex/dd"
8+
"github.com/MassBank/MassBank3/pkg/massbank"
89
)
910

1011
// Filters is the abstract description of filters used to find MassBank records

pkg/database/mongodb.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ package database
33
import (
44
"context"
55
"errors"
6+
"log"
7+
"reflect"
8+
"strconv"
9+
"time"
10+
611
"github.com/MassBank/MassBank3/pkg/massbank"
712
"go.mongodb.org/mongo-driver/bson"
813
"go.mongodb.org/mongo-driver/bson/primitive"
914
"go.mongodb.org/mongo-driver/mongo"
1015
"go.mongodb.org/mongo-driver/mongo/options"
1116
bson2 "gopkg.in/mgo.v2/bson"
12-
"log"
13-
"reflect"
14-
"strconv"
15-
"time"
1617
)
1718

1819
// Mb3MongoDB represents a mongodb connection and should implement [MB3Database]

0 commit comments

Comments
 (0)