Skip to content

Commit 5c7d754

Browse files
authored
Rename make_sub_folders to make_folders. (#223)
* Rename `make_sub_folders` to `make_folders`. * Rename in docs and tests! * Add missed cases, fix tests. * Fix typo.
1 parent 4f5733c commit 5c7d754

12 files changed

Lines changed: 70 additions & 72 deletions

datashuttle/command_line_interface.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ def setup_ssh_connection_to_central_server(*args: Any) -> None:
187187
# -----------------------------------------------------------------------------
188188

189189

190-
def make_sub_folders(project: DataShuttle, args: Any) -> None:
190+
def make_folders(project: DataShuttle, args: Any) -> None:
191191
""""""
192192
kwargs = make_kwargs(args)
193193

194194
filtered_kwargs = {k: v for k, v in kwargs.items() if v is not None}
195195

196-
run_command(project, project.make_sub_folders, **filtered_kwargs)
196+
run_command(project, project.make_folders, **filtered_kwargs)
197197

198198

199199
# -----------------------------------------------------------------------------
@@ -591,19 +591,19 @@ def construct_parser():
591591
# Make Sub Folder
592592
# ----------------------------------------------------------------------
593593

594-
make_sub_folders_parser = subparsers.add_parser(
595-
"make-sub-folders",
596-
aliases=["make_sub_folders"],
597-
description=process_docstring(DataShuttle.make_sub_folders.__doc__),
594+
make_folders_parser = subparsers.add_parser(
595+
"make-folders",
596+
aliases=["make_folders"],
597+
description=process_docstring(DataShuttle.make_folders.__doc__),
598598
formatter_class=argparse.RawTextHelpFormatter,
599599
help="",
600600
)
601-
make_sub_folders_parser = make_sub_folders_parser.add_argument_group(
601+
make_folders_parser = make_folders_parser.add_argument_group(
602602
"named arguments:"
603603
) # type: ignore
604-
make_sub_folders_parser.set_defaults(func=make_sub_folders)
604+
make_folders_parser.set_defaults(func=make_folders)
605605

606-
make_sub_folders_parser.add_argument(
606+
make_folders_parser.add_argument(
607607
"--sub-names",
608608
"--sub_names",
609609
"-sub",
@@ -612,7 +612,7 @@ def construct_parser():
612612
required=True,
613613
help=help("required_str_single_or_multiple_or_all"),
614614
)
615-
make_sub_folders_parser.add_argument(
615+
make_folders_parser.add_argument(
616616
"--ses-names",
617617
"--ses_names",
618618
"-ses",
@@ -621,7 +621,7 @@ def construct_parser():
621621
required=False,
622622
help="Optional: (str, single or multiple) (selection of datatypes, or 'all')",
623623
)
624-
make_sub_folders_parser.add_argument(
624+
make_folders_parser.add_argument(
625625
"--datatype",
626626
"-dt",
627627
type=str,

datashuttle/configs/canonical_folders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_datatype_folders(cfg: Configs) -> dict:
3737
an option for rare cases in which advanced users want to change it.
3838
3939
used : whether the folder is used or not (see make_config_file)
40-
if False, the folder will not be made in make_sub_folders
40+
if False, the folder will not be made in make_folders
4141
even if selected.
4242
4343
level : "sub" or "ses", level to make the folder at.

datashuttle/datashuttle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def set_top_level_folder(self, folder_name):
131131
Set the working top level folder (e.g. 'rawdata', 'derivatives').
132132
133133
The top_level_folder defines in which top level folder new
134-
sub-folders will be made (e.g. make_sub_folders) or at which level
134+
sub-folders will be made (e.g. make_folders) or at which level
135135
folders are transferred with the commands upload / download
136136
and upload_all / download all.
137137
@@ -155,7 +155,7 @@ def set_top_level_folder(self, folder_name):
155155
self.show_top_level_folder()
156156

157157
@check_configs_set
158-
def make_sub_folders(
158+
def make_folders(
159159
self,
160160
sub_names: Union[str, list],
161161
ses_names: Optional[Union[str, list]] = None,
@@ -204,13 +204,13 @@ def make_sub_folders(
204204
205205
Examples
206206
--------
207-
project.make_sub_folders("sub-001", datatype="all")
207+
project.make_folders("sub-001", datatype="all")
208208
209-
project.make_sub_folders("sub-002@TO@005",
209+
project.make_folders("sub-002@TO@005",
210210
["ses-001", "ses-002"],
211211
["ephys", "behav"])
212212
"""
213-
self._start_log("make-sub-folders", local_vars=locals())
213+
self._start_log("make-folders", local_vars=locals())
214214

215215
self.show_top_level_folder()
216216

@@ -322,7 +322,7 @@ def upload(
322322
transfer was taking place, but no files will be moved. Useful
323323
to check which files will be moved on data transfer.
324324
datatype :
325-
see make_sub_folders()
325+
see make_folders()
326326
327327
init_log :
328328
(Optional). Whether to start the logger. This should
@@ -927,7 +927,7 @@ def show_top_level_folder(self):
927927
'rawdata', 'derivatives')
928928
929929
The top_level_folder defines in which top level folder new
930-
sub-folders will be made (e.g. make_sub_folders) or
930+
sub-folders will be made (e.g. make_folders) or
931931
at which level folders are transferred with the commands
932932
upload / download and upload_all / download all.
933933
upload_specific_folder_or_file / download_specific_folder_or_file.
@@ -1013,7 +1013,7 @@ def check_name_formatting(
10131013
) -> None:
10141014
"""
10151015
Pass list of names to check how these will be auto-formatted,
1016-
for example as when passed to make_sub_folders() or upload()
1016+
for example as when passed to make_folders() or upload()
10171017
or download()
10181018
10191019
Useful for checking tags e.g. @TO@, @DATE@, @DATETIME@, @DATE@.

datashuttle/utils/data_transfer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def check_input_arguments(
250250
):
251251
"""
252252
Check the sub / session names passed. The checking here
253-
is stricter than for make_sub_folderss / formatting.check_and_format_names
253+
is stricter than for make_folders / formatting.check_and_format_names
254254
because we want to ensure that a) non-datatype arguments are not
255255
passed at the wrong input (e.g. all_non_ses as a subject name).
256256

datashuttle/utils/folders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def make_folder_trees(
4141
Parameters
4242
----------
4343
44-
sub_names, ses_names, datatype : see make_sub_folders()
44+
sub_names, ses_names, datatype : see make_folders()
4545
4646
log : whether to log or not. If True, logging must
4747
already be initialised.

docs/source/pages/documentation.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Next, we can start setting up the project by automatically creating standardised
104104

105105
In a typical neuroscience experiment, a data-collection session begins by creating the folder for the current subject (e.g. mouse, rat) and current session. Once created, the data for this session is stored in the created folder.
106106

107-
The command `make-sub-folders` can be used automatically create folder trees that adhere to the [SWC-Blueprint](https://swc-blueprint.neuroinformatics.dev/) specification. The linked specifications contain more detail, but at it's heart this requires:
107+
The command `make-folders` can be used automatically create folder trees that adhere to the [SWC-Blueprint](https://swc-blueprint.neuroinformatics.dev/) specification. The linked specifications contain more detail, but at it's heart this requires:
108108

109109
- All subjects are given a numerical (integer) number that is prefixed with the key `sub-`.
110110
- All sessions are also given a numerical (integer) number that is prefixed with the key `ses-`.
@@ -123,7 +123,7 @@ In DataShuttle, this folder tree (excluding the .mp4 file which must be saved us
123123
```
124124
datashuttle \
125125
my_first_project \
126-
make-sub-folders -sub 001 -ses 001_@DATE@ -dt behav
126+
make-folders -sub 001 -ses 001_@DATE@ -dt behav
127127
```
128128

129129
The leading `sub-` or `ses-` is optional when specifying folders to create (e.g. both `-sub 001` and `-sub sub-001` are valid inputs). It is possible to automatically create date, time or datetime key-value pairs with the days `@DATE@`, `@TIME@` or `@DATETIME@` respectively (see the [below section](#automatically-include-date-time-or-datetime
@@ -134,7 +134,7 @@ Another example call, which creates a range of subject and session folders, is s
134134
```
135135
datashuttle \
136136
my_first_project \
137-
make-sub-folders -sub 001@TO@003 -ses 010_@TIME@ -dt all
137+
make-folders -sub 001@TO@003 -ses 010_@TIME@ -dt all
138138
```
139139

140140
When the `all` argument is used for `--datatype` (`-dt`), the folders created depend on the *datatypes* specified during *configuration* setup. For example, if
@@ -210,7 +210,7 @@ SWC-Blueprint defines two main *top-level folders*, `rawdata` and `derivatives`.
210210
└── ...
211211
```
212212

213-
In DataShuttle, the current working *top level folder* is by default `rawdata`. The working *top level folder* determines where folders are created (e.g. `make_sub_folders`), and from which folder data is transferred.
213+
In DataShuttle, the current working *top level folder* is by default `rawdata`. The working *top level folder* determines where folders are created (e.g. `make_folders`), and from which folder data is transferred.
214214

215215
For example, `upload` or `upload-all` will transfer data with `rawdata` from *local* to *central*, if `rawdata` is the current *top-level folder*. `upload` transfers the specified subset of folders, while `upload-all` will upload the entire *top-level folder*.
216216

@@ -339,7 +339,7 @@ project.make_config_file(
339339
and methods for making subject folders and transferring data accessed similarly. Note that the shortcut arguments `-sub`, `-ses`, `-dt` are not available through the Python API, and the full argument names (`sub_names`, `ses_names`, `datatype`) must be used.
340340

341341
```
342-
project.make_sub_folders(
342+
project.make_folders(
343343
sub_names="sub-001@TO@002",
344344
ses_names="ses-001_@DATE@",
345345
datatype="all"
@@ -392,7 +392,7 @@ For example, the command:
392392
```
393393
datashuttle \
394394
my_first_project \
395-
make_sub_folders \
395+
make_folders \
396396
-sub sub_001@DATE@ \
397397
-ses 001@TIME@ 002@DATETIME@
398398
-dt behav
@@ -432,7 +432,7 @@ Note when making folders with the `@TO@` tag, the maximum number of leading zero
432432
```
433433
datashuttle \
434434
my_first_project \
435-
make_sub_folders \
435+
make_folders \
436436
-sub 0001@TO@02
437437
```
438438

@@ -622,10 +622,10 @@ Similarly, the command `show-configs` will print all currently set *configuratio
622622
Detailed logs of all configuration changes, folder creation and data transfers are logged
623623
to the `.datashuttle` folder that is created in the *local* project folder.
624624

625-
For each command run, a log of that command is placed in the logs folder, with the time and date of the command. The log itself contains relevant information pertaining to that command. For example, if the commands `make_sub_folders`, `upload`, `download` were run sequentially, the logs output folder would look like:
625+
For each command run, a log of that command is placed in the logs folder, with the time and date of the command. The log itself contains relevant information pertaining to that command. For example, if the commands `make_folders`, `upload`, `download` were run sequentially, the logs output folder would look like:
626626

627627
```
628-
20230608T095514_make-sub-folders.log
628+
20230608T095514_make-folders.log
629629
20230608T095545_upload-data.log
630630
20230608T095621_download-data.log
631631
```

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def make_and_check_local_project_folders(
442442
def make_local_folders_with_files_in(
443443
project, subs, sessions=None, datatype="all"
444444
):
445-
project.make_sub_folders(subs, sessions, datatype)
445+
project.make_folders(subs, sessions, datatype)
446446
for root, dirs, files in os.walk(project.cfg["local_path"]):
447447
if not dirs:
448448
path_ = Path(root) / "placeholder_file.txt"

tests/tests_integration/test_command_line_interface.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def test_make_config_file_non_default_variables(self, tmp_path):
173173
self.check_kwargs(changed_configs, kwargs_)
174174

175175
@pytest.mark.parametrize("sep", ["-", "_"])
176-
def test_make_sub_folders_variable(self, sep):
176+
def test_make_folders_variable(self, sep):
177177
stdout, _ = test_utils.run_cli(
178-
f" make{sep}sub{sep}folders "
178+
f" make{sep}folders "
179179
f"--datatype all "
180180
f"--sub_names 001 "
181181
f"--ses_names 002 "
@@ -273,9 +273,7 @@ def test_upload_download_folder_or_file(self, upload_or_download, sep):
273273
assert args_[0] == "/fake/filepath"
274274
assert kwargs_["dry_run"] is True
275275

276-
@pytest.mark.parametrize(
277-
"command", ["make_sub_folders", "upload", "download"]
278-
)
276+
@pytest.mark.parametrize("command", ["make_folders", "upload", "download"])
279277
def test_multiple_inputs(self, command):
280278
"""
281279
To process lists, a syntax "<>" is used
@@ -394,15 +392,15 @@ def test_make_config_file_not_defaults(
394392

395393
test_utils.check_config_file(config_path, changed_configs)
396394

397-
def test_make_sub_folders(self, setup_project):
395+
def test_make_folders(self, setup_project):
398396
"""
399397
see test_filesystem_transfer.py
400398
"""
401399
subs = ["sub-011", "sub-002", "sub-333"]
402400
ses = ["ses-123", "ses-999"]
403401

404402
test_utils.run_cli(
405-
f"make_sub_folders --datatype all --sub_names {self.to_cli_input(subs)} --ses_names {self.to_cli_input(ses)} ",
403+
f"make_folders --datatype all --sub_names {self.to_cli_input(subs)} --ses_names {self.to_cli_input(ses)} ",
406404
setup_project.project_name,
407405
)
408406

tests/tests_integration/test_filesystem_transfer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_transfer_empty_folder_structure(
7474
)
7575

7676
def test_empty_folder_is_not_transferred(self, project):
77-
project.make_sub_folders("sub-001")
77+
project.make_folders("sub-001")
7878
project.upload_all()
7979
assert not (project.cfg["central_path"] / "sub-001").is_dir()
8080

@@ -290,7 +290,7 @@ def test_transfer_with_keyword_parameters(
290290
"""
291291
Test the @TO@ keyword is accepted properly when making a session and
292292
transferring it. First pass @TO@-formatted sub and sessions to
293-
make_sub_folders. Then transfer the files (upload or download).
293+
make_folders. Then transfer the files (upload or download).
294294
295295
Finally, check the expected formatting on the subject and session
296296
is observed on the created and transferred file paths.
@@ -425,7 +425,7 @@ def test_rclone_transfer_verbosity(
425425
"""
426426
see test_rclone_options()
427427
"""
428-
project.make_sub_folders(["sub-001"], ["ses-002"], ["behav"])
428+
project.make_folders(["sub-001"], ["ses-002"], ["behav"])
429429
project.update_config("transfer_verbosity", transfer_verbosity)
430430

431431
test_utils.clear_capsys(capsys)
@@ -455,7 +455,7 @@ def test_rclone_overwrite_modified_file(
455455
Path("rawdata") / "sub-001" / "histology" / "test_file.txt"
456456
)
457457

458-
project.make_sub_folders("sub-001")
458+
project.make_folders("sub-001")
459459
local_test_file_path = project.cfg["local_path"] / path_to_test_file
460460
central_test_file_path = (
461461
project.cfg["central_path"] / path_to_test_file
@@ -554,7 +554,7 @@ def test_specific_file_or_folder(
554554

555555
def setup_specific_file_or_folder_files(self, project):
556556
""" """
557-
project.make_sub_folders(["sub-001", "sub-002"], "ses-003")
557+
project.make_folders(["sub-001", "sub-002"], "ses-003")
558558

559559
path_to_test_file_behav = (
560560
Path("rawdata")

tests/tests_integration/test_formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_format_names_prefix(self):
9797
]
9898

9999
def test_warning_non_consecutive_numbers(self, project):
100-
project.make_sub_folders(
100+
project.make_folders(
101101
["sub-01", "sub-2", "sub-04"], ["ses-05", "ses-10"]
102102
)
103103

0 commit comments

Comments
 (0)