truefoundry 0.2.10__py3-none-any.whl → 0.3.0rc2__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 truefoundry might be problematic. Click here for more details.

Files changed (100) hide show
  1. truefoundry/__init__.py +1 -0
  2. truefoundry/autodeploy/cli.py +31 -18
  3. truefoundry/deploy/__init__.py +119 -1
  4. truefoundry/deploy/auto_gen/models.py +1791 -0
  5. truefoundry/deploy/builder/__init__.py +138 -0
  6. truefoundry/deploy/builder/builders/__init__.py +22 -0
  7. truefoundry/deploy/builder/builders/dockerfile.py +57 -0
  8. truefoundry/deploy/builder/builders/tfy_notebook_buildpack/__init__.py +44 -0
  9. truefoundry/deploy/builder/builders/tfy_notebook_buildpack/dockerfile_template.py +51 -0
  10. truefoundry/deploy/builder/builders/tfy_python_buildpack/__init__.py +44 -0
  11. truefoundry/deploy/builder/builders/tfy_python_buildpack/dockerfile_template.py +158 -0
  12. truefoundry/deploy/builder/docker_service.py +168 -0
  13. truefoundry/deploy/cli/cli.py +19 -26
  14. truefoundry/deploy/cli/commands/__init__.py +18 -0
  15. truefoundry/deploy/cli/commands/apply_command.py +52 -0
  16. truefoundry/deploy/cli/commands/build_command.py +45 -0
  17. truefoundry/deploy/cli/commands/build_logs_command.py +89 -0
  18. truefoundry/deploy/cli/commands/create_command.py +75 -0
  19. truefoundry/deploy/cli/commands/delete_command.py +77 -0
  20. truefoundry/deploy/cli/commands/deploy_command.py +99 -0
  21. truefoundry/deploy/cli/commands/get_command.py +216 -0
  22. truefoundry/deploy/cli/commands/list_command.py +171 -0
  23. truefoundry/deploy/cli/commands/login_command.py +33 -0
  24. truefoundry/deploy/cli/commands/logout_command.py +20 -0
  25. truefoundry/deploy/cli/commands/logs_command.py +134 -0
  26. truefoundry/deploy/cli/commands/patch_application_command.py +79 -0
  27. truefoundry/deploy/cli/commands/patch_command.py +70 -0
  28. truefoundry/deploy/cli/commands/redeploy_command.py +41 -0
  29. truefoundry/deploy/cli/commands/terminate_comand.py +44 -0
  30. truefoundry/deploy/cli/commands/trigger_command.py +87 -0
  31. truefoundry/deploy/cli/config.py +10 -0
  32. truefoundry/deploy/cli/console.py +5 -0
  33. truefoundry/deploy/cli/const.py +12 -0
  34. truefoundry/deploy/cli/display_util.py +118 -0
  35. truefoundry/deploy/cli/util.py +92 -0
  36. truefoundry/deploy/core/__init__.py +7 -0
  37. truefoundry/deploy/core/login.py +9 -0
  38. truefoundry/deploy/core/logout.py +5 -0
  39. truefoundry/deploy/function_service/__init__.py +3 -0
  40. truefoundry/deploy/function_service/__main__.py +27 -0
  41. truefoundry/deploy/function_service/app.py +92 -0
  42. truefoundry/deploy/function_service/build.py +45 -0
  43. truefoundry/deploy/function_service/remote/__init__.py +6 -0
  44. truefoundry/deploy/function_service/remote/context.py +3 -0
  45. truefoundry/deploy/function_service/remote/method.py +67 -0
  46. truefoundry/deploy/function_service/remote/remote.py +144 -0
  47. truefoundry/deploy/function_service/route.py +137 -0
  48. truefoundry/deploy/function_service/service.py +113 -0
  49. truefoundry/deploy/function_service/utils.py +53 -0
  50. truefoundry/deploy/io/__init__.py +0 -0
  51. truefoundry/deploy/io/output_callback.py +23 -0
  52. truefoundry/deploy/io/rich_output_callback.py +27 -0
  53. truefoundry/deploy/json_util.py +7 -0
  54. truefoundry/deploy/lib/__init__.py +0 -0
  55. truefoundry/deploy/lib/auth/auth_service_client.py +81 -0
  56. truefoundry/deploy/lib/auth/credential_file_manager.py +115 -0
  57. truefoundry/deploy/lib/auth/credential_provider.py +131 -0
  58. truefoundry/deploy/lib/auth/servicefoundry_session.py +59 -0
  59. truefoundry/deploy/lib/clients/__init__.py +0 -0
  60. truefoundry/deploy/lib/clients/servicefoundry_client.py +723 -0
  61. truefoundry/deploy/lib/clients/shell_client.py +13 -0
  62. truefoundry/deploy/lib/clients/utils.py +41 -0
  63. truefoundry/deploy/lib/const.py +43 -0
  64. truefoundry/deploy/lib/dao/__init__.py +0 -0
  65. truefoundry/deploy/lib/dao/application.py +246 -0
  66. truefoundry/deploy/lib/dao/apply.py +80 -0
  67. truefoundry/deploy/lib/dao/version.py +33 -0
  68. truefoundry/deploy/lib/dao/workspace.py +71 -0
  69. truefoundry/deploy/lib/exceptions.py +23 -0
  70. truefoundry/deploy/lib/logs_utils.py +43 -0
  71. truefoundry/deploy/lib/messages.py +12 -0
  72. truefoundry/deploy/lib/model/__init__.py +0 -0
  73. truefoundry/deploy/lib/model/entity.py +382 -0
  74. truefoundry/deploy/lib/session.py +146 -0
  75. truefoundry/deploy/lib/util.py +70 -0
  76. truefoundry/deploy/lib/win32.py +129 -0
  77. truefoundry/deploy/v2/__init__.py +0 -0
  78. truefoundry/deploy/v2/lib/__init__.py +3 -0
  79. truefoundry/deploy/v2/lib/deploy.py +232 -0
  80. truefoundry/deploy/v2/lib/deployable_patched_models.py +72 -0
  81. truefoundry/deploy/v2/lib/models.py +53 -0
  82. truefoundry/deploy/v2/lib/patched_models.py +515 -0
  83. truefoundry/deploy/v2/lib/source.py +267 -0
  84. truefoundry/flyte/__init__.py +6 -0
  85. truefoundry/langchain/__init__.py +12 -1
  86. truefoundry/langchain/deprecated.py +302 -0
  87. truefoundry/langchain/truefoundry_chat.py +130 -0
  88. truefoundry/langchain/truefoundry_embeddings.py +171 -0
  89. truefoundry/langchain/truefoundry_llm.py +106 -0
  90. truefoundry/langchain/utils.py +85 -0
  91. truefoundry/logger.py +17 -0
  92. truefoundry/pydantic_v1.py +5 -0
  93. truefoundry/python_deploy_codegen.py +132 -0
  94. {truefoundry-0.2.10.dist-info → truefoundry-0.3.0rc2.dist-info}/METADATA +25 -6
  95. truefoundry-0.3.0rc2.dist-info/RECORD +125 -0
  96. truefoundry/deploy/cli/deploy.py +0 -165
  97. truefoundry-0.2.10.dist-info/RECORD +0 -38
  98. /truefoundry/{deploy/cli/version.py → version.py} +0 -0
  99. {truefoundry-0.2.10.dist-info → truefoundry-0.3.0rc2.dist-info}/WHEEL +0 -0
  100. {truefoundry-0.2.10.dist-info → truefoundry-0.3.0rc2.dist-info}/entry_points.txt +0 -0
