Skip to content

Commit 3b215f5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into exclude-date-filters-param
2 parents 4f24766 + 3713c34 commit 3b215f5

40 files changed

Lines changed: 364 additions & 309 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ server/preprocessing/other-scripts/renv
4141
.Rhistory
4242
.Rprofile
4343
.Rproj*
44+
/*.Rproj
4445
.Rproj.user
4546

47+
4648
# python files
4749
*.pyc
4850
*.pkl

docker-compose-end2endtest.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ services:
2424
- db
2525
- backend
2626
restart: "no"
27-
entrypoint: [ "pytest", '/app/workers/tests/test_end2end.py', '-s', '-rfA']
27+
entrypoint: ["pytest", '/app/workers/tests/test_end2end.py', '-s', '-rfA']
2828
networks:
29-
test:
30-
ipv4_address: 172.18.0.2
29+
- test
3130

3231
backend:
3332
container_name: backend
@@ -37,13 +36,47 @@ services:
3736
dockerfile: ./Dockerfile_backend
3837
volumes:
3938
- ./server/:/var/www/html/server
39+
- ./server/workers/tests/test_data/test.sqlite:/var/www/localstorage/test.sqlite
4040
restart: "no"
4141
networks:
42-
test:
43-
ipv4_address: 172.18.0.3
42+
- test
4443
ports:
4544
- "80:80"
4645

46+
api:
47+
build:
48+
context: server
49+
dockerfile: workers/api/Dockerfile
50+
restart: unless-stopped
51+
environment:
52+
SERVICE_VERSION: "test"
53+
BEHIND_PROXY: "false"
54+
DEFAULT_DATABASE: "testdb"
55+
FLASK_ENV: "development"
56+
volumes:
57+
- ./server/workers/tests/mock_app.py:/app/mock_app.py
58+
command: ["python", "mock_app.py"]
59+
networks:
60+
- test
61+
62+
persistence:
63+
container_name: api
64+
hostname: "test_api"
65+
build:
66+
context: server
67+
dockerfile: workers/persistence/Dockerfile
68+
restart: "no"
69+
environment:
70+
SERVICE_VERSION: "test"
71+
BEHIND_PROXY: "false"
72+
DEFAULT_DATABASE: "testdb"
73+
FLASK_ENV: "development"
74+
volumes:
75+
- ./server/workers/tests/mock_app.py:/app/mock_app.py
76+
command: ["python", "mock_app.py"]
77+
networks:
78+
- test
79+
4780
db:
4881
container_name: test_db
4982
image: 'postgres:12.2-alpine'
@@ -63,16 +96,10 @@ services:
6396
ports:
6497
- "5432:5432"
6598
networks:
66-
test:
67-
ipv4_address: 172.18.0.4
99+
- test
68100

69101
volumes:
70102
db_data:
71103

72104
networks:
73105
test:
74-
driver: bridge
75-
ipam:
76-
config:
77-
- subnet: 172.18.0.0/16
78-
gateway: 172.18.0.1

examples/project_website/data/custom_clustering.json

Lines changed: 10 additions & 0 deletions
Large diffs are not rendered by default.

local_dev/config_local_headstart.ini

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ preprocessing_dir = "/var/www/html/dev/server/preprocessing/"
77
# Full path to the images directory for the client. Needs to be in the public_html/www directory. Make sure that your webserver has write access to this directory.
88
images_path = "/var/www/html/dev/server/paper_preview/"
99
# Host of the client visualization
10-
host = "localhost/"
10+
host = "dev-searchflow-1/"
1111
# Relative path to the client visualization. Needs to be in the public_html/www directory.
1212
vis_path = "headstart"
1313
# Relative path to the client REST services. Needs to be in the public_html/www directory.
@@ -17,44 +17,25 @@ services_path = "server/services/"
1717
api_url = "http://proxy-proxy-1/"
1818
# flavor of API, default: stable
1919
api_flavor = "dev"
20-
# The value that is used to determine which db to use: SQLite - 0 or PostgreSQL - 1
21-
shift_read_percentage = 1
2220

2321
[snapshot]
2422
# Set to 1 to enable snapshot feature, 0 to disable
25-
snapshot_enabled = 0
23+
snapshot_enabled = 1
2624
# Absolute path to node binary
27-
node_path = "/path/to/node"
25+
node_path = "/usr/local/nvm/versions/node/v10.17.0/bin/node"
2826
# Absolute paths to node_modules folder, where puppeteer is installed
29-
nodemodules_path = "/path/to/node_modules"
27+
nodemodules_path = "/usr/local/nvm/versions/node/v10.17.0/lib/node_modules/"
3028
# Absolute path to getChartSVG.js
31-
getsvg_path = "/path/to/getChartSVG.js"
29+
getsvg_path = "/var/www/html/headstart/server/services/getChartSVG.js"
3230
# Absolute path to the directory, where the snapshots are stored. Webserver must have write access to this directory
33-
storage_path = "/path/to/storage/"
31+
storage_path = "/var/www/html/snapshots/"
3432
# PHP File responsible for rendering the bubble in a way to be snapshotted. Relative path to general host
35-
snapshot_php = "server/services/snapshot/headstart_snapshot.php"
33+
snapshot_php = "headstart/server/services/snapshot/headstart_snapshot.php"
3634
# snapshot_local_protocol fallback for non-server environments
3735
snapshot_local_protocol = "http://"
38-
39-
[output]
40-
# Relative paths for offline calculation
41-
output_dir = "other-scripts/"
42-
cooc = "cooc.csv";
43-
metadata = "metadata.csv"
44-
output_scaling_clustering = "output_scaling_clustering.csv"
45-
output_naming = "output_naming.csv"
46-
unique_id = "vis_id2"
47-
title = "Visualization"
36+
# Size of thumbnail width
37+
snapshot_width = "1200px"
4838

4939
[connection]
50-
# Full path to the sqlite datatabase file. Make sure that your webserver has write access to this file. For development purposes, duplicate headstart.sqlite in server/storage/ and rename it to a filename of your choice. Enter the path to this file here.
51-
sqlite_db = "/var/www/localstorage/local.sqlite"
5240
# PostgreSQL database
53-
database = "dev"
54-
55-
[calculation]
56-
# Path to the RScript binary
57-
binary = "/usr/bin/Rscript"
58-
# Relative path from preprocessing_dir to the R script
59-
script = "other-scripts/text_similarity.R"
60-
mode = "bookmarks"
41+
database = "dev"
-8.95 MB
Binary file not shown.

local_dev/searchflow-container/Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ MAINTAINER Chris Kittel "christopher.kittel@openknowledgemaps.org"
55
RUN a2enmod rewrite
66
RUN apt-get update && apt-get install -y curl libsqlite3-dev php7.4-sqlite libonig-dev libxml2-dev
77
RUN docker-php-ext-install pdo pdo_sqlite mbstring xml fileinfo
8+
# for puppeteer
9+
RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
10+
ENV NVM_DIR /usr/local/nvm
11+
ENV NODE_VERSION 10.17.0
12+
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.24.1/install.sh | bash \
13+
&& . $NVM_DIR/nvm.sh \
14+
&& nvm install $NODE_VERSION \
15+
&& nvm alias default $NODE_VERSION \
16+
&& nvm use default
817

9-
RUN sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/apache2.conf
10-
RUN mkdir /var/www/localstorage
11-
COPY test.sqlite /var/www/localstorage/local.sqlite
12-
RUN chown -R www-data:www-data /var/www/localstorage
18+
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
19+
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
20+
ENV NPM_PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin/npm
21+
RUN $NPM_PATH install -g puppeteer@^2.0.0 --unsafe-perm=true --allow-root
22+
23+
RUN sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /etc/apache2/apache2.conf

server/classes/headstart/library/APIClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public function load_configs($ini_array) {
1414
$this->ini_array = $ini_array;
1515
$this->settings = $this->ini_array["general"];
1616
$this->database = $this->ini_array["connection"]["database"];
17-
$this->WORKING_DIR = $this->ini_array["general"]["preprocessing_dir"] . $this->ini_array["output"]["output_dir"];
1817
$api_url = $this->ini_array["general"]["api_url"];
1918
$api_flavor = isset($this->ini_array["general"]["api_flavor"])
2019
? ($this->ini_array["general"]["api_flavor"])

server/classes/headstart/persistence/DispatchingPersistence.php

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,118 +2,55 @@
22

33
namespace headstart\persistence;
44

5-
65
/**
76
* This class implements the PersistenceInterface and provides methods to interact with the database.
87
*/
98
class DispatchingPersistence implements Persistence
109
{
11-
private Persistence $oldPersistence;
1210
private Persistence $newPersistence;
13-
private int|float $shiftReadPercentage;
14-
1511

16-
public function __construct(Persistence $oldPersistence, Persistence $newPersistence, $shiftReadPercentage)
12+
public function __construct(Persistence $newPersistence)
1713
{
18-
$this->shiftReadPercentage = $shiftReadPercentage;
19-
$this->oldPersistence = $oldPersistence;
2014
$this->newPersistence = $newPersistence;
2115
}
2216

2317
public function createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json): void
2418
{
25-
$this->oldPersistence->createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json);
2619
$this->newPersistence->createVisualization($vis_id, $vis_title, $input_json, $query, $dirty_query, $params_json);
2720
}
2821

