arkitekt-next 0.7.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.

Potentially problematic release.


This version of arkitekt-next might be problematic. Click here for more details.

Files changed (119) hide show
  1. arkitekt_next/__init__.py +43 -0
  2. arkitekt_next/apps/__init__.py +3 -0
  3. arkitekt_next/apps/easy.py +99 -0
  4. arkitekt_next/apps/next.py +40 -0
  5. arkitekt_next/apps/qt.py +97 -0
  6. arkitekt_next/apps/service/__init__.py +3 -0
  7. arkitekt_next/apps/service/fakts.py +88 -0
  8. arkitekt_next/apps/service/fakts_next.py +79 -0
  9. arkitekt_next/apps/service/fakts_qt.py +82 -0
  10. arkitekt_next/apps/service/fluss_next.py +31 -0
  11. arkitekt_next/apps/service/grant_registry.py +27 -0
  12. arkitekt_next/apps/service/herre.py +24 -0
  13. arkitekt_next/apps/service/herre_qt.py +57 -0
  14. arkitekt_next/apps/service/kabinet.py +31 -0
  15. arkitekt_next/apps/service/mikro_next.py +81 -0
  16. arkitekt_next/apps/service/rekuest_next.py +53 -0
  17. arkitekt_next/apps/service/unlok_next.py +32 -0
  18. arkitekt_next/apps/types.py +53 -0
  19. arkitekt_next/builders.py +264 -0
  20. arkitekt_next/cli/__init__.py +0 -0
  21. arkitekt_next/cli/commands/call/__init__.py +0 -0
  22. arkitekt_next/cli/commands/call/local.py +132 -0
  23. arkitekt_next/cli/commands/call/main.py +22 -0
  24. arkitekt_next/cli/commands/call/remote.py +90 -0
  25. arkitekt_next/cli/commands/gen/__init__.py +0 -0
  26. arkitekt_next/cli/commands/gen/compile.py +45 -0
  27. arkitekt_next/cli/commands/gen/init.py +122 -0
  28. arkitekt_next/cli/commands/gen/main.py +29 -0
  29. arkitekt_next/cli/commands/gen/watch.py +32 -0
  30. arkitekt_next/cli/commands/init/__init__.py +0 -0
  31. arkitekt_next/cli/commands/init/main.py +194 -0
  32. arkitekt_next/cli/commands/inspect/__init__.py +0 -0
  33. arkitekt_next/cli/commands/inspect/definitions.py +53 -0
  34. arkitekt_next/cli/commands/inspect/main.py +22 -0
  35. arkitekt_next/cli/commands/inspect/variables.py +92 -0
  36. arkitekt_next/cli/commands/manifest/__init__.py +0 -0
  37. arkitekt_next/cli/commands/manifest/inspect.py +42 -0
  38. arkitekt_next/cli/commands/manifest/main.py +25 -0
  39. arkitekt_next/cli/commands/manifest/scopes.py +155 -0
  40. arkitekt_next/cli/commands/manifest/version.py +147 -0
  41. arkitekt_next/cli/commands/manifest/wizard.py +94 -0
  42. arkitekt_next/cli/commands/port/__init__.py +0 -0
  43. arkitekt_next/cli/commands/port/build.py +231 -0
  44. arkitekt_next/cli/commands/port/init.py +82 -0
  45. arkitekt_next/cli/commands/port/main.py +31 -0
  46. arkitekt_next/cli/commands/port/publish.py +102 -0
  47. arkitekt_next/cli/commands/port/stage.py +59 -0
  48. arkitekt_next/cli/commands/port/utils.py +47 -0
  49. arkitekt_next/cli/commands/port/validate.py +78 -0
  50. arkitekt_next/cli/commands/port/wizard.py +329 -0
  51. arkitekt_next/cli/commands/run/__init__.py +0 -0
  52. arkitekt_next/cli/commands/run/dev.py +349 -0
  53. arkitekt_next/cli/commands/run/main.py +22 -0
  54. arkitekt_next/cli/commands/run/prod.py +57 -0
  55. arkitekt_next/cli/commands/run/utils.py +10 -0
  56. arkitekt_next/cli/commands/server/__init__.py +0 -0
  57. arkitekt_next/cli/commands/server/down.py +56 -0
  58. arkitekt_next/cli/commands/server/init.py +74 -0
  59. arkitekt_next/cli/commands/server/inspect.py +59 -0
  60. arkitekt_next/cli/commands/server/main.py +33 -0
  61. arkitekt_next/cli/commands/server/open.py +66 -0
  62. arkitekt_next/cli/commands/server/remove.py +60 -0
  63. arkitekt_next/cli/commands/server/stop.py +56 -0
  64. arkitekt_next/cli/commands/server/up.py +70 -0
  65. arkitekt_next/cli/commands/server/utils.py +33 -0
  66. arkitekt_next/cli/configs/base.yaml +867 -0
  67. arkitekt_next/cli/constants.py +63 -0
  68. arkitekt_next/cli/dockerfiles/vanilla.dockerfile +8 -0
  69. arkitekt_next/cli/errors.py +4 -0
  70. arkitekt_next/cli/inspect.py +1 -0
  71. arkitekt_next/cli/io.py +255 -0
  72. arkitekt_next/cli/main.py +83 -0
  73. arkitekt_next/cli/options.py +166 -0
  74. arkitekt_next/cli/schemas/fluss.schema.graphql +2446 -0
  75. arkitekt_next/cli/schemas/gucker.schema.graphql +8908 -0
  76. arkitekt_next/cli/schemas/kabinet.schema.graphql +515 -0
  77. arkitekt_next/cli/schemas/kluster.schema.graphql +109 -0
  78. arkitekt_next/cli/schemas/konviktion.schema.graphql +70 -0
  79. arkitekt_next/cli/schemas/kuay.schema.graphql +356 -0
  80. arkitekt_next/cli/schemas/mikro.schema.graphql +8908 -0
  81. arkitekt_next/cli/schemas/mikro_next.schema.graphql +1639 -0
  82. arkitekt_next/cli/schemas/napari.schema.graphql +8908 -0
  83. arkitekt_next/cli/schemas/omero_ark.schema.graphql +100 -0
  84. arkitekt_next/cli/schemas/port.schema.graphql +356 -0
  85. arkitekt_next/cli/schemas/rekuest.schema.graphql +4630 -0
  86. arkitekt_next/cli/schemas/rekuest_next.schema.graphql +1159 -0
  87. arkitekt_next/cli/schemas/unlok.schema.graphql +1013 -0
  88. arkitekt_next/cli/templates/filter.py +26 -0
  89. arkitekt_next/cli/templates/simple.py +67 -0
  90. arkitekt_next/cli/texts.py +20 -0
  91. arkitekt_next/cli/types.py +365 -0
  92. arkitekt_next/cli/ui.py +111 -0
  93. arkitekt_next/cli/utils.py +15 -0
  94. arkitekt_next/cli/validators.py +17 -0
  95. arkitekt_next/cli/vars.py +39 -0
  96. arkitekt_next/cli/versions/v1.yaml +1 -0
  97. arkitekt_next/constants.py +6 -0
  98. arkitekt_next/model.py +110 -0
  99. arkitekt_next/qt/__init__.py +9 -0
  100. arkitekt_next/qt/assets/dark/gear.png +0 -0
  101. arkitekt_next/qt/assets/dark/green pulse.gif +0 -0
  102. arkitekt_next/qt/assets/dark/orange pulse.gif +0 -0
  103. arkitekt_next/qt/assets/dark/pink pulse.gif +0 -0
  104. arkitekt_next/qt/assets/dark/red pulse.gif +0 -0
  105. arkitekt_next/qt/assets/light/gear.png +0 -0
  106. arkitekt_next/qt/assets/light/green pulse.gif +0 -0
  107. arkitekt_next/qt/assets/light/orange pulse.gif +0 -0
  108. arkitekt_next/qt/assets/light/pink pulse.gif +0 -0
  109. arkitekt_next/qt/assets/light/red pulse.gif +0 -0
  110. arkitekt_next/qt/magic_bar.py +545 -0
  111. arkitekt_next/qt/utils.py +30 -0
  112. arkitekt_next/service_registry.py +51 -0
  113. arkitekt_next/tqdm.py +43 -0
  114. arkitekt_next/utils.py +38 -0
  115. arkitekt_next-0.7.8.dist-info/LICENSE +21 -0
  116. arkitekt_next-0.7.8.dist-info/METADATA +155 -0
  117. arkitekt_next-0.7.8.dist-info/RECORD +119 -0
  118. arkitekt_next-0.7.8.dist-info/WHEEL +4 -0
  119. arkitekt_next-0.7.8.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,63 @@
