Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cb2c3f5
feat: add data insert script, modified decoder, dbconn and dbqry
Viishveesh May 3, 2025
4d298d2
Updated the aggregate table logic in dbconn.py
Viishveesh May 5, 2025
9fa9318
Update dbquery and drcoder.py files
Viishveesh May 8, 2025
5e05b39
update: make dbqury and sqlfcn compatible with global tables and adde…
Viishveesh May 8, 2025
41ccacc
Fix Decoder and add test case to test insertion
Viishveesh May 10, 2025
455cde8
Add test cases to test decoder, sqlfcn, postgres insertion, dbqry
Viishveesh May 15, 2025
008023c
Remove unused code and old commented code
Viishveesh May 15, 2025
290cb9f
Fix the environment variable name in test case
Viishveesh May 21, 2025
9eed084
Fix the test cases
Viishveesh May 21, 2025
29d638e
ignore old test_001_postgres.py file in CI
Viishveesh May 22, 2025
2901fba
Fixing the errors to pass test case
Viishveesh May 22, 2025
3616129
Change the timescaledb-postgres version to 17 in windows job
Viishveesh May 23, 2025
4c8610a
Change the pgRoot in ci pipeline
Viishveesh May 23, 2025
e76f2b2
Add pgsql bin to path
Viishveesh May 23, 2025
b4e275e
Trying to fix the windows timescaledb isntallation
Viishveesh May 23, 2025
e618611
Change the order to run installer before changing the config
Viishveesh May 23, 2025
95f7cc8
Update CI.yml file for fixing timescaledb issye on windows
Viishveesh May 24, 2025
3b2913c
Merge branch 'vishvesh/dev' of github.com:AISViz/AISdb into vishvesh/dev
Viishveesh May 24, 2025
0a56efd
Update CI.yml revoke shared preload lib for Windows timescaledb
tsuzzy May 26, 2025
0b1c590
Update CI.yml change pgdatadir
tsuzzy May 27, 2025
f8a7f21
Update CI.yml
tsuzzy May 27, 2025
1d583b6
Update CI.yml
tsuzzy May 27, 2025
1549367
Update CI.yml remove Win psql conflicts
tsuzzy May 29, 2025
f012660
Update CI.yml
tsuzzy May 29, 2025
e2481a6
Update CI.yml fix postgres variable names
tsuzzy May 29, 2025
e07de70
Update CI.yml
tsuzzy May 29, 2025
03d16ee
Update CI.yml
tsuzzy May 29, 2025
42730a5
Update CI.yml: disable duplicate initialization
tsuzzy May 29, 2025
e40a92e
Update CI.yml
tsuzzy May 30, 2025
c4b0abd
Update CI.yml test windows
tsuzzy May 30, 2025
b329689
Update CI.yml rename environment variables
tsuzzy May 30, 2025
93d9044
Update CI.yml
tsuzzy May 30, 2025
a42eb20
Update CI.yml attribute passwd to PGPASSWD
tsuzzy May 30, 2025
30c10fd
Uncomment and clean up redundant code
tsuzzy May 30, 2025
9d3573a
Address variable passing issue due to windows case insensitive
tsuzzy Jun 2, 2025
91611df
fix: apply fix of the windows job failure
Viishveesh Jun 3, 2025
3c449ea
fix: apply fix for the windows job in pipeline
Viishveesh Jun 3, 2025
3346358
fix pipeline
Viishveesh Jun 3, 2025
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
72 changes: 30 additions & 42 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,57 +75,49 @@ jobs:

- name: Install TimescaleDB on Windows
run: |
# Download the official TimescaleDB installer for PostgreSQL 14.
Invoke-WebRequest -Uri "https://github.com/timescale/timescaledb/releases/latest/download/timescaledb-postgresql-14-windows-amd64.zip" -OutFile "timescaledb.zip"
# Create a dedicated folder for the installer.
# Download TimescaleDB for PostgreSQL 14 (not 17)
Invoke-WebRequest -Uri "https://github.com/timescale/timescaledb/releases/download/2.19.0/timescaledb-postgresql-14-windows-amd64.zip" -OutFile "timescaledb.zip"

# Create a folder for extraction
New-Item -ItemType Directory -Force -Path "C:\timescaledb"

# Extract the ZIP into C:\timescaledb.
Expand-Archive -Path "timescaledb.zip" -DestinationPath "C:\timescaledb"
# Find the setup.exe file in the extracted folder.

# Locate setup.exe
$setupPath = Get-ChildItem -Path "C:\timescaledb" -Recurse -Filter "setup.exe" | Select-Object -First 1 | ForEach-Object { $_.FullName }
Write-Host "Found setup executable at: $setupPath"

