Skip to content

Commit

Permalink
Merge pull request #130 from Michele-Alberti/development
Browse files Browse the repository at this point in the history
🛎️ Add ready/disconnect notification
  • Loading branch information
Michele-Alberti authored Mar 7, 2024
2 parents 4050aec + 41457ec commit 8120b9c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions dlunch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def run_app(config: DictConfig):
)

log.info("set panel config")
# Set notifications options
pn.extension(
disconnect_notification=config.panel.notifications.disconnect_notification,
ready_notification=config.panel.notifications.ready_notification,
)
# Configurations
pn.config.nthreads = config.panel.nthreads
pn.config.notifications = True
Expand Down Expand Up @@ -88,6 +93,10 @@ def run_app(config: DictConfig):
"missing config.server.auth_provider, auth_object dict left empty"
)

# Set session begin/end logs
pn.state.on_session_created(lambda ctx: log.debug("session created"))
pn.state.on_session_destroyed(lambda ctx: log.debug("session closed"))

pn.serve(
panels=pages, **hydra.utils.instantiate(config.server), **auth_object
)
Expand Down
9 changes: 3 additions & 6 deletions dlunch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd

# Import database object
from .models import create_database, create_engine, SCHEMA, Data
from .models import create_database, create_engine, SCHEMA, Data, metadata_obj

# Import functions from core
from .core import clean_tables as clean_tables_func
Expand All @@ -31,9 +31,7 @@
)
@click.pass_context
def cli(ctx, hydra_overrides: tuple | None):
"""Command line interface for creating a local sqlite database.
To be used only for development purposes.
"""
"""Command line interface for managing Data-Lunch database and users."""
# global initialization
initialize(
config_path="conf", job_name="data_lunch_cli", version_base="1.3"
Expand Down Expand Up @@ -230,8 +228,7 @@ def delete_table(obj, name):
# Drop table
try:
engine = create_engine(obj["config"])
command = f"DROP TABLE {name};"
engine.execute(command)
metadata_obj.tables[name].drop(engine)
click.secho(f"Table '{name}' deleted", fg="green")
except Exception as e:
# Generic error
Expand Down
5 changes: 5 additions & 0 deletions dlunch/conf/panel/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ guest_types: # Check also guests icons in panel/gui
# NOTIFICATIONS
notifications:
duration: 0
# Notification on first connection or on disconnection (set to ""
# to deactivate)
disconnect_notification: |-
Connection lost<br>Please reload the page
ready_notification: ""
# Drop unused menus entries in orders tables (drop unused if true)
drop_unused_menu_items: true

Expand Down
6 changes: 5 additions & 1 deletion dlunch/conf/server/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ static_dirs:
compress_response: true
cookie_secret: ${oc.env:DATA_LUNCH_COOKIE_SECRET} # Secure cookies are required (this vakue can't be null)
enable_xsrf_cookies: true
liveness: health
liveness: health
keep_alive_milliseconds: 29000 # Default 37000
check_unused_sessions_milliseconds: 17000 # Default 17000
unused_session_lifetime_milliseconds: 15000 # Default 15000
session_token_expiration: 300 # Default 300

0 comments on commit 8120b9c

Please sign in to comment.