Skip to content

Commit

Permalink
reduced dagster sched to avoid slow load times. added manual load button
Browse files Browse the repository at this point in the history
  • Loading branch information
luutuankiet committed Mar 1, 2024
1 parent fc64c65 commit f925531
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/ETL/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ETL_job = define_asset_job("ETL_job",selection=all_assets)
ETL_schedule = ScheduleDefinition(
job=ETL_job,
cron_schedule="*/5 * * * *",execution_timezone="Asia/Bangkok"
cron_schedule="*/30 * * * *",execution_timezone="Asia/Bangkok"
)

defs = Definitions(
Expand Down
30 changes: 21 additions & 9 deletions app/charts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,28 @@ def get_table_nocache(query):
df = convert_df_to_common_tz(df)
return df

with st.expander("server ops"):

if st.button("force reload server"):
kill = "tmux send-keys -t streamlit.0 C-c"
# setup = "cd ../.. && tmux new-session -s $STREAMLIT -d"
reload = "tmux send-keys -t streamlit.0 'streamlit run main.py' ENTER"
subprocess.run(f"{kill} & {kill}", shell=True)
subprocess.run(f"sleep 10 && {reload}",shell=True)
if st.button("force cache reload"):
st.cache_data.clear()

if st.button("reload data"):
log_path = "/logs/dbt/manual_run_log.txt"
dbt_cmd = "source /main/scrape-ticktick/.venv/bin/activate && source /main/scrape-ticktick/.env && dbt run"

with open(log_path, "w") as output_file:
result = subprocess.run(f"{dbt_cmd}", shell=True, stdout=output_file, stderr=subprocess.STDOUT)


if st.button("force reload server"):
kill = "tmux send-keys -t streamlit.0 C-c"
# setup = "cd ../.. && tmux new-session -s $STREAMLIT -d"
reload = "tmux send-keys -t streamlit.0 'streamlit run main.py' ENTER"
subprocess.run(f"{kill} & {kill}", shell=True)
subprocess.run(f"sleep 10 && {reload}",shell=True)
if st.button("force cache reload"):
st.cache_data.clear()
# Read and display the output file content
with open(log_path, "r") as output_file:
output_content = output_file.read()
st.code(output_content)



Expand Down

0 comments on commit f925531

Please sign in to comment.