Skip to content

Commit 1795cde

Browse files
fix(service): dataset import error (#3670)
1 parent b6dac09 commit 1795cde

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ htmlcov/
5656
nosetests.xml
5757
coverage.xml
5858
*,cover
59+
.hypothesis
5960

6061
# Translations
6162
*.mo

renku/core/dataset/providers/zenodo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class ZenodoDatasetSchema(ProviderDatasetSchema):
179179
"""Schema for Zenodo datasets."""
180180

181181
@pre_load
182-
def fix_data(self, data, **kwargs):
182+
def fix_data(self, data, **_):
183183
"""Fix data that is received from Zenodo."""
184184
# Fix context
185185
context = data.get("@context")
@@ -236,7 +236,7 @@ def fix_data(self, data, **kwargs):
236236
class ZenodoFileSerializer:
237237
"""Zenodo record file."""
238238

239-
def __init__(self, *, id=None, checksum=None, links=None, key=None, size=None, **kwargs):
239+
def __init__(self, *, id=None, checksum=None, links=None, key=None, size=None, **_):
240240
self.id = id
241241
self.checksum = checksum
242242
self.links = links

renku/ui/service/controllers/datasets_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def renku_op(self):
4848
"""Renku operation for the controller."""
4949
job = self.cache.make_job(
5050
self.user,
51-
# NOTE: To support operation to be execute on remote project, this behaviour should be updated.
51+
# NOTE: To support operation to be executed on remote project, this behaviour should be updated.
5252
project=self.ctx["project_id"],
5353
job_data={"renku_op": "dataset_import", "client_extras": self.ctx.get("client_extras")},
5454
)

renku/ui/service/jobs/datasets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def dataset_import(
3737
user_job_id,
3838
project_id,
3939
dataset_uri,
40-
name=None,
40+
slug=None,
4141
extract=False,
4242
tag=None,
4343
timeout=None,
@@ -63,7 +63,7 @@ def dataset_import(
6363
command = import_dataset_command().with_commit_message(commit_message)
6464
command.with_communicator(communicator).build().execute(
6565
uri=dataset_uri,
66-
name=name,
66+
slug=slug,
6767
extract=extract,
6868
tag=tag,
6969
yes=True,
@@ -98,7 +98,7 @@ def _is_safe_to_pass_gitlab_token(project_git_url, dataset_uri):
9898

9999

100100
@requires_cache
101-
def dataset_add_remote_file(cache, user, user_job_id, project_id, create_dataset, commit_message, name, url):
101+
def dataset_add_remote_file(cache, user, user_job_id, project_id, create_dataset, commit_message, slug, url):
102102
"""Add a remote file to a specified dataset."""
103103
user = cache.ensure_user(user)
104104
worker_log.debug(f"executing dataset add remote file job for {user.user_id}:{user.fullname}")
@@ -113,9 +113,9 @@ def dataset_add_remote_file(cache, user, user_job_id, project_id, create_dataset
113113
with renku_project_context(project.abs_path):
114114
urls = url if isinstance(url, list) else [url]
115115

116-
worker_log.debug(f"adding files {urls} to dataset {name}")
116+
worker_log.debug(f"adding files {urls} to dataset {slug}")
117117
command = add_to_dataset_command().with_commit_message(commit_message).build()
118-
result = command.execute(dataset_slug=name, urls=urls, create=create_dataset)
118+
result = command.execute(dataset_slug=slug, urls=urls, create=create_dataset)
119119
if result.error:
120120
raise result.error
121121

tests/service/jobs/test_datasets.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def test_dataset_url_import_job(url, svc_client_with_repo):
8888
@pytest.mark.service
8989
@retry_failed
9090
@pytest.mark.vcr
91-
def test_dataset_import_job(doi, svc_client_with_repo):
92-
"""Test dataset import via doi."""
91+
def test_dataset_import_job_with_slug(doi, svc_client_with_repo):
92+
"""Test dataset import via doi and give it a slug."""
9393
svc_client, headers, project_id, url_components = svc_client_with_repo
9494

9595
user_id = encode_b64(secure_filename("9ab2fc80-3a5c-426d-ae78-56de01d214df"))
@@ -118,7 +118,14 @@ def test_dataset_import_job(doi, svc_client_with_repo):
118118
job_id = response.json["result"]["job_id"]
119119

120120
commit_message = "service: import remote dataset"
121-
dataset_import(user, job_id, project_id, doi, commit_message=commit_message)
121+
dataset_import(
122+
user=user,
123+
user_job_id=job_id,
124+
project_id=project_id,
125+
dataset_uri=doi,
126+
slug="dataset-slug",
127+
commit_message=commit_message,
128+
)
122129

123130
new_commit = Repository(dest).head.commit
124131
assert old_commit.hexsha != new_commit.hexsha
@@ -279,7 +286,16 @@ def test_dataset_add_remote_file(url, svc_client_with_repo):
279286
job_id = response.json["result"]["files"][0]["job_id"]
280287
commit_message = "service: dataset add remote file"
281288

282-
dataset_add_remote_file(user, job_id, project_id, True, commit_message, payload["slug"], url)
289+
# user, user_job_id, project_id, create_dataset, commit_message, slug, url
290+
dataset_add_remote_file(
291+
user=user,
292+
user_job_id=job_id,
293+
project_id=project_id,
294+
create_dataset=True,
295+
commit_message=commit_message,
296+
slug=payload["slug"],
297+
url=url,
298+
)
283299

284300
new_commit = Repository(dest).head.commit
285301

0 commit comments

Comments
 (0)