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

arkitekt_next/builders.py CHANGED
@@ -96,6 +96,7 @@ def easy(
96
96
  NextApp
97
97
  A built app, that can be used to interact with the ArkitektNext server
98
98
  """
99
+ print("CAAAAAAAAAAAAAAAAAAAAAAAAAAAALLLED")
99
100
  registry = registry or check_and_import_services()
100
101
 
101
102
 
@@ -20,6 +20,14 @@ def compile(projects, config):
20
20
  """
21
21
  app_directory = os.getcwd()
22
22
 
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
23
31
  from turms.run import scan_folder_for_single_config, load_projects_from_configpath
24
32
  from turms.cli.main import generate_projects
25
33
 
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import shutil
3
+ from click import ClickException
3
4
  import rich_click as click
4
5
  from arkitekt_next.cli.options import (
5
6
  with_documents,
@@ -13,6 +14,7 @@ from arkitekt_next.cli.options import (
13
14
  import yaml
14
15
  from arkitekt_next.cli.utils import build_relative_dir
15
16
  from arkitekt_next.cli.vars import get_console, get_manifest
17
+ from arkitekt_next.service_registry import check_and_import_services
16
18
 
17
19
 
18
20
  @click.command()
@@ -38,75 +40,68 @@ def init(ctx, boring, services, config, documents, schemas, path, seperate_doc_d
38
40
  app_directory = os.getcwd()
39
41
 
40
42
  app_api_path = os.path.join(app_directory, path)
41
- app_documents = os.path.join(app_directory, "graphql", "documents")
43
+ app_documents = os.path.join(app_directory, "documents")
42
44
 
43
- app_schemas = os.path.join(app_directory, "graphql", "schemas")
45
+ app_schemas = os.path.join(app_directory, "schemas")
44
46
 
45
- if documents:
46
- os.makedirs(app_documents, exist_ok=True)
47
- if schemas:
48
- os.makedirs(app_schemas, exist_ok=True)
49
- if path:
50
- os.makedirs(app_api_path, exist_ok=True)
47
+ os.makedirs(app_documents, exist_ok=True)
48
+ os.makedirs(app_schemas, exist_ok=True)
49
+ os.makedirs(app_api_path, exist_ok=True)
51
50
 
52
51
  # Initializing the config
53
52
  projects = {}
54
53
 
54
+
55
+ registry = check_and_import_services()
56
+
55
57
  base_config = yaml.load(
56
58
  open(build_relative_dir("configs", "base.yaml"), "r"), Loader=yaml.FullLoader
57
59
  )
58
60
 
59
- for service in services:
60
- schema_path = build_relative_dir("schemas", f"{service}.schema.graphql")
61
+ for key, service in registry.service_builders.items():
62
+ try:
61
63
 
62
- if documents:
63
- os.makedirs(os.path.join(app_documents, service), exist_ok=True)
64
- if seperate_doc_dirs:
65
- os.makedirs(
66
- os.path.join(app_documents, service, "queries"), exist_ok=True
67
- )
68
- os.makedirs(
69
- os.path.join(app_documents, service, "mutations"), exist_ok=True
70
- )
71
- os.makedirs(
72
- os.path.join(app_documents, service, "subscriptions"), exist_ok=True
73
- )
64
+ schema, project = service.get_graphql_schema(), service.get_turms_project()
74
65
 
75
- if schemas:
76
- if os.path.exists(schema_path):
77
- try:
78
- shutil.copyfile(
79
- schema_path,
80
- os.path.join(app_schemas, service + ".graphql"),
66
+ if not schema or not project:
67
+ get_console(ctx).print(f"[red]No schema or project found for {key} [/]")
68
+ continue
69
+
70
+ if documents:
71
+ os.makedirs(os.path.join(app_documents, key), exist_ok=True)
72
+ if seperate_doc_dirs:
73
+ os.makedirs(
74
+ os.path.join(app_documents, key, "queries"), exist_ok=True
75
+ )
76
+ os.makedirs(
77
+ os.path.join(app_documents, key, "mutations"), exist_ok=True
78
+ )
79
+ os.makedirs(
80
+ os.path.join(app_documents, key, "subscriptions"), exist_ok=True
81
81
  )
82
- except FileExistsError:
83
- if click.confirm(
84
- f"Schema for {service} already exist. Do you want to overwrite them?"
85
- ):
86
- shutil.copyfile(
87
- schema_path,
88
- os.path.join(app_schemas, service + ".graphql"),
89
- )
90
- else:
91
- get_console(ctx).print(f"[red]No schema found for {service} [/]")
92
82
 
93
- try:
94
- project = base_config["projects"][service]
95
- except KeyError:
96
- get_console(ctx).print(f"[red]No config found for {service} [/]")
97
- continue
98
-
99
- if schemas:
100
- project["schema"] = os.path.join(app_schemas, service + ".graphql")
101
- if documents:
102
- project["documents"] = (
103
- os.path.join(app_documents, service) + "/**/*.graphql"
104
- )
105
-
106
- project["extensions"]["turms"]["out_dir"] = path
107
- project["extensions"]["turms"]["generated_name"] = f"{service}.py"
108
-
109
- projects[service] = project
83
+ if schemas:
84
+ out_path = os.path.join(app_schemas, key + ".schema.graphql")
85
+ with open(out_path, "w") as f:
86
+ f.write(schema)
87
+
88
+
89
+
90
+ if schemas:
91
+ project["schema"] = os.path.join(app_schemas, key + ".schema.graphql")
92
+ if documents:
93
+ project["documents"] = (
94
+ os.path.join(app_documents, key) + "/**/*.graphql"
95
+ )
96
+
97
+ project["extensions"]["turms"]["out_dir"] = path
98
+ project["extensions"]["turms"]["generated_name"] = f"{key}.py"
99
+ del project["extensions"]["turms"]["documents"]
100
+
101
+ projects[key] = project
102
+
103
+ except Exception as e:
104
+ raise ClickException(f"Failed to initialize project for {key}. Error: {e}") from e
110
105
 
111
106
  if os.path.exists(config):
112
107
  if not click.confirm(
@@ -2,46 +2,96 @@ from pydantic import BaseModel, Field
2
2
  from herre_next import Herre
3
3
  from fakts_next import Fakts
4
4
  from .base_models import Manifest, Requirement
5
- from typing import Callable, Dict
5
+ from typing import Callable, Dict, Protocol
6
6
  import importlib
7
7
  import sys
8
8
  import os
9
9
  import traceback
10
10
  import logging
11
11
  import pkgutil
12
+ from typing import runtime_checkable
12
13
 
13
14
  Params = Dict[str, str]
14
15
 
15
16
 
17
+
18
+
19
+
20
+
16
21
  class Registration(BaseModel):
17
22
  name: str
18
23
  requirement: Requirement
19
24
  builder: Callable[[Herre, Fakts, Params], object]
25
+ schema_loader: Callable[[str], object]
26
+
27
+
28
+ @runtime_checkable
29
+ class ArkitektService(Protocol):
30
+
31
+
32
+ def get_service_name(self):
33
+ pass
34
+
35
+
36
+ def build_service(self, fakts: Fakts, herre: Herre, params: Params, manifest: Manifest):
37
+ pass
38
+
39
+
40
+ def get_requirements(self):
41
+ pass
42
+
43
+
44
+ def get_graphql_schema(self):
45
+ pass
46
+
47
+ def get_turms_project(self):
48
+ pass
49
+
50
+
51
+
52
+ class BaseArkitektService:
53
+
54
+
55
+ def get_service_name(self):
56
+ raise NotImplementedError("get_service_name not implemented")
57
+
58
+ def build_service(self, fakts: Fakts, herre: Herre, params: Params, manifest: Manifest):
59
+ raise NotImplementedError("build_service not implemented")
60
+
61
+ def get_requirements(self):
62
+ raise NotImplementedError("get_requirements not implemented")
63
+
64
+ def get_graphql_schema(self):
65
+ return None
66
+
67
+ def get_turms_project(self):
68
+ return None
69
+
20
70
 
21
71
 
22
- basic_requirements = {"lok": Requirement(
72
+ basic_requirements = [Requirement(
23
73
  key="lok",
24
74
  service="live.arkitekt.lok",
25
75
  description="An instance of ArkitektNext Lok to authenticate the user",
26
- )}
76
+ )]
27
77
 
28
78
 
29
79
  class ServiceBuilderRegistry:
30
80
  def __init__(self):
31
- self.service_builders = {}
32
- self.requirements_map = basic_requirements
81
+ self.service_builders: Dict[str, ArkitektService] = {}
33
82
 
34
83
  def register(
35
84
  self,
36
- name: str,
37
- service_builder: Callable[[Herre, Fakts], object],
38
- requirement: Requirement,
85
+ service: ArkitektService,
39
86
  ):
87
+
88
+ name = service.get_service_name()
89
+
40
90
  if name not in self.service_builders:
41
- self.service_builders[name] = service_builder
91
+ self.service_builders[name] = service
92
+ else:
93
+ raise ValueError(f"Service {name} already registered")
42
94
 
43
- if name not in self.requirements_map:
44
- self.requirements_map[name] = requirement
45
95
 
46
96
  def get(self, name):
47
97
  return self.services.get(name)
@@ -49,36 +99,65 @@ class ServiceBuilderRegistry:
49
99
  def build_service_map(
50
100
  self, fakts: Fakts, herre: Herre, params: Params, manifest: Manifest
51
101
  ):
52
- return {
53
- name: builder(fakts, herre, params, manifest)
54
- for name, builder in self.service_builders.items()
102
+ potentially_needed_services = {
103
+ name: service.build_service(fakts, herre, params, manifest)
104
+ for name, service in self.service_builders.items()
55
105
  }
56
106
 
107
+ print(potentially_needed_services.keys())
108
+
109
+
110
+ return {key: value for key, value in potentially_needed_services.items() if value is not None}
111
+
112
+
113
+
57
114
  def get_requirements(self):
58
- return self.requirements_map.values()
115
+
116
+ requirements = basic_requirements
117
+
118
+ for service in self.service_builders.values():
119
+ for requirement in service.get_requirements():
120
+ requirements.append(requirement)
121
+
122
+
123
+
124
+ return requirements
59
125
 
60
126
 
61
127
  class SetupInfo:
62
128
  services: Dict[str, object]
63
129
 
64
130
 
65
- def check_and_import_services() -> ServiceBuilderRegistry:
131
+ import os
132
+ import importlib.util
133
+ import pkgutil
134
+ import traceback
135
+ import logging
66
136
 
137
+ def check_and_import_services() -> ServiceBuilderRegistry:
67
138
  service_builder_registry = ServiceBuilderRegistry()
139
+ processed_modules = set() # Track modules that have already been processed
68
140
 
69
141
  # Function to load and call init_extensions from __rekuest__.py
70
142
  def load_and_call_init_extensions(module_name, rekuest_path):
143
+ if module_name in processed_modules:
144
+ return # Skip if module has already been processed
71
145
  try:
72
146
  spec = importlib.util.spec_from_file_location(
73
147
  f"{module_name}.__arkitekt__", rekuest_path
74
148
  )
75
149
  rekuest_module = importlib.util.module_from_spec(spec)
76
150
  spec.loader.exec_module(rekuest_module)
77
- if hasattr(rekuest_module, "init_services"):
78
- rekuest_module.init_services(service_builder_registry)
79
- logging.info(f"Called init_service function from {module_name}")
151
+ if hasattr(rekuest_module, "build_services"):
152
+ for service in rekuest_module.build_services():
153
+ try:
154
+ service_builder_registry.register(service)
155
+ except ValueError as e:
156
+ print(f"Failed to register service {service}: Another service with the same name is already registered {service_builder_registry.service_builders}")
157
+ logging.info(f"Called build_services function from {module_name}")
80
158
  else:
81
- print(f"No init_services function in {module_name}.__arkitekt__")
159
+ print(f"Discovered Arkitekt-like module (containing __arkitekt__) that doesn't conform with the __arkitekt__ spec. No build_services function in {module_name}.__arkitekt__")
160
+ processed_modules.add(module_name) # Mark this module as processed
82
161
  except Exception as e:
83
162
  print(f"Failed to call init_services for {module_name}: {e}")
84
163
  traceback.print_exc()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: arkitekt-next
3
- Version: 0.8.32
3
+ Version: 0.8.34
4
4
  Summary: client for the arkitekt_next platform
5
5
  License: MIT
6
6
  Author: jhnnsrs
@@ -21,21 +21,21 @@ Requires-Dist: blok (>=0.0.19) ; (python_version >= "3.9" and python_version < "
21
21
  Requires-Dist: cryptography (>=40.0.8) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "blok")
22
22
  Requires-Dist: dokker (>=1.0.0)
23
23
  Requires-Dist: fakts-next (>=1.0.2)
24
- Requires-Dist: fluss-next (>=0.1.90) ; extra == "all"
24
+ Requires-Dist: fluss-next (>=0.1.91) ; extra == "all"
25
25
  Requires-Dist: herre-next (>=1.0.2)
26
- Requires-Dist: kabinet (>=0.1.38) ; (python_version >= "3.9" and python_version < "4.0") and (extra == "all")
26
+ Requires-Dist: kabinet (>=0.1.40) ; (python_version >= "3.9" and python_version < "4.0") and (extra == "all")
27
27
  Requires-Dist: koil (>=1.0.0)
28
- Requires-Dist: kraph (>=0.1.91) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "extended")
29
- Requires-Dist: lovekit (>=0.1.15) ; (python_version >= "3.10" and python_version < "4.0") and (extra == "all")
30
- Requires-Dist: mikro-next (>=0.1.47) ; (python_version >= "3.10" and python_version < "4.0") and (extra == "all")
28
+ Requires-Dist: kraph (>=0.1.92) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "extended")
29
+ Requires-Dist: lovekit (>=0.1.16) ; (python_version >= "3.10" and python_version < "4.0") and (extra == "all")
30
+ Requires-Dist: mikro-next (>=0.1.48) ; (python_version >= "3.10" and python_version < "4.0") and (extra == "all")
31
31
  Requires-Dist: namegenerator (>=1.0.6) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "blok")
32
32
  Requires-Dist: netifaces (>=0.11.0) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "blok")
33
- Requires-Dist: reaktion-next (>=0.1.80) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "all")
34
- Requires-Dist: rekuest-next (>=0.2.43) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "cli" or extra == "all")
33
+ Requires-Dist: reaktion-next (>=0.1.81) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "all")
34
+ Requires-Dist: rekuest-next (>=0.2.44) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "cli" or extra == "all")
35
35
  Requires-Dist: rich-click (>=1.6.1) ; extra == "cli" or extra == "all"
