Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring master into Timescale branch. #87

Merged
merged 44 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
87eb2a5
Changes for SCMN deployment.
Oct 26, 2023
91b2a0f
Added Wombat config script info to webapp.
dajtxx Nov 7, 2023
13fbbdf
Wombat page changes - fixed log upload script, added data upload comm…
dajtxx Nov 17, 2023
0b103e0
Fixed update mapping functions.
Dec 21, 2023
68625e8
Merge pull request #57 from DPIclimate/fix_mappings
mal-22 Dec 21, 2023
fed8e65
..New tap when open Map
mal-22 Jan 24, 2024
4798da8
Merge pull request #58 from DPIclimate/fix_mappings
dajtxx Jan 24, 2024
76855e4
Merge pull request #61 from DPIclimate/master
dajtxx Apr 7, 2024
d5d3d97
Added axistech poller, changed logging in docker compose.
dajtxx Apr 10, 2024
33ddb4f
Merge pull request #64 from DPIclimate/issue_62
dajtxx Apr 10, 2024
3f5845a
Adding the axistech module.
dajtxx Apr 11, 2024
6f93415
Merge pull request #65 from DPIclimate/issue_62
dajtxx Apr 11, 2024
c569228
Changed axistech message format.
dajtxx Apr 12, 2024
536cdda
Merge pull request #66 from DPIclimate/issue_62
dajtxx Apr 12, 2024
03cadcc
Changed handleSubmit to check if event parameter was supplied.
dajtxx May 6, 2024
85d8907
Merge pull request #69 from DPIclimate/issue_67
dajtxx May 6, 2024
550b0a3
Logical mapper drops messages whose timestamp is too far into the fut…
dajtxx May 27, 2024
9b4882f
Fixed pytest unit tests for the /message REST API endpoint.
dajtxx May 27, 2024
665e477
Merge pull request #73 from DPIclimate/issue_70
dajtxx May 27, 2024
18437ab
Merge branch 'scmn' into issue_70_scmn
dajtxx May 27, 2024
bb46277
Merge pull request #74 from DPIclimate/issue_70_scmn
dajtxx May 28, 2024
4443455
AxisTech API only accepts a specific timezone suffix, so changed to u…
May 28, 2024
ba15464
Merge branch 'scmn' of https://github.com/DPIclimate/broker into scmn
May 28, 2024
1425d54
Added the ability to include logical device properties in the ld ls c…
dajtxx May 28, 2024
b9cd3b9
Merge pull request #76 from DPIclimate/issue_75
dajtxx May 28, 2024
3351865
Merge pull request #77 from DPIclimate/master
dajtxx May 28, 2024
fce4894
Merge branch 'scmn' of https://github.com/DPIclimate/broker into scmn
May 28, 2024
534bc61
DB init script now creates version table so DB v1 backups restore cle…
dajtxx Jun 4, 2024
9450549
Added the ability to include logical device properties in the ld ls c…
dajtxx May 28, 2024
fae8cf2
Restoring lost changes to files.
Jun 6, 2024
abe96da
Restoring lost upgrade script.
Jun 6, 2024
8ad0480
Fixing merge conflict.
Jun 6, 2024
b935582
Webapp changes to handle the geometry location columns.
dajtxx Jun 6, 2024
0f7e9e1
Removed unused variable.
dajtxx Jun 6, 2024
ab2b821
Merge pull request #79 from DPIclimate/postgis_and_db_v2
dajtxx Jun 7, 2024
c58a997
Fixed webapp map code to handle location lat or long being None, chan…
dajtxx Jun 7, 2024
51d47ef
Merge branch 'scmn' into master
dajtxx Jun 12, 2024
8fe253b
Issue 82 (#83)
dajtxx Jun 21, 2024
cd1561a
More PostGIS and axistech fixes from SCMN (#86)
dajtxx Jul 3, 2024
41d3984
Added Extract.py to read timeseries data from IoTa database.
dajtxx Jul 15, 2024
b8d8e7f
Merge branch 'master' of https://github.com/DPIclimate/broker
dajtxx Jul 15, 2024
a1bc414
Merge branch 'csu_2023_team_3' into tsdb_master_merge
dajtxx Jul 16, 2024
31a688e
Fix typo in axistech dependency
dajtxx Jul 16, 2024
6d03864
Fix the typo again.
dajtxx Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ TZ=Australia/Sydney

# Used by the Intersect DataBolt delivery service.
DATABOLT_SHARED_DIR=/some/where/raw_data

AXISTECH_TOKEN=
104 changes: 83 additions & 21 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ version: '3.1'

services:
db:
image: postgres:14.2
restart: "no"
image: postgis/postgis:14-3.4
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
volumes:
Expand All @@ -18,7 +22,11 @@ services:
mq:
hostname: "mq"
image: rabbitmq:3.9-management
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
volumes:
Expand All @@ -30,36 +38,45 @@ services:

restapi:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
depends_on:
- "db"
volumes:
- ../src/python:/home/broker/python
working_dir: "/home/broker/python/restapi"
entrypoint: [ "/home/broker/.local/bin/uvicorn", "--host", "0.0.0.0", "--port", "5687", "RestAPI:app", "--reload" ]
healthcheck:
test: curl --fail -I http://localhost:5687/openapi.json || exit 1
interval: 1m
start_period: 20s
entrypoint: [ "/home/broker/.local/bin/uvicorn", "--proxy-headers", "--host", "0.0.0.0", "--port", "5687", "RestAPI:app" ]

website:
image: broker/mgmt-app
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
environment:
- PYTHONPATH=/app:/iota
depends_on:
restapi:
db:
condition: "service_healthy"
volumes:
- ../src/www:/app
- ../src/python:/iota

ttn_webhook:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
Expand All @@ -74,7 +91,11 @@ services:

ttn_processor:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
Expand All @@ -93,7 +114,11 @@ services:

ttn_decoder:
image: broker/ttn_decoder
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
Expand All @@ -106,7 +131,11 @@ services:

ydoc:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
Expand All @@ -123,11 +152,14 @@ services:

wombat:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
- wombat
profiles: ["wombat", "frred"]
depends_on:
db:
condition: "service_healthy"
Expand All @@ -140,7 +172,11 @@ services:

lm:
image: broker/python-base
restart: "no"
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
depends_on:
Expand All @@ -155,6 +191,10 @@ services:

delivery:
image: broker/python-base
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
Expand All @@ -172,6 +212,10 @@ services:

pollers:
image: broker/python-base
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
Expand All @@ -189,6 +233,10 @@ services:

frred:
image: broker/python-base
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
Expand All @@ -201,10 +249,26 @@ services:
condition: "service_healthy"
volumes:
- ../src/python:/home/broker/python
- ${DATABOLT_SHARED_DIR}/raw_data:/raw_data
- ${DATABOLT_SHARED_DIR}/nectar_raw_data:/raw_data
working_dir: "/home/broker/python"
entrypoint: [ "python", "-m", "delivery.FRRED" ]


axistech:
image: broker/python-base
logging:
driver: local
options:
max-file: "3"
restart: unless-stopped
env_file:
- .env
profiles:
- frred
depends_on:
- db
entrypoint: [ "python", "-m", "pollers.axistech" ]

timescaledb:
build: ../timescale # Point to the directory containing the custom Dockerfile
hostname: "tsdb"
Expand Down Expand Up @@ -239,5 +303,3 @@ services:
- ../src/python:/home/broker/python
working_dir: "/home/broker/python"
entrypoint: [ "python", "-m", "timescale.TS_LTSReader" ]


2 changes: 1 addition & 1 deletion compose/production/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
# nginx will accept a connection on 1883, forward it to
# 127.0.0.1:1884, which docker will forward to port 1883
# within the container.
- "127.0.0.1:1884:1883"
- "0.0.0.0:1883:1883"
- "127.0.0.1:15672:15672"
- "127.0.0.1:15692:15692"
volumes:
Expand Down
23 changes: 15 additions & 8 deletions db/init.d/init_db.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CREATE EXTENSION postgis;
CREATE EXTENSION pgcrypto;

create table if not exists sources (
source_name text primary key not null
);
Expand All @@ -6,7 +9,7 @@ create table if not exists physical_devices (
uid integer generated always as identity primary key,
source_name text not null references sources,
name text not null,
location point,
location geometry('POINT', 4283),
last_seen timestamptz,
-- Store only top level key value pairs here; it is used
-- for quickly finding a device using information carried
Expand Down Expand Up @@ -72,7 +75,7 @@ create table if not exists device_blobs (
create table if not exists logical_devices (
uid integer generated always as identity primary key,
name text not null,
location point,
location geometry('POINT', 4283),
last_seen timestamptz,
properties jsonb not null default '{}'
);
Expand All @@ -90,7 +93,7 @@ create table if not exists physical_logical_map (
primary key(physical_uid, logical_uid, start_time)
);

create table if not exists users(
create table if not exists users (
uid integer generated always as identity primary key,
username text not null unique,
salt text not null,
Expand All @@ -100,6 +103,15 @@ create table if not exists users(
read_only boolean default True not null
);

create table if not exists version (
version integer not null
);

create index if not exists pd_src_id_idx on physical_devices using GIN (source_ids);

insert into sources values ('ttn'), ('greenbrain'), ('wombat'), ('ydoc'), ('ict_eagleio');
insert into version values (2);

create table if not exists data_name_map(
input_name text not null primary key,
std_name text not null
Expand Down Expand Up @@ -448,8 +460,3 @@ insert into word_list values
('UP'),
('VAPOUR'),
('WIND');

-- Enable the PostGIS extensions
-- CREATE EXTENSION postgis;
-- CREATE EXTENSION postgis_raster;
-- CREATE EXTENSION postgis_sfcgal;
17 changes: 17 additions & 0 deletions db/upgrade/002.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE EXTENSION postgis;
CREATE EXTENSION pgcrypto;

SELECT AddGeometryColumn('logical_devices','geom',4283,'POINT',2);
SELECT AddGeometryColumn('physical_devices','geom',4283,'POINT',2);

UPDATE logical_devices SET geom = ST_MakePoint(location[1], location[0]) WHERE location IS NOT NULL;
UPDATE physical_devices SET geom = ST_MakePoint(location[1], location[0]) WHERE location IS NOT NULL;

ALTER TABLE logical_devices DROP COLUMN location;
ALTER TABLE physical_devices DROP COLUMN location;

ALTER TABLE logical_devices RENAME COLUMN geom TO location;
ALTER TABLE physical_devices RENAME COLUMN geom TO location;

TRUNCATE version;
insert into version values (2);
2 changes: 1 addition & 1 deletion dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ if [ "$RUN_MODE" != test ]; then
fi
fi

exec docker compose --profile ttn --profile ydoc --profile wombat --profile ubidots --profile pollers --profile frred -p $RUN_MODE -f ../docker-compose.yml -f ./$RUN_MODE.yml $*
exec docker-compose --profile wombat --profile ubidots --profile frred -p $RUN_MODE -f ../docker-compose.yml -f ./$RUN_MODE.yml $*
9 changes: 9 additions & 0 deletions images/restapi/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,38 @@ charset-normalizer==2.1.0
click==8.1.3
dnspython==2.2.1
email-validator==1.2.1
exceptiongroup==1.1.1
fastapi==0.98.0
h11==0.13.0
httpcore==0.17.2
httptools==0.4.0
httpx==0.24.1
idna==3.3
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
numpy==1.26.4
orjson==3.7.7
packaging==23.1
pandas==2.2.1
pika==1.3.0
pluggy==1.2.0
psycopg2-binary==2.9.3
pydantic==1.9.1
pytest==7.4.0
python-dateutil==2.8.2
python-dotenv==0.20.0
python-multipart==0.0.5
pytz==2024.1
PyYAML==6.0
requests==2.28.1
six==1.16.0
sniffio==1.2.0
starlette==0.27.0
tomli==2.0.1
typing_extensions==4.3.0
tzdata==2024.1
ujson==5.4.0
urllib3==1.26.10
uvicorn==0.17.6
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

cd $BROKER_ROOT
cd compose/$MODE
./dc.sh stop
./dc.sh down
cd $BROKER_ROOT
docker build -t broker/python-base -f images/restapi/Dockerfile .
docker build -t broker/ttn_decoder -f images/ttn_decoder/Dockerfile .
Expand Down
1 change: 1 addition & 0 deletions src/python/BrokerConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
WOMBAT = 'wombat'
YDOC = 'ydoc'
ICT_EAGLEIO = 'ict_eagleio'
AXISTECH = 'axistech'

CREATION_CORRELATION_ID_KEY = 'creation_correlation_id'
SENSOR_GROUP_ID_KEY = 'sensor_group_id'
Expand Down
Loading
Loading