Skip to content

Commit e2b6fb7

Browse files
authored
Remove use_ datatype e.g. use_behav configurations. (#227)
* Remove 'use_' datatype settings from datashuttle code. * Update all tests to remove use_datatype flag. * Remove 'all' default for datatype for make_sub_folders and change to '' which will make no datatype by default. * Fix rebase. * Fix documentation. * Fix linting after rebase. * Fix broken test after rebase.
1 parent 6615b8b commit e2b6fb7

13 files changed

+80
-217
lines changed

datashuttle/command_line_interface.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -520,34 +520,6 @@ def construct_parser():
520520
action="store_true",
521521
help=help("flag_default_false"),
522522
)
523-
make_config_file_parser.add_argument(
524-
"--use-ephys",
525-
"--use_ephys",
526-
required=False,
527-
action="store_true",
528-
help=help("flag_default_false"),
529-
)
530-
make_config_file_parser.add_argument(
531-
"--use-behav",
532-
"--use_behav",
533-
required=False,
534-
action="store_true",
535-
help=help("flag_default_false"),
536-
)
537-
make_config_file_parser.add_argument(
538-
"--use-funcimg",
539-
"--use_funcimg",
540-
required=False,
541-
action="store_true",
542-
help=help("flag_default_false"),
543-
)
544-
make_config_file_parser.add_argument(
545-
"--use-histology",
546-
"--use_histology",
547-
required=False,
548-
action="store_true",
549-
help=help("flag_default_false"),
550-
)
551523

552524
make_config_file_parser = subparsers.add_parser(
553525
"update-config",
@@ -627,7 +599,7 @@ def construct_parser():
627599
type=str,
628600
nargs="+",
629601
required=False,
630-
default="all", # TODO: this is not nice, should read the default from API NOT duplicate in CLI
602+
default="", # TODO: this is not nice, should read the default from API NOT duplicate in CLI
631603
help=help("required_str_single_or_multiple_or_all"),
632604
)
633605

datashuttle/configs/canonical_configs.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,23 @@ def get_canonical_config_dict() -> dict:
3838
"show_transfer_progress": None,
3939
}
4040

41-
datatype_configs = get_datatypes(as_dict=True)
42-
config_dict.update(datatype_configs)
43-
4441
return config_dict
4542

4643

47-
def get_datatypes(as_dict: bool = False):
44+
def get_datatypes() -> List[str]:
4845
"""
49-
Canonical list of datatype flags. This is used
50-
to define get_canonical_config_dict() as well
51-
as in testing.
46+
Canonical list of datatype flags based on
47+
NeuroBlueprint.
5248
"""
53-
keys = ["use_ephys", "use_behav", "use_funcimg", "use_histology"]
54-
55-
if as_dict:
56-
return dict(zip(keys, [None] * len(keys)))
57-
else:
58-
return keys
49+
return ["ephys", "behav", "funcimg", "histology"]
5950

6051

6152
def get_flags() -> List[str]:
6253
"""
6354
Return all configs that are bool flags. This is used in
6455
testing and type checking config inputs.
6556
"""
66-
return get_datatypes() + [
57+
return [
6758
"overwrite_old_files",
6859
"show_transfer_progress",
6960
]
@@ -83,10 +74,6 @@ def get_canonical_config_required_types() -> dict:
8374
"overwrite_old_files": bool,
8475
"transfer_verbosity": Literal["v", "vv"],
8576
"show_transfer_progress": bool,
86-
"use_ephys": bool,
87-
"use_behav": bool,
88-
"use_funcimg": bool,
89-
"use_histology": bool,
9077
}
9178

9279
assert (
@@ -168,12 +155,6 @@ def check_dict_values_raise_on_fail(config_dict: Configs) -> None:
168155
f"The passed path was {config_dict[path_type]}"
169156
)
170157