# Unblock the setup executable so it can run.
Write-Host "Unblocking setup.exe..."

# Unblock and set up environment
Unblock-File -Path $setupPath
Set-ExecutionPolicy Bypass -Scope Process -Force

# Setup working directory
$setupDir = Split-Path -Path $setupPath
Write-Host "Setting working directory to: $setupDir"
Set-Location -Path $setupDir

# PostgreSQL paths
# Run the installer first (before editing postgresql.conf)
Start-Process -FilePath $setupPath -ArgumentList "/S --yes" -WorkingDirectory $setupDir -Wait -NoNewWindow

# Modify postgresql.conf now that DLLs are installed
$pgDataDir = "D:\a\_temp\pgdata"
$env:PGPASSWORD="${{ env.pgpass }}"
$pgConfigPath = "D:/a/_temp/pgdata/postgresql.conf"

# Modify postgresql.conf to preload TimescaleDB before installation
Write-Host "Preload TimescaleDB..."
(Get-Content $pgConfigPath) -replace "^#?\s*shared_preload_libraries\s*=.*", "shared_preload_libraries = 'timescaledb'" | Set-Content $pgConfigPath

Write-Host "Restarting PostgreSQL to apply new settings..."
pg_ctl -D $pgDataDir restart
Start-Sleep -Seconds 5

# Run the installer
Write-Host "Running setup.exe..."
Start-Process -FilePath $setupPath -ArgumentList "/S --yes" -WorkingDirectory $setupDir -Wait -NoNewWindow

# Restart PostgreSQL again to apply TimescaleDB settings

# Restart PostgreSQL to load TimescaleDB
Write-Host "Restarting PostgreSQL after installation..."
pg_ctl -D $pgDataDir restart
Start-Sleep -Seconds 5

# Enable the TimescaleDB extension in PostgreSQL.
Write-Host "Configuring PostgreSQL authentication..."

# Enable extension
$env:PGPASSWORD="${{ env.pgpass }}"
Write-Host "Create TimescaleDB extension for database..."
psql -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS timescaledb;"
shell: pwsh
# Enable extension
- name: Verify TimescaleDB Extension
run: |
$env:PGPASSWORD="${{ env.pgpass }}"
psql -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS timescaledb;"

# Verify that the TimescaleDB extension is loaded
Write-Host "Verifying TimescaleDB extension is installed..."
psql -U postgres -d postgres -c "SELECT * FROM pg_extension WHERE extname = 'timescaledb';"

- name: Create Python Virtual Environment and Install Dependencies
run: |
Expand All @@ -140,7 +132,7 @@ jobs:
- name: Run Tests
run: |
AISdb\Scripts\activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -194,6 +186,7 @@ jobs:
database: postgres
postgres-version: "17"
ssl: false
port: 5432
id: postgres

- name: Test PostgreSQL Connection
Expand All @@ -213,11 +206,6 @@ jobs:
run: |
sudo apt-get install -y timescaledb-2-postgresql-17 postgresql-client-17
echo "TimescaleDB Extension installed"

# - name: Apply TimescaleDB tuning
# run: |
# sudo timescaledb-tune --pg-config="/home/runner/work/_temp/pgdata/postgresql.conf" --quiet --yes
# echo "TimescaleDB tuning applied"

- name: Enable TimescaleDB in PostgreSQL Config
run: |
Expand Down Expand Up @@ -248,7 +236,7 @@ jobs:
- name: Run Tests
run: |
source ./AISdb/bin/activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -361,7 +349,7 @@ jobs:
- name: Run Tests
run: |
source ./AISdb/bin/activate
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --maxfail=10
pytest ./aisdb/tests/ --ignore=./aisdb/tests/test_014_marinetraffic.py --ignore=./aisdb/tests/test_001_postgres.py --maxfail=10

