Repository: hed-standard/hed-python (language: python)

Issue:
Def-expand not in its own tag group
When definitions are expanded, the Def-expand tag should be in its own tag group that includes the definition's value:

(Def-expand/play-movie, (xxxxx))

The Def-expand doesn't seem to be in any tag group when definitions are expanded during assembly.


Discussion / hints:
Verified there's an issue with processing base file input with an operation(eg expanding def tags)

Fix will be in later today...

Fix patch:
diff --git a/hedtools/hed/errors/error_types.py b/hedtools/hed/errors/error_types.py
index 843a3eacb..224014c46 100644
--- a/hedtools/hed/errors/error_types.py
+++ b/hedtools/hed/errors/error_types.py
@@ -80,8 +80,7 @@ class SidecarErrors:
 
 class SchemaErrors:
     DUPLICATE_TERMS = 'duplicateTerms'
-    # todo: look at what this should be called.
-    UNKNOWN_ATTRIBUTE = 'unknownAttribute'
+    UNKNOWN_ATTRIBUTE = 'HED_SCHEMA_ATTRIBUTE_INVALID'
 
 
 class SchemaWarnings:
diff --git a/hedtools/hed/models/base_input.py b/hedtools/hed/models/base_input.py
index 6f8d93955..9b97b01e8 100644
--- a/hedtools/hed/models/base_input.py
+++ b/hedtools/hed/models/base_input.py
@@ -11,6 +11,7 @@
 from hed.models import model_constants
 from hed.models.util import translate_ops
 from hed.models.onset_mapper import OnsetMapper
+from hed.models.hed_string import HedString
 
 
 class BaseInput:
@@ -323,6 +324,9 @@ def iter_dataframe(self, mapper=None, return_row_dict=False, validators=None, ex
                 for hed_string_obj in column_to_hed_tags.values():
                     hed_string_obj.apply_ops(tag_ops)
             if return_row_dict:
+                # Todo: refactor this part so it's always run after tag ops, even on the validators.
+                final_hed_string = HedString.create_from_other(column_to_hed_tags.values())
+                row_dict[model_constants.ROW_HED_STRING] = final_hed_string
                 yield row_number + start_at_one, row_dict
             else:
                 yield row_number + start_at_one, column_to_hed_tags
@@ -361,26 +365,6 @@ def set_cell(self, row_number, column_number, new_string_obj, include_column_pre
             adj_row_number += 1
         self._dataframe.iloc[row_number - adj_row_number, column_number - 1] = new_text
 
-    @staticmethod
-    def _get_row_hed_tags_from_dict(row_dict):
-        """Reads in the current row of HED tags from the Excel file. The hed tag columns will be concatenated to form a
-           HED string.
-
-        Parameters
-        ----------
-        row_dict: dict
-            Contains the parsed info from a specific worksheet row.
-            the "HED" entry contains the combined hed string for a given row
-        Returns
-        -------
-        hed_string: str
-            a HED string containing the concatenated HED tag columns.
-        column_tags_dict: dict
-            dictionary which associates columns with HED tags
-
-        """
-        return row_dict[model_constants.ROW_HED_STRING], row_dict[model_constants.COLUMN_TO_HED_TAGS]
-
     def get_worksheet(self, worksheet_name=None):
         """
             Returns the requested worksheet from the workbook by name
diff --git a/hedtools/hed/models/column_mapper.py b/hedtools/hed/models/column_mapper.py
index e1c6d7035..cbc3b4848 100644
--- a/hedtools/hed/models/column_mapper.py
+++ b/hedtools/hed/models/column_mapper.py
@@ -222,8 +222,6 @@ def expand_row_tags(self, row_text):
         result_dict[model_constants.COLUMN_TO_HED_TAGS] = column_to_hed_tags_dictionary
         if column_issues_dict:
             result_dict[model_constants.COLUMN_ISSUES] = column_issues_dict
-        final_hed_string = HedString.create_from_other(column_to_hed_tags_dictionary.values())
-        result_dict[model_constants.ROW_HED_STRING] = final_hed_string
 
         return result_dict
 


Test patch:
diff --git a/hedtools/tests/models/test_column_mapper.py b/hedtools/tests/models/test_column_mapper.py
index 452e4dfaf..b8af34e51 100644
--- a/hedtools/tests/models/test_column_mapper.py
+++ b/hedtools/tests/models/test_column_mapper.py
@@ -205,7 +205,7 @@ def test_add_prefix_verify_short_tag_read(self):
             expected_result = expected_results[test_key]
 
             expanded_row = column_mapper.expand_row_tags([test_string])
-            prepended_hed_string = expanded_row[model_constants.ROW_HED_STRING]
+            prepended_hed_string = expanded_row[model_constants.COLUMN_TO_HED_TAGS][1]
             self.assertEqual(expected_result, str(prepended_hed_string))
 
 
diff --git a/hedtools/tests/models/test_hed_file_input.py b/hedtools/tests/models/test_hed_file_input.py
index a86fbc4a2..fd9b6ec66 100644
--- a/hedtools/tests/models/test_hed_file_input.py
+++ b/hedtools/tests/models/test_hed_file_input.py
@@ -4,6 +4,7 @@
 
 from hed import HedInput, HedString, Sidecar, EventsInput, HedFileError
 import shutil
+from hed.models import model_constants
 
 
 class Test(unittest.TestCase):
@@ -48,9 +49,9 @@ def test_all(self):
 
     def test_get_row_hed_tags(self):
         row_dict = self.generic_file_input._mapper.expand_row_tags(self.row_with_hed_tags)
-        hed_string, column_to_hed_tags_dictionary = self.generic_file_input._get_row_hed_tags_from_dict(row_dict)
-        self.assertIsInstance(hed_string, HedString)
-        self.assertTrue(hed_string)
+        column_to_hed_tags_dictionary = row_dict[model_constants.COLUMN_TO_HED_TAGS]
+        #self.assertIsInstance(hed_string, HedString)
+        #self.assertTrue(hed_string)
         self.assertIsInstance(column_to_hed_tags_dictionary, dict)
         self.assertTrue(column_to_hed_tags_dictionary)
 
diff --git a/hedtools/tests/validator/test_tag_validator.py b/hedtools/tests/validator/test_tag_validator.py
index 542030160..329b0e9ac 100644
--- a/hedtools/tests/validator/test_tag_validator.py
+++ b/hedtools/tests/validator/test_tag_validator.py
@@ -235,6 +235,22 @@ def test_extensions(self):
         }
         self.validator_semantic(test_strings, expected_results, expected_issues, False)
 
+    def test_extension_warning(self):
+        test_strings = {
+            'noWarning': "Condition-variable/ValidExt",
+            'warning': "Task-property/WarningExt"
+        }
+        expected_results = {
+            'noWarning': True,
+            'warning': False,
+        }
+        expected_issues = {
+            'noWarning': [],
+            'warning': self.format_error_but_not_really(ValidationErrors.HED_TAG_EXTENDED, tag=0,
+                                                                 index_in_tag=13, index_in_tag_end=None),
+        }
+        self.validator_semantic(test_strings, expected_results, expected_issues, True)
+
     def test_invalid_placeholder_in_normal_string(self):
         test_strings = {
             'invalidPlaceholder': 'Duration/# ms',