Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ee957d9
First pass on allowing external working directory for remodeling
VisLab Apr 12, 2023
6529ca5
Fixed alt directory summary location
VisLab Apr 12, 2023
8662b7b
Merge pull request #650 from VisLab/develop
VisLab Apr 12, 2023
c349d1f
Improve def-gatherer. Very much improve spec tests/related validator…
IanCa Apr 12, 2023
a9cb39f
Get rid of continue-on-error in spec tests
IanCa Apr 12, 2023
b94f99a
Point spec_tests to the single test file.
IanCa Apr 12, 2023
46035b8
Merge pull request #651 from IanCa/develop
VisLab Apr 13, 2023
edbaef2
Update CHARACTER_INVALID and STYLE_WARNING tests.
IanCa Apr 13, 2023
c6f40ee
point to new spec version
IanCa Apr 13, 2023
6f3d888
Merge pull request #652 from IanCa/develop
VisLab Apr 13, 2023
2508473
Update merged schemas to support rooted tags
IanCa Apr 24, 2023
daa260e
Merge pull request #654 from IanCa/develop
VisLab Apr 25, 2023
83e6c8d
Added --no-summaries and --no-update options to run_remodel
VisLab Apr 25, 2023
5752965
Merge pull request #655 from VisLab/develop
VisLab Apr 25, 2023
32d6b81
Added badges to the README
VisLab Apr 26, 2023
f325deb
Tried a different badge
VisLab Apr 26, 2023
f254589
Merge pull request #656 from VisLab/develop
VisLab Apr 26, 2023
f10553a
Updated the imports for df_util
VisLab Apr 28, 2023
b7ea0e7
Merge pull request #657 from VisLab/develop
VisLab Apr 28, 2023
5960256
Fixed more incomplete imports in models
VisLab May 2, 2023
191ee7c
Merge pull request #658 from VisLab/develop
VisLab May 2, 2023
de0a46f
Added df_util to models init
VisLab May 2, 2023
35f4b6e
Merge pull request #659 from VisLab/develop
VisLab May 2, 2023
6718261
Initial conversion of square brackets to curly braces
IanCa Apr 26, 2023
4a0202e
Add sidecar brace support
IanCa May 8, 2023
4fa1ff0
disable inset tests/fix bad param
IanCa May 8, 2023
4fd9541
Merge pull request #660 from IanCa/dev3
VisLab May 9, 2023
b2d31b7
Make sure setting hed strings can handle empty
IanCa May 9, 2023
fe0d57b
Add Inset tag validation, enable inset spec tests
IanCa May 9, 2023
bff1513
Fix typo
IanCa May 9, 2023
c8759ae
Update dependabot.yml
IanCa May 9, 2023
1b8aee6
Merge pull request #662 from IanCa/develop
VisLab May 10, 2023
26f4ca4
Remove werkzeug requirement, replace generate_filename
IanCa May 11, 2023
65af0aa
Merge pull request #663 from IanCa/develop
VisLab May 11, 2023
6ef0fdc
Added values_per_line and max_categorical to value summary
VisLab May 13, 2023
5e92fbc
Refactored the summaries to pass op and added limits to column value …
VisLab May 14, 2023
2484a6e
Merge pull request #664 from VisLab/develop
VisLab May 14, 2023
294c133
Add 8.2.0 xml directly
IanCa May 15, 2023
adf4889
Switch baseinput/column mapper back to 0 based. Clarify documentatio…
IanCa May 19, 2023
9dcc412
Add a quick spreadsheet validator test
IanCa May 19, 2023
11aa7e0
Merge pull request #666 from IanCa/develop
VisLab May 19, 2023
251b1bf
Minor test changes
VisLab May 19, 2023
36f8356
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab May 19, 2023
ddb40df
Fix to_excel function for new system
IanCa May 23, 2023
57ac1f4
Merge pull request #667 from IanCa/develop
VisLab May 23, 2023
e18e4f2
Resolved conflict in tests
VisLab May 23, 2023
d20d29e
Remove output_assemelbed parameter. Update requirements.txt
IanCa May 24, 2023
bb0b2de
Lower numpy req for python 3.7
IanCa May 24, 2023
fef387e
Lower pandas back down to max for 3.7
IanCa May 24, 2023
2a5f911
Merge pull request #668 from IanCa/develop
VisLab May 25, 2023
4ab33f6
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab May 25, 2023
a247921
Don't add the inLibrary attribute if no withStandard partner
IanCa May 25, 2023
045ee7f
Tweak another save merged spot
IanCa May 25, 2023
813d3de
Merge pull request #669 from IanCa/develop
VisLab May 26, 2023
8e2ba3a
Rewrite column mapper, add more unit tests for it
IanCa May 26, 2023
a89641e
Minor code improvements
IanCa May 26, 2023
ef53a87
rename one variable to be more clear
IanCa May 26, 2023
a4c47eb
Change rooted implementation to new system
IanCa May 29, 2023
d993512
Update tests, further fixes
IanCa May 30, 2023
4f85345
Merge pull request #670 from IanCa/develop
VisLab May 30, 2023
83c61a5
Merge pull request #672 from IanCa/dev_change_rooted2
VisLab May 30, 2023
95b5276
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab Jun 1, 2023
d4e1290
Updated local cache testing to delete cache before start
VisLab Jun 1, 2023
c68ddd8
Merge pull request #674 from VisLab/develop
VisLab Jun 1, 2023
e08c735
Merge branch 'master' of https://github.com/hed-standard/hed-python i…
VisLab Jun 1, 2023
84977f9
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab Jun 1, 2023
0a44970
Minor update to force synchronization
VisLab Jun 1, 2023
5e286ca
Merge pull request #675 from VisLab/develop
VisLab Jun 1, 2023
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: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ updates:
interval: "daily"
target-branch: "develop"
directory: /
automerge: true
3 changes: 1 addition & 2 deletions .github/workflows/spec_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:

