-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix generate_database action * remove unused parts of script
- Loading branch information
Showing
2 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,11 @@ | |
name: Generate Database | ||
|
||
on: | ||
# More details on trigger events: https://docs.github.com/en/actions/reference/events-that-trigger-workflows | ||
# More details on trigger events: | ||
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows | ||
workflow_dispatch: # manual execution | ||
release: | ||
types: [published] | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
|
@@ -34,26 +34,16 @@ jobs: | |
- name: Generate sqlite (file) database | ||
run: | | ||
python scripts/tutorials/generate_database.py sqlite | ||
python simple/utils/generate_database.py | ||
working-directory: . | ||
|
||
# The postgres database creation can take a while on the hobby-dev tier in Heroku | ||
# Disabling until we have a better idea on how to use this | ||
# - name: Generate postgres (Heroku) database | ||
# env: | ||
# SIMPLE_DATABASE_URL: ${{secrets.SIMPLE_DATABASE_URL}} | ||
# run: | | ||
# pip install psycopg2 | ||
# python scripts/tutorials/generate_database.py postgres | ||
# working-directory: . | ||
|
||
- 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 }} | ||
with: | ||
source_file: 'SIMPLE.db' | ||
source_file: 'SIMPLE.sqlite' | ||
destination_repo: 'SIMPLE-AstroDB/SIMPLE-binary' | ||
destination_branch: 'main' | ||
user_email: '[email protected]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Script to generate database from JSON contents | ||
# This gets run automatically with Github Actions | ||
|
||
import argparse | ||
import sys | ||
from astrodb_utils import load_astrodb | ||
|
||
sys.path.append("./") | ||
from simple.schema import REFERENCE_TABLES | ||
from simple.schema import * | ||
|
||
# Location of source data | ||
DB_NAME = "SIMPLE.sqlite" | ||
DB_PATH = "data/" | ||
|
||
|
||
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 | ||
) | ||
print("New database generated.") | ||
|
||
# Close all connections | ||
db.session.close() | ||
db.engine.dispose() |