Skip to content

Commit

Permalink
Added hook to structured_data (row_reader_hook) for integration testi…
Browse files Browse the repository at this point in the history
…ng purposes.
  • Loading branch information
dmichaels-harvard committed Jun 12, 2024
1 parent 348d5de commit fcbfca5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Change Log
======
* Changes related to pyinstaller experimentation for smaht-submitr.
Mostly changing calls to exit to sys.exit; and related license_utils change.
* Added hook to structured_data (row_reader_hook) for integration testing purposes.


8.10.0
Expand Down
4 changes: 4 additions & 0 deletions dcicutils/structured_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, file: Optional[str] = None, portal: Optional[Union[VirtualApp
ref_lookup_nocache: bool = False,
norefs: bool = False, merge: bool = False,
progress: Optional[Callable] = None,
row_reader_hook: Optional[Callable] = None,
debug_sleep: Optional[str] = None) -> None:
self._progress = progress if callable(progress) else None
self._data = {}
Expand All @@ -75,6 +76,7 @@ def __init__(self, file: Optional[str] = None, portal: Optional[Union[VirtualApp
self._autoadd_properties = autoadd if isinstance(autoadd, dict) and autoadd else None
self._norefs = True if norefs is True else False
self._merge = True if merge is True else False # New merge functionality (2024-05-25)
self._row_reader_hook = row_reader_hook if callable(row_reader_hook) else None # Testing support (2024-06-12)
self._debug_sleep = None
if debug_sleep:
try:
Expand Down Expand Up @@ -377,6 +379,8 @@ def _load_reader(self, reader: RowReader, type_name: str) -> None:
structured_row_template = _StructuredRowTemplate(reader.header, schema)
structured_row = structured_row_template.create_row()
for column_name, value in row.items():
if self._row_reader_hook:
value = self._row_reader_hook(reader.sheet_name, column_name, value)
structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number)
if self._autoadd_properties:
self._add_properties(structured_row, self._autoadd_properties, schema)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dcicutils"
version = "8.10.0.1b2" # TODO: To become 8.10.1
version = "8.10.0.1b3" # TODO: To become 8.10.1
description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down

0 comments on commit fcbfca5

Please sign in to comment.