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.
Files changed (35) hide show
  1. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/CHANGELOG +5 -0
  2. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/PKG-INFO +1 -1
  3. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/_version.py +2 -2
  4. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/s3cc.py +13 -6
  5. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/testing.py +4 -1
  6. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/PKG-INFO +1 -1
  7. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_testing.py +27 -1
  8. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.github/workflows/check.yml +0 -0
  9. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.github/workflows/deploy_pypi.yml +0 -0
  10. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/.gitignore +0 -0
  11. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/LICENSE +0 -0
  12. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/MANIFEST.in +0 -0
  13. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/README.rst +0 -0
  14. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/__init__.py +0 -0
  15. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/ckan.py +0 -0
  16. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/data.py +0 -0
  17. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/dcinst.py +0 -0
  18. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/mime.py +0 -0
  19. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/parse.py +0 -0
  20. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/paths.py +0 -0
  21. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/rqjob.py +0 -0
  22. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/s3.py +0 -0
  23. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared/util.py +0 -0
  24. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/SOURCES.txt +0 -0
  25. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/dependency_links.txt +0 -0
  26. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/requires.txt +0 -0
  27. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/dcor_shared.egg-info/top_level.txt +0 -0
  28. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/pyproject.toml +0 -0
  29. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/setup.cfg +0 -0
  30. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/data/calibration_beads_47.rtdc +0 -0
  31. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/requirements.txt +0 -0
  32. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_ckan.py +0 -0
  33. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_data.py +0 -0
  34. {dcor_shared-1.0.2 → dcor_shared-1.0.4}/tests/test_s3.py +0 -0
  35. {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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcor_shared
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Functionalities shared by the DCOR CKAN extensions
5
5
  Author: Paul Müller
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.0.2'
21
- __version_tuple__ = version_tuple = (1, 0, 2)
20
+ __version__ = version = '1.0.4'
21
+ __version_tuple__ = version_tuple = (1, 0, 4)
@@ -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(resource_id):
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="resource")
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
- # Disable basins, because they could point to files on the
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": resource_path.name,
181
+ "name": resource_name,
179
182
  "s3_available": True,
180
183
  }]
181
184
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcor_shared
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: Functionalities shared by the DCOR CKAN extensions
5
5
  Author: Paul Müller
6
6
  Maintainer-email: Paul Müller <dev@craban.de>
@@ -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 make_dataset_via_s3
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