36
36
  Requires-Dist: semver (>=3.0.1) ; extra == "cli" or extra == "all"
37
- Requires-Dist: turms (>=0.6.0) ; (python_version >= "3.9" and python_version < "4.0") and (extra == "cli" or extra == "all")
38
- Requires-Dist: unlok-next (>=0.1.83) ; python_version >= "3.8" and python_version < "4.0"
37
+ Requires-Dist: turms (>=0.7.0) ; (python_version >= "3.9" and python_version < "4.0") and (extra == "cli" or extra == "all")
38
+ Requires-Dist: unlok-next (>=0.1.84) ; python_version >= "3.8" and python_version < "4.0"
39
39
  Requires-Dist: watchfiles (>=0.18.1) ; extra == "cli" or extra == "all"
40
40
  Description-Content-Type: text/markdown
41
41
 
@@ -44,15 +44,15 @@ arkitekt_next/bloks/services/secret.py,sha256=cnZsH09gN9YRXBbmalZaFD2LcmWLlfm52m
44
44
  arkitekt_next/bloks/services/socket.py,sha256=3MbENiJrwQbFKrpWxax56F24elnSD7S-olgycfuOX7s,423
45
45
  arkitekt_next/bloks/socket.py,sha256=IW4954Hgms_oZsDIk9SgLoVGz07gW3sHi7-WuhN074Q,1067
46
46
  arkitekt_next/bloks/tailscale.py,sha256=87cJv9m7N_I3y2ZRvv5WVepRhvIZk4ftUpwa0yUdwj4,2961
47
- arkitekt_next/builders.py,sha256=6SEVMOUohV0elOXPfTeeusF2yZ64x0LYYr6AB2y1h8Y,7464
47
+ arkitekt_next/builders.py,sha256=Oq1MZczo9EwwP9Nxrnm5qGr0ZM0XZZ4zcYLyZGARGGc,7512
48
48
  arkitekt_next/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  arkitekt_next/cli/commands/call/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  arkitekt_next/cli/commands/call/local.py,sha256=OAeC2r9ujBFclaCfKEmUpt0Mt3NAKw3sVPTDvs2w_8E,2059
51
51
  arkitekt_next/cli/commands/call/main.py,sha256=SdxlvSgA17-M_gwItiFU_srbh-CNdHpCTv_DkpOLojE,500
52
52
  arkitekt_next/cli/commands/call/remote.py,sha256=Id6t1nUdXmERx9wbutEhvryUMAM80_G4HVHkhYZosTE,2097
53
53
  arkitekt_next/cli/commands/gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- arkitekt_next/cli/commands/gen/compile.py,sha256=lygqut1fIiopa4MbBXkv1X-45g6UBxDxpGP7R6h-b7U,1445
55
- arkitekt_next/cli/commands/gen/init.py,sha256=JV9x27Iy80QlmigXd7TSG2YIBHPGJBdEQ_HPenQaYZU,4092
54
+ arkitekt_next/cli/commands/gen/compile.py,sha256=F0rAeBL4WWLdBGQRxVNqe5Bjek_SovhNO5rKrMEhj_4,1457
55
+ arkitekt_next/cli/commands/gen/init.py,sha256=AErMu5qiX_9qn7EeYY-0gq53vKMp7VdSbRSLWzqW-EI,3893
56
56
  arkitekt_next/cli/commands/gen/main.py,sha256=_BdkcsXoWY5_3gmboq2e0pGYM6lAnwqQgBAyxmvdf6U,947
57
57
  arkitekt_next/cli/commands/gen/watch.py,sha256=nf4QckdTJOWxvKoeNRwvC4rXQ4xhIx8LCDDJzpPhcY8,1189
58
58
  arkitekt_next/cli/commands/init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -129,11 +129,11 @@ arkitekt_next/qt/builders.py,sha256=zQLn-mJJnfLHSDjfAJ7gfzv66cnQz_yNX9yKTEdapi4,
129
129
  arkitekt_next/qt/magic_bar.py,sha256=_H74_s5Nqj20FpvzLSCxRwZMuZxqobkmn_sdwhpqzCg,17632
