Skip to content

Commit

Permalink
ref: mirgrate to package_revise for updating datasets (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 2, 2021
1 parent 5be4c8e commit 8f03e85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.7.7
- ref: mirgrate to package_revise for updating datasets (#28)
0.7.6
- enh: add "create_task" function for generating custom .dcoraid-task
files in Python scripts
Expand Down
17 changes: 2 additions & 15 deletions dcoraid/api/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,8 @@ def resource_add(dataset_id, path, api, resource_name=None,
else:
# Attempt upload
with path.open("rb") as fd:
e = MultipartEncoder(fields={
'package_id': dataset_id,
'name': resource_name,
'upload': (resource_name, fd)})
m = MultipartEncoderMonitor(e, monitor_callback)
# perform upload
data = api.post("resource_create",
data=m,
dump_json=False,
headers={"Content-Type": m.content_type})
if False:
# TODO: Seems like package_revise does not trigger
# IResourceController.after_create!
# https://github.com/DCOR-dev/DCOR-Aid/issues/28
# https://github.com/ckan/ckan/issues/6472
# use package_revise to upload the resource
# https://github.com/DCOR-dev/DCOR-Aid/issues/28
e = MultipartEncoder(fields={
'match__id': dataset_id,
'update__resources__extend': f'[{{"name":"{resource_name}"}}]',
Expand Down
14 changes: 0 additions & 14 deletions dcoraid/upload/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,20 +404,6 @@ def task_upload_resources(self):
exist_ok=True,
monitor_callback=self.monitor_callback)
self.paths_uploaded.append(path)
# Workaround until `package_revise` is in `resource_add`
# (https://github.com/DCOR-dev/DCOR-Aid/issues/28):
# Wait for the SHA256 sum to be computed by DCOR.
for _ in range(60):
sha256dict = resource_sha256_sums(
dataset_id=self.dataset_id,
api=self.api)
if sha256dict[resource_name] is not None:
break
time.sleep(10)
else:
warnings.warn(
f"SHA256 sum for {self.dataset_id}: "
+ f"{resource_name} not yet computed by DCOR!")
self.end_time = time.perf_counter()
self.set_state("online")
else:
Expand Down

0 comments on commit 8f03e85

Please sign in to comment.