Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 22 additions & 23 deletions .github/workflows/gen-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,30 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install astrodbkit
pip install astrodb_utils
pip install .
run: uv sync

- name: Generate sqlite (file) database
run: |
python simple/utils/generate_database.py
working-directory: .
run: uv run python simple/utils/generate_database.py

- name: Push database file
uses: dmnemec/copy_file_to_another_repo_action@main
# Details for this action at https://github.com/marketplace/actions/push-a-file-to-another-repository
env:
API_TOKEN_GITHUB: ${{ secrets.SIMPLE_TOKEN }}
- name: Checkout destination repo
uses: actions/checkout@v4
with:
source_file: 'SIMPLE.sqlite'
destination_repo: 'SIMPLE-AstroDB/SIMPLE-binary'
destination_branch: 'main'
user_email: 'github-actions@github.com'
user_name: 'github-actions'
repository: SIMPLE-AstroDB/SIMPLE-binary
path: SIMPLE-binary
token: ${{ secrets.SIMPLE_TOKEN }}

- name: Push database file
run: |
cp SIMPLE.sqlite SIMPLE-binary/SIMPLE.sqlite
cp database.toml SIMPLE-binary/database.toml
cd SIMPLE-binary
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git add SIMPLE.sqlite
git add database.toml
git commit -m "Update SIMPLE.sqlite and database.toml from SIMPLE-db release ${{ github.ref_name }}" || echo "No changes to commit"
git push
22 changes: 3 additions & 19 deletions simple/utils/generate_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,14 @@
# This gets run automatically with Github Actions

import argparse
import sys
from astrodb_utils import load_astrodb

sys.path.append("./")
from simple import REFERENCE_TABLES

# Location of source data
DB_NAME = "SIMPLE.sqlite"
DB_PATH = "data/"
SCHEMA_PATH = "simple/schema.yaml"

from astrodb_utils.loaders import build_db_from_json

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate the SIMPLE database")
args = parser.parse_args()

# Run the loader for the specified DB architecture
db = load_astrodb(
DB_NAME,
data_path=DB_PATH,
recreatedb=True,
reference_tables=REFERENCE_TABLES,
felis_schema=SCHEMA_PATH,
)
db = build_db_from_json(settings_file="database.toml")

print("New database generated.")

# Close all connections
Expand Down
Loading