130
130
  arkitekt_next/qt/types.py,sha256=RzliCycvB_i7SZcXgahfXCJ9ft8QNsJKkrzpNbXF9qQ,4042
131
131
  arkitekt_next/qt/utils.py,sha256=MgBPtPmCSBkIuATov3UgREESwxAHh77lWNNxyE7Qs48,773
132
- arkitekt_next/service_registry.py,sha256=_ajPWQKA5clfQ_Nb7V-qr_k2ypw9F5iQMDaLpfwVh4A,3736
132
+ arkitekt_next/service_registry.py,sha256=vSQE9kaeNLva8cn_Q5Fu3mWf5A7ktLhnPQPzq75-7rU,5776
133
133
  arkitekt_next/tqdm.py,sha256=lQcJI5Q6Py7Gy88hOCiJujjPEEGd8G2k1mOVJJ6oYe8,1531
134
134
  arkitekt_next/utils.py,sha256=QETdzn_GIMSw6LdaXL89bqvqp9MGwEBK8Lj54MpnMwc,2396
135
- arkitekt_next-0.8.32.dist-info/LICENSE,sha256=YZ2oRjC248t-GpoEyw7J13vwKYNG6zhYMaEAix6EzF0,1089
136
- arkitekt_next-0.8.32.dist-info/METADATA,sha256=ZD0KcOefthfHkq0fMnwMGlaNfW2oSOoKdEIyt8lGCxI,6210
137
- arkitekt_next-0.8.32.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
138
- arkitekt_next-0.8.32.dist-info/entry_points.txt,sha256=-hxikQx4xZ6TiOnWVDOlTN_kcAISgGFvTHXIchsCHSc,60
139
- arkitekt_next-0.8.32.dist-info/RECORD,,
135
+ arkitekt_next-0.8.34.dist-info/LICENSE,sha256=YZ2oRjC248t-GpoEyw7J13vwKYNG6zhYMaEAix6EzF0,1089
136
+ arkitekt_next-0.8.34.dist-info/METADATA,sha256=dKpU8OXTj0ZRc0WBfYq0b9mg1kpsCx1bVrd8T2xHAFY,6210
137
+ arkitekt_next-0.8.34.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
138
+ arkitekt_next-0.8.34.dist-info/entry_points.txt,sha256=-hxikQx4xZ6TiOnWVDOlTN_kcAISgGFvTHXIchsCHSc,60
139
+ arkitekt_next-0.8.34.dist-info/RECORD,,