cafs-cache-cdn-client 1.0.7__py3-none-any.whl → 1.0.8__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.
@@ -1 +1,2 @@
1
+ from .cafs import CompressionT
1
2
  from .client import CacheCdnClient
@@ -28,6 +28,9 @@ def is_file_already_compressed(file_path: Path) -> bool:
28
28
  def choose_compression(
29
29
  file_path: Path, preferred_compression: CompressionT = CompressionT.NONE
30
30
  ) -> CompressionT:
31
+ if preferred_compression == CompressionT.NONE:
32
+ return preferred_compression
33
+
31
34
  if file_path.stat().st_size < MINIMAL_COMPRESSION_SIZE:
32
35
  return CompressionT.NONE
33
36
 
@@ -7,7 +7,7 @@ from typing import Any, Self, TypeVar
7
7
 
8
8
  import aiofiles.os as aio_os
9
9
 
10
- from cafs_cache_cdn_client.cafs import CAFSClient
10
+ from cafs_cache_cdn_client.cafs import CAFSClient, CompressionT
11
11
  from cafs_cache_cdn_client.file_utils import (
12
12
  LocalFile,
13
13
  compare_file_lists,
@@ -64,6 +64,7 @@ class CacheCdnClient:
64
64
  directory: Path | str,
65
65
  ttl_hours: int = 0,
66
66
  comment: str | None = None,
67
+ compression: CompressionT = CompressionT.NONE,
67
68
  ) -> None:
68
69
  if isinstance(directory, str):
69
70
  directory = Path(directory)
@@ -71,7 +72,8 @@ class CacheCdnClient:
71
72
  raise ValueError(f'{directory} is not a directory')
72
73
  files = walk(directory)
73
74
  hashes = await self._cafs_client.stream_batch(
74
- [directory / file.path for file in files]
75
+ [directory / file.path for file in files],
76
+ compression=compression,
75
77
  )
76
78
  await self._repo_client.post_ref_info(
77
79
  repo,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cafs-cache-cdn-client
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Async Cache CDN client implementation
5
5
  Keywords: cafs,cache
6
6
  Author: Konstantin Belov
@@ -38,7 +38,7 @@ pip install cafs-cache-cdn-client
38
38
  import asyncio
39
39
  import logging
40
40
  from pathlib import Path
41
- from cafs_cache_cdn_client import CacheCdnClient
41
+ from cafs_cache_cdn_client import CacheCdnClient, CompressionT
42
42
 
43
43
  # Configure logging to see detailed operation information
44
44
  logging.basicConfig(level=logging.DEBUG)
@@ -54,10 +54,11 @@ async def main():
54
54
 
55
55
  # Use as an async context manager to ensure proper resource cleanup
56
56
  async with client:
57
- # Push a local directory to cache with a 2-hour TTL
57
+ # Push a local directory to cache with a 2-hour TTL and preferred ZSTD compression
58
58
  await client.push('project_name', 'build_artifacts',
59
59
  '/path/to/build/output', ttl_hours=2,
60
- comment='Build artifacts from CI run #123')
60
+ comment='Build artifacts from CI run #123',
61
+ compression=CompressionT.ZSTD)
61
62
 
62
63
  # Check if a reference exists
63
64
  exists = await client.check('project_name', 'build_artifacts')
@@ -90,7 +91,7 @@ if __name__ == '__main__':
90
91
  - `connection_per_cafs_server`: Number of concurrent connections per CAFS server
91
92
 
92
93
  - **Methods**:
93
- - `push(repo: str, ref: str, directory: Path | str, ttl_hours: int = 0, comment: str | None = None)` - Push a local directory to cache
94
+ - `push(repo: str, ref: str, directory: Path | str, ttl_hours: int = 0, comment: str | None = None, compression: CompressionT = CompressionT.NONE)` - Push a local directory to cache
94
95
  - `pull(repo: str, ref: str, directory: Path | str)` - Pull cached content to a local directory
95
96
  - `check(repo: str, ref: str) -> bool` - Check if a reference exists
