Skip to content

Commit

Permalink
Bump to Skyportal 88a5874ef43bf29d0822e03f280c4a018987a461
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPeloton committed Nov 29, 2024
1 parent 17af1d1 commit 292ef22
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
14 changes: 12 additions & 2 deletions extensions/skyportal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ help: baselayer/Makefile
baselayer/Makefile:
git submodule update --init

dependencies_no_js: ## Install Python dependencies and check environment, without checking/installing JS dependencies
@PYTHONPATH=. pip install packaging
@baselayer/tools/check_app_environment.py
@PYTHONPATH=. python baselayer/tools/pip_install_requirements.py baselayer/requirements.txt requirements.txt

docker-images: ## Make and upload docker images
docker-images: docker-local
@# Add --no-cache flag to rebuild from scratch
Expand Down Expand Up @@ -50,19 +55,24 @@ prepare_seed_data:

load_demo_data: ## Import example dataset
load_demo_data: FLAGS := $(if $(FLAGS),$(FLAGS),--config=config.yaml)
load_demo_data: | dependencies prepare_seed_data
load_demo_data: | dependencies_no_js prepare_seed_data
@PYTHONPATH=. python tools/data_loader.py data/db_demo.yaml $(FLAGS)

load_seed_data: ## Seed database with common telescopes, instruments, and a taxonomy
load_seed_data: FLAGS := $(if $(FLAGS),$(FLAGS),--config=config.yaml)
load_seed_data: | dependencies prepare_seed_data
load_seed_data: | dependencies_no_js prepare_seed_data
@PYTHONPATH=. python tools/data_loader.py data/db_seed.yaml $(FLAGS)

load_grandma_data: ## Seed database with data from grandma collaboration
load_grandma_data: FLAGS := $(if $(FLAGS),$(FLAGS),--config=config.yaml)
load_grandma_data: | dependencies prepare_seed_data
@PYTHONPATH=. python tools/data_loader.py data/db_grandma.yaml $(FLAGS)

db_create_tables: ## Create tables in the database
db_create_tables: FLAGS := $(if $(FLAGS),$(FLAGS),--config=config.yaml)
db_create_tables: | dependencies_no_js
@PYTHONPATH=. python skyportal/initial_setup.py $(FLAGS)

db_migrate: ## Migrate database to latest schema
db_migrate: FLAGS := $(if $(FLAGS),$(FLAGS),--config=config.yaml)
db_migrate: FLAGS := $(subst --,-x ,$(FLAGS))
Expand Down
30 changes: 10 additions & 20 deletions extensions/skyportal/skyportal/initial_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,36 @@
import model_util

from baselayer.app.env import load_env
from baselayer.app.model_util import create_tables, drop_tables
from baselayer.app.model_util import create_tables
from baselayer.tools.status import status
from baselayer.app.psa import TornadoStorage
from skyportal.models import Base, DBSession, User, init_db

"""
usage: initial_setup.py [-h] [--nodrop] [--adminusername ADMINUSER]
[--username USER]
usage: initial_setup.py [-h] [--adminusername ADMINUSER]
[--username USER] [--config CONFIG]
Initialize Skyportal and add admin/users
optional arguments:
-h, --help show this help message and exit
--nodrop do not force drop existing databases
--config CONFIG Path to config file (default: config.yaml)
--adminusername ADMINUSER
Email of the admin user (e.g., testuser@cesium-ml.org)
--username USER Email of a normal user (e.g., user@cesium-ml.org)
e.g.
PYTHONPATH=$PYTHONPATH:"." python skyportal/initial_setup.py \
--adminuser=<email> --user=<anotheremail>
If you just want to add a user to an existing database make sure you add the `--nodrop` flag:
PYTHONPATH=$PYTHONPATH:"." python skyportal/initial_setup.py \
--nodrop --user=<anotheremail>
"""

parser = argparse.ArgumentParser(description="Initialize Skyportal and add admin/users")

parser.add_argument(
"--nodrop",
action="store_true",
default=False,
dest="nodrop",
help="do not force drop existing databases",
'--config',
dest='config',
default='config.yaml',
help='Path to config file (default: config.yaml)',
)

parser.add_argument(
Expand Down Expand Up @@ -76,13 +71,8 @@
with status(f"Connecting to database {cfg['database.database']}"):
init_db(**cfg['database'])

if not results.nodrop:
with status("Force dropping all tables"):
drop_tables()

with status(
"Creating tables. If you really want to start from scratch,"
" do a make db_clear; make db_init"
f"Creating tables in database {cfg['database.database']} if they do not exist"
):
create_tables()

Expand Down

0 comments on commit 292ef22

Please sign in to comment.