Skip to content

Commit

Permalink
Merge branch 'develop' into rework_store_search
Browse files Browse the repository at this point in the history
  • Loading branch information
omad authored Jun 13, 2024
2 parents 77a070d + e3bc788 commit ffbb2d6
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 60 deletions.
43 changes: 43 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Byte-compiled / optimized / DLL files
**/__pycache__/
**/.pytest_cache/

# Unit test / coverage reports
**/htmlcov/
**/.tox/
**/.coverage
**/.coverage.*
**/.cache
**/nosetests.xml
**/coverage.xml
**/*.cover
**/.hypothesis

# Translations
**/*.mo
**/*.pot

# Django stuff:
**/*.log

# Sphinx documentation
**/docs/_build/

# PyBuilder
**/target/
**/.idea/

# iPython Notebook
**/.ipynb_checkpoints

# Mac OS X
**/.DS_Store

# Environment-specific templates
**/*.env.html
**/settings.env.py

# Ignore vscode
**/.vscode

.dockerignore
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
.hypothesis

# Translations
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
rev: v0.4.8
hooks:
- id: ruff
args: [--fix, --show-fixes, --output-format, grouped]
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
version: 2
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.10"
apt_packages:
- libgdal-dev
- gdal-bin
Expand Down
46 changes: 22 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,50 @@ ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
PYTHONFAULTHANDLER=1

# Environment can be whatever is supported by setup.py
# so, either deployment, test
ARG ENVIRONMENT=deployment
# ARG ENVIRONMENT=test

# Apt installation
# git: required by setuptools_scm.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
git \
# For Psycopg2
libpq5 \
tini \
postgresql-client \
python3-pip \
&& ([ "$ENVIRONMENT" = "deployment" ] || \
apt-get install -y --no-install-recommends \
git) && \
apt-get autoclean && \
&& apt-get autoclean && \
apt-get autoremove && \
rm -rf /var/lib/{apt,dpkg,cache,log}

# Environment can be whatever is supported by setup.py
# so, either deployment, test
ARG ENVIRONMENT=deployment
# ARG ENVIRONMENT=test

RUN echo "Environment is: $ENVIRONMENT" && \
[ "$ENVIRONMENT" = "deployment" ] || \
pip install --disable-pip-version-check pip-tools pytest-cov
rm -rf /var/lib/{apt,dpkg,cache,log} && \
echo "Environment is: $ENVIRONMENT" && \
([ "$ENVIRONMENT" = "deployment" ] || \
pip install --disable-pip-version-check pip-tools pytest-cov)

# Set up a nice workdir and add the live code
ENV APPDIR=/code
WORKDIR $APPDIR
COPY . $APPDIR