96
97
  - `tag(repo: str, ref: str, tag: str)` - Create a tag for a reference
@@ -1,18 +1,18 @@
1
- cafs_cache_cdn_client/__init__.py,sha256=N-Gpb6OMWWaEruRwbPjkrZ0Uta8gsQFmq1yFhGcvtcc,35
1
+ cafs_cache_cdn_client/__init__.py,sha256=B07eCJXxADkPLzWp6JKDUbdJy-vfhKj_mUdeR26qQKI,66
2
2
  cafs_cache_cdn_client/cafs/README.md,sha256=bcn9CEX4O74jY4kRi2oJb37oi55aneyQxDji76SU4Aw,2554
3
3
  cafs_cache_cdn_client/cafs/__init__.py,sha256=Ae2WHVqgI9dEuWG5cX-8nbuUH_wpW-5dACt6JGM3FcE,123
4
4
  cafs_cache_cdn_client/cafs/blob/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cafs_cache_cdn_client/cafs/blob/hash_.py,sha256=tI4qenyHnEEtKnNUOq4a25L1GnlKjoieyPGQDoz14rA,736
6
6
  cafs_cache_cdn_client/cafs/blob/package.py,sha256=pOMF5Dw42APHqIlRfcs1YPscqjcbO32Z35aEG0SqoHo,5865
7
- cafs_cache_cdn_client/cafs/blob/utils.py,sha256=tqAOvPWIL-sOwXwPiH9Kbsqn5VekJtlf6UO8V9TTtwM,1021
7
+ cafs_cache_cdn_client/cafs/blob/utils.py,sha256=jIfLhpX-zz2c_lINaM7OziJuHiwgf0ZpqHsuQNnRHqw,1110
8
8
  cafs_cache_cdn_client/cafs/client.py,sha256=ebaFivgSQAzS0verVwuzRGZ98pwSEoaiTaUlmL8VB3o,18536
9
9
  cafs_cache_cdn_client/cafs/exceptions.py,sha256=I4E3lFrQ_ysR8gDIh3E0Gz4OMihfLD6vLj_KwKzxnTU,654
10
10
  cafs_cache_cdn_client/cafs/types.py,sha256=q7zqDQ8yKRn-HRSsXDuzawmikAEcyoYQ-_p2WmuDFy4,324
11
- cafs_cache_cdn_client/client.py,sha256=d7Dw2U9h8dPYRDPu0mbnXc62SlLy4ruvQk2Alj3cVk8,4584
11
+ cafs_cache_cdn_client/client.py,sha256=mjq1okUZEGGDt-c8zsToL70FtyLiPVgcwo_gVjI2Jd0,4691
12
12
  cafs_cache_cdn_client/file_utils.py,sha256=uX5gAc3CUGXpOktD3m_xrz31d4PRnKkq2RkBMqZSe0o,2677
13
13
  cafs_cache_cdn_client/repo/__init__.py,sha256=JzCxKznnLV7WElJuznG_jL2s9tYPecJL5uJRnPZsW5M,58
14
14
  cafs_cache_cdn_client/repo/client.py,sha256=cxZ6PLwqKG0tIbAXYacpd_eB_TE31-u506q2JyjOenY,3546
15
15
  cafs_cache_cdn_client/repo/datatypes.py,sha256=aTlzFoEibfAOQTqcsg-RmFjnwenS_rBCEMKtN6glOhY,531
16
- cafs_cache_cdn_client-1.0.7.dist-info/METADATA,sha256=8Bgg1yCjjO5LCpRiX0IaJ6G7RuMhzmGlJp_xu0mtZLA,3666
17
- cafs_cache_cdn_client-1.0.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
18
- cafs_cache_cdn_client-1.0.7.dist-info/RECORD,,
16
+ cafs_cache_cdn_client-1.0.8.dist-info/METADATA,sha256=87BrdEHCertEgXXGo44vPAk3Iua-SVMQtMPuj7J2czs,3815
17
+ cafs_cache_cdn_client-1.0.8.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
18
+ cafs_cache_cdn_client-1.0.8.dist-info/RECORD,,