arkitekt-next 0.13.0__py3-none-any.whl → 0.14.1__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 arkitekt-next might be problematic. Click here for more details.

Files changed (48) hide show
  1. arkitekt_next/__blok__.py +4 -0
  2. arkitekt_next/__init__.py +1 -1
  3. arkitekt_next/app/__init__.py +3 -0
  4. arkitekt_next/{apps/protocols.py → app/app.py} +8 -4
  5. arkitekt_next/{apps/service/fakts_next.py → app/fakts.py} +7 -5
  6. arkitekt_next/bloks/admin.py +1 -1
  7. arkitekt_next/bloks/alpaka.py +74 -42
  8. arkitekt_next/bloks/arkitekt.py +4 -1
  9. arkitekt_next/bloks/gateway.py +6 -0
  10. arkitekt_next/bloks/l.py +136 -0
  11. arkitekt_next/bloks/livekit.py +4 -3
  12. arkitekt_next/bloks/lovekit.py +199 -0
  13. arkitekt_next/bloks/ollama.py +12 -7
  14. arkitekt_next/bloks/services/admin.py +5 -6
  15. arkitekt_next/bloks/services/livekit.py +6 -3
  16. arkitekt_next/bloks/services/ollama.py +7 -2
  17. arkitekt_next/bloks/services/secret.py +1 -3
  18. arkitekt_next/builders.py +10 -17
  19. arkitekt_next/cli/commands/inspect/implementations.py +1 -1
  20. arkitekt_next/cli/commands/inspect/requirements.py +1 -1
  21. arkitekt_next/cli/commands/kabinet/build.py +0 -1
  22. arkitekt_next/cli/commands/kabinet/types.py +3 -5
  23. arkitekt_next/cli/commands/run/dev.py +6 -22
  24. arkitekt_next/cli/commands/run/utils.py +6 -6
  25. arkitekt_next/cli/types.py +1 -2
  26. arkitekt_next/cli/ui.py +2 -2
  27. arkitekt_next/cli/utils.py +1 -1
  28. arkitekt_next/init_registry.py +32 -27
  29. arkitekt_next/protocols.py +7 -24
  30. arkitekt_next/qt/__init__.py +2 -2
  31. arkitekt_next/qt/builders.py +11 -118
  32. arkitekt_next/qt/magic_bar.py +1 -1
  33. arkitekt_next/qt/types.py +1 -1
  34. arkitekt_next/service_registry.py +13 -29
  35. arkitekt_next/utils.py +1 -1
  36. {arkitekt_next-0.13.0.dist-info → arkitekt_next-0.14.1.dist-info}/METADATA +3 -4
  37. {arkitekt_next-0.13.0.dist-info → arkitekt_next-0.14.1.dist-info}/RECORD +40 -45
  38. arkitekt_next/apps/__init__.py +0 -3
  39. arkitekt_next/apps/service/__init__.py +0 -3
  40. arkitekt_next/apps/service/fakts_qt.py +0 -57
  41. arkitekt_next/apps/service/grant_registry.py +0 -27
  42. arkitekt_next/apps/service/herre.py +0 -26
  43. arkitekt_next/apps/service/herre_qt.py +0 -57
  44. arkitekt_next/apps/service/local_fakts.py +0 -95
  45. arkitekt_next/base_models.py +0 -104
  46. {arkitekt_next-0.13.0.dist-info → arkitekt_next-0.14.1.dist-info}/WHEEL +0 -0
  47. {arkitekt_next-0.13.0.dist-info → arkitekt_next-0.14.1.dist-info}/entry_points.txt +0 -0
  48. {arkitekt_next-0.13.0.dist-info → arkitekt_next-0.14.1.dist-info}/licenses/LICENSE +0 -0
arkitekt_next/__blok__.py CHANGED
@@ -10,6 +10,8 @@ from arkitekt_next.bloks.postgres import PostgresBlok
10
10
  from arkitekt_next.bloks.minio import MinioBlok
11
11
  from arkitekt_next.bloks.kabinet import KabinetBlok
