Skip to content

Commit

Permalink
Merge pull request #51 from spectriclabs/dev
Browse files Browse the repository at this point in the history
Constrain ellipses to a configurable level
  • Loading branch information
desean1625 authored Feb 21, 2024
2 parents cc7d78e + 4528626 commit 892446a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion elastic_datashader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Config:
datashader_headers: Dict[Any, Any]
elastic_hosts: str
ellipse_render_mode: str
ellipse_render_min_zoom: int
hostname: str
log_level: int
max_batch: int
Expand Down Expand Up @@ -93,14 +94,15 @@ def config_from_env(env) -> Config:
datashader_headers=load_datashader_headers(env.get("DATASHADER_HEADER_FILE", "headers.yaml")),
elastic_hosts=env.get("DATASHADER_ELASTIC", "http://localhost:9200"),
ellipse_render_mode=env.get("DATASHADER_ELLIPSE_RENDER_MODE", "matrix"),
ellipse_render_min_zoom=env.get("DATASHADER_ELLIPSE_RENDER_MIN_ZOOM", 8),
hostname=getfqdn(),
log_level=get_log_level(env.get("DATASHADER_LOG_LEVEL", None)),
max_batch=int(env.get("DATASHADER_MAX_BATCH", 10_000)),
max_bins=int(env.get("DATASHADER_MAX_BINS", 10_000)),
max_ellipses_per_tile=int(env.get("DATASHADER_MAX_ELLIPSES_PER_TILE", 100_000)),
max_legend_items_per_tile=int(env.get("MAX_LEGEND_ITEMS_PER_TILE", 20)),
num_ellipse_points=int(env.get("DATASHADER_NUM_ELLIPSE_POINTS", 100)),
query_timeout_seconds=int(env.get("DATASHADER_QUERY_TIMEOUT", 0)),
query_timeout_seconds=int(env.get("DATASHADER_QUERY_TIMEOUT", 900)),
render_timeout=timedelta(seconds=int(env.get("DATASHADER_RENDER_TIMEOUT", 30))),
tms_key=env.get("DATASHADER_TMS_KEY", None),
use_scroll=true_if_none(env.get("DATASHADER_USE_SCROLL", None)),
Expand Down
2 changes: 1 addition & 1 deletion elastic_datashader/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def get_search_base(
# Connect to Elasticsearch
es = Elasticsearch(
hosts_url_to_nodeconfig(elastic_hosts),
timeout=900,
timeout=config.query_timeout_seconds,
headers=get_es_headers(headers, user, x_opaque_id),
)

Expand Down
3 changes: 3 additions & 0 deletions elastic_datashader/tilegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ def generate_nonaggregated_tile(
metrics = {"over_max": False}

if render_mode == "ellipses":
if z < config.ellipse_render_min_zoom:
img = gen_overlay(gen_empty(tile_width_px, tile_height_px), color=(128, 128, 128, 128))
return img, metrics
field_names = get_ellipse_field_names(params)
count_s = count_s.source(includes=populated_field_names(field_names))
df = pd.DataFrame.from_dict(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_config_defaults():
assert cfg.max_batch == 10000
assert cfg.max_ellipses_per_tile == 100000
assert cfg.allowlist_headers is None
assert cfg.query_timeout_seconds == 0
assert cfg.query_timeout_seconds == 900
assert cfg.hostname == socket.getfqdn()


Expand Down

0 comments on commit 892446a

Please sign in to comment.