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

Develop updated the archiving in dispatcher #543

Merged
merged 24 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d543e4f
Minor correction to tests (#537)
VisLab Sep 12, 2022
1dafed1
Added datetime option on generate filenames
VisLab Sep 13, 2022
04e4081
Fixed missing exclude_dirs in bids_file_group bug
VisLab Sep 13, 2022
4a71cef
Merge branch 'master' of https://github.com/hed-standard/hed-python i…
VisLab Sep 13, 2022
ac009a9
Corrected the hed type summary format
VisLab Sep 14, 2022
c7efd1e
Started implementation of backup_manager
VisLab Sep 18, 2022
5c8153a
Fixed automerge issues
VisLab Sep 18, 2022
b31c54a
Updated tests for the CLI
VisLab Sep 22, 2022
fed69f5
Updated tests for remodel with hed
VisLab Sep 23, 2022
7e68433
Replaced iteritems with items()
VisLab Sep 23, 2022
ea5bd03
Updating the api docs - no success
VisLab Sep 23, 2022
ecd0a7c
Modified unit test
VisLab Sep 23, 2022
1f597f3
Test with windows path
VisLab Sep 24, 2022
9f7cedb
Still testing get_path_components
VisLab Sep 24, 2022
be51d75
Still working on the path normalization issue for windows paths on linux
VisLab Sep 24, 2022
f49e0a5
Still not getting the current path correctly for path components
VisLab Sep 24, 2022
eaa67d9
Updated the docs
VisLab Sep 24, 2022
a631ca8
generated docs
VisLab Sep 26, 2022
a7d5b3d
Updated rst
VisLab Sep 27, 2022
9376d4e
Correcting merge errors
VisLab Sep 27, 2022
47eb493
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab Sep 27, 2022
e111ad9
Made model required for remodel
VisLab Sep 27, 2022
69d02d0
Merge branch 'develop' of https://github.com/hed-standard/hed-python …
VisLab Sep 27, 2022
a852d59
Corrected dispatcher archive save bug
VisLab Sep 28, 2022
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
2 changes: 1 addition & 1 deletion hed/tools/remodeling/cli/run_remodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_parser():
help="Format for saving any summaries, if any. If empty, then no summaries are saved.")
parser.add_argument("-b", "--bids-format", action='store_true', dest="use_bids",
help="If present, the dataset is in BIDS format with sidecars. HED analysis is available.")
parser.add_argument("-n", "--backup_name", default=BackupManager.DEFAULT_BACKUP_NAME, dest="backup_name",
parser.add_argument("-n", "--backup-name", default=BackupManager.DEFAULT_BACKUP_NAME, dest="backup_name",
help="Name of the default backup for remodeling")
parser.add_argument("-v", "--verbose", action='store_true',
help="If present, output informative messages as computation progresses.")
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/remodeling/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def archive_context(self, archive=None, file_formats=['.txt', '.json'], verbose=
archive = io.BytesIO()
for context_name, context_item in self.context_dict.items():
file_base = generate_filename(context_item.context_filename, append_datetime=True)
with zipfile.ZipFile(archive, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
with zipfile.ZipFile(archive, mode="a", compression=zipfile.ZIP_DEFLATED) as zf:
for file_format in file_formats:
if file_format == '.txt':
summary = context_item.get_text_summary(verbose=True)
Expand Down
18 changes: 13 additions & 5 deletions tests/tools/remodeling/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def test_archive_context(self):
with open(self.archive_zip, "wb") as f: # use `wb` mode
f.write(archive_io.getvalue())
self.assertTrue(os.path.exists(self.archive_zip))
the_zip = zipfile.ZipFile(self.archive_zip)
self.assertFalse(the_zip.testzip())

def test_archive_data_file(self):
file_list = get_file_list(self.test_root_back1, name_suffix='events', extensions=['.tsv'],
Expand All @@ -108,21 +110,27 @@ def test_archive_data_file(self):
for file in file_list:
df = pd.read_csv(file, sep='\t', header=0)
self.assertIsInstance(df, pd.DataFrame)
Dispatcher.archive_data_file(df, file, archive=archive_one)
archive_one = Dispatcher.archive_data_file(df, file, archive=archive_one)
self.assertFalse(os.path.exists(self.archive_zip))
Dispatcher.save_archive(archive_one, self.archive_zip)
self.assertTrue(os.path.exists(self.archive_zip))
the_zip = zipfile.ZipFile(self.archive_zip)
self.assertFalse(the_zip.testzip())

def test_archive_data_file_with_context(self):
with open(self.summarize_model) as fp:
model1 = json.load(fp)
dispatch1 = Dispatcher(model1, data_root=self.test_root_back1, backup_name='back1')
file_list = get_file_list(self.test_root_back1, name_suffix='events', extensions=['.tsv'],
exclude_dirs=['derivatives'])
for file in file_list:
dispatch1.run_operations(file)

archive_io = dispatch1.archive_context()
df = dispatch1.run_operations(file_list[0])
archive_one = io.BytesIO()
archive_one = Dispatcher.archive_data_file(df, file_list[0], archive=archive_one)
archive_one = dispatch1.archive_context(archive=archive_one)
Dispatcher.save_archive(archive_one, self.archive_zip)
self.assertTrue(os.path.exists(self.archive_zip))
the_zip = zipfile.ZipFile(self.archive_zip)
self.assertFalse(the_zip.testzip())

def test_get_context_save_dir(self):
model_path1 = os.path.join(self.data_path, 'simple_reorder_remdl.json')
Expand Down