thds.core 1.36.20250602165821__py3-none-any.whl → 1.36.20250602182925__py3-none-any.whl
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.
Potentially problematic release.
This version of thds.core might be problematic. Click here for more details.
- thds/core/git.py +7 -0
- thds/core/hash_cache.py +2 -1
- thds/core/source/_download.py +4 -1
- thds/core/source/serde.py +6 -4
- thds/core/timer.py +1 -1
- {thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/METADATA +1 -1
- {thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/RECORD +10 -10
- {thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/WHEEL +0 -0
- {thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/entry_points.txt +0 -0
- {thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/top_level.txt +0 -0
thds/core/git.py
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
import os
|
|
6
6
|
import subprocess as sp
|
|
7
7
|
import typing as ty
|
|
8
|
+
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from . import log
|
|
11
|
+
from .lazy import lazy
|
|
10
12
|
|
|
11
13
|
LOGGER = log.getLogger(__name__)
|
|
12
14
|
CALGITVER_NO_SECONDS_FORMAT = "%Y%m%d.%H%M"
|
|
@@ -79,3 +81,8 @@ def get_commit_datetime_str(commit_hash: str, date_format: str = CALGITVER_NO_SE
|
|
|
79
81
|
f"git log -n 1 --date=format-local:{date_format} --format=format:'%cd' {commit_hash}",
|
|
80
82
|
env=dict(os.environ, TZ="UTC0"),
|
|
81
83
|
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@lazy
|
|
87
|
+
def get_repo_root() -> Path:
|
|
88
|
+
return Path(_simple_run(["git", "rev-parse", "--show-toplevel"]))
|
thds/core/hash_cache.py
CHANGED
|
@@ -12,6 +12,7 @@ functions themselves.
|
|
|
12
12
|
|
|
13
13
|
import hashlib
|
|
14
14
|
import os
|
|
15
|
+
import sys
|
|
15
16
|
from pathlib import Path
|
|
16
17
|
from typing import Any
|
|
17
18
|
|
|
@@ -83,4 +84,4 @@ def hash_file(filepath: StrOrPath, hasher: Any) -> bytes:
|
|
|
83
84
|
def filehash(algo: str, pathlike: os.PathLike) -> Hash:
|
|
84
85
|
"""Wraps a cached hash of a file in a core.hashing.Hash object, which carries the name
|
|
85
86
|
of the hash algorithm used."""
|
|
86
|
-
return Hash(algo, hash_file(pathlike, hashlib.new(algo)))
|
|
87
|
+
return Hash(sys.intern(algo), hash_file(pathlike, hashlib.new(algo)))
|
thds/core/source/_download.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
yet will not be downloaded (if non-local) until it is actually opened or unwrapped.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
+
import sys
|
|
6
7
|
import typing as ty
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
@@ -11,6 +12,8 @@ from ..files import is_file_uri, path_from_uri
|
|
|
11
12
|
from ..hash_cache import filehash
|
|
12
13
|
from ..hashing import Hash
|
|
13
14
|
|
|
15
|
+
SHA256 = "sha256" # this hopefully interns the string which makes sure that all our pickles reuse the reference
|
|
16
|
+
|
|
14
17
|
|
|
15
18
|
class Downloader(ty.Protocol):
|
|
16
19
|
def __call__(self, hash: ty.Optional[Hash]) -> Path:
|
|
@@ -73,7 +76,7 @@ class SourceHashMismatchError(ValueError):
|
|
|
73
76
|
|
|
74
77
|
|
|
75
78
|
def _check_hash(expected_hash: ty.Optional[Hash], path: Path) -> Hash:
|
|
76
|
-
hash_algo = expected_hash.algo if expected_hash else
|
|
79
|
+
hash_algo = sys.intern(expected_hash.algo if expected_hash else SHA256)
|
|
77
80
|
with log.logger_context(hash_for=f"source-{hash_algo}"):
|
|
78
81
|
computed_hash = filehash(hash_algo, path)
|
|
79
82
|
if expected_hash and expected_hash != computed_hash:
|
thds/core/source/serde.py
CHANGED
|
@@ -7,23 +7,25 @@ from pathlib import Path
|
|
|
7
7
|
from thds.core import files, hashing, log, types
|
|
8
8
|
|
|
9
9
|
from . import _construct
|
|
10
|
+
from ._download import SHA256
|
|
10
11
|
from .src import Source
|
|
11
12
|
|
|
12
13
|
_SHA256_B64 = "sha256b64"
|
|
13
14
|
_MD5_B64 = "md5b64"
|
|
15
|
+
MD5 = "md5"
|
|
14
16
|
|
|
15
17
|
logger = log.getLogger(__name__)
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
def _from_sha256b64(d: dict) -> ty.Optional[hashing.Hash]:
|
|
19
21
|
if "sha256b64" in d:
|
|
20
|
-
return hashing.Hash(algo=
|
|
22
|
+
return hashing.Hash(algo=SHA256, bytes=hashing.db64(d[_SHA256_B64]))
|
|
21
23
|
return None
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
def _from_md5b64(d: dict) -> ty.Optional[hashing.Hash]:
|
|
25
27
|
if "md5b64" in d:
|
|
26
|
-
return hashing.Hash(algo=
|
|
28
|
+
return hashing.Hash(algo=MD5, bytes=hashing.db64(d[_MD5_B64]))
|
|
27
29
|
return None
|
|
28
30
|
|
|
29
31
|
|
|
@@ -51,8 +53,8 @@ def _generic_hash_serializer(
|
|
|
51
53
|
return None
|
|
52
54
|
|
|
53
55
|
|
|
54
|
-
_to_sha256b64 = partial(_generic_hash_serializer,
|
|
55
|
-
_to_md5b64 = partial(_generic_hash_serializer,
|
|
56
|
+
_to_sha256b64 = partial(_generic_hash_serializer, SHA256, hashing.b64, _SHA256_B64)
|
|
57
|
+
_to_md5b64 = partial(_generic_hash_serializer, MD5, hashing.b64, _MD5_B64)
|
|
56
58
|
|
|
57
59
|
HashSerializer = ty.Callable[[hashing.Hash], ty.Optional[dict]]
|
|
58
60
|
_BASE_HASH_SERIALIZERS: ty.Tuple[HashSerializer, ...] = (_to_md5b64, _to_sha256b64) # type: ignore
|
thds/core/timer.py
CHANGED
|
@@ -161,7 +161,7 @@ class TimeTracker:
|
|
|
161
161
|
self._start_times = []
|
|
162
162
|
|
|
163
163
|
def to_json(self) -> Iterator[str]:
|
|
164
|
-
if SINGLE_LINE_JSON_TIMERS:
|
|
164
|
+
if SINGLE_LINE_JSON_TIMERS():
|
|
165
165
|
for name, timer in sorted(self.tracked_times.items(), key=lambda x: x[0]):
|
|
166
166
|
yield json.dumps({name: dict(timer)}, indent=None)
|
|
167
167
|
else:
|
|
@@ -13,8 +13,8 @@ thds/core/exit_after.py,sha256=0lz63nz2NTiIdyBDYyRa9bQShxQKe7eISy8VhXeW4HU,3485
|
|
|
13
13
|
thds/core/files.py,sha256=NJlPXj7BejKd_Pa06MOywVv_YapT4bVedfsJHrWX8nI,4579
|
|
14
14
|
thds/core/fretry.py,sha256=PKgOxCMjcF4zsFfXFvPXpomv5J6KU6llB1EaKukugig,6942
|
|
15
15
|
thds/core/generators.py,sha256=rcdFpPj0NMJWSaSZTnBfTeZxTTORNB633Lng-BW1284,1939
|
|
16
|
-
thds/core/git.py,sha256=
|
|
17
|
-
thds/core/hash_cache.py,sha256=
|
|
16
|
+
thds/core/git.py,sha256=cfdN1oXyfz7k7T2XaseTqL6Ng53B9lfKtzDLmFjojRs,2947
|
|
17
|
+
thds/core/hash_cache.py,sha256=OKudAvqyaCzNRkhPAHbdHJKxHFxMRRyG3S1uFcq0jv4,3746
|
|
18
18
|
thds/core/hashing.py,sha256=OqaV65vGKpT3l78jm-Uh7xG4DtAczGjk9-Q60OGmhY0,3521
|
|
19
19
|
thds/core/home.py,sha256=tTClL_AarIKeri1aNCpuIC6evD7qr83ESGD173B81hU,470
|
|
20
20
|
thds/core/hostname.py,sha256=canFGr-JaaG7nUfsQlyL0JT-2tnZoT1BvXzyaOMK1vA,208
|
|
@@ -37,7 +37,7 @@ thds/core/scope.py,sha256=iPRhS-lIe-axDctqxBtEPeF0PM_w-0tRS-9kPweUGBY,7205
|
|
|
37
37
|
thds/core/source_serde.py,sha256=X4c7LiT3VidejqtTel9YB6dWGB3x-ct39KF9E50Nbx4,139
|
|
38
38
|
thds/core/stack_context.py,sha256=17lPOuYWclUpZ-VXRkPgI4WbiMzq7_ZY6Kj1QK_1oNo,1332
|
|
39
39
|
thds/core/thunks.py,sha256=p1OvMBJ4VGMsD8BVA7zwPeAp0L3y_nxVozBF2E78t3M,1053
|
|
40
|
-
thds/core/timer.py,sha256=
|
|
40
|
+
thds/core/timer.py,sha256=aOpNP-wHKaKs6ONK5fOtIOgx00FChVZquG4PeaEYH_k,5376
|
|
41
41
|
thds/core/tmp.py,sha256=KgBAwQCmpm7I762eLRu-3MSfH3dKnqlrJkZ5nmPcRbc,3110
|
|
42
42
|
thds/core/types.py,sha256=sFqI_8BsB1u85PSizjBZw8PBtplC7U54E19wZZWCEvI,152
|
|
43
43
|
thds/core/log/__init__.py,sha256=bDbZvlxyymY6VrQzD8lCn0egniLEiA9hpNMAXZ7e7wY,1348
|
|
@@ -49,8 +49,8 @@ thds/core/log/logfmt.py,sha256=i66zoG2oERnE1P_0TVXdlfJ1YgUmvtMjqRtdV5u2SvU,10366
|
|
|
49
49
|
thds/core/source/__init__.py,sha256=0Zy3mwJgwLtc4jq14Cwu6d_Rq-aZOMIlu4zaADeKgmo,487
|
|
50
50
|
thds/core/source/_construct.py,sha256=plSyQZRe8h0X7PpbfMjhm1qkFgrcyuSrReyWQo28YfA,3121
|
|
51
51
|
thds/core/source/_construct_tree.py,sha256=5Zk3a5a0uVxklWw6q4JOvI_bErqwlBngUz4TyEAWn1g,616
|
|
52
|
-
thds/core/source/_download.py,sha256=
|
|
53
|
-
thds/core/source/serde.py,sha256=
|
|
52
|
+
thds/core/source/_download.py,sha256=d4MMcZllifXFfCyhSJgsPM9BIKRBd1D3GNjCA7gBveM,3059
|
|
53
|
+
thds/core/source/serde.py,sha256=CPIVu6N-G-IhHiyZrNk4bQwYDTt8BUw31-TuwvkXoaw,3573
|
|
54
54
|
thds/core/source/src.py,sha256=9A_8kSBUc5k6OLAYe5EW_VogpXFIqofow7Rxl8xv-eg,4559
|
|
55
55
|
thds/core/source/tree.py,sha256=iNCoCE655MwXQwc2Y0IIm1HMVk5Inj0NGVU9U8Wl_90,4317
|
|
56
56
|
thds/core/sqlite/__init__.py,sha256=tDMzuO76qTtckJHldPQ6nPZ6kcvhhoJrVuuW42JtaSQ,606
|
|
@@ -68,8 +68,8 @@ thds/core/sqlite/structured.py,sha256=SvZ67KcVcVdmpR52JSd52vMTW2ALUXmlHEeD-VrzWV
|
|
|
68
68
|
thds/core/sqlite/types.py,sha256=oUkfoKRYNGDPZRk29s09rc9ha3SCk2SKr_K6WKebBFs,1308
|
|
69
69
|
thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
|
|
70
70
|
thds/core/sqlite/write.py,sha256=z0219vDkQDCnsV0WLvsj94keItr7H4j7Y_evbcoBrWU,3458
|
|
71
|
-
thds_core-1.36.
|
|
72
|
-
thds_core-1.36.
|
|
73
|
-
thds_core-1.36.
|
|
74
|
-
thds_core-1.36.
|
|
75
|
-
thds_core-1.36.
|
|
71
|
+
thds_core-1.36.20250602182925.dist-info/METADATA,sha256=iC2KzoEcpmtPPyZXeXIB3_ZMk1yNnGZrunshVce4Cwc,2275
|
|
72
|
+
thds_core-1.36.20250602182925.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
73
|
+
thds_core-1.36.20250602182925.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
|
|
74
|
+
thds_core-1.36.20250602182925.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
75
|
+
thds_core-1.36.20250602182925.dist-info/RECORD,,
|
|
File without changes
|
{thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_core-1.36.20250602165821.dist-info → thds_core-1.36.20250602182925.dist-info}/top_level.txt
RENAMED
|
File without changes
|