1
+ from .types import Requirement
2
+ from .utils import build_relative_dir
3
+ from typing import List
4
+ import os
5
+
6
+
7
+ def compile_scopes() -> List[str]:
8
+ """Compile all available scopes"""
9
+ return ["read", "write"]
10
+
11
+
12
+ def compile_requirements():
13
+ """Compile all available requirements"""
14
+ return [Requirement.GPU.value]
15
+
16
+
17
+ def compile_builders():
18
+ return ["arkitekt_next.builders.easy", "arkitekt_next.builders.port"]
19
+
20
+
21
+ def compile_runtimes():
22
+ return ["nvidia", "standard"]
23
+
24
+
25
+ def compile_schema_versions() -> List[str]:
26
+ z = build_relative_dir("schemas")
27
+ return [
28
+ os.path.basename(f) for f in os.listdir(z) if os.path.isdir(os.path.join(z, f))
29
+ ]
30
+
31
+
32
+ def compile_configs() -> List[str]:
33
+ z = build_relative_dir("configs")
34
+ return [
35
+ os.path.basename(f) for f in os.listdir(z) if os.path.isdir(os.path.join(z, f))
36
+ ]
37
+
38
+
39
+ def compile_dockerfiles() -> List[str]:
40
+ z = build_relative_dir("dockerfiles")
41
+ return [
42
+ os.path.basename(f).replace(".dockerfile", "")
43
+ for f in os.listdir(z)
44
+ if os.path.isfile(os.path.join(z, f))
45
+ ]
46
+
47
+
48
+ def compile_templates() -> List[str]:
49
+ z = build_relative_dir("templates")
50
+ return [
51
+ os.path.basename(f).split(".")[0]
52
+ for f in os.listdir(z)
53
+ if os.path.isfile(os.path.join(z, f))
54
+ ]
55
+
56
+
57
+ def compile_services() -> List[str]:
58
+ z = build_relative_dir("schemas")
59
+ return [
60
+ os.path.basename(f).split(".")[0]
61
+ for f in os.listdir(z)
62
+ if os.path.isfile(os.path.join(z, f))
63
+ ]
@@ -0,0 +1,8 @@
1
+ FROM python:3.8-slim-buster
2
+
3
+ RUN pip install "arkitekt_next[all]>=0.7.a7"
4
+
5
+ RUN mkdir /app
6
+ WORKDIR /app
7
+ COPY .arkitekt_next /app/.arkitekt_next
8
+ COPY app.py /app/app.py
@@ -0,0 +1,4 @@
1
+ class ValidationError(Exception):
2
+ """Raised when a validation error occurs."""
3
+
4
+ pass
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,255 @@
1
+ from arkitekt_next.utils import create_arkitekt_next_folder
2
+ import os
3
+ from typing import Optional, List, Dict
4
+ from arkitekt_next.cli.types import (
5
+ Inspection,
6
+ Manifest,
7
+ Build,
8
+ BuildsConfigFile,
9
+ Deployment,
10
+ Flavour,
11
+ DeploymentsConfigFile,
12
+ DefinitionInput,
13
+ )
14
+ import yaml
15
+ import json
16
+ import rich_click as click
17
+
18
+
19
+ def load_manifest_yaml(path: str) -> Manifest:
20
+ """Loads a manifest from a yaml file
21
+
22
+ Uses yaml safe load to load the manifest from a yaml file
23
+ (to avoid unsafe yaml attributes)
24
+
25
+ Parameters
26
+ ----------
27
+ path : str
28
+ The path to the yaml file
29
+
30
+ Returns
31
+ -------
32
+ Manifest
33
+ The loaded manifest
34
+ """
35
+ with open(path, "r") as file:
36
+ manifest = yaml.safe_load(file)
37
+ return Manifest(**manifest)
38
+
39
+
40
+ def load_manifest() -> Optional[Manifest]:
41
+ """Loads the manifest from the arkitekt_next folder
42
+
43
+ Will load the manifest from the current working directories
44
+ arkitekt_next folder. If no folder exists, it will create one, but
45
+ will not create a manifest.
46
+
47
+ Returns
48
+ -------
49
+ Optional[Manifest]
50
+ The loaded manifest, or None if no manifest exists
51
+ """
52
+ path = create_arkitekt_next_folder()
53
+ config_file = os.path.join(path, "manifest.yaml")
54
+ if os.path.exists(config_file):
55
+ return load_manifest_yaml(config_file)
56
+ return None
57
+
58
+
59
+ def write_manifest(manifest: Manifest):
60
+ """Writes a manifest to the arkitekt_next folder
61
+
62
+ Will write a manifest to the current working directories
63
+ arkitekt_next folder. If no folder exists, it will create one.
64
+
65
+
66
+ Parameters
67
+ ----------
68
+ manifest : Manifest
69
+ The manifest to write
70
+ """
71
+ path = create_arkitekt_next_folder()
72
+ config_file = os.path.join(path, "manifest.yaml")
73
+
74
+ with open(config_file, "w") as file:
75
+ yaml.safe_dump(
76
+ json.loads(manifest.json(exclude_none=True, exclude_unset=True)),
77
+ file,
78
+ sort_keys=True,
79
+ )
80
+
81
+
82
+ def get_builds(selected_run: Optional[str] = None) -> Dict[str, Build]:
83
+ """Will load the builds.yaml file and return a dictionary of builds
84
+
85
+ Will load the builds.yaml file and return a dictionary of builds
86
+ where the key is the build_id and the value is the build object.
87
+
88
+
89
+ Returns
90
+ -------
91
+ Dict[str, Build]
92
+ The loaded builds
93
+ """
94
+ path = create_arkitekt_next_folder()
95
+ config_file = os.path.join(path, "builds.yaml")
96
+
97
+ builds = {}
98
+
99
+ if os.path.exists(config_file):
100
+ with open(config_file, "r") as file:
101
+ config = BuildsConfigFile(**yaml.safe_load(file))
102
+
103
+ # We will only return the builds from the selected run
104
+ selected_run = selected_run or config.latest_build_run
105
+
106
+ builds = {
107
+ build.build_id: build
108
+ for build in config.builds
109
+ if build.build_run == selected_run
110
+ }
111
+ return builds
112
+ else:
113
+ raise click.ClickException(
114
+ "Could not find any builds. Please run `arkitekt_next port build` first"
115
+ )
116
+
117
+
118
+ def generate_build(
119
+ build_run: str,
120
+ build_id: str,
121
+ flavour_name: str,
122
+ flavour: Flavour,
123
+ manifest: Manifest,
124
+ inspection: Optional[Inspection],
125
+ ) -> Build:
126
+ """Generates a build from a builder, build_id and manifest
127
+
128
+ Will generate a build from a builder, build_id and manifest,
129
+ and write it to the builds.yaml file in the arkitekt_next folder.
130
+
131
+
132
+ Parameters
133
+ ----------
134
+ builder : str
135
+ The builder that was used to build the build
136
+ build_id : str
137
+ The build_id of the build
138
+ manifest : Manifest
139
+ The manifest of the build
140
+
141
+ Returns
142
+ -------
143
+ Build
144
+ The generated build
145
+ """
146
+ path = create_arkitekt_next_folder()
147
+
148
+ config_file = os.path.join(path, "builds.yaml")
149
+
150
+ build = Build(
151
+ manifest=manifest,
152
+ flavour=flavour_name,
153
+ selectors=flavour.selectors,
154
+ build_id=build_id,
155
+ build_run=build_run,
156
+ description=flavour.description,
157
+ inspection=inspection,
158
+ )
159
+
160
+ if os.path.exists(config_file):
161
+ with open(config_file, "r") as file:
162
+ config = BuildsConfigFile(**yaml.safe_load(file))
163
+ config.builds.append(build)
164
+ config.latest_build_run = build_run
165
+ else:
166
+ config = BuildsConfigFile(builds=[build], latest_build_run=build_run)
167
+
168
+ with open(config_file, "w") as file:
169
+ yaml.safe_dump(
170
+ json.loads(
171
+ config.json(exclude_none=True, exclude_unset=True, by_alias=True)
172
+ ),
173
+ file,
174
+ sort_keys=True,
175
+ )
176
+
177
+ return build
178
+
179
+
180
+ def get_deployments() -> DeploymentsConfigFile:
181
+ """Loads the deployments.yaml file and returns the deployments
182
+
183
+ Will load the deployments.yaml file and return the deployments
184
+ as a DeploymentsConfigFile object. If no deployments.yaml file
185
+ exists, it will return an empty DeploymentsConfigFile object.
186
+
187
+ Returns
188
+ -------
189
+ DeploymentsConfigFile
190
+ The deployments as a DeploymentsConfigFile object
191
+ """
192
+ path = create_arkitekt_next_folder()
193
+ config_file = os.path.join(path, "deployments.yaml")
194
+ if os.path.exists(config_file):
195
+ with open(config_file, "r") as file:
196
+ return DeploymentsConfigFile(**yaml.safe_load(file))
197
+ else:
198
+ return DeploymentsConfigFile()
199
+
200
+
201
+ def generate_deployment(
202
+ deployment_run: str,
203
+ build: Build,
204
+ image: str,
205
+ definitions: Optional[List[DefinitionInput]] = None,
206
+ ) -> Deployment:
207
+ """Generates a deployment from a build and an image
208
+
209
+ Parameters
210
+ ----------
211
+
212
+ build : Build
213
+ The build that should be deployed
214
+ image: str
215
+ The image that is the actuall deployment of the build
216
+ with_definitions: bool:
217
+ Should we generated and inspect definitions to bundle with
218
+ the deployment?
219
+
220
+ Returns:
221
+ ------
222
+ Deployment: The created deployment
223
+
224
+ """
225
+
226
+ path = create_arkitekt_next_folder()
227
+
228
+ config_file = os.path.join(path, "deployments.yaml")
229
+
230
+ deployment = Deployment(
231
+ build_id=build.build_id,
232
+ manifest=build.manifest,
233
+ flavour=build.flavour,
234
+ selectors=build.selectors,
235
+ inspection=build.inspection,
236
+ image=image,
237
+ )
238
+
239
+ if os.path.exists(config_file):
240
+ with open(config_file, "r") as file:
241
+ config = DeploymentsConfigFile(**yaml.safe_load(file))
242
+ config.deployments.append(deployment)
243
+ config.latest_deployment_run = deployment_run
244
+ else:
245
+ config = DeploymentsConfigFile(deployments=[deployment])
246
+ config.latest_deployment_run = deployment_run
247
+
248
+ with open(config_file, "w") as file:
249
+ yaml.safe_dump(
250
+ json.loads(config.json(exclude_none=True, by_alias=True)),
251
+ file,
252
+ sort_keys=True,
253
+ )
254
+
255
+ return deployment
@@ -0,0 +1,83 @@
1
+ import sys
2
+ import os
3
+
4
+ try:
5
+ import rich_click as click
6
+
7
+ from rich.console import Console
8
+ except ImportError:
9
+ print(
10
+ "ArkitektNext CLI is not installed, please install it first. By installing the cli, e.g with `pip install arkitekt_next[cli]`, you can use the `arkitekt_next` command."
11
+ )
12
+ sys.exit(1)
13
+
14
+ from arkitekt_next.cli.vars import *
15
+ from arkitekt_next.cli.constants import *
16
+ from arkitekt_next.cli.texts import *
17
+ from arkitekt_next.cli.commands.run.main import run
18
+ from arkitekt_next.cli.commands.gen.main import gen
19
+ from arkitekt_next.cli.commands.server.main import server
20
+ from arkitekt_next.cli.commands.port.main import port
21
+ from arkitekt_next.cli.commands.init.main import init
22
+ from arkitekt_next.cli.commands.manifest.main import manifest
23
+ from arkitekt_next.cli.commands.inspect.main import inspect
24
+ from arkitekt_next.cli.commands.call.main import call
25
+ from arkitekt_next.cli.io import load_manifest
26
+ from arkitekt_next.utils import create_arkitekt_next_folder
27
+
28
+ default_docker_file = """
29
+ FROM python:3.8-slim-buster
30
+
31
+
32
+ RUN pip install arkitekt_next==0.4.23
33
+
34
+
35
+ RUN mkdir /app
36
+ COPY . /app
37
+ WORKDIR /app
38
+
39
+ """
40
+
41
+
42
+ click.rich_click.HEADER_TEXT = LOGO
43
+ click.rich_click.ERRORS_EPILOGUE = ERROR_EPILOGUE
44
+ click.rich_click.USE_RICH_MARKUP = True
45
+
46
+
47
+ @click.group()
48
+ @click.pass_context
49
+ def cli(ctx):
50
+ """ArkitektNext is a framework for building safe and performant apps that then can be centrally orchestrated and managed
51
+ in workflows.
52
+
53
+
54
+ This is the CLI for the ArkitektNext Python SDK. It allows you to create and deploy ArkitektNext Apps from your python code
55
+ as well as to run them locally for testing and development. For more information about ArkitektNext, please visit
56
+ [link=https://arkitekt_next.live]https://arkitekt_next.live[/link]
57
+ """
58
+ sys.path.append(os.getcwd())
59
+
60
+ ctx.obj = {}
61
+ console = Console()
62
+ set_console(ctx, console)
63
+
64
+ create_arkitekt_next_folder()
65
+
66
+ manifest = load_manifest()
67
+ if manifest:
68
+ set_manifest(ctx, manifest)
69
+
70
+ pass
71
+
72
+
73
+ cli.add_command(init, "init")
74
+ cli.add_command(run, "run")
75
+ cli.add_command(gen, "gen")
76
+ cli.add_command(port, "port")
77
+ cli.add_command(manifest, "manifest")
78
+ cli.add_command(inspect, "inspect")
79
+ cli.add_command(server, "server")
80
+ cli.add_command(call, "call")
81
+
82
+ if __name__ == "__main__":
83
+ cli()
@@ -0,0 +1,166 @@
1
+ import rich_click as click
2
+
3
+ from arkitekt_next.constants import DEFAULT_ARKITEKT_URL
4
+ from .constants import *
5
+ from .types import *
6
+ from .vars import *
7
+ from .ui import *
8
+
9
+ with_fakts_url = click.option(
10
+ "--url",
11
+ "-u",
12
+ help="The fakts url for connection",
13
+ default=DEFAULT_ARKITEKT_URL,
14
+ envvar="FAKTS_URL",
15
+ )
16
+
17
+ with_token = click.option(
18
+ "--token",
19
+ "-t",
20
+ help="The token for the fakts instance",
21
+ envvar="FAKTS_TOKEN",
22
+ required=False,
23
+ )
24
+ with_version = click.option(
25
+ "--version",
26
+ "-v",
27
+ help="Override the version of the app",
28
+ envvar="ARKITEKT_VERSION",
29
+ )
30
+
31
+ with_log_level = click.option(
32
+ "--log",
33
+ "-l",
34
+ help="Override the logging level",
35
+ type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]),
36
+ envvar="ARKITEKT_LOG_LEVEL",
37
+ )
38
+
39
+
40
+ with_skip_cache = click.option(
41
+ "--no-cache",
42
+ "-nc",
43
+ is_flag=True,
44
+ default=False,
45
+ help="Should we skip the cache",
46
+ envvar="ARKITEKT_NO_CACHE",
47
+ )
48
+
49
+ with_instance_id = click.option(
50
+ "--instance-id",
51
+ "-i",
52
+ default="main",
53
+ help="The token for the fakts instance",
54
+ envvar="REKUEST_INSTANCE",
55
+ )
56
+
57
+ with_log_level = click.option(
58
+ "--log-level",
59
+ "-l",
60
+ default="ERROR",
61
+ help="The token for the fakts instance",
62
+ envvar="ARKITEKT_LOG_LEVEL",
63
+ )
64
+
65
+
66
+ with_builder = click.option(
67
+ "--builder",
68
+ "-b",
69
+ default="arkitekt_next.builders.easy",
70
+ help="The builder for this run",
71
+ envvar="ARKITEKT_BUILDER",
72
+ )
73
+
74
+ with_headless = click.option(
75
+ "--headless",
76
+ "-h",
77
+ is_flag=True,
78
+ default=False,
79
+ help="Should we start headless",
80
+ envvar="ARKITEKT_HEADLESS",
81
+ )
82
+
83
+
84
+ def check_gen_boring(ctx, param, value):
85
+ """Callback to check and prompt for file overwrite."""
86
+
87
+ if not value:
88
+ get_console(ctx).print(construct_codegen_welcome_panel())
89
+
90
+ return value
91
+
92
+
93
+ with_boring = click.option(
94
+ "--boring",
95
+ help="Should we skip the welcome message?",
96
+ is_flag=True,
97
+ default=False,
98
+ callback=check_gen_boring,
99
+ )
100
+ with_seperate_document_dirs = click.option(
101
+ "--seperate-doc-dirs",
102
+ "-sd",
103
+ help="Should we generate seperate dirs for the documents?",
104
+ is_flag=True,
105
+ default=False,
106
+ )
107
+ with_choose_services = click.option(
108
+ "--services",
109
+ "-s",
110
+ help="The services to create the codegen for",
111
+ multiple=True,
112
+ type=click.Choice(compile_services()),
113
+ default=["mikro"],
114
+ )
115
+ with_graphql_config = click.option(
116
+ "--config",
117
+ "-c",
118
+ help="The name of the configuration file",
119
+ type=str,
120
+ default="graphql.config.yaml",
121
+ )
122
+ with_api_path = click.option(
123
+ "--path",
124
+ "-c",
125
+ help="The path of the api to be generated",
126
+ prompt="Where should we generate the api? (relative to the current directory)",
127
+ type=str,
128
+ default="api",
129
+ )
130
+
131
+
132
+ def check_overwrite_config(ctx, param, value):
133
+ """Callback to check and prompt for file overwrite."""
134
+
135
+ config = ctx.params["config"]
136
+ if os.path.exists(config) and not value:
137
+ should_overwrite = click.confirm(
138
+ "GraphQL Config file already exists. Do you want to overwrite?"
139
+ )
140
+ return should_overwrite
141
+
142
+ return value
143
+
144
+
145
+ with_overwrite_graphql = click.option(
146
+ "--overwrite-config",
147
+ "-o",
148
+ help="Should we overwrite the config file if it already exists",
149
+ is_flag=True,
150
+ default=False,
151
+ callback=check_overwrite_config,
152
+ )
153
+ with_documents = click.option(
154
+ "--documents",
155
+ "-d",
156
+ help="With documents",
157
+ is_flag=True,
158
+ default=True,
159
+ )
160
+ with_schemas = click.option(
161
+ "--schemas",
162
+ "-s",
163
+ help="Should we copy the schemas",
164
+ is_flag=True,
165
+ default=True,
166
+ )