COPY --from=builder --link /build/*.whl ./
RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \
rm *.whl

# These ENVIRONMENT flags make this a bit complex, but basically, if we are in dev
# then we want to link the source (with the -e flag) and if we're in prod, we
# want to delete the stuff in the /code folder to keep it simple.
RUN if [ "$ENVIRONMENT" = "deployment" ] ; then\
pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT]; \
rm -rf /code/* /code/.git* ; \
else \
pip --disable-pip-version-check install --editable .[$ENVIRONMENT]; \
fi && \
COPY --from=builder --link /build/*.whl ./
RUN python3.10 -m pip --disable-pip-version-check -q install *.whl && \
rm *.whl && \
([ "$ENVIRONMENT" = "deployment" ] || \
pip --disable-pip-version-check install --editable .[$ENVIRONMENT]) && \
([ "$ENVIRONMENT" != "deployment" ] || \
(pip --no-cache-dir --disable-pip-version-check install .[$ENVIRONMENT] && \
rm -rf /code/* /code/.git*)) && \
pip freeze && \
([ "$ENVIRONMENT" != "deployment" ] || \
apt-get remove -y \
git \
git-man \
python3-pip)

ENTRYPOINT ["/bin/tini", "--"]
Expand Down
10 changes: 5 additions & 5 deletions cubedash/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import flask
import pytz
from datacube.index.fields import Field
from datacube.model import Dataset, DatasetType, Range
from datacube.model import Dataset, Product, Range
from dateutil import tz
from flask import Blueprint
from markupsafe import Markup, escape
Expand Down Expand Up @@ -226,7 +226,7 @@ def _max_val(ls):


@bp.app_template_filter("product_license_link")
def _product_license(product: DatasetType):
def _product_license(product: Product):
license_ = _utils.product_license(product)

if license_ is None:
Expand All @@ -244,7 +244,7 @@ def _product_license(product: DatasetType):


@bp.app_template_filter("searchable_fields")
def _searchable_fields(product: DatasetType):
def _searchable_fields(product: Product):
"""Searchable field names for a product"""

# No point searching fields that are fixed for this product
Expand All @@ -254,12 +254,12 @@ def _searchable_fields(product: DatasetType):
return sorted(
(key, field)
for key, field in product.metadata_type.dataset_fields.items()
if key not in skippable_product_keys and key != "product"
if key not in skippable_product_keys and key != "product" and field.indexed
)


@bp.app_template_filter("searchable_fields_keys")
def _searchable_fields_keys(product: DatasetType):
def _searchable_fields_keys(product: Product):
"""List of keys of searchable field names for a product"""
fields = _searchable_fields(product)
return [k for k, _ in fields]
Expand Down
47 changes: 35 additions & 12 deletions cubedash/templates/metadata-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,42 @@ <h3>
</h3>
<div class="{% if metadata_type.dataset_fields | length > 8 %}columned{% endif %}">
{% for key, field in metadata_type.dataset_fields | dictsort %}
<div>
{{ key }}
{%- if field.indexed is true %}
<div>
{{ key }}

<span class="badge">
{{- field.type_name -}}
{%- if field.indexed is true %}
<span title="indexed"><i class="fa fa-square" aria-hidden="true"></i></span>
{%- endif -%}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
<span class="badge">
{{- field.type_name -}}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
{%- endif -%}
{% endfor %}
</div>
</div>


<div class="panel">
<h3>
Additional Fields
{{ hanchor('additional-fields') }}
</h3>
<div class="{% if metadata_type.dataset_fields | length > 8 %}columned{% endif %}">
{% for key, field in metadata_type.dataset_fields | dictsort %}
{%- if field.indexed is false %}
<div>
{{ key }}

<span class="badge">
{{- field.type_name -}}
</span>
{% if field.description and ('TODO' not in field.description) %}
<span class="muted">{{ field.description }}</span>
{% endif %}
</div>
{%- endif -%}
{% endfor %}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
- postgres

postgres:
image: postgis/postgis:13-3.4
image: postgis/postgis:16-3.4
hostname: postgres
environment:
- POSTGRES_DB=opendatacube
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ autodocsumm==0.2.9
beautifulsoup4==4.11.0
nbsphinx==0.8.9
pydata-sphinx-theme==0.9.0
Sphinx==4.5.0
Sphinx==5.0.0
sphinx-autodoc-typehints==1.19.0
sphinx-click==4.2.0
6 changes: 5 additions & 1 deletion docs/rtd-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dask[array]==2023.1.1
# via
# datacube
# distributed
datacube==1.8.10
datacube==1.8.18
# via
# datacube-explorer (setup.py)
# eodatasets3
Expand All @@ -89,6 +89,8 @@ defusedxml==0.7.1
# via eodatasets3
distributed==2023.1.1
# via datacube
deprecat==2.1.1
# via datacube
eodatasets3==0.30.1
# via datacube-explorer (setup.py)
fiona==1.9.0
Expand Down Expand Up @@ -306,6 +308,8 @@ urllib3==1.26.14
# sentry-sdk
werkzeug==2.2.2
# via flask
wrapt==1.16.0
# via deprecat
xarray==2023.1.0
# via
# datacube
Expand Down
10 changes: 3 additions & 7 deletions integration_tests/test_page_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,9 @@ def test_search_time_completion(client: FlaskClient):
assert len(search_results) == 4

# if not provided as a span, it should become a span of one day
html = get_html(client, "/datasets/ga_ls8c_ard_3?creation_time=2022-02-14")
assert (
one_element(html, "#search-creation_time-before").attrs["value"] == "2022-02-14"
)
assert (
one_element(html, "#search-creation_time-after").attrs["value"] == "2022-02-15"
)
html = get_html(client, "/datasets/ga_ls8c_ard_3?time=2022-07-18")
assert one_element(html, "#search-time-before").attrs["value"] == "2022-07-18"
assert one_element(html, "#search-time-after").attrs["value"] == "2022-07-19"
search_results = html.find(".search-result a")
assert len(search_results) == 2

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
requires = ["setuptools>=61", "wheel", "setuptools_scm[toml]>=8"]

[tool.setuptools_scm]
write_to = "cubedash/_version.py"

[tool.black]
line-length = 88
target_version = ['py36', 'py37', 'py38']
target_version = ['py39', 'py310', 'py311', 'py312']
include = '\.pyi?$'
exclude = '''
/(
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
long_description_content_type="text/markdown",
use_scm_version=True,
setup_requires=["setuptools_scm"],
python_requires=">=3.7",
python_requires=">=3.9",
url="https://github.com/opendatacube/datacube-explorer",
author="Geoscience Australia",
author_email="earth.observation@ga.gov.au",
Expand All @@ -64,15 +64,17 @@
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
],
include_package_data=True,
install_requires=[
"cachetools",
"click",
"datacube>=1.8.10",
"datacube>=1.8.18",
"eodatasets3>=0.30.1",
"fiona",
"flask",
Expand Down

0 comments on commit ffbb2d6

Please sign in to comment.