- name: Clean Up
run: |
Expand Down Expand Up @@ -599,4 +587,4 @@ jobs:
# - name: Clean Up
# run: |
# rm -rf gh-pages
# rm -rf docs/dist_sphinx
# rm -rf docs/dist_sphinx
17 changes: 17 additions & 0 deletions aisdb/aisdb_sql/createtable_static_global_aggregate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS static_global_aggregate (
mmsi INTEGER PRIMARY KEY,
imo INTEGER,
vessel_name TEXT,
ship_type INTEGER,
call_sign TEXT,
dim_bow INTEGER,
dim_stern INTEGER,
dim_port INTEGER,
dim_star INTEGER,
draught INTEGER,
destination TEXT,
eta_month INTEGER,
eta_day INTEGER,
eta_hour INTEGER,
eta_minute INTEGER
);
6 changes: 6 additions & 0 deletions aisdb/aisdb_sql/cte_aliases_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dynamic_global AS (
{}
),
static_global AS (
{}
)
13 changes: 13 additions & 0 deletions aisdb/aisdb_sql/cte_dynamic_clusteredidx_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
d.mmsi,
d.time,
d.utc_second,
d.longitude,
d.latitude,
d.rot,
d.sog,
d.cog,
d.heading,
d.maneuver
FROM ais_global_dynamic AS d
WHERE
16 changes: 16 additions & 0 deletions aisdb/aisdb_sql/cte_static_aggregate_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SELECT
agg.mmsi,
TRIM(agg.vessel_name) as vessel_name,
agg.ship_type,
agg.imo,
agg.dim_bow,
agg.dim_stern,
agg.dim_port,
agg.dim_star,
agg.draught,
agg.destination,
agg.eta_month,
agg.eta_day,
agg.eta_hour,
agg.eta_minute
FROM static_global_aggregate AS agg
16 changes: 16 additions & 0 deletions aisdb/aisdb_sql/new_insert_dynamic_clusteredidx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
INSERT INTO ais_global_dynamic
(
mmsi,
time,
longitude,
latitude,
rot,
sog,
cog,
heading,
maneuver,
utc_second,
source
)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)
ON CONFLICT DO NOTHING;
23 changes: 23 additions & 0 deletions aisdb/aisdb_sql/new_insert_static.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
INSERT INTO ais_global_static (
mmsi,
time,
vessel_name,
ship_type,
call_sign,
imo,
dim_bow,
dim_stern,
dim_port,
dim_star,
draught,
destination,
ais_version,
fixing_device,
eta_month,
eta_day,
eta_hour,
eta_minute,
source
)
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19)
ON CONFLICT DO NOTHING;
28 changes: 28 additions & 0 deletions aisdb/aisdb_sql/select_join_dynamic_static_clusteredidx_global.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SELECT
dynamic.mmsi,
dynamic.time,
dynamic.utc_second,
dynamic.longitude,
dynamic.latitude,
dynamic.rot,
dynamic.sog,
dynamic.cog,
dynamic.heading,
dynamic.maneuver,
static.imo,
static.ship_type,
static.vessel_name,
static.dim_bow,
static.dim_stern,
static.dim_port,
static.dim_star,
static.draught,
static.destination,
static.eta_month,
static.eta_day,
static.eta_hour,
static.eta_minute,
ref.coarse_type_txt AS ship_type_txt
FROM ais_global_dynamic AS dynamic
LEFT JOIN ais_global_static AS static ON dynamic.mmsi = static.mmsi
LEFT JOIN ref ON static.ship_type = ref.coarse_type
6 changes: 3 additions & 3 deletions aisdb/aisdb_sql/timescale_createtable_dynamic.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS ais_{0}_dynamic
CREATE TABLE IF NOT EXISTS ais_global_dynamic
(
mmsi INTEGER NOT NULL,
time INTEGER NOT NULL,
Expand All @@ -15,14 +15,14 @@ CREATE TABLE IF NOT EXISTS ais_{0}_dynamic
);

SELECT create_hypertable(
'ais_{0}_dynamic',
'ais_global_dynamic',
'time',
partitioning_column => 'mmsi',
number_partitions => 4,
chunk_time_interval => 604800
);

ALTER TABLE ais_{0}_dynamic SET (
ALTER TABLE ais_global_dynamic SET (
timescaledb.compress = false,
timescaledb.compress_orderby = 'time ASC, latitude ASC, longitude ASC',
timescaledb.compress_segmentby = 'mmsi'
Expand Down
6 changes: 3 additions & 3 deletions aisdb/aisdb_sql/timescale_createtable_static.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE IF NOT EXISTS ais_{0}_static
CREATE TABLE IF NOT EXISTS ais_global_static
(
mmsi INTEGER NOT NULL,
time INTEGER NOT NULL,
Expand All @@ -23,14 +23,14 @@ CREATE TABLE IF NOT EXISTS ais_{0}_static
);

SELECT create_hypertable(
'ais_{0}_static',
'ais_global_static',
'time',
partitioning_column => 'mmsi',
number_partitions => 4,
chunk_time_interval => 604800
);

ALTER TABLE ais_{0}_static SET (
ALTER TABLE ais_global_static SET (
timescaledb.compress = false,
timescaledb.compress_orderby = 'time ASC',
timescaledb.compress_segmentby = 'mmsi'
Expand Down
3 changes: 3 additions & 0 deletions aisdb/database/create_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

with open(os.path.join(sqlpath, 'createtable_static_aggregate.sql'), 'r') as f:
sql_aggregate = f.read()

with open(os.path.join(sqlpath, 'createtable_static_global_aggregate.sql'), 'r') as f:
sql_global_aggregate = f.read()
Loading
Loading