Downloading a specific file with the new API
Hi I am updating my scripts to work with the new Coscine Python SDK.
I am struggling to download a specific file from Coscine to a specific local folder.
Previously I was doing:
PROCESSED_RESOURCE.object(TARGET_FOLDER + "/" +
METADATA_FILE).download(CACHE_FOLDER)
I guess that the new equivalent would be:
PROCESSED_RESOURCE.file(TARGET_FOLDER + "/" +
METADATA_FILE).download(path=CACHE_FOLDER)
However, this results in the error:
File "/Users/me/mambaforge/envs/mermaid/lib/python3.12/site-packages/coscine/resource.py", line 1089, in download
with open(path, "wb") as fp:
FileNotFoundError: [Errno 2] No such file or directory: '/CACHE_FOLDER/TARGET_FOLDER/METADATA_FILE'
I am only able to download the file if the target local path already contains a folder with the same name as the parent folder of the file in coscine.
Example:
Works:
target_path = Path("/Users/me/Software_Projects/mermaid/mermaid/.cache/my_experiment")
target_path.mkdir(parents=True, exist_ok=True)
PROCESSED_RESOURCE.file("/my_experiment/experiment.json").download(path=
"/Users/me/Software_Projects/mermaid/mermaid/.cache/")
Error:
PROCESSED_RESOURCE.file("/my_experiment/experiment.json").download(path=
"/Users/me/Software_Projects/mermaid/mermaid/.cache/")
I just want to download experiment.json to .cache without having to create additional folders.
Am I doing something wrong?
Thank you!