12
12
  from arkitekt_next.bloks.lok import LokBlok
13
+ from arkitekt_next.bloks.alpaka import AlpakaBlok
14
+ from arkitekt_next.bloks.lovekit import LovekitBlok
13
15
  from arkitekt_next.bloks.config import ConfigBlok
14
16
  from arkitekt_next.bloks.mount import MountBlok
15
17
  from arkitekt_next.bloks.internal_docker import InternalDockerBlok
@@ -33,6 +35,8 @@ def get_bloks() -> list[Blok]:
33
35
  FlussBlok(),
34
36
  RedisBlok(),
35
37
  CaddyBlok(),
38
+ AlpakaBlok(),
39
+ LovekitBlok(),
36
40
  LocalLiveKitBlok(),
37
41
  PostgresBlok(),
38
42
  MinioBlok(),
arkitekt_next/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from .builders import easy, interactive
2
- from .apps.protocols import App
2
+ from .app.app import App
3
3
  from fakts_next.helpers import afakt, fakt
4
4
  from .init_registry import init, InitHookRegistry, get_default_init_hook_registry
5
5
  from .service_registry import (
@@ -0,0 +1,3 @@
1
+ from .app import App
2
+
3
+ __all__ = ["App"]
@@ -12,10 +12,8 @@ an import exception to the app.
12
12
  import logging
13
13
  from typing import Any, Dict, TYPE_CHECKING
14
14
  from koil import unkoil
15
- from arkitekt_next.base_models import Manifest
16
15
  from koil.composition import Composition
17
16
  from fakts_next import Fakts
18
- from herre_next import Herre
19
17
 
20
18
 
21
19
  if TYPE_CHECKING:
@@ -29,8 +27,6 @@ class App(Composition):
29
27
  """An app that is built with the easy builder"""
30
28
 
31
29
  fakts: Fakts
32
- herre: Herre
33
- manifest: Manifest
34
30
  services: Dict[str, Any]
35
31
 
36
32
  @property
@@ -55,6 +51,14 @@ class App(Composition):
55
51
 
56
52
  self.rekuest.register(*args, **kwargs)
57
53
 
54
+ def register_startup(self, *args, **kwargs):
55
+ """Register a startup service"""
56
+ self.rekuest.register_startup(*args, **kwargs)
57
+
58
+ def register_background(self, *args, **kwargs):
59
+ """Register a background service"""
60
+ self.rekuest.register_background(*args, **kwargs)
61
+
58
62
  async def __aenter__(self):
59
63
  await super().__aenter__()
60
64
  for service in self.services.values():
@@ -11,10 +11,10 @@ from fakts_next.grants.remote.demanders.device_code import (
11
11
  from fakts_next.grants.remote.claimers.post import ClaimEndpointClaimer
12
12
  from fakts_next.grants.remote.demanders.redeem import RedeemDemander
13
13
  from fakts_next.cache.file import FileCache
14
- from arkitekt_next.base_models import Manifest
14
+ from fakts_next.models import Manifest
15
15
 
16
16
 
17
- def build_arkitekt_next_fakts_next(
17
+ def build_device_code_fakts(
18
18
  manifest: Manifest,
19
19
  url: Optional[str] = None,
20
20
  no_cache: bool = False,
@@ -37,6 +37,7 @@ def build_arkitekt_next_fakts_next(
37
37
  discovery=WellKnownDiscovery(url=url, auto_protocols=["https", "http"]),
38
38
  claimer=ClaimEndpointClaimer(),
39
39
  ),
40
+ manifest=manifest,
40
41
  cache=FileCache(
41
42
  cache_file=f".arkitekt_next/cache/{identifier}-{version}_fakts_cache.json",
42
43
  hash=manifest.hash() + url,
@@ -44,11 +45,12 @@ def build_arkitekt_next_fakts_next(
44
45
  )
45
46
 
46
47
 
47
- def build_arkitekt_next_redeem_fakts_next(manifest: Manifest, redeem_token: str, url: str) -> Fakts:
48
+ def build_redeem_fakts(manifest: Manifest, redeem_token: str, url: str) -> Fakts:
48
49
  identifier = manifest.identifier
49
50
  version = manifest.version
50
51
 
51
52
  return Fakts(
53
+ manifest=manifest,
52
54
  grant=RemoteGrant(
53
55
  demander=RedeemDemander(token=redeem_token, manifest=manifest),
54
56
  discovery=WellKnownDiscovery(url=url, auto_protocols=["https", "http"]),
@@ -61,7 +63,7 @@ def build_arkitekt_next_redeem_fakts_next(manifest: Manifest, redeem_token: str,
61
63
  )
62
64
 
63
65
 
64
- def build_arkitekt_next_token_fakts_next(
66
+ def build_token_fakts(
65
67
  manifest: Manifest,
66
68
  token: str,
67
69
  url: str,
@@ -70,6 +72,7 @@ def build_arkitekt_next_token_fakts_next(
70
72
  version = manifest.version
71
73
 
72
74
  return Fakts(
75
+ manifest=manifest,
73
76
  grant=RemoteGrant(
74
77
  demander=StaticDemander(token=token), # type: ignore
75
78
  discovery=WellKnownDiscovery(url=url, auto_protocols=["https", "http"]),
@@ -80,4 +83,3 @@ def build_arkitekt_next_token_fakts_next(
80
83
  hash=manifest.hash() + url,
81
84
  ),
82
85
  )
83
-
@@ -2,7 +2,7 @@ from blok import blok, InitContext, Option
2
2
  from arkitekt_next.bloks.services.admin import AdminService, AdminCredentials
3
3
 
4
4
 
5
- @blok(AdminService, description="sdmin credentials for the application")
5
+ @blok(AdminService, description="Admin credentials for the application")
6
6
  class AdminBlok:
7
7
  def __init__(self) -> None:
8
8
  self.password = "admin"
@@ -1,3 +1,4 @@
1
+ from dataclasses import asdict
1
2
  from typing import Dict, Any
2
3
  import secrets
3
4
 
@@ -9,6 +10,7 @@ from arkitekt_next.bloks.services.db import DBService
9
10
  from arkitekt_next.bloks.services.gateway import GatewayService
10
11
  from arkitekt_next.bloks.services.lok import LokService
11
12
  from arkitekt_next.bloks.services.mount import MountService
13
+ from arkitekt_next.bloks.services.ollama import OllamaService
12
14
  from arkitekt_next.bloks.services.redis import RedisService
13
15
  from arkitekt_next.bloks.services.s3 import S3Service
14
16
  from arkitekt_next.bloks.services.secret import SecretService
@@ -20,6 +22,9 @@ from arkitekt_next.bloks.base import BaseArkitektService
20
22
 
21
23
  @blok("live.arkitekt.alpaka", description="a container and app management service")
22
24
  class AlpakaBlok(BaseArkitektService):
25
+ def get_builder(self):
26
+ return "arkitekt.generic"
27
+
23
28
  def __init__(self) -> None:
24
29
  self.dev = False
25
30
  self.host = "alpaka"
@@ -35,23 +40,18 @@ class AlpakaBlok(BaseArkitektService):
35
40
  self.secret_key = secrets.token_hex(16)
36
41
  self.image = "jhnnsrs/alpaka:nightly"
37
42
 
38
- def get_additional_config(self):
39
- return {"ensured_repos": self.ensured_repos}
40
-
41
43
  def preflight(
42
44
  self,
43
- init: InitContext,
44
45
  lok: LokService,
45
46
  db: DBService,
46
47
  redis: RedisService,
47
48
  s3: S3Service,
48
49
  config: ConfigService,
49
- channel: ChannelService,
50
+ ollama: OllamaService,
50
51
  mount: MountService,
51
52
  admin: AdminService,
52
53
  secret: SecretService,
53
- gateway: GatewayService | None = None,
54
- dns: DnsService = None,
54
+ gateway: GatewayService,
55
55
  mount_repo: bool = False,
56
56
  host: str = "",
57
57
  image: str = "",
@@ -62,43 +62,75 @@ class AlpakaBlok(BaseArkitektService):
62
62
  disable: bool = False,
63
63
  dev: bool = False,
64
64
  ):
65
- return super().preflight(
66
- init,
67
- lok,
68
- db,
69
- redis,
70
- s3,
71
- config,
72
- channel,
73
- mount,
74
- admin,
75
- secret,
76
- gateway,
77
- dns,
78
- mount_repo,
79
- host,
80
- image,
81
- secret_key,
82
- build_repo,
83
- command,
84
- repo,
85
- disable,
86
- dev,
87
- )
65
+ lok.register_scopes(self.scopes)
88
66
 
89
- def get_builder(self):
90
- return "arkitekt.generic"
67
+ path_name = self.host
68
+
69
+ gateway.expose(path_name, 80, self.host)
70
+
71
+ postgress_access = db.register_db(self.host)
72
+ redis_access = redis.register()
73
+ lok_access = lok.retrieve_credentials()
74
+ admin_access = admin.retrieve()
75
+ minio_access = s3.create_buckets(self.buckets)
76
+ lok_labels = lok.retrieve_labels("live.arkitekt.alpaka", self.get_builder())
77
+ ollama_access = ollama.get_access()
91
78
 
92
- def build(self, context: ExecutionContext):
93
- context.docker_compose.set_nested("services", self.host, self.service)
79
+ django_secret = secret.retrieve_secret()
94
80
 
95
- def get_additional_options(self):
96
- with_repos = Option(
97
- subcommand="repos",
98
- help="The default repos to enable for the service",
99
- default=self.secret_key,
81
+ csrf_trusted_origins = []
82
+
83
+ configuration = YamlFile(
84
+ **{
85
+ "db": asdict(postgress_access),
86
+ "django": {
87
+ "admin": asdict(admin_access),
88
+ "debug": True,
89
+ "hosts": ["*"],
90
+ "secret_key": django_secret,
91
+ },
92
+ "redis": asdict(redis_access),
93
+ "lok": asdict(lok_access),
94
+ "s3": asdict(minio_access),
95
+ "scopes": self.scopes,
96
+ "force_script_name": path_name,
97
+ "csrf_trusted_origins": csrf_trusted_origins,
98
+ **self.get_additional_config(),
99
+ }
100
100
  )
101
101
 
102
- return [
103
- with_repos,
104
- ]
102
+ config_mount = config.register_config(f"{self.host}.yaml", configuration)
103
+
104
+ depends_on = []
105
+
106
+ if redis_access.dependency:
107
+ depends_on.append(redis_access.dependency)
108
+
109
+ if postgress_access.dependency:
110
+ depends_on.append(postgress_access.dependency)
111
+
112
+ if minio_access.dependency:
113
+ depends_on.append(minio_access.dependency)
114
+
115
+ if ollama_access.dependency:
116
+ depends_on.append(ollama_access.dependency)
117
+
118
+ service = {
119
+ "labels": lok_labels,
120
+ "volumes": [f"{config_mount}:/workspace/config.yaml"],
121
+ "depends_on": depends_on,
122
+ }
123
+
124
+ if mount_repo or dev:
125
+ mount = mount.register_mount(self.host, Repo(repo))
126
+ service["volumes"].extend([f"{mount}:/workspace"])
127
+
128
+ if build_repo or dev:
129
+ mount = mount.register_mount(self.host, Repo(repo))
130
+ service["build"] = mount
131
+ else:
132
+ service["image"] = image
133
+
134
+ service["command"] = command
135
+
136
+ self.service = service
@@ -10,12 +10,13 @@ from blok import InitContext, Panel, Renderer, blok
10
10
  from .fluss import FlussBlok
11
11
  from .internal_docker import InternalDockerBlok
12
12
  from .kabinet import KabinetBlok
13
- from .livekit import LocalLiveKitBlok
14
13
  from .mikro import MikroBlok
15
14
  from .orkestrator import OrkestratorBlok
16
15
  from .rekuest import RekuestBlok
17
16
  from .ollama import OllamaBlok
18
17
  from .elektro import ElektroBlok
18
+ from .alpaka import AlpakaBlok
19
+ from .lovekit import LovekitBlok
19
20
 
20
21
 
21
22
  class AdminCredentials(BaseModel):
@@ -34,7 +35,9 @@ class AdminCredentials(BaseModel):
34
35
  FlussBlok.as_dependency(True, True),
35
36
  InternalDockerBlok.as_dependency(True, True),
36
37
  KraphBlok.as_dependency(True, True),
38
+ AlpakaBlok.as_dependency(True, True),
37
39
  ElektroBlok.as_dependency(True, True),
40
+ LovekitBlok.as_dependency(True, True),
38
41
  ],
39
42
  )
40
43
  class ArkitektBlok:
@@ -68,10 +68,14 @@ class CaddyBlok:
68
68
  self,
69
69
  init: InitContext,
70
70
  name: NameService,
71
+ certs: CerterService,
71
72
  ):
72
73
  for key, value in init.kwargs.items():
73
74
  setattr(self, key, value)
74
75
 
76
+ self.cert_mount = certs.retrieve_certs_mount()
77
+ self.depends_on = certs.retrieve_depends_on()
78
+
75
79
  self.gateway_network = name.retrieve_name().replace("-", "_")
76
80
 
77
81
  def build(
@@ -164,6 +168,8 @@ class CaddyBlok:
164
168
  ]
165
169
 
166
170
  volumes = ["./configs/Caddyfile:/etc/caddy/Caddyfile"]
171
+ if self.cert_mount:
172
+ volumes.append(f"{self.cert_mount}:/certs")
167
173
 
168
174
  caddy_container = {
169
175
  "image": "caddy:latest",
@@ -0,0 +1,136 @@
1
+ from dataclasses import asdict
2
+ from typing import Dict, Any
3
+ import secrets
4
+
5
+
6
+ from arkitekt_next.bloks.services.admin import AdminService
7
+ from arkitekt_next.bloks.services.channel import ChannelService
8
+ from arkitekt_next.bloks.services.config import ConfigService
9
+ from arkitekt_next.bloks.services.db import DBService
10
+ from arkitekt_next.bloks.services.gateway import GatewayService
11
+ from arkitekt_next.bloks.services.lok import LokService
12
+ from arkitekt_next.bloks.services.mount import MountService
13
+ from arkitekt_next.bloks.services.ollama import OllamaService
14
+ from arkitekt_next.bloks.services.redis import RedisService
15
+ from arkitekt_next.bloks.services.s3 import S3Service
16
+ from arkitekt_next.bloks.services.secret import SecretService
17
+ from blok import blok, InitContext, ExecutionContext, Option
18
+ from blok.bloks.services.dns import DnsService
19
+ from blok.tree import Repo, YamlFile
20
+ from arkitekt_next.bloks.base import BaseArkitektService
21
+
22
+
23
+ @blok("live.arkitekt.alpaka", description="a container and app management service")
24
+ class AlpakaBlok(BaseArkitektService):
25
+ def get_builder(self):
26
+ return "arkitekt.generic"
27
+
28
+ def __init__(self) -> None:
29
+ self.dev = False
30
+ self.host = "alpaka"
31
+ self.command = "bash run-debug.sh"
32
+ self.repo = "https://github.com/arkitektio/alpaka-server"
33
+ self.scopes = {
34
+ "alpaka_pull": "Pull new Models",
35
+ "alpaka_chat": "Add repositories to the database",
36
+ }
37
+ self.mount_repo = False
38
+ self.build_repo = False
39
+ self.buckets = ["media"]
40
+ self.secret_key = secrets.token_hex(16)
41
+ self.image = "jhnnsrs/alpaka:nightly"
42
+
43
+ def preflight(
44
+ self,
45
+ lok: LokService,
46
+ db: DBService,
47
+ redis: RedisService,
48
+ s3: S3Service,
49
+ config: ConfigService,
50
+ ollama: OllamaService,
51
+ mount: MountService,
52
+ admin: AdminService,
53
+ secret: SecretService,
54
+ gateway: GatewayService,
55
+ mount_repo: bool = False,
56
+ host: str = "",
57
+ image: str = "",
58
+ secret_key: str = "",
59
+ build_repo: bool = False,
60
+ command: str = "",
61
+ repo: str = "",
62
+ disable: bool = False,
63
+ dev: bool = False,
64
+ ):
65
+ lok.register_scopes(self.scopes)
66
+
67
+ path_name = self.host
68
+
69
+ gateway.expose(path_name, 80, self.host)
70
+
71
+ postgress_access = db.register_db(self.host)
72
+ redis_access = redis.register()
73
+ lok_access = lok.retrieve_credentials()
74
+ admin_access = admin.retrieve()
75
+ minio_access = s3.create_buckets(self.buckets)
76
+ lok_labels = lok.retrieve_labels("live.arkitekt.alpaka", self.get_builder())
77
+ ollama_access = ollama.get_access()
78
+
79
+ django_secret = secret.retrieve_secret()
80
+
81
+ csrf_trusted_origins = []
82
+
83
+ configuration = YamlFile(
84
+ **{
85
+ "db": asdict(postgress_access),
86
+ "django": {
87
+ "admin": asdict(admin_access),
88
+ "debug": True,
89
+ "hosts": ["*"],
90
+ "secret_key": django_secret,
91
+ },
92
+ "redis": asdict(redis_access),
93
+ "lok": asdict(lok_access),
94
+ "s3": asdict(minio_access),
95
+ "scopes": self.scopes,
96
+ "force_script_name": path_name,
97
+ "csrf_trusted_origins": csrf_trusted_origins,
98
+ **self.get_additional_config(),
99
+ }
100
+ )
101
+
102
+ config_mount = config.register_config(f"{self.host}.yaml", configuration)
103
+
104
+ depends_on = []
105
+
106
+ if redis_access.dependency:
107
+ depends_on.append(redis_access.dependency)
108
+
109
+ if postgress_access.dependency:
110
+ depends_on.append(postgress_access.dependency)
111
+
112
+ if minio_access.dependency:
113
+ depends_on.append(minio_access.dependency)
114
+
115
+ if ollama_access.dependency:
116
+ depends_on.append(ollama_access.dependency)
117
+
118
+ service = {
119
+ "labels": lok_labels,
120
+ "volumes": [f"{config_mount}:/workspace/config.yaml"],
121
+ "depends_on": depends_on,
122
+ }
123
+
124
+ if mount_repo or dev:
125
+ mount = mount.register_mount(self.host, Repo(repo))
126
+ service["volumes"].extend([f"{mount}:/workspace"])
127
+
128
+ if build_repo or dev:
129
+ mount = mount.register_mount(self.host, Repo(repo))
130
+ service["build"] = mount
131
+ else:
132
+ service["image"] = image
133
+
134
+ service["command"] = command
135
+
136
+ self.service = service
@@ -21,9 +21,9 @@ class LocalLiveKitBlok:
21
21
  self.api_key = "devkey"
22
22
  self.api_secret = "secret"
23
23
  self.skip = False
24
+ self.api_port = 7880
24
25
 
25
26
  def preflight(self, init: InitContext, gateway: GatewayService):
26
-
27
27
  for key, value in init.kwargs.items():
28
28
  setattr(self, key, value)
29
29
 
@@ -37,12 +37,13 @@ class LocalLiveKitBlok:
37
37
 
38
38
  self.initialized = True
39
39
 
40
- def retrieve_access(self):
40
+ def get_access(self):
41
41
  return LivekitCredentials(
42
42
  **{
43
43
  "api_key": self.api_key,
44
44
  "api_secret": self.api_secret,
45
- "api_url": f"http://{self.host}:7880",
45
+ "host": self.host,
46
+ "port": self.api_port,
46
47
  }
47
48
  )
48
49