dcor-shared 0.12.2__tar.gz → 0.12.3__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 (36) hide show
  1. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/CHANGELOG +2 -0
  2. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/PKG-INFO +1 -1
  3. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/__init__.py +2 -1
  4. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/_version.py +2 -2
  5. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/data.py +15 -13
  6. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/s3.py +1 -1
  7. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/testing.py +8 -4
  8. dcor_shared-0.12.3/dcor_shared/util.py +10 -0
  9. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared.egg-info/PKG-INFO +1 -1
  10. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared.egg-info/SOURCES.txt +1 -0
  11. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/.github/workflows/check.yml +0 -0
  12. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/.github/workflows/deploy_pypi.yml +0 -0
  13. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/.gitignore +0 -0
  14. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/LICENSE +0 -0
  15. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/MANIFEST.in +0 -0
  16. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/README.rst +0 -0
  17. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/ckan.py +0 -0
  18. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/dcinst.py +0 -0
  19. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/mime.py +0 -0
  20. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/parse.py +0 -0
  21. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/paths.py +0 -0
  22. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/rqjob.py +0 -0
  23. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared/s3cc.py +0 -0
  24. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared.egg-info/dependency_links.txt +0 -0
  25. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared.egg-info/requires.txt +0 -0
  26. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/dcor_shared.egg-info/top_level.txt +0 -0
  27. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/pyproject.toml +0 -0
  28. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/setup.cfg +0 -0
  29. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/data/calibration_beads_47.rtdc +0 -0
  30. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/requirements.txt +0 -0
  31. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_basic.py +0 -0
  32. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_ckan.py +0 -0
  33. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_data.py +0 -0
  34. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_s3.py +0 -0
  35. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_s3cc.py +0 -0
  36. {dcor_shared-0.12.2 → dcor_shared-0.12.3}/tests/test_testing.py +0 -0
@@ -1,3 +1,5 @@
1
+ 0.12.3
2
+ - enh: improved resource availability check
1
3
  0.12.2
2
4
  - fix: testing did not append S3 resources
3
5
  0.12.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcor_shared
3
- Version: 0.12.2
3
+ Version: 0.12.3
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,10 @@
2
2
  from .ckan import (
3
3
  get_ckan_config_option, get_resource_dc_config, get_resource_path, get_resource_info
4
4
  )
5
- from .data import DUMMY_BYTES, sha256sum, wait_for_resource
5
+ from .data import DUMMY_BYTES, wait_for_resource
6
6
  from .dcinst import get_dc_instance
7
7
  from .mime import DC_MIME_TYPES, VALID_FORMATS
8
8
  from . import paths
9
9
  from .rqjob import RQJob, rqjob_register
10
+ from .util import sha256sum
10
11
  from ._version import version as __version__
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.12.2'
21
- __version_tuple__ = version_tuple = (0, 12, 2)
20
+ __version__ = version = '0.12.3'
21
+ __version_tuple__ = version_tuple = (0, 12, 3)
@@ -1,24 +1,16 @@
1
1
  import functools
2
- import hashlib
3
2
  import pathlib
4
3
  import time
5
4
 
6
5
  from .ckan import get_resource_path
6
+ from . import s3cc
7
+ from .util import sha256sum # noqa: F401
7
8
 
8
9
 
9
10
  #: Content of the dummy file created when importing data.
10
11
  DUMMY_BYTES = b"[Data import pending]"
11
12
 
12
13
 
13
- def sha256sum(path):
14
- """Compute the SHA256 hash of a file in 1MB chunks"""
15
- file_hash = hashlib.sha256()
16
- with open(path, "rb") as fd:
17
- while data := fd.read(2 ** 20):
18
- file_hash.update(data)
19
- return file_hash.hexdigest()
20
-
21
-
22
14
  @functools.lru_cache(maxsize=100)
23
15
  def wait_for_resource(resource_id: str,
24
16
  timeout: float = 10):
@@ -67,13 +59,23 @@ def wait_for_resource(resource_id: str,
67
59
  time.sleep(5)
68
60
  continue
69
61
 
62
+ # object exists in database?
70
63
  s3_ok = res_dict.get("s3_available", None)
64
+ if s3_ok:
65
+ # If the resource is on S3, it is considered to be available.
66
+ break
67
+
68
+ # object exists on S3?
69
+ try:
70
+ s3_exist = s3cc.artifact_exists(res_dict["id"])
71
+ except BaseException:
72
+ s3_exist = False
73
+ if s3_exist:
74
+ break
75
+
71
76
  if time.time() - t0 > timeout:
72
77
  raise OSError("Data import seems to take too long "
73
78
  "for '{}'!".format(path))
74
- elif s3_ok is not None:
75
- # If the dataset is on S3, it is considered to be available.
76
- break
77
79
  elif not path.exists():
78
80
  time.sleep(5)
79
81
  continue
@@ -14,7 +14,7 @@ import boto3
14
14
  import botocore.exceptions
15
15
 
16
16
  from .ckan import get_ckan_config_option
17
- from .data import sha256sum
17
+ from .util import sha256sum
18
18
 
19
19
 
20
20
  def compute_checksum(bucket_name, object_name, max_size=None):
@@ -8,6 +8,7 @@ import uuid
8
8
  import warnings
9
9
 
10
10
  import ckan.authz
11
+ import ckan.model
11
12
  import ckan.tests.factories as factories
12
13
  import ckan.tests.helpers as helpers
13
14
  from ckan.tests.pytest_ckan.fixtures import FakeFileStorage
@@ -134,7 +135,9 @@ def make_dataset_via_s3(
134
135
  """
135
136
  if create_context is None:
136
137
  user = factories.User()
138
+ user_obj = ckan.model.User.by_name(user["name"])
137
139
  create_context = {'ignore_auth': False,
140
+ 'auth_user_obj': user_obj,
138
141
  'user': user['name'],
139
142
  'api_version': 3}
140
143
  user_id = user["id"]
@@ -144,10 +147,11 @@ def make_dataset_via_s3(
144
147
  create_context["user"], allow_none=True)
145
148
 
146
149
  if owner_org is None:
147
- owner_org = factories.Organization(users=[{
148
- 'name': user_id,
149
- 'capacity': 'admin'
150
- }])
150
+ owner_org = factories.Organization(
151
+ users=[{
152
+ 'name': user_id,
153
+ 'capacity': 'admin'
154
+ }])
151
155
 
152
156
  if "title" not in kwargs:
153
157
  kwargs["title"] = "test-dataset-S3"
@@ -0,0 +1,10 @@
1
+ import hashlib
2
+
3
+
4
+ def sha256sum(path):
5
+ """Compute the SHA256 hash of a file in 1MB chunks"""
6
+ file_hash = hashlib.sha256()
7
+ with open(path, "rb") as fd:
8
+ while data := fd.read(2 ** 20):
9
+ file_hash.update(data)
10
+ return file_hash.hexdigest()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dcor_shared
3
- Version: 0.12.2
3
+ Version: 0.12.3
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>
@@ -18,6 +18,7 @@ dcor_shared/rqjob.py
18
18
  dcor_shared/s3.py
19
19
  dcor_shared/s3cc.py
20
20
  dcor_shared/testing.py
21
+ dcor_shared/util.py
21
22
  dcor_shared.egg-info/PKG-INFO
22
23
  dcor_shared.egg-info/SOURCES.txt
23
24
  dcor_shared.egg-info/dependency_links.txt
File without changes
File without changes
File without changes
File without changes
File without changes