-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix generate_database action #479
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3684825
fix generate_database action
kelle 1822680
run the action on pull requests
kelle 829bfda
typo
kelle 9c913e4
fix generate_database action
kelle efdc12a
run the action on pull requests
kelle a641e67
typo
kelle 0964da1
Merge branch 'fix-generate-db' of github.com:kelle/SIMPLE-db into fix…
kelle a95c9a9
trying new generate_db script
kelle 2544011
remove sqlite arg
kelle 7e5c365
remove unused parts of script
kelle 6a1f24a
removed unused bits. [skip ci]
kelle de1fe79
Merge branch 'main' into fix-generate-db
kelle 3c1528e
remove pull request from action
kelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,12 @@ | |
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 | ||
pull_request: # added for testing | ||
workflow_dispatch: # manual execution | ||
release: | ||
types: [published] | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
|
@@ -34,26 +35,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' | ||
Comment on lines
-56
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once this is merged, we will need to go to the binary repo and delete the old db file to avoid confusion. |
||
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,45 @@ | ||
# Script to generate database from JSON contents | ||
# This gets run automatically with Github Actions | ||
|
||
import argparse | ||
import sys | ||
import os | ||
from astrodb_utils import load_astrodb | ||
|
||
sys.path.append("./") | ||
from simple.schema import * | ||
from simple.schema import REFERENCE_TABLES | ||
|
||
# Location of source data | ||
DB_PATH = "data" | ||
DB_NAME = "SIMPLE.sqlite" | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Generate the SIMPLE database") | ||
# parser.add_argument( | ||
# "architecture", | ||
# choices=["sqlite", "postgres"], | ||
# help="Database architecture to use.", | ||
# ) | ||
# parser.add_argument( | ||
# "connection_string", | ||
# nargs="?", | ||
# help="Connection string to use for non-sqlite databases.", | ||
# ) | ||
|
||
args = parser.parse_args() | ||
|
||
# Get the connection string for any non-sqlite database | ||
# if args.connection_string is not None: | ||
# connection_string = args.connection_string | ||
# else: | ||
connection_string = os.getenv("SIMPLE_DATABASE_URL", default="") | ||
kelle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Run the loader for the specified DB architecture | ||
db = load_astrodb(DB_NAME, reference_tables=REFERENCE_TABLES) | ||
print("New database generated.") | ||
|
||
# Close all connections | ||
db.session.close() | ||
db.engine.dispose() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not do this on a pull_request, as this action essentially builds the binary file for purposes of the website. That should only be done when we are ready to push a change, not when someone opens a pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure I added this here just so it would run on this PR. in order to test the script.