33from sqlalchemy .orm import Session
44from tqdm import tqdm
55
6- from aross_stations_db .config import CliLoadSettings , Settings
6+ from aross_stations_db .config import CliLoadSettings
77from aross_stations_db .db .setup import (
88 generate_event_objects ,
99 load_events ,
@@ -21,25 +21,26 @@ def cli() -> None:
2121 pass
2222
2323
24+ @click .option (
25+ "--skip-load" ,
26+ help = "Skip loading data; only initialize tables." ,
27+ is_flag = True ,
28+ )
2429@cli .command
25- def init () -> None :
26- """Create the database tables, dropping any that pre-exist ."""
30+ def init (skip_load : bool = False ) -> None :
31+ """Load the database from files on disk ."""
2732 # TODO: False-positive. Remove type-ignore.
2833 # See: https://github.com/pydantic/pydantic/issues/6713
29- config = Settings () # type:ignore[call-arg]
34+ config = CliLoadSettings () # type:ignore[call-arg]
3035
3136 with Session (config .db_engine ) as db_session :
3237 recreate_tables (db_session )
3338
34- logger .success ("Database initialized" )
39+ logger .info ("Database tables initialized" )
3540
36-
37- @cli .command
38- def load () -> None :
39- """Load the database tables from files on disk."""
40- # TODO: False-positive. Remove type-ignore.
41- # See: https://github.com/pydantic/pydantic/issues/6713
42- config = CliLoadSettings () # type:ignore[call-arg]
41+ if skip_load :
42+ logger .warning ("Skipping data load." )
43+ return
4344
4445 raw_stations = get_stations (config .stations_metadata_filepath )
4546 raw_events = get_events (config .events_dir )
0 commit comments