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

Add functionality for setting custom names #361

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

marcellevstek
Copy link
Contributor

@marcellevstek marcellevstek commented Sep 30, 2024

of downloaded files

REID-2630

@marcellevstek marcellevstek force-pushed the modify/download branch 5 times, most recently from 49152bd to 914fd71 Compare September 30, 2024 11:39
Copy link
Member

@JureZmrzlikar JureZmrzlikar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, PR looks ready - technical wise. However, I have second thoughts regaridn the arguments. One way to provide custom name is the way you did:

Data.download(
    field_name="bam",
    download_dir="/my/dir/",
    custom_file_name="foo.txt"
)

The other option would be to make a breaking change:

Data.download(
    field_name="bam",
    target="/my/dir/foo.txt",  # If one just wants to specify dir, target= "/my/dir/"
)

The naming target, resembles Path.rename, we could also use dst as in os.rename. What do you think? Do you have any opinion @gregorjerse ?

src/resdk/resources/data.py Outdated Show resolved Hide resolved
tests/unit/test_data.py Show resolved Hide resolved
@marcellevstek
Copy link
Contributor Author

@JureZmrzlikar I agree with you about making the breaking change. I didn't want to incorporate it in the current implementation, but it makes complete sense not to use two distinct arguments for constructing the path.

@gregorjerse please review.

src/resdk/resolwe.py Outdated Show resolved Hide resolved
src/resdk/resolwe.py Outdated Show resolved Hide resolved
src/resdk/resolwe.py Outdated Show resolved Hide resolved
src/resdk/resources/collection.py Outdated Show resolved Hide resolved
src/resdk/resources/data.py Outdated Show resolved Hide resolved
src/resdk/resources/data.py Outdated Show resolved Hide resolved
@marcellevstek marcellevstek force-pushed the modify/download branch 2 times, most recently from 43ad5bb to b9661da Compare October 17, 2024 12:28
@marcellevstek
Copy link
Contributor Author

@gregorjerse I have added a new function for downloading and renaming a single file. Can you please guide me how to create a test, as I have problem mocking the download function.

)
return

file_names = self.download(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be called by constructing kwargs. @gregorjerse if current implementation is not okay, I can change it.

)
if len(file_names) != 1:
raise ValueError(
f"Expected one file to be downloaded, but got {len(file_names)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the files have already been downloaded and are left in the download folder. What to do with them?

raise ValueError(
f"Expected one file to be downloaded, but got {len(file_names)}"
)
og_file_name = file_names[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does og_file_name stand for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file name that is present on the platform.

@marcellevstek marcellevstek force-pushed the modify/download branch 3 times, most recently from 049e24c to e920b10 Compare October 21, 2024 11:31
src/resdk/resolwe.py Show resolved Hide resolved
src/resdk/resolwe.py Show resolved Hide resolved
src/resdk/resources/data.py Outdated Show resolved Hide resolved
@gregorjerse gregorjerse merged commit 7e07be5 into genialis:master Nov 7, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants