arkitekt-next 0.7.31__py3-none-any.whl → 0.7.33__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.

@@ -0,0 +1,25 @@
1
+ from arkitekt_next.bloks.admin import AdminBlok
2
+ from arkitekt_next.bloks.arkitekt import ArkitektBlok
3
+ from arkitekt_next.bloks.mikro import MikroBlok
4
+ from arkitekt_next.bloks.fluss import FlussBlok
5
+ from arkitekt_next.bloks.redis import RedisBlok
6
+ from arkitekt_next.bloks.gateway import GatewayBlok
7
+ from arkitekt_next.bloks.livekit import LiveKitBlok
8
+ from arkitekt_next.bloks.postgres import PostgresBlok
9
+ from arkitekt_next.bloks.minio import MinioBlok
10
+ from arkitekt_next.bloks.lok import LokBlok
11
+
12
+
13
+ def get_bloks():
14
+ return [
15
+ AdminBlok(),
16
+ ArkitektBlok(),
17
+ MikroBlok(),
18
+ FlussBlok(),
19
+ RedisBlok(),
20
+ GatewayBlok(),
21
+ LiveKitBlok(),
22
+ PostgresBlok(),
23
+ MinioBlok(),
24
+ LokBlok(),
25
+ ]
@@ -0,0 +1 @@
1
+ from .admin import AdminBlok
@@ -0,0 +1,53 @@
1
+ from pydantic import BaseModel
2
+ from typing import Dict, Any
3
+ from blok import blok, InitContext, CLIOption
4
+
5
+
6
+ class AdminCredentials(BaseModel):
7
+ password: str
8
+ username: str
9
+ email: str
10
+
11
+
12
+ @blok("live.arkitekt.admin")
13
+ class AdminBlok:
14
+ def __init__(self) -> None:
15
+ self.password = "admin"
16
+ self.username = "admin"
17
+ self.email = "admin@admin.com"
18
+
19
+ def init(self, init: InitContext):
20
+ for key, value in init.kwargs.items():
21
+ setattr(self, key, value)
22
+
23
+ def build(self, cwd):
24
+ pass
25
+
26
+ def retrieve(self):
27
+ return AdminCredentials(
28
+ password=self.password,
29
+ username=self.username,
30
+ email=self.email,
31
+ )
32
+
33
+ def get_options(self):
34
+ with_username = CLIOption(
35
+ subcommand="username",
36
+ help="Which admin username to use",
37
+ default=self.username,
38
+ show_default=True,
39
+ )
40
+ with_username = CLIOption(
41
+ subcommand="password",
42
+ help="Which password to use",
43
+ default=self.password,
44
+ show_default=True,
45
+ )
46
+ with_email = CLIOption(
47
+ subcommand="password",
48
+ help="Which password to use",
49
+ default=self.password,
50
+ show_default=True,
51
+ )
52
+
53
+ return [with_username, with_username, with_email]
@@ -0,0 +1,51 @@
1
+ from pydantic import BaseModel
2
+ from typing import Dict, Any
3
+ from blok import blok, InitContext, Renderer, Panel
4
+
5
+
6
+ class AdminCredentials(BaseModel):
7
+ password: str
8
+ username: str
9
+ email: str
10
+
11
+
12
+ @blok("live.arkitekt")
13
+ class ArkitektBlok:
14
+ def __init__(self) -> None:
15
+ pass
16
+
17
+ def get_dependencies(self):
18
+ return [
19
+ "live.arkitekt.lok",
20
+ "live.arkitekt.mikro",
21
+ "live.arkitekt.kabinet",
22
+ "live.arkitekt.gateway",
23
+ "io.livekit.livekit",
24
+ ]
25
+
26
+ def entry(self, renderer: Renderer):
27
+ renderer.render(
28
+ Panel(
29
+ f"This is the arkitekt build that allows you to setup a full stack arkitekt application. Make sure to understand how bloks work before proceeding.",
30
+ expand=False,
31
+ title="Welcome to Arkitekt!",
32
+ style="bold magenta",
33
+ )
34
+ )
35
+
36
+ def init(self, init: InitContext):
37
+ for key, value in init.kwargs.items():
38
+ setattr(self, key, value)
39
+
40
+ def build(self, cwd):
41
+ pass
42
+
43
+ def retrieve(self):
44
+ return AdminCredentials(
45
+ password=self.password,
46
+ username=self.username,
47
+ email=self.email,
48
+ )
49
+
50
+ def get_options(self):
51
+ return []
@@ -0,0 +1,138 @@
1
+ import secrets
2
+ from blok import blok, InitContext, ExecutionContext, CLIOption
3
+ from blok.tree import YamlFile, Repo
4
+
5
+
6
+ DEFAULT_ARKITEKT_URL = "http://localhost:8000"
7
+
8
+
9
+ @blok("live.arkitekt.kabinet")
10
+ class FlussBlok:
11
+ def __init__(self) -> None:
12
+ self.host = "fluss"
13
+ self.command = "bash run-debug.sh"
14
+ self.repo = "https://github.com/jhnnsrs/fluss-server-next"
15
+ self.scopes = {"read_image": "Read image from the database"}
16
+ self.mount_repo = True
17
+ self.build_repo = True
18
+ self.secret_key = secrets.token_hex(16)
19
+ self.ensured_repos = []
20
+
21
+ def get_dependencies(self):
22
+ return [
23
+ "live.arkitekt.gateway",
24
+ "live.arkitekt.postgres",
25
+ "live.arkitekt.lok",
26
+ "live.arkitekt.admin",
27
+ "live.arkitekt.redis",
28
+ "live.arkitekt.s3",
29
+ ]
30
+
31
+ def init(self, init: InitContext):
32
+ for key, value in init.kwargs.items():
33
+ setattr(self, key, value)
34
+
35
+ deps = init.dependencies
36
+
37
+ deps["live.arkitekt.lok"].register_scopes(self.scopes)
38
+
39
+ self.gateway_access = deps["live.arkitekt.gateway"].expose(
40
+ self.host, 80, self.host
41
+ )
42
+
43
+ self.postgress_access = deps["live.arkitekt.postgres"].register_db(self.host)
44
+ self.redis_access = deps["live.arkitekt.redis"].register()
45
+ self.lok_access = deps["live.arkitekt.lok"].retrieve_credentials()
46
+ self.admin_access = deps["live.arkitekt.admin"].retrieve()
47
+ self.minio_access = deps["live.arkitekt.s3"].retrieve_credentials(["media"])
48
+ self.initialized = True
49
+
50
+ def build(self, context: ExecutionContext):
51
+ depends_on = []
52
+
53
+ if self.redis_access.dependency:
54
+ depends_on.append(self.redis_access.dependency)
55
+
56
+ if self.postgress_access.dependency:
57
+ depends_on.append(self.postgress_access.dependency)
58
+
59
+ db_service = {
60
+ "labels": [
61
+ "fakts.service=live.arkitekt.fluss",
62
+ "fakts.builder=arkitekt.fluss",
63
+ ],
64
+ "depends_on": depends_on,
65
+ }
66
+
67
+ if self.mount_repo:
68
+ context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
69
+ db_service["volumes"] = [f"./mounts/{self.host}:/workspace"]
70
+
71
+ if self.build_repo:
72
+ context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
73
+ db_service["build"] = f"./mounts/{self.host}"
74
+
75
+ db_service["command"] = self.command
76
+
77
+ configuration = YamlFile(
78
+ **{
79
+ "db": self.postgress_access.dict(),
80
+ "django": {
81
+ "admin": self.admin_access.dict(),
82
+ "debug": True,
83
+ "hosts": ["*"],
84
+ "secret_key": self.secret_key,
85
+ },
86
+ "redis": self.redis_access.dict(),
87
+ "lok": self.lok_access.dict(),
88
+ "s3": self.minio_access.dict(),
89
+ "scopes": self.scopes,
90
+ }
91
+ )
92
+
93
+ context.file_tree.set_nested("configs", "fluss.yaml", configuration)
94
+
95
+ context.docker_compose.set_nested("services", self.host, db_service)
96
+
97
+ def get_options(self):
98
+ with_repo = CLIOption(
99
+ subcommand="with_repo",
100
+ help="Which repo should we use when building the service? Only active if build_repo or mount_repo is active",
101
+ default=self.repo,
102
+ )
103
+ with_command = CLIOption(
104
+ subcommand="command",
105
+ help="Which command should be run when starting the service",
106
+ default=self.command,
107
+ )
108
+ mount_repo = CLIOption(
109
+ subcommand="mount_repo",
110
+ help="Should we mount the repo into the container?",
111
+ is_flag=True,
112
+ default=True,
113
+ )
114
+ build_repo = CLIOption(
115
+ subcommand="build_repo",
116
+ help="Should we build the container from the repo?",
117
+ is_flag=True,
118
+ default=True,
119
+ )
120
+ with_host = CLIOption(
121
+ subcommand="host",
122
+ help="How should the service be named inside the docker-compose file?",
123
+ default=self.host,
124
+ )
125
+ with_secret_key = CLIOption(
126
+ subcommand="secret_key",
127
+ help="The secret key to use for the django service",
128
+ default=self.secret_key,
129
+ )
130
+
131
+ return [
132
+ with_repo,
133
+ mount_repo,
134
+ build_repo,
135
+ with_host,
136
+ with_command,
137
+ with_secret_key,
138
+ ]
@@ -0,0 +1,153 @@
1
+ from blok import blok, InitContext, ExecutionContext, CLIOption
2
+ from blok.tree import YamlFile, Repo
3
+ from pydantic import BaseModel
4
+ from typing import Dict, Any
5
+
6
+ from blok import blok, InitContext
7
+
8
+
9
+ DEFAULT_PUBLIC_URLS = ["127.0.0.1"]
10
+ DEFAULT_PUBLIC_HOSTS = ["localhost"]
11
+
12
+
13
+ class ExposedHost(BaseModel):
14
+ host: str
15
+ port: int
16
+ stip_prefix: bool = True
17
+
18
+
19
+ class ExposedPort(BaseModel):
20
+ port: int
21
+ host: str
22
+ tls: bool = False
23
+
24
+
25
+ @blok("live.arkitekt.gateway")
26
+ class GatewayBlok:
27
+ def __init__(self) -> None:
28
+ self.exposed_hosts = {}
29
+ self.http_expose_default = None
30
+ self.exposed_ports = {}
31
+ self.with_certer = True
32
+ self.with_tailscale = True
33
+ self.http_port = 80
34
+ self.https_port = 443
35
+
36
+ def get_identifier(self):
37
+ return "live.arkitekt.gateway"
38
+
39
+ def get_dependencies(self):
40
+ return []
41
+
42
+ def init(self, init: InitContext):
43
+ for key, value in init.kwargs.items():
44
+ setattr(self, key, value)
45
+
46
+ def build(self, context: ExecutionContext):
47
+ caddyfile = """
48
+ {
49
+ auto_https off
50
+ }
51
+ """
52
+
53
+ for key, port in self.exposed_ports.items():
54
+ if port.tls:
55
+ caddyfile += f"""
56
+ :{port.port} {{
57
+ tls /certs/caddy.crt /certs/caddy.key
58
+ reverse_proxy {port.host}:{port.port}
59
+ }}
60
+ """
61
+ else:
62
+ caddyfile += f"""
63
+ :{port.port} {{
64
+ reverse_proxy {port.host}:{port.port}
65
+ }}
66
+ """
67
+
68
+ caddyfile += """
69
+ https:// {
70
+ tls /certs/caddy.crt /certs/caddy.key
71
+
72
+ header {
73
+ -Server
74
+ X-Forwarded-Proto {scheme}
75
+ X-Forwarded-For {remote}
76
+ X-Forwarded-Port {server_port}
77
+ X-Forwarded-Host {host}
78
+ }
79
+ """
80
+
81
+ for path_name, exposed_host in self.exposed_hosts.items():
82
+ if exposed_host.stip_prefix:
83
+ caddyfile += f"""
84
+ @{path_name} path /{path_name} {{
85
+ uri strip_prefix /{path_name}
86
+ reverse_proxy {exposed_host.host}:{exposed_host.port}
87
+ }}
88
+ """
89
+ else:
90
+ caddyfile += f"""
91
+ @{path_name} path /{path_name}{{
92
+ reverse_proxy {exposed_host.host}:{exposed_host.port}
93
+ }}
94
+ """
95
+
96
+ caddyfile += """
97
+ }
98
+ """
99
+
100
+ context.file_tree.set_nested("config", "Caddyfile", caddyfile)
101
+
102
+ caddy_depends_on = []
103
+ if self.with_certer:
104
+ caddy_depends_on.append("certer")
105
+
106
+ caddy_container = {
107
+ "image": "caddy:latest",
108
+ "volumes": ["./config/Caddyfile:/etc/caddy/Caddyfile"],
109
+ "ports": [f"{self.http_port}:80", f"{self.https_port}:443"],
110
+ "depends_on": caddy_depends_on,
111
+ }
112
+
113
+ context.docker_compose.set_nested("services", "caddy", caddy_container)
114
+
115
+ if self.with_certer:
116
+ context.file_tree.set_nested("certs", {})
117
+ caddy_container = {
118
+ "image": "jhnnsrs/certer:latest",
119
+ "volumes": ["./certs:/certs"],
120
+ "ports": [f"{self.http_port}:80", f"{self.https_port}:443"],
121
+ "depends_on": caddy_depends_on,
122
+ }
123
+
124
+ def expose(self, path_name: str, port: int, host: str, strip_prefix: bool = True):
125
+ self.exposed_hosts[path_name] = ExposedHost(
126
+ host=host, port=port, stip_prefix=strip_prefix
127
+ )
128
+
129
+ def expose_default(self, port: int, host: str):
130
+ self.http_expose_default = ExposedHost(host=host, port=port, stip_prefix=False)
131
+
132
+ def expose_port(self, port: int, host: str, tls: bool = False):
133
+ self.exposed_ports[port] = ExposedPort(port=port, host=host, tls=tls)
134
+
135
+ def get_options(self):
136
+ with_public_urls = CLIOption(
137
+ subcommand="public_url",
138
+ help="Which public urls to use",
139
+ type=str,
140
+ multiple=True,
141
+ default=DEFAULT_PUBLIC_URLS,
142
+ show_default=True,
143
+ )
144
+ with_public_services = CLIOption(
145
+ subcommand="public_hosts",
146
+ help="Which public hosts to use",
147
+ type=str,
148
+ multiple=True,
149
+ default=DEFAULT_PUBLIC_HOSTS,
150
+ show_default=True,
151
+ )
152
+
153
+ return [with_public_urls, with_public_services]
@@ -0,0 +1,143 @@
1
+ from typing import Dict, Any
2
+ import secrets
3
+
4
+ from blok import blok, InitContext, ExecutionContext
5
+ from blok.tree import Repo, YamlFile
6
+
7
+
8
+ @blok("live.arkitekt.kabinet")
9
+ class KabinetBlok:
10
+ def __init__(self) -> None:
11
+ self.host = "kabinet"
12
+ self.command = "bash run-debug.sh"
13
+ self.repo = "https://github.com/jhnnsrs/kabinet-server"
14
+ self.scopes = {"read_image": "Read image from the database"}
15
+ self.mount_repo = True
16
+ self.build_repo = True
17
+ self.secret_key = secrets.token_hex(16)
18
+ self.ensured_repos = []
19
+
20
+ def get_dependencies(self):
21
+ return [
22
+ "live.arkitekt.gateway",
23
+ "live.arkitekt.postgres",
24
+ "live.arkitekt.lok",
25
+ "live.arkitekt.admin",
26
+ "live.arkitekt.redis",
27
+ "live.arkitekt.s3",
28
+ ]
29
+
30
+ def init(self, init: InitContext):
31
+ for key, value in init.kwargs.items():
32
+ setattr(self, key, value)
33
+
34
+ deps = init.dependencies
35
+
36
+ deps["live.arkitekt.lok"].register_scopes(self.scopes)
37
+
38
+ self.gateway_access = deps["live.arkitekt.gateway"].expose(
39
+ self.host, 80, self.host
40
+ )
41
+
42
+ self.postgress_access = deps["live.arkitekt.postgres"].register_db(self.host)
43
+ self.redis_access = deps["live.arkitekt.redis"].register()
44
+ self.lok_access = deps["live.arkitekt.lok"].retrieve_credentials()
45
+ self.admin_access = deps["live.arkitekt.admin"].retrieve()
46
+ self.minio_access = deps["live.arkitekt.s3"].retrieve_credentials(["media"])
47
+ self.initialized = True
48
+
49
+ def build(self, context: ExecutionContext):
50
+ depends_on = []
51
+
52
+ if self.redis_access.dependency:
53
+ depends_on.append(self.redis_access.dependency)
54
+
55
+ if self.postgress_access.dependency:
56
+ depends_on.append(self.postgress_access.dependency)
57
+
58
+ db_service = {
59
+ "labels": [
60
+ "fakts.service=live.arkitekt.mikro",
61
+ "fakts.builder=arkitekt.mikro",
62
+ ],
63
+ "depends_on": depends_on,
64
+ }
65
+
66
+ if self.mount_repo:
67
+ context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
68
+ db_service["volumes"] = [f"./mounts/{self.host}:/workspace"]
69
+
70
+ if self.build_repo:
71
+ context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
72
+ db_service["build"] = f"./mounts/{self.host}"
73
+
74
+ db_service["command"] = self.command
75
+
76
+ configuration = YamlFile(
77
+ **{
78
+ "db": self.postgress_access.dict(),
79
+ "django": {
80
+ "admin": self.admin_access.dict(),
81
+ "debug": True,
82
+ "hosts": ["*"],
83
+ "secret_key": self.secret_key,
84
+ },
85
+ "redis": self.redis_access.dict(),
86
+ "lok": self.lok_access.dict(),
87
+ "s3": self.minio_access.dict(),
88
+ "scopes": self.scopes,
89
+ }
90
+ )
91
+
92
+ context.file_tree.set_nested("configs", "kabinet.yaml", configuration)
93
+
94
+ context.docker_compose.set_nested("services", self.host, db_service)
95
+
96
+ def get_options(self):
97
+ with_repo = CLIOptions(
98
+ subcommand="with_repo",
99
+ help="Which repo should we use when building the service? Only active if build_repo or mount_repo is active",
100
+ default=self.repo,
101
+ )
102
+ with_command = CLIOptions(
103
+ subcommand="command",
104
+ help="Which command should be run when starting the service",
105
+ default=self.command,
106
+ )
107
+ mount_repo = CLIOptions(
108
+ subcommand="mount_repo",
109
+ help="Should we mount the repo into the container?",
110
+ is_flag=True,
111
+ default=True,
112
+ )
113
+ build_repo = CLIOptions(
114
+ subcommand="build_repo",
115
+ help="Should we build the container from the repo?",
116
+ is_flag=True,
117
+ default=True,
118
+ )
119
+ with_host = CLIOptions(
120
+ subcommand="host",
121
+ help="How should the service be named inside the docker-compose file?",
122
+ default=self.host,
123
+ )
124
+ with_secret_key = CLIOptions(
125
+ subcommand="secret_key",
126
+ help="The secret key to use for the django service",
127
+ default=self.secret_key,
128
+ )
129
+ with_repos = CLIOptions(
130
+ subcommand="repos",
131
+ help="The default repos to enable for the service",
132
+ default=self.secret_key,
133
+ )
134
+
135
+ return [
136
+ with_repo,
137
+ mount_repo,
138
+ build_repo,
139
+ with_host,
140
+ with_command,
141
+ with_secret_key,
142
+ with_repos,
143
+ ]
@@ -0,0 +1,71 @@
1
+ from typing import Dict, Any
2
+ import secrets
3
+
4
+ from blok import blok, InitContext, ExecutionContext, CLIOption
5
+ from blok.tree import YamlFile, Repo
6
+
7
+
8
+ @blok("io.livekit.livekit")
9
+ class LiveKitBlok:
10
+ def __init__(self) -> None:
11
+ self.host = "livekit"
12
+ self.command = ["--dev", "--bind", "0.0.0.0"]
13
+ self.image = "livekit/livekit-server:latest"
14
+ self.mount_repo = True
15
+ self.build_repo = True
16
+ self.secret_key = secrets.token_hex(16)
17
+ self.ensured_repos = []
18
+ self.port_range = [50000, 50030]
19
+
20
+ def get_dependencies(self):
21
+ return [
22
+ "live.arkitekt.gateway",
23
+ ]
24
+
25
+ def init(self, init: InitContext):
26
+ for key, value in init.kwargs.items():
27
+ setattr(self, key, value)
28
+
29
+ deps = init.dependencies
30
+
31
+ deps["live.arkitekt.gateway"].expose_port(7880, self.host, True)
32
+ deps["live.arkitekt.gateway"].expose_port(7881, self.host, True)
33
+
34
+ self.initialized = True
35
+
36
+ def build(self, context: ExecutionContext):
37
+ db_service = {
38
+ "labels": [
39
+ "fakts.service=io.livekit.livekit",
40
+ "fakts.builder=livekitio.livekit",
41
+ ],
42
+ "image": self.image,
43
+ "command": self.command,
44
+ "ports": [
45
+ f"{self.port_range[0]}-{self.port_range[1]}:{self.port_range[0]}-{self.port_range[1]}"
46
+ ],
47
+ }
48
+
49
+ context.docker_compose.set_nested("services", self.host, db_service)
50
+
51
+ def get_options(self):
52
+ with_command = CLIOption(
53
+ subcommand="command",
54
+ help="The fakts url for connection",
55
+ default=self.command,
56
+ )
57
+ with_host = CLIOption(
58
+ subcommand="host",
59
+ help="The fakts url for connection",
60
+ default=self.host,
61
+ )
62
+
63
+ return [
64
+ with_host,
65
+ with_command,
66
+ ]
67
+
68
+ def __str__(self) -> str:
69
+ return (
70
+ f"LiveKitBlok(host={self.host}, command={self.command}, image={self.image})"
71
+ )