dcor-shared 1.0.2__tar.gz → 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/CHANGELOG +5 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/PKG-INFO +1 -1
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/_version.py +2 -2
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/s3cc.py +13 -6
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/testing.py +4 -1
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/PKG-INFO +1 -1
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_testing.py +27 -1
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.github/workflows/check.yml +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.github/workflows/deploy_pypi.yml +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.gitignore +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/LICENSE +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/MANIFEST.in +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/README.rst +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/__init__.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/ckan.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/data.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/dcinst.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/mime.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/parse.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/paths.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/rqjob.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/s3.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/util.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/SOURCES.txt +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/dependency_links.txt +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/requires.txt +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/top_level.txt +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/pyproject.toml +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/setup.cfg +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/data/calibration_beads_47.rtdc +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/requirements.txt +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_ckan.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_data.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_s3.py +0 -0
- {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_s3cc.py +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
1.0.4
|
|
2
|
+
- enh: implement "artifact" kwarg for `s3cc.compute_checksum`
|
|
3
|
+
- enh: introduce `enable_basins` in `s3cc.get_s3_dc_handle`
|
|
4
|
+
1.0.3
|
|
5
|
+
- enh: allow to specify resource name when creating test resource
|
|
1
6
|
1.0.2
|
|
2
7
|
- ref: disable threading and use 1GiB threshold for multipart uploads
|
|
3
8
|
1.0.1
|
|
@@ -34,10 +34,12 @@ def artifact_exists(
|
|
|
34
34
|
return s3.object_exists(bucket_name=bucket_name, object_name=object_name)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def compute_checksum(
|
|
37
|
+
def compute_checksum(
|
|
38
|
+
resource_id: str,
|
|
39
|
+
artifact: Literal["condensed", "preview", "resource"] = "resource"):
|
|
38
40
|
"""Compute the SHA256 checksum of the corresponding CKAN resource"""
|
|
39
41
|
bucket_name, object_name = get_s3_bucket_object_for_artifact(
|
|
40
|
-
resource_id=resource_id, artifact=
|
|
42
|
+
resource_id=resource_id, artifact=artifact)
|
|
41
43
|
s3h = s3.compute_checksum(bucket_name=bucket_name, object_name=object_name)
|
|
42
44
|
return s3h
|
|
43
45
|
|
|
@@ -188,12 +190,19 @@ def get_s3_bucket_name_for_resource(resource_id):
|
|
|
188
190
|
|
|
189
191
|
def get_s3_dc_handle(
|
|
190
192
|
resource_id: str,
|
|
191
|
-
artifact: Literal["condensed", "preview", "resource"] = "resource"
|
|
193
|
+
artifact: Literal["condensed", "preview", "resource"] = "resource",
|
|
194
|
+
enable_basins: bool = False,
|
|
195
|
+
):
|
|
192
196
|
"""Return an instance of :class:`RTDC_S3`
|
|
193
197
|
|
|
194
198
|
The data are accessed directly via S3 using DCOR's access credentials.
|
|
195
199
|
Use this if you need to access the original raw file.
|
|
196
200
|
|
|
201
|
+
If you set `enable_basins` to True, basins of the data on S3 will
|
|
202
|
+
be considered. This is turned off for performance reasons. Note that
|
|
203
|
+
since an instance of `RTDC_S3` is returned, no local basins are
|
|
204
|
+
allowed.
|
|
205
|
+
|
|
197
206
|
The resource with the identifier `resource_id` must exist in the
|
|
198
207
|
CKAN database.
|
|
199
208
|
"""
|
|
@@ -204,9 +213,7 @@ def get_s3_dc_handle(
|
|
|
204
213
|
"dcor_object_store.access_key_id"),
|
|
205
214
|
secret_access_key=get_ckan_config_option(
|
|
206
215
|
"dcor_object_store.secret_access_key"),
|
|
207
|
-
|
|
208
|
-
# local file system (security).
|
|
209
|
-
enable_basins=False,
|
|
216
|
+
enable_basins=enable_basins,
|
|
210
217
|
)
|
|
211
218
|
return ds
|
|
212
219
|
|
|
@@ -149,11 +149,14 @@ def make_resource_via_s3(
|
|
|
149
149
|
resource_path: pathlib.Path | str,
|
|
150
150
|
organization_id: str,
|
|
151
151
|
dataset_id: str,
|
|
152
|
+
resource_name: str = None,
|
|
152
153
|
private: bool = False,
|
|
153
154
|
ret_dict: bool = False,
|
|
154
155
|
):
|
|
155
156
|
"""Upload a resource to S3 and register it with CKAN"""
|
|
156
157
|
resource_path = pathlib.Path(resource_path)
|
|
158
|
+
if resource_name is None:
|
|
159
|
+
resource_name = resource_path.name
|
|
157
160
|
|
|
158
161
|
user = factories.Sysadmin()
|
|
159
162
|
create_context = {'ignore_auth': False,
|
|
@@ -175,7 +178,7 @@ def make_resource_via_s3(
|
|
|
175
178
|
"match": {"id": dataset_id},
|
|
176
179
|
"update__resources__extend": [{
|
|
177
180
|
"id": rid,
|
|
178
|
-
"name":
|
|
181
|
+
"name": resource_name,
|
|
179
182
|
"s3_available": True,
|
|
180
183
|
}]
|
|
181
184
|
}
|
|
@@ -2,9 +2,12 @@ import pathlib
|
|
|
2
2
|
import pytest
|
|
3
3
|
|
|
4
4
|
import ckan.tests.factories as factories
|
|
5
|
+
import ckan.tests.helpers as helpers
|
|
5
6
|
import requests
|
|
6
7
|
|
|
7
|
-
from dcor_shared.testing import
|
|
8
|
+
from dcor_shared.testing import (
|
|
9
|
+
make_dataset_via_s3, make_resource_via_s3, activate_dataset
|
|
10
|
+
)
|
|
8
11
|
from dcor_shared import s3cc, sha256sum
|
|
9
12
|
|
|
10
13
|
data_path = pathlib.Path(__file__).parent / "data"
|
|
@@ -47,3 +50,26 @@ def test_make_dataset_with_resource_via_s3(tmp_path):
|
|
|
47
50
|
|
|
48
51
|
assert sha256sum(dl_path) == \
|
|
49
52
|
"490efdf5d9bb4cd4b2a6bcf2fe54d4dc201c38530140bcb168980bf8bf846c73"
|
|
53
|
+
|
|
54
|
+
assert res_dict["name"] == "calibration_beads_47.rtdc"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@pytest.mark.ckan_config('ckan.plugins', 'dcor_schemas')
|
|
58
|
+
@pytest.mark.usefixtures('clean_db', 'with_request_context')
|
|
59
|
+
def test_make_resource_via_s3_name(tmp_path):
|
|
60
|
+
# upload a *valid* [sic] .rtdc File (this is the control)
|
|
61
|
+
ds_dict = make_dataset_via_s3(
|
|
62
|
+
activate=False,
|
|
63
|
+
private=False,
|
|
64
|
+
)
|
|
65
|
+
rid = make_resource_via_s3(
|
|
66
|
+
resource_path=data_path / "calibration_beads_47.rtdc",
|
|
67
|
+
resource_name="peter.rtdc",
|
|
68
|
+
organization_id=ds_dict["organization"]["id"],
|
|
69
|
+
dataset_id=ds_dict["id"],
|
|
70
|
+
private=False,
|
|
71
|
+
)
|
|
72
|
+
activate_dataset(ds_dict["id"])
|
|
73
|
+
|
|
74
|
+
res_dict = helpers.call_action("resource_show", id=rid)
|
|
75
|
+
assert res_dict["name"] == "peter.rtdc"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|