Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not flag read-only fields with value as broken #169

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Bugfixes
~~~~~~~~

* :class:`scitacean.Client` no longer requires a file transfer during upload if the dataset has no files that need to be uploaded.
* The HTML representation of datasets no longer flags read-only fields with a value as broken.

Documentation
~~~~~~~~~~~~~
Expand Down
11 changes: 6 additions & 5 deletions src/scitacean/_html_repr/_dataset_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ def _get_fields(dset: Dataset) -> List[Field]:


def _check_error(field: Dataset.Field, validation: Dict[str, str]) -> Optional[str]:
if field.name in validation:
# TODO validation uses model names (camelCase)
return validation[field.name]
return None
field_spec = next(filter(lambda f: f.name == field.name, Dataset.fields()))
return validation.get(field_spec.scicat_name, None)


def _validate(dset: Dataset) -> Dict[str, str]:
Expand Down Expand Up @@ -209,6 +207,9 @@ def _human_readable_size(size_in_bytes: int) -> str:
def _row_highlight_classes(field: Field) -> str:
if field.required and field.value is None:
return "cean-missing-value"
if field.error:
# 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 ""
5 changes: 5 additions & 0 deletions src/scitacean/_html_repr/styles/dataset.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ td.cean-field-description {
border-right: var(--cean-error-color) 4px solid !important;
}

.cean-missing-value .cean-empty-field,
.cean-error .cean-field-value {
color: var(--cean-error-color);
}

table.cean-dataset {
/* space between details marker and table */
margin-left: 1em !important;
Expand Down
Loading