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,82 @@
1
+ from arkitekt_next.cli.constants import compile_dockerfiles
2
+ from arkitekt_next.cli.types import Flavour
3
+ from arkitekt_next.cli.utils import build_relative_dir
4
+ import rich_click as click
5
+ from click import Context
6
+ from rich import get_console
7
+ from arkitekt_next.utils import create_arkitekt_next_folder
8
+ import yaml
9
+ from rich.panel import Panel
10
+
11
+ try:
12
+ pass
13
+ except ImportError as e:
14
+ raise ImportError("Please install rekuest to use this feature") from e
15
+
16
+ import os
17
+
18
+
19
+ @click.command()
20
+ @click.option("--flavour", "-f", help="The flavour to use", default="vanilla")
21
+ @click.option(
22
+ "--description",
23
+ "-d",
24
+ help="The description for this flavour to use",
25
+ default="This is a vanilla flavour",
26
+ )
27
+ @click.option(
28
+ "--overwrite",
29
+ "-o",
30
+ help="Should we overwrite the existing Dockerfile?",
31
+ is_flag=True,
32
+ default=False,
33
+ )
34
+ @click.option(
35
+ "--template",
36
+ "-t",
37
+ help="The dockerfile template to use",
38
+ default="vanilla",
39
+ type=click.Choice(compile_dockerfiles()),
40
+ )
41
+ @click.pass_context
42
+ def init(
43
+ ctx: Context, description: str, overwrite: bool, flavour: str, template: str
44
+ ) -> None:
45
+ """Runs the port wizard to generate a dockerfile to be used with port"""
46
+
47
+ arkitekt_next_folder = create_arkitekt_next_folder()
48
+
49
+ flavour_folder = os.path.join(arkitekt_next_folder, "flavours", flavour)
50
+ if os.path.exists(flavour_folder) and not overwrite:
51
+ raise click.ClickException(
52
+ f"The flavour {flavour} does already exist. Please initialize a different flavour or use the --overwrite flag"
53
+ )
54
+ else:
55
+ os.makedirs(flavour_folder, exist_ok=True)
56
+
57
+ config_file = os.path.join(flavour_folder, "config.yaml")
58
+ dockerfile = os.path.join(flavour_folder, "Dockerfile")
59
+
60
+ fl = Flavour(
61
+ selectors=[],
62
+ description=description,
63
+ dockerfile="Dockerfile",
64
+ )
65
+
66
+ with open(config_file, "w") as file:
67
+ yaml.dump(fl.dict(), file)
68
+
69
+ with open(build_relative_dir("dockerfiles", f"{template}.dockerfile"), "r") as f:
70
+ dockerfile_content = f.read()
71
+
72
+ with open(dockerfile, "w") as f:
73
+ f.write(dockerfile_content)
74
+
75
+ panel = Panel(
76
+ title=f"Created new flavour [bold]{flavour}[/bold]\n",
77
+ renderable="You can now edit the Dockerfile and add selectors to the config.yaml file\n"
78
+ + "To learn more about selectors and how flavours work, please visit [link=https://arkitekt_next.live]https://arkitekt_next.live[/link]",
79
+ style="green",
80
+ )
81
+
82
+ get_console().print(panel)
@@ -0,0 +1,31 @@
1
+ import rich_click as click
2
+ from .build import build
3
+ from .publish import publish
4
+ from .stage import stage
5
+ from .init import init
6
+ from .wizard import wizard
7
+ from .validate import validate
8
+ from click import Context
9
+
10
+
11
+ @click.group()
12
+ @click.pass_context
13
+ def port(ctx: Context) -> None:
14
+ """Deploy the arkitekt_next app with Port
15
+
16
+ The port deployer is an arkitekt_next plugin service, which allows you to deploy your arkitekt_next app to
17
+ any arkitekt_next instance and make it instantly available to the world. Port uses docker to containerize
18
+ your application and will publish it locally to your dockerhub account, and mark it locally as
19
+ deployed. People can then use your github repository to deploy your app to their arkitekt_next instance.
20
+
21
+ """
22
+
23
+ pass
24
+
25
+
26
+ port.add_command(build, "build")
27
+ port.add_command(init, "init")
28
+ port.add_command(validate, "validate")
29
+ port.add_command(publish, "publish")
30
+ port.add_command(stage, "stage")
31
+ port.add_command(wizard, "wizard")
@@ -0,0 +1,102 @@
1
+ import rich_click as click
2
+ import subprocess
3
+ from .utils import search_username_in_docker_info
4
+ from arkitekt_next.cli.vars import get_console
5
+ from arkitekt_next.cli.types import Build
6
+ from rich.panel import Panel
7
+ from arkitekt_next.cli.io import get_builds, get_deployments, generate_deployment
8
+ from click import Context
9
+ import uuid
10
+
11
+
12
+ def check_if_build_already_deployed(build: Build) -> None:
13
+ """Checks if a manifest has already been deployed. If it has, it raises a click.ClickException.
14
+
15
+ Parameters
16
+ ----------
17
+ manifest : Manifest
18
+ THe manifest to check
19
+
20
+ Raises
21
+ ------
22
+ click.ClickException
23
+ A click exception if the manifest has already been deployed
24
+ """
25
+ config = get_deployments()
26
+ for deployment in config.deployments:
27
+ if (
28
+ deployment.manifest.identifier == build.manifest.identifier
29
+ and deployment.manifest.version == build.manifest.version
30
+ and deployment.flavour == build.flavour
31
+ ):
32
+ raise click.ClickException(
33
+ f"Deployment of {build.manifest.identifier}/{build.manifest.version} in the {build.flavour} flavour already exists."
34
+ + " You cannot deploy a build twice for the same version and flavour"
35
+ )
36
+
37
+
38
+ @click.command()
39
+ @click.option("--build", help="The build run to use", type=str, default=None)
40
+ @click.option("--tag", help="The tag to use")
41
+ @click.pass_context
42
+ def publish(ctx: Context, build: str, tag: str) -> None:
43
+ """Deploys aa previous build to dockerhub"""
44
+
45
+ console = get_console(ctx)
46
+
47
+ deployment_run = str(uuid.uuid4())
48
+
49
+ builds = get_builds(selected_run=build)
50
+
51
+ if len(builds) == 0:
52
+ raise click.ClickException("Could not find any builds")
53
+
54
+ docker_info = subprocess.check_output(["docker", "info"]).decode("utf-8")
55
+ username = search_username_in_docker_info(docker_info)
56
+ if not username:
57
+ username = click.prompt(
58
+ "Could not find username in docker info. Please provide your docker username"
59
+ )
60
+
61
+ for build_id, build_model in builds.items():
62
+ if build_model.manifest.version == "dev":
63
+ raise click.ClickException(
64
+ "You cannot deploy a dev version. Please run `arkitekt_next version` first to set a version"
65
+ )
66
+
67
+ check_if_build_already_deployed(build_model)
68
+
69
+ tag = tag or click.prompt(
70
+ "The tag to use",
71
+ default=f"{username}/{build_model.manifest.identifier}:{build_model.manifest.version}-{build_model.flavour}",
72
+ )
73
+
74
+ md = Panel("Building Docker Container")
75
+ console.print(md)
76
+
77
+ docker_run = subprocess.run(["docker", "tag", build_model.build_id, tag])
78
+ if docker_run.returncode != 0:
79
+ raise click.ClickException("Could not retag docker container")
80
+
81
+ console.print(md)
82
+ docker_run = subprocess.run(["docker", "push", tag])
83
+ if docker_run.returncode != 0:
84
+ raise click.ClickException("Could not push docker container")
85
+
86
+ generate_deployment(
87
+ deployment_run,
88
+ build_model,
89
+ tag,
90
+ definitions=[],
91
+ )
92
+
93
+ md = Panel(
94
+ f"[bold green] Sucessfully pushed {tag} your plugin to dockerhub"
95
+ + "We have also generated a deployment file for you. "
96
+ + "Make sure to commit and push your changes to github to make them available to others.",
97
+ title="Yeah! Success",
98
+ title_align="center",
99
+ border_style="green",
100
+ style="green",
101
+ )
102
+ console.print(md)
@@ -0,0 +1,59 @@
1
+ import rich_click as click
2
+ from arkitekt_next.cli.vars import get_manifest
3
+ import subprocess
4
+ from click import Context
5
+ from arkitekt_next.cli.io import get_builds
6
+ from arkitekt_next.constants import DEFAULT_ARKITEKT_URL
7
+
8
+
9
+ @click.command()
10
+ @click.option("--build", help="The build to use", type=str, default=None)
11
+ @click.option("--flavour", "-f", help="The flavour to use", default="vanilla")
12
+ @click.option(
13
+ "--url", "-u", help="The fakts server to use", type=str, default=DEFAULT_ARKITEKT_URL
14
+ )
15
+ @click.option(
16
+ "--builder", help="The builder to use", type=str, default="arkitekt_next.builders.easy"
17
+ )
18
+ @click.pass_context
19
+ def stage(ctx: Context, build: str, url: str, flavour: str, builder: str) -> None:
20
+ """Stages the latest Build for testing
21
+
22
+ Stages the current build for testing. This will create a temporary staged version
23
+ of the app that is run agains the local arkitekt_next instance. The builder will be changed
24
+ to the easy or provided builder to ensure that the app can be run headlessly
25
+
26
+
27
+ """
28
+
29
+ get_manifest(ctx)
30
+
31
+ builds = get_builds(build)
32
+
33
+ if len(builds) == 0:
34
+ raise click.ClickException("Could not find any builds")
35
+
36
+ if len(builds) > 1:
37
+ try:
38
+ build_model = next(
39
+ build for build in builds.values() if build.flavour == flavour
40
+ )
41
+ except StopIteration:
42
+ raise click.ClickException(
43
+ f"Could not find a build for flavour {flavour}. Please run `arkitekt_next port build` "
44
+ + "first to build the flavour"
45
+ )
46
+
47
+ else:
48
+ build_model = list(builds.values())[0]
49
+
50
+ command = build_model.build_docker_command() + build_model.build_arkitekt_next_command(
51
+ url
52
+ )
53
+
54
+ click.echo(f"Staging build {build} with flavour {flavour} against {url}")
55
+ click.echo("Running command: " + " ".join(command))
56
+
57
+ subprocess.run(" ".join(command), shell=True)
58
+
59
+ raise click.ClickException("Docker container exited")
@@ -0,0 +1,47 @@
1
+ from typing import Optional
2
+ import os
3
+ import yaml
4
+ from arkitekt_next.cli.types import Flavour
5
+ from arkitekt_next.cli.vars import get_console
6
+ import rich_click as click
7
+
8
+
9
+ def search_username_in_docker_info(docker_info: str):
10
+ for line in docker_info.splitlines():
11
+ if "Username" in line:
12
+ return line.split(":")[1].strip()
13
+
14
+
15
+ def validate_flavours(flavours_folder: str, only: Optional[str]):
16
+ for dir_name in os.listdir(flavours_folder):
17
+ dir = os.path.join(flavours_folder, dir_name)
18
+ if os.path.isdir(dir):
19
+ if only is not None and only != dir_name:
20
+ continue
21
+
22
+ if os.path.exists(os.path.join(dir, "config.yaml")):
23
+ with open(os.path.join(dir, "config.yaml")) as f:
24
+ valued = yaml.load(f, Loader=yaml.SafeLoader)
25
+ try:
26
+ flavour = Flavour(**valued)
27
+
28
+ except Exception as e:
29
+ get_console().print_exception()
30
+ raise click.ClickException(f"Flavour {dir_name} is invalid") from e
31
+
32
+ try:
33
+ flavour.check_relative_paths(dir)
34
+ except Exception as e:
35
+ raise click.ClickException(
36
+ f"Relative Paths in Flavour {dir_name} are invalid. {e}"
37
+ ) from e
38
+
39
+ else:
40
+ raise click.ClickException(
41
+ f"Flavour {dir_name} is invalid. No config.yaml file found"
42
+ )
43
+
44
+ else:
45
+ print(
46
+ f"Found file {dir_name} in flavours folder. Not a valid flavour. Ignoring"
47
+ )
@@ -0,0 +1,78 @@
1
+ from arkitekt_next.cli.types import Flavour
2
+ import rich_click as click
3
+ from click import Context
4
+ from rich import get_console
5
+ from arkitekt_next.utils import create_arkitekt_next_folder
6
+ import yaml
7
+
8
+
9
+ try:
10
+ pass
11
+ except ImportError as e:
12
+ raise ImportError("Please install rekuest to use this feature") from e
13
+
14
+ import os
15
+
16
+
17
+ @click.command()
18
+ @click.option("--flavour", "-f", help="The flavour to use", default=None)
19
+ @click.option(
20
+ "--description",
21
+ "-d",
22
+ help="The description for this flavour to use",
23
+ default="This is a vanilla flavour",
24
+ )
25
+ @click.option(
26
+ "--overwrite",
27
+ "-o",
28
+ help="Should we overwrite the existing Dockerfile?",
29
+ is_flag=True,
30
+ default=False,
31
+ )
32
+ @click.pass_context
33
+ def validate(ctx: Context, description: str, overwrite: bool, flavour: str) -> None:
34
+ """Runs the port wizard to generate a dockerfile to be used with port"""
35
+
36
+ arkitekt_next_folder = create_arkitekt_next_folder()
37
+
38
+ flavours_folder = os.path.join(arkitekt_next_folder, "flavours")
39
+
40
+ if not os.path.exists(flavours_folder):
41
+ raise click.ClickException(
42
+ "We could not find the flavours folder. Please run arkitekt_next port init first"
43
+ )
44
+
45
+ for dir_name in os.listdir(flavours_folder):
46
+ dir = os.path.join(flavours_folder, dir_name)
47
+ if os.path.isdir(dir):
48
+ if flavour is not None and flavour != dir_name:
49
+ continue
50
+
51
+ if os.path.exists(os.path.join(dir, "config.yaml")):
52
+ with open(os.path.join(dir, "config.yaml")) as f:
53
+ valued = yaml.load(f, Loader=yaml.SafeLoader)
54
+ try:
55
+ flavour = Flavour(**valued)
56
+
57
+ except Exception as e:
58
+ get_console().print_exception()
59
+ raise click.ClickException(f"Flavour {dir_name} is invalid") from e
60
+
61
+ try:
62
+ flavour.check_relative_paths(dir)
63
+ except Exception as e:
64
+ raise click.ClickException(
65
+ f"Relative Paths in Flavour {dir_name} are invalid. {e}"
66
+ ) from e
67
+
68
+ else:
69
+ raise click.ClickException(
70
+ f"Flavour {dir_name} is invalid. No config.yaml file found"
71
+ )
72
+
73
+ else:
74
+ print(
75
+ f"Found file {dir_name} in flavours folder. Not a valid flavour. Ignoring"
76
+ )
77
+
78
+ click.echo("Ice Ice Baby! All flavours are valid")