Skip to content

Commit

Permalink
Updating Versions table
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-rodriguez committed Apr 19, 2024
1 parent 9581636 commit 290de6e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
8 changes: 7 additions & 1 deletion data/Versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@
"description": "UCDs in PhotometryFilters table"
},
{
"version": "latest",
"version": "2024.4",
"start_date": "2024-04-17",
"end_date": "2024-04-19",
"description": "Renaming Spectra.spectrum to Spectra.access_url"
},
{
"version": "latest",
"start_date": "2024-04-19",
"end_date": null,
"description": "Version in development"
}
Expand Down
1 change: 1 addition & 0 deletions scripts/updates/update_spectra_colnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sqlalchemy as sa
from astrodb_utils import load_astrodb

from simple.schema import REFERENCE_TABLES

# Establish connection to database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
# Script to show how to update the version number

import logging
from scripts.ingests.utils import logger, load_simpledb
from astrodb_utils import load_astrodb

SAVE_DB = True # save the data files in addition to modifying the .db file
RECREATE_DB = True # recreates the .db file from the data files
from simple.schema import REFERENCE_TABLES, Versions

logger.setLevel(logging.INFO)
SAVE_DB = True # save the data files in addition to modifying the .db file

db = load_simpledb('SIMPLE.db', recreatedb=RECREATE_DB)
db = load_astrodb("SIMPLE.sqlite", recreatedb=True, reference_tables=REFERENCE_TABLES)

# Check all versions
print(db.query(db.Versions).table())

# Add new version, add new entries as appropriate
# Note that start_date and end_date are strings of the date in format YYYY-MM-DD
data = [{'version': '2023.2',
'start_date': '2023-07-11',
'end_date': '2023-07-25',
'description': 'Added JWST spectra for VHS 1256b'}]
with db.engine.connect() as conn:
conn.execute(db.Versions.insert().values(data))
conn.commit()

obj = Versions(version="2024.4",
start_date="2024-04-17",
end_date="2024-04-19",
description="Renaming Spectra.spectrum to Spectra.access_url")
with db.session as session:
session.add(obj)
session.commit()

# Fetch data of latest release
latest_date = db.query(db.Versions.c.end_date).order_by(db.Versions.c.end_date.desc()).limit(1).table()
Expand All @@ -35,10 +32,12 @@
conn.commit()

# Add latest
data = [{'version': 'latest', 'start_date': latest_date, 'description': 'Version in development'}]
with db.engine.connect() as conn:
conn.execute(db.Versions.insert().values(data))
conn.commit()
obj = Versions(version="latest",
start_date=latest_date,
description="Version in development")
with db.session as session:
session.add(obj)
session.commit()

print(db.query(db.Versions).table())

Expand Down

0 comments on commit 290de6e

Please sign in to comment.