171-
if not any([config_dict[key] for key in get_datatypes()]):
172-
utils.log_and_raise_error(
173-
f"At least one datatype must be True in "
174-
f"configs, from: {' '.join(get_datatypes())}."
175-
)
176-
177158
# Check SSH settings
178159
if config_dict["connection_method"] == "ssh" and (
179160
not config_dict["central_host_id"]

datashuttle/configs/canonical_folders.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,23 @@ def get_datatype_folders(cfg: Configs) -> dict:
3636
This should always match the canonical name, but left as
3737
an option for rare cases in which advanced users want to change it.
3838
39-
used : whether the folder is used or not (see make_config_file)
40-
if False, the folder will not be made in make_folders
41-
even if selected.
42-
4339
level : "sub" or "ses", level to make the folder at.
44-
45-
Notes
46-
------
47-
48-
In theory, adding a new folder should only require
49-
adding an entry to this dictionary. However, this will not
50-
update configs e.g. use_xxx. This has not been
51-
directly tested yet, but if it does not work when attempted
52-
it should be configured to from then on.
5340
"""
5441
return {
5542
"ephys": Folder(
5643
name="ephys",
57-
used=cfg["use_ephys"],
5844
level="ses",
5945
),
6046
"behav": Folder(
6147
name="behav",
62-
used=cfg["use_behav"],
6348
level="ses",
6449
),
6550
"funcimg": Folder(
6651
name="funcimg",
67-
used=cfg["use_funcimg"],
6852
level="ses",
6953
),
7054
"histology": Folder(
7155
name="histology",
72-
used=cfg["use_histology"],
7356
level="sub",
7457
),
7558
}

datashuttle/datashuttle.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def make_folders(
159159
self,
160160
sub_names: Union[str, list],
161161
ses_names: Optional[Union[str, list]] = None,
162-
datatype: Union[List[str], str] = "all",
162+
datatype: str = "",
163163
) -> None:
164164
"""
165165
Create a subject / session folder tree in the project
@@ -180,11 +180,10 @@ def make_folders(
180180
folders are made.
181181
datatype :
182182
The datatype to make in the sub / ses folders.
183-
(e.g. "ephys", "behav", "histology"). Only datatypes
184-
that are enabled in the configs (e.g. use_behav) will be
185-
created. If "all" is selected, folders will be created
186-
for all datatype enabled in config. Use empty string "" for
187-
none.
183+
(e.g. "ephys", "behav", "histology"). If "all"
184+
is selected, all datatypes permitted in
185+
NeuroBlueprint will be created. If "" is passed
186+
no datatype will be created.
188187
189188
Notes
190189
-----
@@ -616,10 +615,6 @@ def make_config_file(
616615
overwrite_old_files: bool = False,
617616
transfer_verbosity: str = "v",
618617
show_transfer_progress: bool = False,
619-
use_ephys: bool = False,
620-
use_behav: bool = False,
621-
use_funcimg: bool = False,
622-
use_histology: bool = False,
623618
) -> None:
624619
"""
625620
Initialise the configurations for datashuttle to use on the
@@ -680,18 +675,6 @@ def make_config_file(
680675
681676
show_transfer_progress :
682677
If true, the real-time progress of file transfers will be printed.
683-
684-
use_ephys :
685-
if True, will allow ephys folder creation
686-
687-
use_funcimg :
688-
if True, will allow funcimg folder creation
689-
690-
use_histology :
691-
if True, will allow histology folder creation
692-
693-
use_behav :
694-
if True, will allow behav folder creation
695678
"""
696679
self._start_log(
697680
"make-config-file",
@@ -712,10 +695,6 @@ def make_config_file(
712695
"overwrite_old_files": overwrite_old_files,
713696
"transfer_verbosity": transfer_verbosity,
714697
"show_transfer_progress": show_transfer_progress,
715-
"use_ephys": use_ephys,
716-
"use_behav": use_behav,
717-
"use_funcimg": use_funcimg,
718-
"use_histology": use_histology,
719698
},
720699
)
721700

datashuttle/utils/folder_class.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class Folder:
99
def __init__(
1010
self,
1111
name: str,
12-
used: bool,
1312
level: str,
1413
):
1514
self.name = name
16-
self.used = used
1715
self.level = level

datashuttle/utils/folders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def make_datatype_folders(
104104
datatype_items = cfg.get_datatype_items(datatype)
105105

106106
for datatype_key, datatype_folder in datatype_items: # type: ignore
107-
if datatype_folder.used and datatype_folder.level == level:
107+
if datatype_folder.level == level:
108108
datatype_path = sub_or_ses_level_path / datatype_folder.name
109109

110110
make_folders(datatype_path, log)

docs/source/pages/documentation.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ The command `make-config-file` is used for the initial setup of the project. The
6868

6969
`connection_method`: `local_filesystem` or `ssh`. Local filesystem can be used if the *central* storage is mounted to the local machine. Otherwise `ssh` can be used.
7070

71-
Finally, the *datatype* flags `--use_ephys`, `--use_funcimg`, `--use_histology`, `--use_behav` set the types of data required for the project on the local machine. While individual flags are optional, at least one must be chosen when initialising the project.
72-
7371
### Optional Arguments
7472

7573
If connection method is `ssh`, the `central_host_id`, `central_host_username` must be set, and a one-time SSH setup command run (see the [SSH section](#ssh) for details).
@@ -92,7 +90,7 @@ ssh \
9290
--central_host_id ssh.swc.ucl.ac.uk \
9391
--central_host_username username \
9492
--transfer_verbosity v \
95-
--use-ephys --use-behav --use-histology --overwrite_old_files
93+
--overwrite_old_files
9694
```
9795

9896

@@ -134,11 +132,8 @@ Another example call, which creates a range of subject and session folders, is s
134132
```
135133
datashuttle \
136134
my_first_project \
137-
make-folders -sub 001@TO@003 -ses 010_@TIME@ -dt all
138-
```
139135
140-
When the `all` argument is used for `--datatype` (`-dt`), the folders created depend on the *datatypes* specified during *configuration* setup. For example, if
141-
`--use_behav`, `--use_funcimg`, `--use_histology` were set during *configuration* setup, the folder tree from the above command (assuming the time is `4.02.48 PM`), would look like:
136+
make-sub-folders -sub 001@TO@003 -ses 010_@TIME@ -dt behav funcimg histology
142137
143138
```
144139
├── sub-001/
@@ -330,9 +325,6 @@ project.make_config_file(
330325
central_host_username="username",
331326
overwrite_old_files=True,
332327
transfer_verbosity="v",
333-
use_ephys=True,
334-
use_behav=True,
335-
use_histology=True,
336328
)
337329
```
338330

0 commit comments

Comments
 (0)