From aedd2288eaf3ad27c9ad0ac13fac7f8d7b818f54 Mon Sep 17 00:00:00 2001 From: kelle Date: Tue, 14 Apr 2026 16:45:39 -0400 Subject: [PATCH] update generate_database to use new functions --- .github/workflows/gen-db.yml | 45 +++++++++++++++---------------- simple/utils/generate_database.py | 22 +++------------ 2 files changed, 25 insertions(+), 42 deletions(-) diff --git a/.github/workflows/gen-db.yml b/.github/workflows/gen-db.yml index a847f4237..49622066c 100644 --- a/.github/workflows/gen-db.yml +++ b/.github/workflows/gen-db.yml @@ -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 diff --git a/simple/utils/generate_database.py b/simple/utils/generate_database.py index 718eee5de..ec0d12049 100644 --- a/simple/utils/generate_database.py +++ b/simple/utils/generate_database.py @@ -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