diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d02b3de6..316d45dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +Release 0.3.1 July 3, 2023 +- Pinned the version of the pydantic and inflect libraries due to inflict. +- Reorganized JSON output of remodeling summaries so that all of consistent form. +- Fixed summarize_hed_tags_op so that tags were correctly categorized for output. +- Minor refactoring to reduce code complexity. +- BaseInput and Sidecar now raise HedFileError if input could not be read. + + Release 0.3.0 June 20, 2023 - Introduction of partnered schema. - Improved error handling for schema validation. diff --git a/LICENSE b/LICENSE index 2be171efb..2e7808f43 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -MIT License +The MIT License (MIT) Copyright (c) 2020+ HED Standard Working Group diff --git a/hed/errors/exceptions.py b/hed/errors/exceptions.py index 9f8ddbeb7..a1def1caf 100644 --- a/hed/errors/exceptions.py +++ b/hed/errors/exceptions.py @@ -11,7 +11,7 @@ class HedExceptions: INVALID_EXTENSION = 'invalidExtension' INVALID_DATAFRAME = 'INVALID_DATAFRAME' - + INVALID_FILE_FORMAT = 'INVALID_FILE_FORMAT' # These are actual schema issues, not that the file cannot be found or parsed SCHEMA_HEADER_MISSING = 'HED_SCHEMA_HEADER_INVALID' HED_SCHEMA_HEADER_INVALID = 'HED_SCHEMA_HEADER_INVALID' diff --git a/hed/models/base_input.py b/hed/models/base_input.py index 5a78729e8..852d7bd6f 100644 --- a/hed/models/base_input.py +++ b/hed/models/base_input.py @@ -45,6 +45,8 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T - A duplicate or empty column name appears - Cannot open the indicated file - The specified worksheet name does not exist + - If the sidecar file or tabular file had invalid format and could not be read. + """ if mapper is None: mapper = ColumnMapper() @@ -77,7 +79,7 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T self._dataframe = pandas.read_csv(file, delimiter='\t', header=pandas_header, dtype=str, keep_default_na=True, na_values=None) except Exception as e: - raise HedFileError(HedExceptions.GENERIC_ERROR, str(e), self.name) from e + raise HedFileError(HedExceptions.INVALID_FILE_FORMAT, str(e), self.name) from e # Convert nan values to a known value self._dataframe = self._dataframe.fillna("n/a") elif input_type in self.EXCEL_EXTENSION: @@ -96,7 +98,7 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T # todo: Can we get rid of this behavior now that we're using pandas? column_issues = ColumnMapper.check_for_blank_names(self.columns, allow_blank_names=allow_blank_names) if column_issues: - raise HedFileError(HedExceptions.BAD_COLUMN_NAMES, "Duplicate or blank columns found. See issues.", + raise HedFileError(HedExceptions.BAD_COLUMN_NAMES, "Duplicate or blank columns found. See issues.", self.name, issues=column_issues) self.reset_mapper(mapper) @@ -287,7 +289,7 @@ def set_cell(self, row_number, column_number, new_string_obj, tag_form="short_ta Notes: Any attribute of a HedTag that returns a string is a valid value of tag_form. - + :raises ValueError: - There is not a loaded dataframe diff --git a/hed/models/sidecar.py b/hed/models/sidecar.py index 867ba2e20..d3038fff6 100644 --- a/hed/models/sidecar.py +++ b/hed/models/sidecar.py @@ -127,15 +127,13 @@ def load_sidecar_file(self, file): if not file: return {} elif isinstance(file, str): + if not self.name: + self.name = file try: with open(file, "r") as fp: - if not self.name: - self.name = file return self._load_json_file(fp) except OSError as e: raise HedFileError(HedExceptions.FILE_NOT_FOUND, e.strerror, file) from e - except TypeError as e: - raise HedFileError(HedExceptions.FILE_NOT_FOUND, str(e), file) from e else: return self._load_json_file(file)