@@ -2,34 +2,27 @@ import logging
2
2
  import sys
3
3
 
4
4
  import rich_click as click
5
- from servicefoundry import logger
6
- from servicefoundry.cli.commands import (
7
- deploy_patch_v2_command,
5
+
6
+ from truefoundry import logger
7
+ from truefoundry.deploy.cli.commands import (
8
8
  get_apply_command,
9
+ get_build_command,
9
10
  get_delete_command,
11
+ get_deploy_command,
10
12
  get_login_command,
11
13
  get_logout_command,
14
+ get_patch_application_command,
12
15
  get_patch_command,
13
16
  )
14
- from servicefoundry.cli.config import CliConfig
15
- from servicefoundry.cli.const import GROUP_CLS
16
- from servicefoundry.cli.util import setup_rich_click
17
- from servicefoundry.lib.util import is_debug_env_set, is_experimental_env_set
18
- from servicefoundry.logger import logger as servicefoundry_logger
19
-
20
- from truefoundry.deploy.cli.deploy import deploy_v2_command
21
- from truefoundry.deploy.cli.version import __version__
22
-
23
- servicefoundry_logger.setLevel(level=logging.INFO)
24
-
17
+ from truefoundry.deploy.cli.config import CliConfig
18
+ from truefoundry.deploy.cli.const import GROUP_CLS
19
+ from truefoundry.deploy.cli.util import setup_rich_click
20
+ from truefoundry.deploy.lib.util import is_debug_env_set, is_internal_env_set
21
+ from truefoundry.version import __version__
25
22
 
26
23
  click.rich_click.USE_RICH_MARKUP = True
27
24
 
28
25
 
29
- def _add_experimental_commands(cli):
30
- pass
31
-
32
-
33
26
  def create_truefoundry_cli():
34
27
  """Generates CLI by combining all subcommands into a main CLI and returns in
35
28
 
@@ -38,17 +31,17 @@ def create_truefoundry_cli():
38
31
  """
39
32
  cli = truefoundry_cli
40
33
  cli.add_command(get_login_command())
41
- cli.add_command(get_delete_command())
42
34
  cli.add_command(get_logout_command())
43
- cli.add_command(deploy_v2_command)
44
- cli.add_command(deploy_patch_v2_command)
45
35
  cli.add_command(get_apply_command())
36
+ cli.add_command(get_deploy_command())
37
+ cli.add_command(get_patch_application_command())
38
+ cli.add_command(get_delete_command())
46
39
 
47
40
  if not (sys.platform.startswith("win32") or sys.platform.startswith("cygwin")):
48
41
  cli.add_command(get_patch_command())
49
42
 
50
- if is_experimental_env_set():
51
- _add_experimental_commands(cli)
43
+ if is_internal_env_set():
44
+ cli.add_command(get_build_command())
52
45
  return cli
53
46
 
54
47
 
@@ -73,12 +66,12 @@ CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) # noqa: C408
73
66
  @click.pass_context
