Skip to content

Commit a4ffabf

Browse files
authored
Merge pull request #867 from OpenKnowledgeMaps/base-contentproviders-cacheupdate
Base contentproviders cacheupdate
2 parents c307b6f + bbad5ed commit a4ffabf

3 files changed

Lines changed: 48828 additions & 1 deletion

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
rm(list = ls())
2+
3+
args <- commandArgs(TRUE)
4+
wd <- args[1]
5+
setwd(wd)
6+
7+
renv::activate()
8+
renv::restore(lockfile = '../renv.lock')
9+
Sys.setlocale(category = "LC_ALL", locale = "en_US.UTF-8")
10+
11+
library(jsonlite)
12+
library(rbace)
13+
library(logging)
14+
15+
source('utils.R')
16+
if (Sys.getenv("LOGLEVEL") == "DEBUG") {
17+
DEBUG <- FALSE
18+
} else {
19+
DEBUG <- TRUE
20+
}
21+
22+
if (DEBUG == TRUE) {
23+
setup_logging('DEBUG')
24+
} else {
25+
setup_logging('INFO')
26+
}
27+
28+
log <- getLogger('update_contentproviders')
29+
30+
output_path <- if (length(args) >= 2) args[2] else {
31+
file.path(wd, "../../workers/common/common/contentproviders.json")
32+
}
33+
output_path <- normalizePath(output_path, mustWork = FALSE)
34+
35+
tryCatch({
36+
contentproviders <- bs_repositories("")
37+
if (is.null(contentproviders) || nrow(contentproviders) == 0) {
38+
stop("No content providers retrieved.")
39+
}
40+
triple <- list(name = "GoTriple", internal_name = "fttriple")
41+
contentproviders <- rbind(contentproviders, triple)
42+
43+
write(toJSON(contentproviders, pretty = TRUE), file = output_path)
44+
log$info(paste("contentproviders.json updated:", output_path,
45+
"", nrow(contentproviders), "entries"))
46+
}, error = function(err) {
47+
log$error(paste("Content provider update failed", "base",
48+
"update_contentproviders", "", err, sep = "||"))
49+
quit(status = 1)
50+
})

server/workers/build_docker_images.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
# Defines the script directory
44
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
55

6+
CONTENTPROVIDERS_FILE="$SCRIPT_DIR/common/common/contentproviders.json"
7+
8+
# Update contentproviders.json cache from the running dev-base-1 container
9+
echo ""
10+
echo "Updating contentproviders.json cache..."
11+
echo ""
12+
docker exec dev-base-1 Rscript /headstart/other-scripts/update_contentproviders.R \
13+
/headstart/other-scripts \
14+
/common/contentproviders.json
15+
docker cp dev-base-1:/common/contentproviders.json "$CONTENTPROVIDERS_FILE"
16+
17+
# Commit if the file changed
18+
cd "$SCRIPT_DIR/../.." && git diff --quiet "$CONTENTPROVIDERS_FILE"
19+
if [ $? -ne 0 ]; then
20+
echo "contentproviders.json changed, committing..."
21+
git add "$CONTENTPROVIDERS_FILE"
22+
git commit -m "update of contentprovider.json cache"
23+
fi
24+
cd "$SCRIPT_DIR"
25+
626
# Define the list of services
727
services=("api" "persistence" "dataprocessing" "base" "pubmed" "openaire" "orcid" "metrics")
828

server/workers/common/common/contentproviders.json

Lines changed: 48758 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)