- name: Test with unittest
run: |
python -m unittest spec_tests/* > test_results.txt
continue-on-error: true
python -m unittest spec_tests/test_errors.py > test_results.txt

- name: Upload spec test results
uses: actions/upload-artifact@v3
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/11bf2329590e7b0164ba/maintainability)](https://codeclimate.com/github/hed-standard/hed-python/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/11bf2329590e7b0164ba/test_coverage)](https://codeclimate.com/github/hed-standard/hed-python/test_coverage)
![PyPI - Status](https://img.shields.io/pypi/v/hedtools)

# HEDTools - Python
HED (Hierarchical Event Descriptors) is a framework for systematically describing
both laboratory and real-world events as well as other experimental metadata.
Expand Down Expand Up @@ -95,7 +99,7 @@ Use `hed.schema.set_cache_directory` to change the location.
The HED cache can be shared across processes.

Starting with `hedtools 0.2.0` local copies of the most recent schema versions
are stored within the code modules for easy access.
are stored within the code modules for easy access.

### Other links of interest

Expand Down
12 changes: 5 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
defusedxml>=0.7.1
inflect>=5.5.1
inflect>=6.0.2
myst-parser>=0.18.1
openpyxl>=3.0.9
numpy>=1.21.6
openpyxl>=3.1.0
pandas>=1.3.5
portalocker>=2.4.0
semantic_version>=2.9.0
portalocker>=2.7.0
semantic_version>=2.10.0
Sphinx>=5.2.2
sphinx_rtd_theme>=1.0.0

# This is just needed for secure_filename and should probably be removed
Werkzeug>=2.1.2
3 changes: 2 additions & 1 deletion hed/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .error_reporter import ErrorHandler, get_printable_issue_string, sort_issues
from .error_types import DefinitionErrors, OnsetErrors, SchemaErrors, SchemaWarnings, SidecarErrors, ValidationErrors
from .error_types import DefinitionErrors, OnsetErrors, SchemaErrors, SchemaWarnings, SidecarErrors, \
ValidationErrors, ColumnErrors
from .error_types import ErrorContext, ErrorSeverity
from .exceptions import HedExceptions, HedFileError
179 changes: 119 additions & 60 deletions hed/errors/error_messages.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions hed/errors/error_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@

# ErrorContext which is expected to be int based.
int_sort_list = [
ErrorContext.ROW,
ErrorContext.COLUMN,
ErrorContext.ROW
]

hed_string_sort_list = [
Expand Down Expand Up @@ -397,10 +396,9 @@ def val_error_unknown(*args, **kwargs):

Returns:
str: The error message.
dict: The extra args.

"""
return f"Unknown error. Args: {str(args)}", kwargs
return f"Unknown error. Args: {str(args), str(kwargs)}"

@staticmethod
def filter_issues_by_severity(issues_list, severity):
Expand Down
103 changes: 60 additions & 43 deletions hed/errors/error_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,30 @@ class ValidationErrors:
DEF_EXPAND_INVALID = "DEF_EXPAND_INVALID"
DEF_INVALID = "DEF_INVALID"
DEFINITION_INVALID = "DEFINITION_INVALID"

# NOT OFFICIAL
NODE_NAME_EMPTY = 'NODE_NAME_EMPTY'
ONSET_OFFSET_INSET_ERROR = 'ONSET_OFFSET_INSET_ERROR'
PARENTHESES_MISMATCH = 'PARENTHESES_MISMATCH'
PLACEHOLDER_INVALID = 'PLACEHOLDER_INVALID'
REQUIRED_TAG_MISSING = 'REQUIRED_TAG_MISSING'
SIDECAR_INVALID = 'SIDECAR_INVALID'
SIDECAR_KEY_MISSING = 'SIDECAR_KEY_MISSING'
STYLE_WARNING = "STYLE_WARNING"
TAG_EMPTY = 'TAG_EMPTY'
TAG_EXPRESSION_REPEATED = 'TAG_EXPRESSION_REPEATED'
TAG_EXTENDED = 'TAG_EXTENDED'
TAG_EXTENSION_INVALID = 'TAG_EXTENSION_INVALID'
TAG_GROUP_ERROR = "TAG_GROUP_ERROR"
TAG_INVALID = "TAG_INVALID"
TAG_NOT_UNIQUE = 'TAG_NOT_UNIQUE'
TAG_PREFIX_INVALID = 'TAG_PREFIX_INVALID'
TAG_REQUIRES_CHILD = 'TAG_REQUIRES_CHILD'
TILDES_UNSUPPORTED = 'TILDES_UNSUPPORTED'
UNITS_INVALID = 'UNITS_INVALID'
UNITS_MISSING = 'UNITS_MISSING'
VERSION_DEPRECATED = 'VERSION_DEPRECATED'
VALUE_INVALID = 'VALUE_INVALID'

# Internal codes
HED_DEF_UNMATCHED = "HED_DEF_UNMATCHED"
HED_DEF_VALUE_MISSING = "HED_DEF_VALUE_MISSING"
HED_DEF_VALUE_EXTRA = "HED_DEF_VALUE_EXTRA"
Expand All @@ -37,57 +59,41 @@ class ValidationErrors:
HED_DEF_EXPAND_UNMATCHED = "HED_DEF_EXPAND_UNMATCHED"
HED_DEF_EXPAND_VALUE_MISSING = "HED_DEF_EXPAND_VALUE_MISSING"
HED_DEF_EXPAND_VALUE_EXTRA = "HED_DEF_EXPAND_VALUE_EXTRA"
# END NOT OFFICIAL

HED_NODE_NAME_EMPTY = 'HED_NODE_NAME_EMPTY'
HED_ONSET_OFFSET_ERROR = 'HED_ONSET_OFFSET_ERROR'
HED_PARENTHESES_MISMATCH = 'HED_PARENTHESES_MISMATCH'
HED_PLACEHOLDER_INVALID = 'HED_PLACEHOLDER_INVALID'
HED_REQUIRED_TAG_MISSING = 'HED_REQUIRED_TAG_MISSING'
HED_SIDECAR_KEY_MISSING = 'HED_SIDECAR_KEY_MISSING'
HED_STYLE_WARNING = 'HED_STYLE_WARNING'
HED_TAG_EMPTY = 'HED_TAG_EMPTY'
HED_TAG_EXTENDED = 'HED_TAG_EXTENDED'
HED_TAG_GROUP_ERROR = "HED_TAG_GROUP_ERROR"
HED_TAG_INVALID = "HED_TAG_INVALID"
HED_TAG_NOT_UNIQUE = 'HED_TAG_NOT_UNIQUE'

HED_TAG_REPEATED = 'HED_TAG_REPEATED'
HED_TAG_REPEATED_GROUP = 'HED_TAG_REPEATED_GROUP'
HED_TAG_REQUIRES_CHILD = 'HED_TAG_REQUIRES_CHILD'
HED_TILDES_UNSUPPORTED = 'HED_TILDES_UNSUPPORTED'
HED_UNITS_INVALID = 'HED_UNITS_INVALID'
HED_UNITS_DEFAULT_USED = 'HED_UNITS_DEFAULT_USED'
HED_VALUE_INVALID = 'HED_VALUE_INVALID'
HED_LIBRARY_UNMATCHED = "HED_LIBRARY_UNMATCHED"
TAG_PREFIX_INVALID = "TAG_PREFIX_INVALID"
# HED_VERSION_WARNING

HED_MISSING_REQUIRED_COLUMN = "HED_MISSING_REQUIRED_COLUMN"
HED_UNKNOWN_COLUMN = "HED_UNKNOWN_COLUMN"
HED_DUPLICATE_COLUMN = "HED_DUPLICATE_COLUMN"
HED_BLANK_COLUMN = "HED_BLANK_COLUMN"


# Below here shows what the given error maps to
HED_GROUP_EMPTY = 'emptyHedGroup'
INVALID_TAG_CHARACTER = 'invalidTagCharacter'

# These are all HED_TAG_INVALID
INVALID_EXTENSION = 'invalidExtension'
INVALID_PARENT_NODE = "invalidParent"
NO_VALID_TAG_FOUND = "invalidTag"

# These are misc errors that need categorization.
HED_LIBRARY_UNMATCHED = "HED_LIBRARY_UNMATCHED"

HED_TOP_LEVEL_TAG = "HED_TOP_LEVEL_TAG"
HED_MULTIPLE_TOP_TAGS = "HED_MULTIPLE_TOP_TAGS"
HED_TAG_GROUP_TAG = "HED_TAG_GROUP_TAG"

HED_GROUP_EMPTY = 'HED_GROUP_EMPTY'
# end internal codes


# Still being worked on below this line

HED_MISSING_REQUIRED_COLUMN = "HED_MISSING_REQUIRED_COLUMN"
HED_UNKNOWN_COLUMN = "HED_UNKNOWN_COLUMN"
SIDECAR_AND_OTHER_COLUMNS = "SIDECAR_AND_OTHER_COLUMNS"

DUPLICATE_COLUMN_IN_LIST = "DUPLICATE_COLUMN_IN_LIST"
DUPLICATE_COLUMN_BETWEEN_SOURCES = "DUPLICATE_COLUMN_BETWEEN_SOURCES"
HED_BLANK_COLUMN = "HED_BLANK_COLUMN"

# Below here shows what the given error maps to

INVALID_TAG_CHARACTER = 'invalidTagCharacter'



class SidecarErrors:
# These are for json sidecar validation errors(sidecars can also produce most normal validation errors)
SIDECAR_INVALID = "SIDECAR_INVALID" # this is the generic error reported for several later ones
BLANK_HED_STRING = 'blankValueString'
WRONG_HED_DATA_TYPE = 'wrongHedDataType'
INVALID_POUND_SIGNS_VALUE = 'invalidNumberPoundSigns'
Expand All @@ -96,10 +102,13 @@ class SidecarErrors:
SIDECAR_HED_USED_COLUMN = 'SIDECAR_HED_USED_COLUMN'
SIDECAR_NA_USED = 'SIDECAR_NA_USED'
SIDECAR_HED_USED = 'SIDECAR_HED_USED'
SIDECAR_BRACES_INVALID = "SIDECAR_BRACES_INVALID"


class SchemaErrors:
HED_SCHEMA_DUPLICATE_NODE = 'HED_SCHEMA_DUPLICATE_NODE'
HED_SCHEMA_ATTRIBUTE_INVALID = 'HED_SCHEMA_ATTRIBUTE_INVALID'
HED_SCHEMA_DUPLICATE_FROM_LIBRARY = "SCHEMA_LIBRARY_INVALID"


class SchemaWarnings:
Expand All @@ -109,27 +118,35 @@ class SchemaWarnings:
HED_SCHEMA_CHARACTER_INVALID = "HED_SCHEMA_CHARACTER_INVALID"
INVALID_CAPITALIZATION = 'invalidCaps'
NON_PLACEHOLDER_HAS_CLASS = 'NON_PLACEHOLDER_HAS_CLASS'
INVALID_ATTRIBUTE = "INVALID_ATTRIBUTE"


# These are all DEFINITION_INVALID errors
class DefinitionErrors:
DEF_TAG_IN_DEFINITION = 'DEF_TAG_IN_DEFINITION'
WRONG_NUMBER_GROUP_TAGS = 'wrongNumberGroupTags'
# These are all DEFINITION_INVALID errors
WRONG_NUMBER_PLACEHOLDER_TAGS = 'wrongNumberPlaceholderTags'
DUPLICATE_DEFINITION = 'duplicateDefinition'
TAG_IN_SCHEMA = 'defAlreadyInSchema'
INVALID_DEFINITION_EXTENSION = 'invalidDefExtension'
DEF_TAG_IN_DEFINITION = 'DEF_TAG_IN_DEFINITION'
NO_DEFINITION_CONTENTS = "NO_DEFINITION_CONTENTS"
PLACEHOLDER_NO_TAKES_VALUE = 'PLACEHOLDER_NO_TAKES_VALUE'

WRONG_NUMBER_TAGS = 'WRONG_NUMBER_TAGS'
WRONG_NUMBER_GROUPS = 'WRONG_NUMBER_GROUPS'
BAD_PROP_IN_DEFINITION = 'BAD_PROP_IN_DEFINITION'

BAD_DEFINITION_LOCATION = 'BAD_DEFINITION_LOCATION'


class OnsetErrors:
# These are all ONSET_OFFSET_INSET_ERROR
OFFSET_BEFORE_ONSET = "OFFSET_BEFORE_ONSET"
ONSET_DEF_UNMATCHED = "ONSET_DEF_UNMATCHED"
ONSET_WRONG_NUMBER_GROUPS = "ONSET_WRONG_NUMBER_GROUPS"
ONSET_NO_DEF_TAG_FOUND = "ONSET_NO_DEF_TAG_FOUND"
ONSET_PLACEHOLDER_WRONG = "ONSET_PLACEHOLDER_WRONG"
ONSET_TOO_MANY_DEFS = "ONSET_TOO_MANY_DEFS"
ONSET_TAG_OUTSIDE_OF_GROUP = "ONSET_TAG_OUTSIDE_OF_GROUP"

INSET_BEFORE_ONSET = "INSET_BEFORE_ONSET"

class ColumnErrors:
INVALID_COLUMN_REF = "INVALID_COLUMN_REF"
Expand Down
17 changes: 13 additions & 4 deletions hed/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ class HedExceptions:
# 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'
BAD_HED_LIBRARY_NAME = 'badHedLibraryName'

SCHEMA_LIBRARY_INVALID = "SCHEMA_LIBRARY_INVALID"
BAD_HED_LIBRARY_NAME = 'SCHEMA_LIBRARY_INVALID'
BAD_WITH_STANDARD = "SCHEMA_LIBRARY_INVALID"
BAD_WITH_STANDARD_VERSION = "SCHEMA_LIBRARY_INVALID"
ROOTED_TAG_INVALID = "SCHEMA_LIBRARY_INVALID"
ROOTED_TAG_HAS_PARENT = "SCHEMA_LIBRARY_INVALID"
ROOTED_TAG_DOES_NOT_EXIST = "SCHEMA_LIBRARY_INVALID"
IN_LIBRARY_IN_UNMERGED = "SCHEMA_LIBRARY_INVALID"

HED_SCHEMA_VERSION_INVALID = 'HED_SCHEMA_VERSION_INVALID'
SCHEMA_START_MISSING = 'HED_WIKI_SEPARATOR_INVALID'
SCHEMA_END_INVALID = 'HED_WIKI_SEPARATOR_INVALID'
Expand All @@ -31,14 +40,14 @@ class HedExceptions:

class HedFileError(Exception):
"""Exception raised when a file cannot be parsed due to being malformed, file IO, etc."""
def __init__(self, error_type, message, filename, issues=None):
self.error_type = error_type
def __init__(self, code, message, filename, issues=None):
self.code = code
self.message = message
self.filename = filename
self.issues = issues
if self.issues is None:
self.issues = [
{'message': message,
ErrorContext.FILE_NAME: filename,
'error_code': error_type}
'code': code}
]
1 change: 1 addition & 0 deletions hed/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
from .sidecar import Sidecar
from .tabular_input import TabularInput
from .timeseries_input import TimeseriesInput
from .df_util import get_assembled, convert_to_form, shrink_defs, expand_defs, process_def_expands
Loading