From ac30ac78c72e57057fb53c492b964251a8542beb Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Fri, 30 Aug 2024 11:40:17 +0200 Subject: [PATCH 1/2] Include error message in html table --- src/scitacean/_html_repr/_dataset_html.py | 13 +++++++------ .../templates/dataset_field_repr.html.template | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/scitacean/_html_repr/_dataset_html.py b/src/scitacean/_html_repr/_dataset_html.py index 4e0659aa..4046bece 100644 --- a/src/scitacean/_html_repr/_dataset_html.py +++ b/src/scitacean/_html_repr/_dataset_html.py @@ -99,7 +99,7 @@ def _format_field(field: Field) -> str: ) typ = format_type(field.type) description = html.escape(field.description) - row_highlight = _row_highlight_classes(field) + row_highlight, title = _row_highlight_classes_and_title(field) template = _resources.dataset_field_repr_template() return template.substitute( @@ -109,6 +109,7 @@ def _format_field(field: Field) -> str: value=value, description=description, extra_classes=row_highlight, + field_title=f'title="{title}"' if title else "", ) @@ -157,7 +158,7 @@ def _get_fields(dset: Dataset) -> list[Field]: def _check_error(field: Dataset.Field, validation: dict[str, str]) -> str | None: - field_spec = next(filter(lambda f: f.name == field.name, Dataset.fields())) + field_spec = next(f for f in Dataset.fields() if f.name == field.name) return validation.get(field_spec.scicat_name, None) @@ -205,12 +206,12 @@ def _human_readable_size(size_in_bytes: int) -> str: return f"{size_in_bytes} B" -def _row_highlight_classes(field: Field) -> str: +def _row_highlight_classes_and_title(field: Field) -> tuple[str, str | None]: if field.required and field.value is None: - return "cean-missing-value" + return "cean-missing-value", "Missing required field" # Do not flag read-only fields with a value as errors. # Validation is geared towards uploading where such fields must be None. # But here, we don't want to flag downloaded datasets as bad because of this. if field.error and not (field.read_only and field.error.startswith("Extra inputs")): - return "cean-error" - return "" + return "cean-error", field.error + return "", None diff --git a/src/scitacean/_html_repr/templates/dataset_field_repr.html.template b/src/scitacean/_html_repr/templates/dataset_field_repr.html.template index c85590c5..2edb9d57 100644 --- a/src/scitacean/_html_repr/templates/dataset_field_repr.html.template +++ b/src/scitacean/_html_repr/templates/dataset_field_repr.html.template @@ -1,4 +1,4 @@ - + ${flag} ${name} ${type} From 45239dd2076f65092b7fbb3cd84693b83a12406e Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Fri, 30 Aug 2024 11:41:21 +0200 Subject: [PATCH 2/2] Update dependencies --- .pre-commit-config.yaml | 2 +- requirements/base.txt | 8 ++++---- requirements/ci.txt | 4 ++-- requirements/dev.txt | 6 +++--- requirements/docs.txt | 10 +++++----- requirements/mypy.txt | 4 ++-- requirements/test.txt | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84a76a6d..729be7c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: args: ["--drop-empty-cells", "--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.1 + rev: v0.6.3 hooks: - id: ruff-format types_or: [ python, pyi ] diff --git a/requirements/base.txt b/requirements/base.txt index 09385ba7..e8d19041 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -11,7 +11,7 @@ anyio==4.4.0 # via httpx bcrypt==4.2.0 # via paramiko -certifi==2024.7.4 +certifi==2024.8.30 # via # httpcore # httpx @@ -29,14 +29,14 @@ h11==0.14.0 # via httpcore httpcore==1.0.5 # via httpx -httpx==0.27.0 +httpx==0.27.2 # via -r base.in -idna==3.7 +idna==3.8 # via # anyio # email-validator # httpx -paramiko==3.4.0 +paramiko==3.4.1 # via -r base.in pycparser==2.22 # via cffi diff --git a/requirements/ci.txt b/requirements/ci.txt index 3fd44369..8540e673 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -5,7 +5,7 @@ # # pip-compile-multi # -cachetools==5.4.0 +cachetools==5.5.0 # via tox chardet==5.2.0 # via tox @@ -29,7 +29,7 @@ pluggy==1.5.0 # via tox pyproject-api==1.7.1 # via tox -tox==4.17.1 +tox==4.18.0 # via -r ci.in virtualenv==20.26.3 # via tox diff --git a/requirements/dev.txt b/requirements/dev.txt index 5560f69f..3b9fe309 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -49,7 +49,7 @@ jupyter-server==2.14.2 # notebook-shim jupyter-server-terminals==0.5.3 # via jupyter-server -jupyterlab==4.2.4 +jupyterlab==4.2.5 # via -r dev.in jupyterlab-server==2.27.3 # via jupyterlab @@ -73,7 +73,7 @@ rfc3986-validator==0.1.1 # via # jsonschema # jupyter-events -ruff==0.5.7 +ruff==0.6.3 # via -r dev.in send2trash==1.8.3 # via jupyter-server @@ -85,7 +85,7 @@ toposort==1.10 # via pip-compile-multi uri-template==1.3.0 # via jsonschema -webcolors==24.6.0 +webcolors==24.8.0 # via jsonschema websocket-client==1.8.0 # via jupyter-server diff --git a/requirements/docs.txt b/requirements/docs.txt index f95dc2a2..ae28de35 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -49,7 +49,7 @@ imagesize==1.4.1 # via sphinx ipykernel==6.29.5 # via -r docs.in -ipython==8.26.0 +ipython==8.27.0 # via # -r docs.in # ipykernel @@ -107,7 +107,7 @@ nbformat==5.10.4 # nbclient # nbconvert # nbsphinx -nbsphinx==0.9.4 +nbsphinx==0.9.5 # via -r docs.in nest-asyncio==1.6.0 # via ipykernel @@ -140,7 +140,7 @@ pygments==2.18.0 # sphinx python-dotenv==1.0.1 # via pydantic-settings -pyzmq==26.1.0 +pyzmq==26.2.0 # via # ipykernel # jupyter-client @@ -156,7 +156,7 @@ rpds-py==0.20.0 # referencing snowballstemmer==2.2.0 # via sphinx -soupsieve==2.5 +soupsieve==2.6 # via beautifulsoup4 sphinx==8.0.2 # via @@ -168,7 +168,7 @@ sphinx==8.0.2 # sphinx-autodoc-typehints # sphinx-copybutton # sphinx-design -sphinx-autodoc-typehints==2.2.3 +sphinx-autodoc-typehints==2.3.0 # via -r docs.in sphinx-copybutton==0.5.2 # via -r docs.in diff --git a/requirements/mypy.txt b/requirements/mypy.txt index f08583e3..e5b4900e 100644 --- a/requirements/mypy.txt +++ b/requirements/mypy.txt @@ -6,7 +6,7 @@ # pip-compile-multi # -r test.txt -mypy==1.11.1 +mypy==1.11.2 # via -r mypy.in mypy-extensions==1.0.0 # via mypy @@ -14,7 +14,7 @@ types-docutils==0.21.0.20240724 # via -r mypy.in types-paramiko==3.4.0.20240423 # via -r mypy.in -types-python-dateutil==2.9.0.20240316 +types-python-dateutil==2.9.0.20240821 # via -r mypy.in types-pyyaml==6.0.12.20240808 # via -r mypy.in diff --git a/requirements/test.txt b/requirements/test.txt index 0ecad8df..7407c4fa 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -12,7 +12,7 @@ execnet==2.1.1 # via pytest-xdist filelock[typing]==3.15.4 # via -r test.in -hypothesis==6.110.1 +hypothesis==6.111.2 # via -r test.in iniconfig==2.0.0 # via pytest