omdev 0.0.0.dev240__py3-none-any.whl → 0.0.0.dev242__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.
@@ -4,9 +4,11 @@ import dataclasses as dc
4
4
  import typing as ta
5
5
 
6
6
  from omlish.lite.timing import log_timing_context
7
+ from omlish.text.mangle import StringMangler
7
8
 
8
9
  from ..cache import FileCache
9
10
  from .cache import DockerCache
11
+ from .cache import DockerCacheKey
10
12
  from .cmds import is_docker_image_present
11
13
  from .cmds import pull_docker_image
12
14
 
@@ -44,11 +46,9 @@ class DockerImagePullingImpl(DockerImagePulling):
44
46
  if not self._config.always_pull and (await is_docker_image_present(image)):
45
47
  return
46
48
 
47
- dep_suffix = image
48
- for c in '/:.-_':
49
- dep_suffix = dep_suffix.replace(c, '-')
49
+ key_content = StringMangler.of('-', '/:._').mangle(image)
50
50
 
51
- cache_key = f'docker-{dep_suffix}'
51
+ cache_key = DockerCacheKey(['docker'], key_content)
52
52
  if (
53
53
  self._docker_cache is not None and
54
54
  (await self._docker_cache.load_cache_docker_image(cache_key)) is not None
omdev/ci/docker/inject.py CHANGED
@@ -9,29 +9,58 @@ from .buildcaching import DockerBuildCaching
9
9
  from .buildcaching import DockerBuildCachingImpl
10
10
  from .cache import DockerCache
11
11
  from .cache import DockerCacheImpl
12
+ from .cacheserved.cache import CacheServedDockerCache
12
13
  from .imagepulling import DockerImagePulling
13
14
  from .imagepulling import DockerImagePullingImpl
15
+ from .repositories import DockerImageRepositoryOpener
16
+ from .repositories import DockerImageRepositoryOpenerImpl
14
17
 
15
18
 
16
19
  ##
17
20
 
18
21
 
19
22
  def bind_docker(
20
- *,
21
- build_caching_config: DockerBuildCachingImpl.Config,
22
- image_pulling_config: DockerImagePullingImpl.Config = DockerImagePullingImpl.Config(),
23
+ *,
24
+ build_caching_config: DockerBuildCachingImpl.Config,
25
+ cache_served_docker_cache_config: ta.Optional[CacheServedDockerCache.Config] = None,
26
+ image_pulling_config: DockerImagePullingImpl.Config = DockerImagePullingImpl.Config(),
23
27
  ) -> InjectorBindings:
24
- lst: ta.List[InjectorBindingOrBindings] = [
28
+ lst: ta.List[InjectorBindingOrBindings] = []
29
+
30
+ #
31
+
32
+ lst.extend([
25
33
  inj.bind(build_caching_config),
26
34
  inj.bind(DockerBuildCachingImpl, singleton=True),
27
35
  inj.bind(DockerBuildCaching, to_key=DockerBuildCachingImpl),
36
+ ])
37
+
38
+ #
39
+
40
+ if cache_served_docker_cache_config is not None:
41
+ lst.extend([
42
+ inj.bind(DockerImageRepositoryOpenerImpl, singleton=True),
43
+ inj.bind(DockerImageRepositoryOpener, to_key=DockerImageRepositoryOpenerImpl),
28
44
 
29
- inj.bind(DockerCacheImpl, singleton=True),
30
- inj.bind(DockerCache, to_key=DockerCacheImpl),
45
+ inj.bind(cache_served_docker_cache_config),
46
+ inj.bind(CacheServedDockerCache, singleton=True),
47
+ inj.bind(DockerCache, to_key=CacheServedDockerCache),
48
+ ])
31
49
 
50
+ else:
51
+ lst.extend([
52
+ inj.bind(DockerCacheImpl, singleton=True),
53
+ inj.bind(DockerCache, to_key=DockerCacheImpl),
54
+ ])
55
+
56
+ #
57
+
58
+ lst.extend([
32
59
  inj.bind(image_pulling_config),
33
60
  inj.bind(DockerImagePullingImpl, singleton=True),
34
61
  inj.bind(DockerImagePulling, to_key=DockerImagePullingImpl),
35
- ]
62
+ ])
63
+
64
+ #
36
65
 
37
66
  return inj.as_bindings(*lst)
omdev/ci/github/client.py CHANGED
@@ -213,7 +213,7 @@ class GithubCacheServiceV1BaseClient(GithubCacheClient, abc.ABC):
213
213
 
214
214
  #
215
215
 
216
- KEY_PART_SEPARATOR = '--'
216
+ KEY_PART_SEPARATOR = '---'
217
217
 
218
218
  def fix_key(self, s: str, partial_suffix: bool = False) -> str:
219
219
  return self.KEY_PART_SEPARATOR.join([
@@ -230,7 +230,7 @@ class GithubCacheServiceV1BaseClient(GithubCacheClient, abc.ABC):
230
230
 
231
231
  def get_entry_url(self, entry: GithubCacheClient.Entry) -> ta.Optional[str]:
232
232
  entry1 = check.isinstance(entry, self.Entry)
233
- return entry1.artifact.cache_key
233
+ return entry1.artifact.archive_location
234
234
 
235
235
  #
236
236
 
omdev/ci/github/inject.py CHANGED
@@ -5,6 +5,7 @@ from omlish.lite.inject import InjectorBindingOrBindings
5
5
  from omlish.lite.inject import InjectorBindings
6
6
  from omlish.lite.inject import inj
7
7
 
8
+ from ..cache import DataCache
8
9
  from ..cache import FileCache
9
10
  from .cache import GithubCache
10
11
 
@@ -15,6 +16,7 @@ from .cache import GithubCache
15
16
  def bind_github() -> InjectorBindings:
16
17
  lst: ta.List[InjectorBindingOrBindings] = [
17
18
  inj.bind(GithubCache, singleton=True),
19
+ inj.bind(DataCache, to_key=GithubCache),
18
20
  inj.bind(FileCache, to_key=GithubCache),
19
21
  ]
20
22
 
omdev/ci/inject.py CHANGED
@@ -5,10 +5,13 @@ from omlish.lite.inject import InjectorBindingOrBindings
5
5
  from omlish.lite.inject import InjectorBindings
6
6
  from omlish.lite.inject import inj
7
7
 
8
+ from .cache import DataCache
8
9
  from .cache import DirectoryFileCache
9
10
  from .cache import FileCache
11
+ from .cache import FileCacheDataCache
10
12
  from .ci import Ci
11
13
  from .docker.buildcaching import DockerBuildCachingImpl
14
+ from .docker.cacheserved.cache import CacheServedDockerCache
12
15
  from .docker.imagepulling import DockerImagePullingImpl
13
16
  from .docker.inject import bind_docker
14
17
  from .github.inject import bind_github
@@ -24,6 +27,8 @@ def bind_ci(
24
27
  directory_file_cache_config: ta.Optional[DirectoryFileCache.Config] = None,
25
28
 
26
29
  github: bool = False,
30
+
31
+ cache_served_docker: bool = False,
27
32
  ) -> InjectorBindings:
28
33
  lst: ta.List[InjectorBindingOrBindings] = [ # noqa
29
34
  inj.bind(config),
@@ -37,6 +42,10 @@ def bind_ci(
37
42
  always_build=config.always_build,
38
43
  ),
39
44
 
45
+ cache_served_docker_cache_config=CacheServedDockerCache.Config(
46
+ #
47
+ ) if cache_served_docker else None,
48
+
40
49
  image_pulling_config=DockerImagePullingImpl.Config(
41
50
  always_pull=config.always_pull,
42
51
  ),
@@ -50,7 +59,13 @@ def bind_ci(
50
59
 
51
60
  if github:
52
61
  lst.append(bind_github())
62
+
53
63
  else:
54
- lst.append(inj.bind(FileCache, to_key=DirectoryFileCache))
64
+ lst.extend([
65
+ inj.bind(FileCache, to_key=DirectoryFileCache),
66
+
67
+ inj.bind(FileCacheDataCache, singleton=True),
68
+ inj.bind(DataCache, to_key=FileCacheDataCache),
69
+ ])
55
70
 
56
71
  return inj.as_bindings(*lst)
omdev/dataserver/http.py CHANGED
@@ -3,6 +3,7 @@
3
3
  TODO:
4
4
  - asyncio
5
5
  - chunked transfer - both output and urllib input
6
+ - range headers
6
7
  """
7
8
  import typing as ta
8
9
 
omdev/precheck/lite.py CHANGED
@@ -68,6 +68,7 @@ class LitePython8Precheck(Precheck['LitePython8Precheck.Config']):
68
68
  @staticmethod
69
69
  def _load_file_module(fp: str) -> None:
70
70
  import os.path # noqa
71
+ import sys # noqa
71
72
  import types # noqa
72
73
 
73
74
  fp = os.path.abspath(fp)
@@ -83,6 +84,8 @@ class LitePython8Precheck(Precheck['LitePython8Precheck.Config']):
83
84
  mod.__builtins__ = __builtins__ # type: ignore
84
85
  mod.__spec__ = None
85
86
 
87
+ sys.modules[mn] = mod
88
+
86
89
  code = compile(src, fp, 'exec')
87
90
  exec(code, mod.__dict__, mod.__dict__)
88
91
 
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env python3
2
2
  # @omlish-lite
3
3
  # @omlish-script
4
+ """
5
+ TODO:
6
+ - https://github.com/mtkennerly/dunamai
7
+ """
4
8
  import argparse
5
9
  import re
6
10
  import string