2922
public function getRevision($vis_id, $rev_id): array|bool
3023
{
31-
$randomFloat = getRandomFloat();
32-
33-
if (($randomFloat * 100) > ($this->shiftReadPercentage * 100)) {
34-
$result = $this->oldPersistence->getRevision($vis_id, $rev_id);
35-
} else {
36-
$result = $this->newPersistence->getRevision($vis_id, $rev_id);
37-
}
38-
39-
return $result;
24+
return $this->newPersistence->getRevision($vis_id, $rev_id);
4025
}
4126

4227
public function writeRevision($vis_id, $data): void
4328
{
44-
$this->oldPersistence->writeRevision($vis_id, $data);
4529
$this->newPersistence->writeRevision($vis_id, $data);
4630
}
4731

4832
public function existsVisualization($vis_id): array|bool
4933
{
50-
$randomFloat = getRandomFloat();
51-
52-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
53-
$result = $this->oldPersistence->existsVisualization($vis_id);
54-
} else {
55-
$result = $this->newPersistence->existsVisualization($vis_id);
56-
}
57-
58-
return $result;
34+
return $this->newPersistence->existsVisualization($vis_id);
5935
}
6036

6137
public function getLastVersion($vis_id, $details, $context): array|bool
6238
{
63-
$randomFloat = getRandomFloat();
64-
65-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
66-
$result = $this->oldPersistence->getLastVersion($vis_id, $details, $context);
67-
} else {
68-
$result = $this->newPersistence->getLastVersion($vis_id, $details, $context);
69-
}
70-
71-
return $result;
39+
return $this->newPersistence->getLastVersion($vis_id, $details, $context);
7240
}
7341