74
67
  def truefoundry_cli(ctx, json, debug):
75
68
  """
76
- Truefoundry provides an easy way to deploy your services, jobs and models.
69
+ TrueFoundry provides an easy way to deploy your Services, Jobs and Models.
77
70
  \b
78
71
 
79
- To start, login to your Truefoundry account with [i]tfy login[/]
72
+ To start, login to your TrueFoundry account with [b]tfy login[/]
80
73
 
81
- Then start deploying with [i]tfy deploy[/]
74
+ Then start deploying with [b]tfy deploy[/]
82
75
 
83
76
  And more: [link=https://docs.truefoundry.com/docs]https://docs.truefoundry.com/docs[/]
84
77
 
@@ -0,0 +1,18 @@
1
+ from truefoundry.deploy.cli.commands.apply_command import get_apply_command
2
+ from truefoundry.deploy.cli.commands.build_command import get_build_command
3
+ from truefoundry.deploy.cli.commands.build_logs_command import get_build_logs_command
4
+ from truefoundry.deploy.cli.commands.create_command import get_create_command
5
+ from truefoundry.deploy.cli.commands.delete_command import get_delete_command
6
+ from truefoundry.deploy.cli.commands.deploy_command import get_deploy_command
7
+ from truefoundry.deploy.cli.commands.get_command import get_get_command
8
+ from truefoundry.deploy.cli.commands.list_command import get_list_command
9
+ from truefoundry.deploy.cli.commands.login_command import get_login_command
10
+ from truefoundry.deploy.cli.commands.logout_command import get_logout_command
11
+ from truefoundry.deploy.cli.commands.logs_command import get_logs_command
12
+ from truefoundry.deploy.cli.commands.patch_application_command import (
13
+ get_patch_application_command,
14
+ )
15
+ from truefoundry.deploy.cli.commands.patch_command import get_patch_command
16
+ from truefoundry.deploy.cli.commands.redeploy_command import get_redeploy_command
17
+ from truefoundry.deploy.cli.commands.terminate_comand import get_terminate_command
18
+ from truefoundry.deploy.cli.commands.trigger_command import get_trigger_command
@@ -0,0 +1,52 @@
1
+ from typing import List, Tuple
2
+
3
+ import rich_click as click
4
+
5
+ from truefoundry.deploy.cli.console import console
6
+ from truefoundry.deploy.cli.const import GROUP_CLS
7
+ from truefoundry.deploy.cli.util import handle_exception_wrapper
8
+ from truefoundry.deploy.lib.clients.servicefoundry_client import (
9
+ ServiceFoundryServiceClient,
10
+ )
11
+ from truefoundry.deploy.lib.dao import apply as apply_lib
12
+ from truefoundry.deploy.lib.messages import PROMPT_APPLYING_MANIFEST
13
+ from truefoundry.deploy.lib.model.entity import ApplyResult
14
+
15
+
16
+ @click.group(
17
+ name="apply",
18
+ cls=GROUP_CLS,
19
+ invoke_without_command=True,
20
+ help="Create resources by appling manifest locally from Truefoundry spec",
21
+ context_settings={"ignore_unknown_options": True, "allow_interspersed_args": True},
22
+ )
23
+ @click.option(
24
+ "-f",
25
+ "--file",
26
+ "files",
27
+ type=click.Path(exists=True, dir_okay=False, resolve_path=True),
28
+ help="Path to yaml manifest file (You can apply multiple files at once by providing multiple -f options)",
29
+ show_default=True,
30
+ required=True,
31
+ multiple=True,
32
+ )
33
+ @handle_exception_wrapper
34
+ def apply_command(files: Tuple[str, ...]):
35
+ apply_results: List[ApplyResult] = []
36
+ client = ServiceFoundryServiceClient()
37
+ for file in files:
38
+ with console.status(PROMPT_APPLYING_MANIFEST.format(file), spinner="dots"):
39
+ for apply_result in apply_lib.apply_manifest_file(file, client):
40
+ if apply_result.success:
41
+ console.print(f"[green]\u2714 {apply_result.message}[/]")
42
+ else:
43
+ console.print(f"[red]\u2718 {apply_result.message}[/]")
44
+
45
+ apply_results.append(apply_result)
46
+
47
+ if not all(apply_result.success for apply_result in apply_results):
48
+ raise Exception("Failed to apply one or more manifests")
49
+
50
+
51
+ def get_apply_command():
52
+ return apply_command
@@ -0,0 +1,45 @@
1
+ import json
2
+
3
+ import rich_click as click
4
+
5
+ from truefoundry.deploy import builder
6
+ from truefoundry.deploy.cli.console import console
7
+ from truefoundry.deploy.cli.const import GROUP_CLS
8
+ from truefoundry.deploy.cli.util import handle_exception_wrapper
9
+ from truefoundry.version import __version__
10
+
11
+
12
+ @click.group(
13
+ name="build",
14
+ cls=GROUP_CLS,
15
+ invoke_without_command=True,
16
+ help="Build docker image locally from Truefoundry spec",
17
+ context_settings={"ignore_unknown_options": True, "allow_interspersed_args": True},
18
+ )
19
+ @click.option(
20
+ "--name",
21
+ type=click.STRING,
22
+ required=True,
23
+ help="Name for the image being build - used as docker tag",
24
+ )
25
+ @click.option(
26
+ "--build-config",
27
+ "--build_config",
28
+ type=click.STRING,
29
+ required=True,
30
+ help="Build part of the spec as a json spec",
31
+ )
32
+ @click.argument("extra_opts", nargs=-1, type=click.UNPROCESSED)
33
+ @handle_exception_wrapper
34
+ def build_command(name, build_config, extra_opts):
35
+ if build_config:
36
+ console.print(rf"\[build] TrueFoundry CLI version: {__version__}")
37
+ builder.build(
38
+ build_configuration=json.loads(build_config),
39
+ tag=name,
40
+ extra_opts=extra_opts,
41
+ )
42
+
43
+
44
+ def get_build_command():
45
+ return build_command
@@ -0,0 +1,89 @@
1
+ from typing import Optional
2
+
3
+ import rich_click as click
4
+
5
+ from truefoundry.deploy.cli.const import COMMAND_CLS
6
+ from truefoundry.deploy.cli.util import handle_exception_wrapper
7
+ from truefoundry.deploy.io.rich_output_callback import RichOutputCallBack
8
+ from truefoundry.deploy.lib.clients.servicefoundry_client import (
9
+ ServiceFoundryServiceClient,
10
+ )
11
+ from truefoundry.deploy.lib.util import get_deployment_fqn_from_application_fqn
12
+ from truefoundry.logger import logger
13
+
14
+
15
+ @click.command(name="build-logs", cls=COMMAND_CLS)
16
+ @click.option(
17
+ "--application-fqn",
18
+ "--application_fqn",
19
+ type=click.STRING,
20
+ help="Application FQN",
21
+ required=True,
22
+ )
23
+ @click.option(
24
+ "--version",
25
+ type=click.INT,
26
+ help="Deployment version. If no deployment version "
27
+ "given, logs will be fetched for the latest version",
28
+ )
29
+ @click.option("-f", "--follow", help="Follow log output", is_flag=True, default=False)
30
+ @handle_exception_wrapper
31
+ def build_logs_command(
32
+ application_fqn: str,
33
+ version: Optional[int],
34
+ follow: bool,
35
+ ) -> None:
36
+ """
37
+ Get build logs for application fqn and deployment version
38
+ """
39
+ output_hook = RichOutputCallBack()
40
+ tfs_client = ServiceFoundryServiceClient()
41
+
42
+ if not version:
43
+ app_fqn_response = tfs_client.get_application_info_by_fqn(application_fqn)
44
+ application_info = tfs_client.get_application_info(
45
+ app_fqn_response.applicationId
46
+ )
47
+ version = application_info.lastVersion
48
+
49
+ deployment_fqn = get_deployment_fqn_from_application_fqn(
50
+ application_fqn=application_fqn, version=version
51
+ )
52
+
53
+ deployment_fqn_response = tfs_client.get_deployment_info_by_fqn(
54
+ deployment_fqn=deployment_fqn
55
+ )
56
+
57
+ build_responses = tfs_client.get_deployment_build_response(
58
+ application_id=deployment_fqn_response.applicationId,
59
+ deployment_id=deployment_fqn_response.deploymentId,
60
+ )
61
+
62
+ if not build_responses:
63
+ raise Exception(
64
+ f"Unable to find a build version for application fqn {application_fqn} and version {version}"
65
+ )
66
+
67
+ build_response = build_responses[0]
68
+ if not follow:
69
+ tfs_client.fetch_build_logs(
70
+ build_response=build_response,
71
+ callback=output_hook,
72
+ )
73
+ else:
74
+ try:
75
+ logger.info(
76
+ "You can press Ctrl + C to exit the tailing of build "
77
+ "logs and deployment will continue on the server"
78
+ )
79
+ tfs_client.tail_build_logs(
80
+ build_response=build_response,
81
+ callback=output_hook,
82
+ wait=True,
83
+ )
84
+ except KeyboardInterrupt:
85
+ logger.info("Ctrl-C executed. The deployment will still continue.")
86
+
87
+
88
+ def get_build_logs_command():
89
+ return build_logs_command
@@ -0,0 +1,75 @@
1
+ from typing import Optional
2
+
3
+ import rich_click as click
4
+
5
+ from truefoundry.deploy.cli.const import COMMAND_CLS, GROUP_CLS
6
+ from truefoundry.deploy.cli.display_util import print_obj
7
+ from truefoundry.deploy.cli.util import handle_exception_wrapper
8
+ from truefoundry.deploy.lib.dao import workspace as workspace_lib
9
+
10
+
11
+ @click.group(name="create", cls=GROUP_CLS)
12
+ def create_command():
13
+ # TODO (chiragjn): Figure out a way to update supported resources based on ENABLE_* flags
14
+ """
15
+ Create TrueFoundry resources
16
+
17
+ \b
18
+ Supported resources:
19
+ - Workspace
20
+ """
21
+ pass
22
+
23
+
24
+ @click.command(name="workspace", cls=COMMAND_CLS, help="Create a new Workspace")
25
+ @click.argument("name", type=click.STRING)
26
+ @click.option(
27
+ "-c",
28
+ "--cluster-name",
29
+ "--cluster_name",
30
+ type=click.STRING,
31
+ required=True,
32
+ help="Cluster to create this workspace in",
33
+ )
34
+ @click.option(
35
+ "--cpu-limit",
36
+ "--cpu_limit",
37
+ type=click.FLOAT,
38
+ default=None,
39
+ help="CPU Limit",
40
+ )
41
+ @click.option(
42
+ "--memory-limit",
43
+ "--memory_limit",
44
+ type=click.INT,
45
+ default=None,
46
+ help="Memory Limit in MB",
47
+ )
48
+ @click.option(
49
+ "--ephemeral-storage-limit",
50
+ "--ephemeral_storage_limit",
51
+ type=click.INT,
52
+ default=None,
53
+ help="Ephemeral Storage Limit in GB",
54
+ )
55
+ @handle_exception_wrapper
56
+ def create_workspace(
57
+ name: str,
58
+ cluster_name: str,
59
+ cpu_limit: Optional[float],
60
+ memory_limit: Optional[int],
61
+ ephemeral_storage_limit: Optional[int],
62
+ ):
63
+ workspace = workspace_lib.create_workspace(
64
+ name=name,
65
+ cpu_limit=cpu_limit,
66
+ memory_limit=memory_limit,
67
+ ephemeral_storage_limit=ephemeral_storage_limit,
68
+ cluster_name=cluster_name,
69
+ )
70
+ print_obj("Workspace", workspace.dict())
71
+
72
+
73
+ def get_create_command():
74
+ create_command.add_command(create_workspace)
75
+ return create_command
@@ -0,0 +1,77 @@
1
+ import rich_click as click
2
+
3
+ from truefoundry.deploy.cli.config import CliConfig
4
+ from truefoundry.deploy.cli.const import COMMAND_CLS, GROUP_CLS
5
+ from truefoundry.deploy.cli.display_util import print_json
6
+ from truefoundry.deploy.cli.util import handle_exception_wrapper
7
+ from truefoundry.deploy.io.rich_output_callback import RichOutputCallBack
8
+ from truefoundry.deploy.lib.dao import application as application_lib
9
+ from truefoundry.deploy.lib.dao import workspace as workspace_lib
10
+ from truefoundry.deploy.lib.messages import (
11
+ PROMPT_DELETED_APPLICATION,
12
+ PROMPT_DELETED_WORKSPACE,
13
+ )
14
+
15
+ # TODO (chiragjn): --json should disable all non json console prints
16
+
17
+
18
+ @click.group(name="delete", cls=GROUP_CLS)
19
+ def delete_command():
20
+ """
21
+ Delete TrueFoundry resources
22
+
23
+ \b
24
+ Supported resources:
25
+ - Workspace
26
+ - Application
27
+ """
28
+ pass
29
+
30
+
31
+ @click.command(name="workspace", cls=COMMAND_CLS, help="Delete a Workspace")
32
+ @click.option(
33
+ "-w",
34
+ "--workspace-fqn",
35
+ "--workspace_fqn",
36
+ type=click.STRING,
37
+ default=None,
38
+ help="FQN of the Workspace to delete",
39
+ required=True,
40
+ )
41
+ @click.confirmation_option(prompt="Are you sure you want to delete this workspace?")
42
+ @handle_exception_wrapper
43
+ def delete_workspace(workspace_fqn):
44
+ deleted_workspace = workspace_lib.delete_workspace(
45
+ workspace_fqn=workspace_fqn,
46
+ )
47
+ output_hook = RichOutputCallBack()
48
+ output_hook.print_line(PROMPT_DELETED_WORKSPACE.format(workspace_fqn))
49
+ if CliConfig.get("json"):
50
+ print_json(data=deleted_workspace.dict())
51
+
52
+
53
+ @click.command(name="application", cls=COMMAND_CLS, help="Delete an Application")
54
+ @click.option(
55
+ "--application-fqn",
56
+ "--application_fqn",
57
+ type=click.STRING,
58
+ default=None,
59
+ help="FQN of the Application to delete",
60
+ required=True,
61
+ )
62
+ @click.confirmation_option(prompt="Are you sure you want to delete this application?")
63
+ @handle_exception_wrapper
64
+ def delete_application(application_fqn):
65
+ response = application_lib.delete_application(
66
+ application_fqn=application_fqn,
67
+ )
68
+ output_hook = RichOutputCallBack()
69
+ output_hook.print_line(PROMPT_DELETED_APPLICATION.format(application_fqn))
70
+ if CliConfig.get("json"):
71
+ print_json(data=response)
72
+
73
+
74
+ def get_delete_command():
75
+ delete_command.add_command(delete_workspace)
76
+ delete_command.add_command(delete_application)
77
+ return delete_command
@@ -0,0 +1,99 @@
1
+ import os
2
+ import sys
3
+
4
+ import rich_click as click
5
+ import yaml
6
+ from click import UsageError
7
+ from click.exceptions import ClickException
8
+
9
+ from truefoundry.autodeploy.cli import cli as autodeploy_cli
10
+ from truefoundry.autodeploy.exception import InvalidRequirementsException
11
+ from truefoundry.deploy.cli.const import GROUP_CLS
12
+
13
+
14
+ def _get_default_spec_file():
15
+ paths = [
16
+ "./truefoundry.yaml",
17
+ "./truefoundry.yml",
18
+ "./servicefoundry.yaml",
19
+ "./servicefoundry.yml",
20
+ ]
21
+ for path in paths:
22
+ if os.path.exists(path):
23
+ return path
24
+
25
+
26
+ @click.group(
27
+ name="deploy",
28
+ cls=GROUP_CLS,
29
+ invoke_without_command=True,
30
+ help="Deploy application to Truefoundry",
31
+ )
32
+ @click.option(
33
+ "-f",
34
+ "--file",
35
+ type=click.Path(exists=True, dir_okay=False, resolve_path=True),
36
+ default=_get_default_spec_file(),
37
+ help="Path to truefoundry.yaml file",
38
+ show_default=True,
39
+ )
40
+ @click.option(
41
+ "-w",
42
+ "--workspace-fqn",
43
+ "--workspace_fqn",
44
+ required=True,
45
+ help="FQN of the Workspace to deploy to",
46
+ )
47
+ @click.option(
48
+ "--wait/--no-wait",
49
+ "--wait/--no_wait",
50
+ is_flag=True,
51
+ show_default=True,
52
+ default=True,
53
+ help="Wait and tail the deployment progress",
54
+ )
55
+ def deploy_command(file: str, workspace_fqn: str, wait: bool):
56
+ from truefoundry.deploy.lib.auth.servicefoundry_session import ServiceFoundrySession
57
+ from truefoundry.deploy.v2.lib.deployable_patched_models import Application
58
+
59
+ try:
60
+ _ = ServiceFoundrySession()
61
+ except Exception as e:
62
+ raise ClickException(message=str(e)) from e
63
+
64
+ if file:
65
+ with open(file, "r") as f:
66
+ application_definition = yaml.safe_load(f)
67
+
68
+ application = Application.parse_obj(application_definition)
69
+ application.deploy(workspace_fqn=workspace_fqn, wait=wait)
70
+ sys.exit(0)
71
+
72
+ click.echo(
73
+ click.style(
74
+ "We did not find any truefoundry.yaml or servicefoundry.yaml at the root path.",
75
+ fg="red",
76
+ ),
77
+ color=True,
78
+ )
79
+
80
+ if not sys.stdout.isatty():
81
+ click.echo(
82
+ click.style(
83
+ 'Please create a truefoundry.yaml or pass the file name with "--file file_name"',
84
+ fg="yellow",
85
+ ),
86
+ color=True,
87
+ )
88
+ sys.exit(1)
89
+
90
+ try:
91
+ autodeploy_cli(project_root_path=".", deploy=True, workspace_fqn=workspace_fqn)
92
+ except InvalidRequirementsException as e:
93
+ raise UsageError(message=e.message) from e
94
+ except Exception as e:
95
+ raise UsageError(message=str(e)) from e
96
+
97
+
98
+ def get_deploy_command():
99
+ return deploy_command