Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
znicholls committed Aug 20, 2024
1 parent 2029612 commit b257fce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/openscm_zenodo/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ def upload_files_command(
"""
Upload files to a Zenodo deposition
"""
if files_to_upload is None:
msg = "You must supply some files to upload"
raise ValueError(msg)

zenoodo_interactor = ZenodoInteractor(
token=token,
zenodo_domain=zenodo_domain,
Expand Down
16 changes: 9 additions & 7 deletions src/openscm_zenodo/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import json
import logging
import os.path
from collections.abc import Iterable
from collections.abc import Collection, Iterable
from enum import Enum, auto
from pathlib import Path
from typing import Any, Optional, Union
Expand Down Expand Up @@ -499,7 +499,7 @@ def upload_file_to_bucket_url(
def upload_files(
self,
deposition_id: str,
to_upload: Iterable[Path],
to_upload: Collection[Path],
tqdm_kwargs: Optional[dict[str, Any]] = None,
n_threads: int = 4,
) -> tuple[requests.models.Response, ...]:
Expand Down Expand Up @@ -610,7 +610,7 @@ def delete_deposition(self, deposition_id: str) -> None:
def remove_files(
self,
deposition_id: str,
to_remove: Iterable[Path],
to_remove: Collection[Path],
# # Off until parallelism works
# n_threads: int = 4,
) -> tuple[requests.models.Response, ...]:
Expand Down Expand Up @@ -674,10 +674,12 @@ def remove_files_by_id(
The response(s) from the file removal request(s)
"""
# Wanted to do this in parallel, but weirdly flaky
responses = [
self.remove_file_id(deposition_id=deposition_id, to_remove_id=file_id)
for file_id in tqdm.tqdm(file_ids_to_remove, desc="Files to remove")
]
responses = tuple(
[
self.remove_file_id(deposition_id=deposition_id, to_remove_id=file_id)
for file_id in tqdm.tqdm(file_ids_to_remove, desc="Files to remove")
]
)
# with concurrent.futures.ThreadPoolExecutor(max_workers=n_threads) as executor:
# futures = [
# executor.submit(
Expand Down

0 comments on commit b257fce

Please sign in to comment.