7442
public function getLatestRevisions(): array|bool
7543
{
76-
$randomFloat = getRandomFloat();
77-
78-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
79-
$result = $this->oldPersistence->getLatestRevisions();
80-
} else {
81-
$result = $this->newPersistence->getLatestRevisions();
82-
}
83-
84-
return $result;
44+
return $this->newPersistence->getLatestRevisions();
8545
}
8646

8747
public function getContext($vis_id): array|bool
8848
{
89-
$randomFloat = getRandomFloat();
90-
91-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
92-
$result = $this->oldPersistence->getContext($vis_id);
93-
} else {
94-
$result = $this->newPersistence->getContext($vis_id);
95-
}
96-
97-
return $result;
49+
return $this->newPersistence->getContext($vis_id);
9850
}
9951

10052
public function createID($string_array, $payload): string
10153
{
102-
$randomFloat = getRandomFloat();
103-
104-
if ($randomFloat * 100 > $this->shiftReadPercentage * 100) {
105-
$result = $this->oldPersistence->createID($string_array, $payload);
106-
} else {
107-
$result = $this->newPersistence->createID($string_array, $payload);
108-
}
109-
110-
return $result;
54+
return $this->newPersistence->createID($string_array, $payload);
11155
}
11256
}
113-
114-
115-
// function for random float number generation from 0 to 1
116-
function getRandomFloat(): float
117-
{
118-
return mt_rand() / mt_getrandmax();
119-
}

server/classes/headstart/persistence/Persistence.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?php
22

33
namespace headstart\persistence;
4-
/**
5-
* Description of Logger
6-
*
7-
* @author pkraker
8-
*/
94

105
/**
116
* Interface Persistence

server/classes/headstart/persistence/PostgresPersistence.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace headstart\persistence;
44
use headstart\library\APIClient;
55

6+
require_once 'Persistence.php';
7+
68
/**
79
* This class implements the PersistenceInterface and provides methods to interact with the database.
810
*/
11+
912
class PostgresPersistence implements Persistence
1013
{
1114

@@ -99,4 +102,4 @@ public function createID($string_array, $payload): string
99102

100103
throw new \Exception("Could not create ID, response code was : " . $res["httpcode"]);
101104
}
102-
}
105+
}

0 commit comments

Comments
 (0)