-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Summary**: Basic demo letting you start and stop Postgres. **Demo**: (Yes, this is a demo of the demo). The demo uses `pgrep postgres` to show that no Postgres instance is running. Then the user is able to start/stop Postgres on the web UI. The results of that are verified using `pgrep postgres`. https://github.com/user-attachments/assets/e407df5d-62b6-4c14-90c8-7602d2d8dce1 **Details**: * Uses `streamlit` for the frontend. * Uses the recently factored out `PostgresConn` in the backend. * Right now is only deployable locally. In the future we'll want to deploy it on a CMU-DB machine so people can play around with it. * It currently relies on the same workspace used in development. In the future, we may want to give the demo its own workspace. The setup process of this workspace would then require more scripting.
- Loading branch information
1 parent
2faecff
commit 72e9808
Showing
10 changed files
with
102 additions
and
16 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
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 |
---|---|---|
|
@@ -134,3 +134,4 @@ virtualenv==20.25.0 | |
Werkzeug==3.0.1 | ||
wrapt==1.14.1 | ||
zipp==3.17.0 | ||
streamlit==1.39.0 |
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
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
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,2 @@ | ||
#!/bin/bash | ||
python -m streamlit run tune/demo/main.py |
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
Empty file.
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,64 @@ | ||
import streamlit as st | ||
|
||
from tune.env.pg_conn import PostgresConn | ||
from util.pg import DEFAULT_POSTGRES_PORT, get_is_postgres_running | ||
from util.workspace import ( | ||
DEFAULT_BOOT_CONFIG_FPATH, | ||
DBGymConfig, | ||
default_dbdata_parent_dpath, | ||
default_pgbin_path, | ||
default_pristine_dbdata_snapshot_path, | ||
make_standard_dbgym_cfg, | ||
) | ||
|
||
|
||
# This ensures that DBGymConfig is only created once. Check DBGymConfig.__init__() for why we must do this. | ||
@st.cache_resource | ||
def make_dbgym_cfg() -> DBGymConfig: | ||
return make_standard_dbgym_cfg() | ||
|
||
|
||
class Demo: | ||
BENCHMARK = "tpch" | ||
SCALE_FACTOR = 0.01 | ||
|
||
def __init__(self) -> None: | ||
self.dbgym_cfg = make_dbgym_cfg() | ||
self.pristine_dbdata_snapshot_path = default_pristine_dbdata_snapshot_path( | ||
self.dbgym_cfg.dbgym_workspace_path, Demo.BENCHMARK, Demo.SCALE_FACTOR | ||
) | ||
self.dbdata_parent_dpath = default_dbdata_parent_dpath( | ||
self.dbgym_cfg.dbgym_workspace_path | ||
) | ||
self.pgbin_dpath = default_pgbin_path(self.dbgym_cfg.dbgym_workspace_path) | ||
self.pg_conn = PostgresConn( | ||
self.dbgym_cfg, | ||
DEFAULT_POSTGRES_PORT, | ||
self.pristine_dbdata_snapshot_path, | ||
self.dbdata_parent_dpath, | ||
self.pgbin_dpath, | ||
False, | ||
DEFAULT_BOOT_CONFIG_FPATH, | ||
) | ||
|
||
def main(self) -> None: | ||
is_postgres_running = get_is_postgres_running() | ||
|
||
if is_postgres_running: | ||
st.write("Postgres is running") | ||
|
||
if st.button("Stop Postgres"): | ||
self.pg_conn.shutdown_postgres() | ||
st.rerun() | ||
else: | ||
st.write("Postgres is not running") | ||
|
||
if st.button("Start Postgres"): | ||
self.pg_conn.restore_pristine_snapshot() | ||
self.pg_conn.start_with_changes() | ||
st.rerun() | ||
|
||
|
||
if __name__ == "__main__": | ||
demo = Demo() | ||
demo.main() |
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
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