-
Notifications
You must be signed in to change notification settings - Fork 31
Fix #619: Default 'subject' and 'session' to 'all' in TUI custom tran… #621
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
base: main
Are you sure you want to change the base?
Fix #619: Default 'subject' and 'session' to 'all' in TUI custom tran… #621
Conversation
…l' in TUI custom transfer if fields are left blank. (Final formatting fix)
|
Hi @NobleCoder69 could you make sure to fill out the PR template? |
|
Hi @adamltyson, Ready for review when convenient. 👍 |
|
Thanks @NobleCoder69, I'm not sure I can see any changes to the typing here although mentioned in the PR body. Nonetheless this indeed sets It is quite good that you are working on this issue because the most user friendly way to handle this is not clear, and requires some thought. If you could generate a test project and play around with the transfer, and let me know what you think is the best 'default' for leaving this boxes empty. The current default of passing through as |
|
Thanks a lot for the feedback! I see what you mean about handling this in the TUI instead. I’ll go through the code you mentioned and create a small test project to experiment with different defaults. I’ll try both throwing an error and pre-filling “all” to see what feels more intuitive, then share my thoughts here. |
|
Hi @NobleCoder69, are you still interested in working on this issue? |
|
Hi all — I’m still actively working on this. Thanks for the feedback @JoeZiminski. Plan
I’ll push a follow-up commit with tests and update the PR description accordingly. If reviewers prefer a different token (e.g., Also: I noticed a CI failure on macOS Python 3.9 — if it still fails after my update, I’ll check logs and ask for guidance if needed. It may be unrelated / flaky. Thanks! |
… environment variables
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to fix issue #619 where the TUI transfer process fails when the subject or session fields are left blank. However, the implementation has a critical bug that prevents it from actually fixing the issue. Additionally, the PR includes significant and unrelated changes to the GDrive test utilities that introduce breaking changes.
Key changes:
- Adds default value handling for empty subject/session fields in the TUI transfer tab (but with incorrect logic)
- Completely rewrites the GDrive test utility functions (unrelated to the stated PR purpose)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
datashuttle/tui/tabs/transfer.py |
Attempts to default empty sub_names and ses_names to ["all"] but uses incorrect logic that won't catch empty input fields |
tests/tests_transfers/gdrive/gdrive_test_utils.py |
Complete rewrite of GDrive test utilities with breaking API changes, updated authentication methods, and new helper functions |
Comments suppressed due to low confidence (4)
tests/tests_transfers/gdrive/gdrive_test_utils.py:68
- There is trailing whitespace at the end of this line. This should be removed for consistency with coding standards.
for key in [
tests/tests_transfers/gdrive/gdrive_test_utils.py:40
- The function signature has been changed from
setup_project_for_gdrive(project: DataShuttle)tosetup_project_for_gdrive(tmp_path), but the test intest_gdrive_transfer.pyat line 23 still calls it with aprojectparameter. This will cause the test to fail. Additionally, the functionsetup_gdrive_connectionis no longer defined but is still being called in the test at line 26.
def setup_project_for_gdrive(project: DataShuttle):
"""Set up a project with configs for Google Drive transfers.
The connection credentials are fetched from the environment which
the developer shall set themselves to test locally. In the CI, these
are set using the github secrets. A random string is added to the
central path so that the test project paths do not interfere while
running multiple test instances simultaneously in CI.
"""
# Check if required environment variables are set
if not has_gdrive_environment_variables():
pytest.skip("Google Drive environment variables not set")
random_string = utils.get_random_string()
project.update_config_file(
connection_method="gdrive",
central_path=f"/{random_string}/{project.project_name}",
gdrive_client_id=os.environ["GDRIVE_CLIENT_ID"],
gdrive_root_folder_id=os.environ["GDRIVE_ROOT_FOLDER_ID"],
)
def setup_gdrive_connection(project: DataShuttle):
"""
Convenience function to set up the Google Drive connection by
mocking user input.
The mock input is triggered twice. First, to deny the presence of
a browser. Second, to enter a `GDRIVE_CONFIG_TOKEN` needed to set up
tests/tests_transfers/gdrive/gdrive_test_utils.py:29
- Call to method DataShuttle.update_config_file with too many arguments; should be no more than 0.
gdrive_client_id=os.environ["GDRIVE_CLIENT_ID"],
tests/tests_transfers/gdrive/gdrive_test_utils.py:30
- Call to method DataShuttle.update_config_file with too many arguments; should be no more than 0.
gdrive_root_folder_id=os.environ["GDRIVE_ROOT_FOLDER_ID"],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if not sub_names: | ||
| sub_names = ["all"] | ||
|
|
||
| if not ses_names: |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition if not sub_names: will not catch the case when the input field is empty. When an input is left blank, the as_names_list() method (which calls "".split(",")) returns [""] (a list with one empty string), not an empty list. Since [""] is truthy, the condition if not sub_names: evaluates to False, and the default value will not be applied. This means the bug is not actually fixed.
The condition should check for both empty lists and lists containing only an empty string. A similar pattern can be found in datashuttle/tui/tabs/create_folders.py at line 435 where it checks if sub_names == [""]:.
| if not sub_names: | |
| sub_names = ["all"] | |
| if not ses_names: | |
| if not sub_names or sub_names == [""]: | |
| sub_names = ["all"] | |
| if not ses_names or ses_names == [""]: |
| if key not in os.environ: | ||
| return False | ||
|
|
||
| # On CI triggered by forked repositories, secrets are empty |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring is empty. Consider adding a brief description of what this function does, such as "Create the rclone configuration file contents using environment variables."
Fix transfer if fields are left blank. (Final formatting fix)
Before submitting a pull request (PR), please read the contributing guide.
Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)
Description
This PR fixes the issue where the TUI transfer process failed when the
subjectorsessionfields were left blank.It also corrects type hints in the affected functions to use
list[str]instead of genericListtypes.Local verification of Sphinx docs was blocked due to environment-related issues, but all code changes were tested locally.
What is this PR
Why is this PR needed?
Previously, leaving the
subjectorsessionfields empty in the transfer interface would cause the operation to fail.This fix ensures that transfers proceed successfully even when these fields are blank, improving usability and robustness.
What does this PR do?
subjectandsessionwhen left blank.list[str].pre-commit.References
Fixes: #619
How has this PR been tested?
pytestand manually testing the TUI transfer workflow.subjectandsessionno longer interrupts transfer execution.pre-commitsuccessfully for code style and static checks.Is this a breaking change?
No, this change is backward-compatible.
It only modifies behavior when the
subjectorsessionfields are left blank, and does not affect existing workflows.Does this PR require an update to the documentation?
No documentation updates are required, as this change only affects default handling in the TUI transfer behavior.
Checklist: