Skip to content

Commit

Permalink
#254: option to disable shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
aschonfeld committed Aug 28, 2020
1 parent 830bd62 commit 7982c38
Show file tree
Hide file tree
Showing 15 changed files with 846 additions and 744 deletions.
13 changes: 9 additions & 4 deletions dtale/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ def build_app(
url,
host=None,
reaper_on=True,
hide_shutdown=False,
github_fork=False,
app_root=None,
):
"""
Expand All @@ -235,8 +233,6 @@ def build_app(
app_root=app_root,
)
app.config["SECRET_KEY"] = "Dtale"
app.config["HIDE_SHUTDOWN"] = hide_shutdown
app.config["GITHUB_FORK"] = github_fork

app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
Expand Down Expand Up @@ -536,6 +532,8 @@ def show(
allow_cell_edits=True,
inplace=False,
drop_index=False,
hide_shutdown=False,
github_fork=False,
**kwargs
):
"""
Expand Down Expand Up @@ -583,6 +581,11 @@ def show(
:type inplace: bool, optional
:param drop_index: If true, this will drop any pre-existing index on the dataframe input.
:type drop_index: bool, optional
:param hide_shutdown: If true, this will hide the "Shutdown" buton from users
:type hide_shutdown: bool, optional
:param github_fork: If true, this will display a "Fork me on GitHub" ribbon in the upper right-hand corner of the
app
:type github_fork: bool, optional
:Example:
Expand Down Expand Up @@ -627,6 +630,8 @@ def show(
allow_cell_edits=allow_cell_edits,
inplace=inplace,
drop_index=drop_index,
hide_shutdown=hide_shutdown,
github_fork=github_fork,
)
is_active = not running_with_flask_debug() and is_up(app_url)
if is_active:
Expand Down
14 changes: 13 additions & 1 deletion dtale/cli/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@
@click.option(
"--no-cell-edits",
is_flag=True,
help="flag to turn off auto-reaping (process cleanup after period of inactivity)",
help="flag to turn off auto-reaping (process cleanup after period of inactivity",
)
@click.option(
"--hide-shutdown", is_flag=True, help='flag to hide "Shutdown" button from users'
)
@click.option(
"--github-fork",
is_flag=True,
help='flag to show "Fork Me On GitHub" link in upper right-hand corner of the app',
)
@setup_loader_options()
@click.option("--log", "logfile", help="Log file name")
Expand All @@ -47,6 +55,8 @@ def main(
open_browser=False,
name=None,
no_cell_edits=False,
hide_shutdown=False,
github_fork=False,
**kwargs
):
"""
Expand All @@ -72,6 +82,8 @@ def main(
open_browser=open_browser,
name=name,
allow_cell_edits=not no_cell_edits,
hide_shutdown=hide_shutdown,
github_fork=github_fork,
**kwargs
)

Expand Down
3 changes: 2 additions & 1 deletion dtale/column_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ def build_inner_code(self):
unit = self.cfg.get("unit") or "D"
if unit == "YYYYMMDD":
return "pd.Series({s}.astype(str).apply(pd.Timestamp), name='{name}', index={s}.index)".format(
s=s, name=self.name,
s=s,
name=self.name,
)
return "pd.Series(pd.to_datetime({s}, unit='{unit}'), name='{name}', index={s}.index)".format(
s=s, name=self.name, unit=unit
Expand Down
26 changes: 19 additions & 7 deletions dtale/dash_application/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

def get_url_parser():
"""
Returns URL parser based on whether Python 2 or 3 is being used.
Returns URL parser based on whether Python 2 or 3 is being used.
"""
if PY3:
return urllib.parse.parse_qsl
Expand Down Expand Up @@ -267,10 +267,14 @@ def _build_axes(y):
pos = axis_ct / 20.0
value["position"] = (1 - pos) if right else pos
positions.append(value["position"])
if y2 in axis_data and not (
axis_data[y2]["min"],
axis_data[y2]["max"],
) == (mins[y2], maxs[y2]):
if (
y2 in axis_data
and not (
axis_data[y2]["min"],
axis_data[y2]["max"],
)
== (mins[y2], maxs[y2])
):
value["range"] = [axis_data[y2]["min"], axis_data[y2]["max"]]
if classify_type(dtypes.get(y2)) == "I":
value["tickformat"] = ".0f"
Expand Down Expand Up @@ -1627,7 +1631,10 @@ def _build_heatmap_axis(col, data, title):
x_axis = _build_heatmap_axis(x, x_data, x_title)
y_axis = _build_heatmap_axis(y, y_data, y_title)

hm_kwargs = dict_merge(hm_kwargs, dict(colorbar={"title": z_title}, text=text),)
hm_kwargs = dict_merge(
hm_kwargs,
dict(colorbar={"title": z_title}, text=text),
)

hm_kwargs = dict_merge(hm_kwargs, {"z": heat_data})
layout_cfg = build_layout(
Expand Down Expand Up @@ -1746,7 +1753,12 @@ def candlestick_builder(data_id, export=False, **inputs):
dupe_cols = [x] + make_list(group)
if agg is not None:
data, agg_code = build_agg_data(
data, x, [cs_open, cs_close, high, low], inputs, agg, group_col=group,
data,
x,
[cs_open, cs_close, high, low],
inputs,
agg,
group_col=group,
)
code += agg_code
if not len(data):
Expand Down
9 changes: 6 additions & 3 deletions dtale/dash_application/drilldown_modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def load_drilldown_content(
return hist_chart, dict(display="none")
else:
xy_query = build_group_inputs_filter(
global_state.get_data(data_id), [point_filter],
global_state.get_data(data_id),
[point_filter],
)
if not query:
query = xy_query
Expand Down Expand Up @@ -285,7 +286,8 @@ def load_drilldown_content(
return hist_chart, dict(display="none")
else:
map_query = build_group_inputs_filter(
global_state.get_data(data_id), [point_filter],
global_state.get_data(data_id),
[point_filter],
)
if not query:
query = map_query
Expand Down Expand Up @@ -322,7 +324,8 @@ def load_drilldown_content(
return hist_chart, dict(display="none")
else:
x_query = build_group_inputs_filter(
global_state.get_data(data_id), [point_filter],
global_state.get_data(data_id),
[point_filter],
)
if not query:
query = x_query
Expand Down
Loading

0 comments on commit 7982c38

Please # to comment.