snowflake-cli-labs 2.8.0rc1__py3-none-any.whl → 3.0.0__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.
Files changed (251) hide show
  1. snowflake/cli/__about__.py +1 -1
  2. snowflake/cli/{app → _app}/__main__.py +1 -1
  3. snowflake/cli/{app → _app}/cli_app.py +22 -13
  4. snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +15 -19
  5. snowflake/cli/{app → _app}/commands_registration/command_plugins_loader.py +9 -9
  6. snowflake/cli/{app → _app}/commands_registration/commands_registration_with_callbacks.py +4 -4
  7. snowflake/cli/{app → _app}/commands_registration/exception_logging.py +2 -2
  8. snowflake/cli/{app → _app}/commands_registration/typer_registration.py +2 -2
  9. snowflake/cli/{app → _app}/dev/docs/commands_docs_generator.py +30 -12
  10. snowflake/cli/{app → _app}/dev/docs/generator.py +3 -3
  11. snowflake/cli/{app → _app}/dev/docs/project_definition_docs_generator.py +4 -4
  12. snowflake/cli/{app → _app}/dev/docs/templates/usage.rst.jinja2 +14 -4
  13. snowflake/cli/{app → _app}/main_typer.py +2 -2
  14. snowflake/cli/{app → _app}/printing.py +2 -2
  15. snowflake/cli/_app/secret.py +9 -0
  16. snowflake/cli/{app → _app}/snow_connector.py +127 -61
  17. snowflake/cli/{app → _app}/telemetry.py +38 -7
  18. snowflake/cli/_app/version_check.py +74 -0
  19. snowflake/cli/{plugins → _plugins}/connection/commands.py +34 -11
  20. snowflake/cli/_plugins/connection/plugin_spec.py +30 -0
  21. snowflake/cli/{plugins → _plugins}/connection/util.py +16 -0
  22. snowflake/cli/{plugins → _plugins}/cortex/commands.py +54 -49
  23. snowflake/cli/{plugins → _plugins}/cortex/constants.py +1 -1
  24. snowflake/cli/{plugins → _plugins}/cortex/manager.py +5 -5
  25. snowflake/cli/{plugins → _plugins}/cortex/plugin_spec.py +1 -1
  26. snowflake/cli/{plugins → _plugins}/git/commands.py +79 -26
  27. snowflake/cli/{plugins → _plugins}/git/manager.py +72 -17
  28. snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
  29. snowflake/cli/_plugins/helpers/commands.py +90 -0
  30. snowflake/cli/{plugins/notebook → _plugins/helpers}/plugin_spec.py +1 -1
  31. snowflake/cli/{plugins → _plugins}/init/commands.py +10 -6
  32. snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
  33. snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +24 -9
  34. snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
  35. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +4 -4
  36. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +37 -18
  37. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +249 -0
  38. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +5 -2
  39. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +5 -5
  40. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +1 -1
  41. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +29 -34
  42. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +114 -0
  43. snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +252 -132
  44. snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
  45. snowflake/cli/_plugins/nativeapp/entities/application.py +878 -0
  46. snowflake/cli/_plugins/nativeapp/entities/application_package.py +1392 -0
  47. snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +3 -12
  48. snowflake/cli/_plugins/nativeapp/manager.py +415 -0
  49. snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
  50. snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +3 -0
  51. snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +36 -20
  52. snowflake/cli/_plugins/nativeapp/run_processor.py +184 -0
  53. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +70 -0
  54. snowflake/cli/_plugins/nativeapp/teardown_processor.py +70 -0
  55. snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +262 -0
  56. snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +20 -49
  57. snowflake/cli/_plugins/nativeapp/version/version_processor.py +98 -0
  58. snowflake/cli/{plugins → _plugins}/notebook/commands.py +8 -6
  59. snowflake/cli/{plugins → _plugins}/notebook/manager.py +14 -14
  60. snowflake/cli/{plugins/nativeapp → _plugins/notebook}/plugin_spec.py +1 -1
  61. snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -1
  62. snowflake/cli/{plugins → _plugins}/object/command_aliases.py +6 -5
  63. snowflake/cli/{plugins → _plugins}/object/commands.py +16 -10
  64. snowflake/cli/{plugins → _plugins}/object/manager.py +43 -21
  65. snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
  66. snowflake/cli/_plugins/snowpark/commands.py +450 -0
  67. snowflake/cli/_plugins/snowpark/common.py +268 -0
  68. snowflake/cli/{plugins → _plugins}/snowpark/models.py +2 -8
  69. snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +2 -36
  70. snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
  71. snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +4 -3
  72. snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
  73. snowflake/cli/_plugins/snowpark/plugin_spec.py +30 -0
  74. snowflake/cli/_plugins/snowpark/snowpark_entity.py +29 -0
  75. snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +173 -0
  76. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +109 -0
  77. snowflake/cli/{plugins → _plugins}/snowpark/snowpark_shared.py +0 -36
  78. snowflake/cli/{plugins → _plugins}/snowpark/zipper.py +16 -8
  79. snowflake/cli/{plugins → _plugins}/spcs/__init__.py +5 -7
  80. snowflake/cli/{plugins → _plugins}/spcs/compute_pool/commands.py +29 -28
  81. snowflake/cli/{plugins → _plugins}/spcs/compute_pool/manager.py +3 -3
  82. snowflake/cli/{plugins → _plugins}/spcs/image_registry/commands.py +3 -3
  83. snowflake/cli/{plugins → _plugins}/spcs/image_repository/commands.py +25 -19
  84. snowflake/cli/{plugins → _plugins}/spcs/image_repository/manager.py +1 -1
  85. snowflake/cli/{plugins → _plugins}/spcs/plugin_spec.py +1 -1
  86. snowflake/cli/{plugins → _plugins}/spcs/services/commands.py +66 -32
  87. snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
  88. snowflake/cli/{plugins → _plugins}/sql/commands.py +20 -17
  89. snowflake/cli/{plugins → _plugins}/sql/manager.py +1 -1
  90. snowflake/cli/{plugins → _plugins}/sql/plugin_spec.py +1 -1
  91. snowflake/cli/{plugins → _plugins}/stage/commands.py +20 -17
  92. snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
  93. snowflake/cli/{plugins → _plugins}/stage/manager.py +62 -24
  94. snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
  95. snowflake/cli/_plugins/stage/utils.py +54 -0
  96. snowflake/cli/{plugins → _plugins}/streamlit/commands.py +71 -62
  97. snowflake/cli/{plugins → _plugins}/streamlit/manager.py +68 -70
  98. snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
  99. snowflake/cli/_plugins/streamlit/streamlit_entity.py +12 -0
  100. snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +66 -0
  101. snowflake/cli/_plugins/workspace/action_context.py +18 -0
  102. snowflake/cli/_plugins/workspace/commands.py +306 -0
  103. snowflake/cli/_plugins/workspace/manager.py +74 -0
  104. snowflake/cli/_plugins/workspace/plugin_spec.py +30 -0
  105. snowflake/cli/api/cli_global_context.py +152 -295
  106. snowflake/cli/api/commands/common.py +25 -0
  107. snowflake/cli/api/commands/decorators.py +19 -4
  108. snowflake/cli/api/commands/experimental_behaviour.py +2 -3
  109. snowflake/cli/api/commands/flags.py +143 -222
  110. snowflake/cli/api/commands/overrideable_parameter.py +143 -0
  111. snowflake/cli/api/commands/snow_typer.py +21 -11
  112. snowflake/cli/api/commands/utils.py +18 -0
  113. snowflake/cli/api/config.py +44 -12
  114. snowflake/cli/api/connections.py +216 -0
  115. snowflake/cli/api/console/abc.py +8 -3
  116. snowflake/cli/api/constants.py +11 -0
  117. snowflake/cli/api/entities/common.py +56 -0
  118. snowflake/cli/api/entities/utils.py +370 -0
  119. snowflake/cli/api/errno.py +1 -0
  120. snowflake/cli/api/exceptions.py +31 -5
  121. snowflake/cli/api/feature_flags.py +0 -1
  122. snowflake/cli/api/identifiers.py +45 -9
  123. snowflake/cli/api/metrics.py +92 -0
  124. snowflake/cli/api/project/definition.py +48 -6
  125. snowflake/cli/api/project/definition_conversion.py +400 -0
  126. snowflake/cli/api/project/definition_manager.py +16 -5
  127. snowflake/cli/api/project/project_verification.py +3 -3
  128. snowflake/cli/api/project/schemas/entities/common.py +91 -16
  129. snowflake/cli/api/project/schemas/entities/entities.py +37 -6
  130. snowflake/cli/api/project/schemas/project_definition.py +180 -49
  131. snowflake/cli/api/project/schemas/updatable_model.py +11 -3
  132. snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
  133. snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +3 -1
  134. snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
  135. snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +8 -9
  136. snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
  137. snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +7 -1
  138. snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
  139. snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
  140. snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
  141. snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
  142. snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
  143. snowflake/cli/api/project/util.py +23 -6
  144. snowflake/cli/api/rendering/jinja.py +14 -8
  145. snowflake/cli/api/rendering/project_definition_templates.py +5 -1
  146. snowflake/cli/api/rendering/sql_templates.py +56 -11
  147. snowflake/cli/api/rest_api.py +11 -5
  148. snowflake/cli/api/secure_path.py +16 -18
  149. snowflake/cli/api/secure_utils.py +90 -1
  150. snowflake/cli/api/sql_execution.py +47 -27
  151. snowflake/cli/api/utils/definition_rendering.py +45 -13
  152. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/METADATA +20 -18
  153. snowflake_cli_labs-3.0.0.dist-info/RECORD +242 -0
  154. snowflake_cli_labs-3.0.0.dist-info/entry_points.txt +2 -0
  155. snowflake/cli/api/commands/project_initialisation.py +0 -65
  156. snowflake/cli/api/commands/typer_pre_execute.py +0 -26
  157. snowflake/cli/api/project/schemas/entities/application_entity.py +0 -44
  158. snowflake/cli/api/project/schemas/entities/application_package_entity.py +0 -66
  159. snowflake/cli/app/build_and_push.sh +0 -8
  160. snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
  161. snowflake/cli/plugins/nativeapp/init.py +0 -345
  162. snowflake/cli/plugins/nativeapp/manager.py +0 -823
  163. snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
  164. snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
  165. snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
  166. snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
  167. snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
  168. snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
  169. snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
  170. snowflake/cli/plugins/snowpark/commands.py +0 -548
  171. snowflake/cli/plugins/snowpark/common.py +0 -307
  172. snowflake/cli/plugins/snowpark/manager.py +0 -109
  173. snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
  174. snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
  175. snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
  176. snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
  177. snowflake/cli/plugins/streamlit/__init__.py +0 -13
  178. snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
  179. snowflake/cli/plugins/workspace/__init__.py +0 -13
  180. snowflake/cli/plugins/workspace/commands.py +0 -35
  181. snowflake/cli/plugins/workspace/plugin_spec.py +0 -30
  182. snowflake/cli/templates/default_snowpark/.gitignore +0 -4
  183. snowflake/cli/templates/default_snowpark/app/common.py +0 -2
  184. snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
  185. snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
  186. snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
  187. snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
  188. snowflake/cli/templates/default_streamlit/.gitignore +0 -4
  189. snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
  190. snowflake/cli/templates/default_streamlit/environment.yml +0 -6
  191. snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
  192. snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
  193. snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
  194. snowflake_cli_labs-2.8.0rc1.dist-info/RECORD +0 -240
  195. snowflake_cli_labs-2.8.0rc1.dist-info/entry_points.txt +0 -2
  196. /snowflake/cli/{app → _app}/__init__.py +0 -0
  197. /snowflake/cli/{api/project/schemas/native_app → _app/api_impl}/__init__.py +0 -0
  198. /snowflake/cli/{api/project/schemas/snowpark → _app/api_impl/plugin}/__init__.py +0 -0
  199. /snowflake/cli/{app → _app}/api_impl/plugin/plugin_config_provider_impl.py +0 -0
  200. /snowflake/cli/{app → _app}/commands_registration/__init__.py +0 -0
  201. /snowflake/cli/{app → _app}/commands_registration/threadsafe.py +0 -0
  202. /snowflake/cli/{app → _app}/constants.py +0 -0
  203. /snowflake/cli/{api/project/schemas/streamlit → _app/dev}/__init__.py +0 -0
  204. /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
  205. /snowflake/cli/{app/api_impl → _app/dev/docs}/__init__.py +0 -0
  206. /snowflake/cli/{app → _app}/dev/docs/project_definition_generate_json_schema.py +0 -0
  207. /snowflake/cli/{app → _app}/dev/docs/template_utils.py +0 -0
  208. /snowflake/cli/{app → _app}/dev/docs/templates/definition_description.rst.jinja2 +0 -0
  209. /snowflake/cli/{app → _app}/dev/docs/templates/overview.rst.jinja2 +0 -0
  210. /snowflake/cli/{app → _app}/dev/pycharm_remote_debug.py +0 -0
  211. /snowflake/cli/{app → _app}/loggers.py +0 -0
  212. /snowflake/cli/{app/api_impl/plugin → _plugins}/__init__.py +0 -0
  213. /snowflake/cli/{app/dev → _plugins/connection}/__init__.py +0 -0
  214. /snowflake/cli/{app/dev/docs → _plugins/cortex}/__init__.py +0 -0
  215. /snowflake/cli/{plugins → _plugins}/cortex/types.py +0 -0
  216. /snowflake/cli/{plugins → _plugins/git}/__init__.py +0 -0
  217. /snowflake/cli/{plugins/connection → _plugins/helpers}/__init__.py +0 -0
  218. /snowflake/cli/{plugins/cortex → _plugins/init}/__init__.py +0 -0
  219. /snowflake/cli/{plugins/git → _plugins/nativeapp}/__init__.py +0 -0
  220. /snowflake/cli/{plugins/init → _plugins/nativeapp/codegen}/__init__.py +0 -0
  221. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
  222. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
  223. /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
  224. /snowflake/cli/{templates/default_snowpark/app → _plugins/nativeapp/entities}/__init__.py +0 -0
  225. /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
  226. /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
  227. /snowflake/cli/{plugins/nativeapp → _plugins/nativeapp/version}/__init__.py +0 -0
  228. /snowflake/cli/{plugins/nativeapp/codegen → _plugins/notebook}/__init__.py +0 -0
  229. /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
  230. /snowflake/cli/{plugins/nativeapp/version → _plugins/object}/__init__.py +0 -0
  231. /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
  232. /snowflake/cli/{plugins/notebook → _plugins/snowpark}/__init__.py +0 -0
  233. /snowflake/cli/{plugins/object → _plugins/snowpark/package}/__init__.py +0 -0
  234. /snowflake/cli/{plugins → _plugins}/snowpark/package/utils.py +0 -0
  235. /snowflake/cli/{plugins → _plugins}/spcs/common.py +0 -0
  236. /snowflake/cli/{plugins/snowpark → _plugins/spcs/compute_pool}/__init__.py +0 -0
  237. /snowflake/cli/{plugins/snowpark/package → _plugins/spcs/image_registry}/__init__.py +0 -0
  238. /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
  239. /snowflake/cli/{plugins/spcs/compute_pool → _plugins/spcs/image_repository}/__init__.py +0 -0
  240. /snowflake/cli/{plugins/spcs/image_registry → _plugins/spcs/services}/__init__.py +0 -0
  241. /snowflake/cli/{plugins/spcs/image_repository → _plugins/sql}/__init__.py +0 -0
  242. /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
  243. /snowflake/cli/{plugins/spcs/jobs → _plugins/stage}/__init__.py +0 -0
  244. /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
  245. /snowflake/cli/{plugins/spcs/services → _plugins/streamlit}/__init__.py +0 -0
  246. /snowflake/cli/{plugins/sql → _plugins/workspace}/__init__.py +0 -0
  247. /snowflake/cli/{plugins/stage → api/project/schemas/entities}/__init__.py +0 -0
  248. /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
  249. /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
  250. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/WHEEL +0 -0
  251. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -20,26 +20,28 @@ from typing import Optional
20
20
  import requests
21
21
  import typer
22
22
  from click import ClickException
23
+ from snowflake.cli._plugins.object.command_aliases import (
24
+ add_object_command_aliases,
25
+ scope_option,
26
+ )
27
+ from snowflake.cli._plugins.spcs.image_registry.manager import RegistryManager
28
+ from snowflake.cli._plugins.spcs.image_repository.manager import ImageRepositoryManager
23
29
  from snowflake.cli.api.commands.flags import (
24
30
  IfNotExistsOption,
25
31
  ReplaceOption,
32
+ identifier_argument,
26
33
  like_option,
27
34
  )
28
35
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
29
36
  from snowflake.cli.api.console import cli_console
30
37
  from snowflake.cli.api.constants import ObjectType
38
+ from snowflake.cli.api.identifiers import FQN
31
39
  from snowflake.cli.api.output.types import (
32
40
  CollectionResult,
33
41
  MessageResult,
34
42
  SingleQueryResult,
35
43
  )
36
44
  from snowflake.cli.api.project.util import is_valid_object_name
37
- from snowflake.cli.plugins.object.command_aliases import (
38
- add_object_command_aliases,
39
- scope_option,
40
- )
41
- from snowflake.cli.plugins.spcs.image_registry.manager import RegistryManager
42
- from snowflake.cli.plugins.spcs.image_repository.manager import ImageRepositoryManager
43
45
 
44
46
  app = SnowTyperFactory(
45
47
  name="image-repository",
@@ -48,18 +50,18 @@ app = SnowTyperFactory(
48
50
  )
49
51
 
50
52
 
51
- def _repo_name_callback(name: str):
52
- if not is_valid_object_name(name, max_depth=2, allow_quoted=False):
53
+ def _repo_name_callback(name: FQN):
54
+ if not is_valid_object_name(name.identifier, max_depth=2, allow_quoted=False):
53
55
  raise ClickException(
54
56
  f"'{name}' is not a valid image repository name. Note that image repository names must be unquoted identifiers. The same constraint also applies to database and schema names where you create an image repository."
55
57
  )
56
58
  return name
57
59
 
58
60
 
59
- REPO_NAME_ARGUMENT = typer.Argument(
60
- help="Name of the image repository.",
61
+ REPO_NAME_ARGUMENT = identifier_argument(
62
+ sf_object="image repository",
63
+ example="my_repository",
61
64
  callback=_repo_name_callback,
62
- show_default=False,
63
65
  )
64
66
 
65
67
  add_object_command_aliases(
@@ -76,7 +78,7 @@ add_object_command_aliases(
76
78
 
77
79
  @app.command(requires_connection=True)
78
80
  def create(
79
- name: str = REPO_NAME_ARGUMENT,
81
+ name: FQN = REPO_NAME_ARGUMENT,
80
82
  replace: bool = ReplaceOption(),
81
83
  if_not_exists: bool = IfNotExistsOption(),
82
84
  **options,
@@ -86,21 +88,21 @@ def create(
86
88
  """
87
89
  return SingleQueryResult(
88
90
  ImageRepositoryManager().create(
89
- name=name, replace=replace, if_not_exists=if_not_exists
91
+ name=name.identifier, replace=replace, if_not_exists=if_not_exists
90
92
  )
91
93
  )
92
94
 
93
95
 
94
96
  @app.command("list-images", requires_connection=True)
95
97
  def list_images(
96
- name: str = REPO_NAME_ARGUMENT,
98
+ name: FQN = REPO_NAME_ARGUMENT,
97
99
  **options,
98
100
  ) -> CollectionResult:
99
101
  """Lists images in the given repository."""
100
102
  repository_manager = ImageRepositoryManager()
101
103
  database = repository_manager.get_database()
102
104
  schema = repository_manager.get_schema()
103
- url = repository_manager.get_repository_url(name)
105
+ url = repository_manager.get_repository_url(name.identifier)
104
106
  api_url = repository_manager.get_repository_api_url(url)
105
107
  bearer_login = RegistryManager().login_to_registry(api_url)
106
108
  repos = []
@@ -136,7 +138,7 @@ def list_images(
136
138
 
137
139
  @app.command("list-tags", requires_connection=True)
138
140
  def list_tags(
139
- name: str = REPO_NAME_ARGUMENT,
141
+ name: FQN = REPO_NAME_ARGUMENT,
140
142
  image_name: str = typer.Option(
141
143
  ...,
142
144
  "--image-name",
@@ -150,7 +152,7 @@ def list_tags(
150
152
  """Lists tags for the given image in a repository."""
151
153
 
152
154
  repository_manager = ImageRepositoryManager()
153
- url = repository_manager.get_repository_url(name)
155
+ url = repository_manager.get_repository_url(name.identifier)
154
156
  api_url = repository_manager.get_repository_api_url(url)
155
157
  bearer_login = RegistryManager().login_to_registry(api_url)
156
158
 
@@ -187,10 +189,14 @@ def list_tags(
187
189
 
188
190
  @app.command("url", requires_connection=True)
189
191
  def repo_url(
190
- name: str = REPO_NAME_ARGUMENT,
192
+ name: FQN = REPO_NAME_ARGUMENT,
191
193
  **options,
192
194
  ):
193
195
  """Returns the URL for the given repository."""
194
196
  return MessageResult(
195
- (ImageRepositoryManager().get_repository_url(repo_name=name, with_scheme=False))
197
+ (
198
+ ImageRepositoryManager().get_repository_url(
199
+ repo_name=name.identifier, with_scheme=False
200
+ )
201
+ )
196
202
  )
@@ -14,10 +14,10 @@
14
14
 
15
15
  from urllib.parse import urlparse
16
16
 
17
+ from snowflake.cli._plugins.spcs.common import handle_object_already_exists
17
18
  from snowflake.cli.api.constants import ObjectType
18
19
  from snowflake.cli.api.identifiers import FQN
19
20
  from snowflake.cli.api.sql_execution import SqlExecutionMixin
20
- from snowflake.cli.plugins.spcs.common import handle_object_already_exists
21
21
  from snowflake.connector.errors import ProgrammingError
22
22
 
23
23
 
@@ -12,13 +12,13 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from snowflake.cli._plugins.spcs import app
15
16
  from snowflake.cli.api.plugins.command import (
16
17
  SNOWCLI_ROOT_COMMAND_PATH,
17
18
  CommandSpec,
18
19
  CommandType,
19
20
  plugin_hook_impl,
20
21
  )
21
- from snowflake.cli.plugins.spcs import app
22
22
 
23
23
 
24
24
  @plugin_hook_impl
@@ -20,13 +20,25 @@ from typing import List, Optional
20
20
 
21
21
  import typer
22
22
  from click import ClickException
23
+ from snowflake.cli._plugins.object.command_aliases import (
24
+ add_object_command_aliases,
25
+ scope_option,
26
+ )
27
+ from snowflake.cli._plugins.object.common import CommentOption, Tag, TagOption
28
+ from snowflake.cli._plugins.spcs.common import (
29
+ print_log_lines,
30
+ validate_and_set_instances,
31
+ )
32
+ from snowflake.cli._plugins.spcs.services.manager import ServiceManager
23
33
  from snowflake.cli.api.commands.flags import (
24
34
  IfNotExistsOption,
25
35
  OverrideableOption,
36
+ identifier_argument,
26
37
  like_option,
27
38
  )
28
39
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
29
40
  from snowflake.cli.api.constants import ObjectType
41
+ from snowflake.cli.api.identifiers import FQN
30
42
  from snowflake.cli.api.output.types import (
31
43
  CommandResult,
32
44
  QueryJsonValueResult,
@@ -34,16 +46,6 @@ from snowflake.cli.api.output.types import (
34
46
  SingleQueryResult,
35
47
  )
36
48
  from snowflake.cli.api.project.util import is_valid_object_name
37
- from snowflake.cli.plugins.object.command_aliases import (
38
- add_object_command_aliases,
39
- scope_option,
40
- )
41
- from snowflake.cli.plugins.object.common import CommentOption, Tag, TagOption
42
- from snowflake.cli.plugins.spcs.common import (
43
- print_log_lines,
44
- validate_and_set_instances,
45
- )
46
- from snowflake.cli.plugins.spcs.services.manager import ServiceManager
47
49
 
48
50
  app = SnowTyperFactory(
49
51
  name="service",
@@ -52,19 +54,18 @@ app = SnowTyperFactory(
52
54
  )
53
55
 
54
56
 
55
- def _service_name_callback(name: str) -> str:
56
- if not is_valid_object_name(name, max_depth=2, allow_quoted=False):
57
+ def _service_name_callback(name: FQN) -> FQN:
58
+ if not is_valid_object_name(name.identifier, max_depth=2, allow_quoted=False):
57
59
  raise ClickException(
58
60
  f"'{name}' is not a valid service name. Note service names must be unquoted identifiers. The same constraint also applies to database and schema names where you create a service."
59
61
  )
60
62
  return name
61
63
 
62
64
 
63
- ServiceNameArgument = typer.Argument(
64
- ...,
65
- help="Name of the service.",
65
+ ServiceNameArgument = identifier_argument(
66
+ sf_object="service",
67
+ example="my_service",
66
68
  callback=_service_name_callback,
67
- show_default=False,
68
69
  )
69
70
 
70
71
  SpecPathOption = typer.Option(
@@ -116,7 +117,7 @@ add_object_command_aliases(
116
117
 
117
118
  @app.command(requires_connection=True)
118
119
  def create(
119
- name: str = ServiceNameArgument,
120
+ name: FQN = ServiceNameArgument,
120
121
  compute_pool: str = typer.Option(
121
122
  ...,
122
123
  "--compute-pool",
@@ -145,7 +146,7 @@ def create(
145
146
  min_instances, max_instances, "instances"
146
147
  )
147
148
  cursor = ServiceManager().create(
148
- service_name=name,
149
+ service_name=name.identifier,
149
150
  min_instances=min_instances,
150
151
  max_instances=max_instances,
151
152
  compute_pool=compute_pool,
@@ -161,17 +162,50 @@ def create(
161
162
 
162
163
 
163
164
  @app.command(requires_connection=True)
164
- def status(name: str = ServiceNameArgument, **options) -> CommandResult:
165
+ def execute_job(
166
+ name: FQN = ServiceNameArgument,
167
+ compute_pool: str = typer.Option(
168
+ ...,
169
+ "--compute-pool",
170
+ help="Compute pool to run the job service on.",
171
+ show_default=False,
172
+ ),
173
+ spec_path: Path = SpecPathOption,
174
+ external_access_integrations: Optional[List[str]] = typer.Option(
175
+ None,
176
+ "--eai-name",
177
+ help="Identifies External Access Integrations(EAI) that the job service can access. This option may be specified multiple times for multiple EAIs.",
178
+ ),
179
+ query_warehouse: Optional[str] = QueryWarehouseOption(),
180
+ comment: Optional[str] = CommentOption(help=_COMMENT_HELP),
181
+ **options,
182
+ ) -> CommandResult:
183
+ """
184
+ Creates and executes a job service in the current schema.
185
+ """
186
+ cursor = ServiceManager().execute_job(
187
+ job_service_name=name.identifier,
188
+ compute_pool=compute_pool,
189
+ spec_path=spec_path,
190
+ external_access_integrations=external_access_integrations,
191
+ query_warehouse=query_warehouse,
192
+ comment=comment,
193
+ )
194
+ return SingleQueryResult(cursor)
195
+
196
+
197
+ @app.command(requires_connection=True)
198
+ def status(name: FQN = ServiceNameArgument, **options) -> CommandResult:
165
199
  """
166
200
  Retrieves the status of a service.
167
201
  """
168
- cursor = ServiceManager().status(service_name=name)
202
+ cursor = ServiceManager().status(service_name=name.identifier)
169
203
  return QueryJsonValueResult(cursor)
170
204
 
171
205
 
172
206
  @app.command(requires_connection=True)
173
207
  def logs(
174
- name: str = ServiceNameArgument,
208
+ name: FQN = ServiceNameArgument,
175
209
  container_name: str = typer.Option(
176
210
  ...,
177
211
  "--container-name",
@@ -193,7 +227,7 @@ def logs(
193
227
  Retrieves local logs from a service container.
194
228
  """
195
229
  results = ServiceManager().logs(
196
- service_name=name,
230
+ service_name=name.identifier,
197
231
  instance_id=instance_id,
198
232
  container_name=container_name,
199
233
  num_lines=num_lines,
@@ -205,7 +239,7 @@ def logs(
205
239
 
206
240
  @app.command(requires_connection=True)
207
241
  def upgrade(
208
- name: str = ServiceNameArgument,
242
+ name: FQN = ServiceNameArgument,
209
243
  spec_path: Path = SpecPathOption,
210
244
  **options,
211
245
  ):
@@ -213,20 +247,20 @@ def upgrade(
213
247
  Updates an existing service with a new specification file.
214
248
  """
215
249
  return SingleQueryResult(
216
- ServiceManager().upgrade_spec(service_name=name, spec_path=spec_path)
250
+ ServiceManager().upgrade_spec(service_name=name.identifier, spec_path=spec_path)
217
251
  )
218
252
 
219
253
 
220
254
  @app.command("list-endpoints", requires_connection=True)
221
- def list_endpoints(name: str = ServiceNameArgument, **options):
255
+ def list_endpoints(name: FQN = ServiceNameArgument, **options):
222
256
  """
223
257
  Lists the endpoints in a service.
224
258
  """
225
- return QueryResult(ServiceManager().list_endpoints(service_name=name))
259
+ return QueryResult(ServiceManager().list_endpoints(service_name=name.identifier))
226
260
 
227
261
 
228
262
  @app.command(requires_connection=True)
229
- def suspend(name: str = ServiceNameArgument, **options) -> CommandResult:
263
+ def suspend(name: FQN = ServiceNameArgument, **options) -> CommandResult:
230
264
  """
231
265
  Suspends the service, shutting down and deleting all its containers.
232
266
  """
@@ -234,7 +268,7 @@ def suspend(name: str = ServiceNameArgument, **options) -> CommandResult:
234
268
 
235
269
 
236
270
  @app.command(requires_connection=True)
237
- def resume(name: str = ServiceNameArgument, **options) -> CommandResult:
271
+ def resume(name: FQN = ServiceNameArgument, **options) -> CommandResult:
238
272
  """
239
273
  Resumes the service from a SUSPENDED state.
240
274
  """
@@ -243,7 +277,7 @@ def resume(name: str = ServiceNameArgument, **options) -> CommandResult:
243
277
 
244
278
  @app.command("set", requires_connection=True)
245
279
  def set_property(
246
- name: str = ServiceNameArgument,
280
+ name: FQN = ServiceNameArgument,
247
281
  min_instances: Optional[int] = MinInstancesOption(default=None, show_default=False),
248
282
  max_instances: Optional[int] = MaxInstancesOption(show_default=False),
249
283
  query_warehouse: Optional[str] = QueryWarehouseOption(show_default=False),
@@ -255,7 +289,7 @@ def set_property(
255
289
  Sets one or more properties for the service.
256
290
  """
257
291
  cursor = ServiceManager().set_property(
258
- service_name=name,
292
+ service_name=name.identifier,
259
293
  min_instances=min_instances,
260
294
  max_instances=max_instances,
261
295
  query_warehouse=query_warehouse,
@@ -267,7 +301,7 @@ def set_property(
267
301
 
268
302
  @app.command("unset", requires_connection=True)
269
303
  def unset_property(
270
- name: str = ServiceNameArgument,
304
+ name: FQN = ServiceNameArgument,
271
305
  min_instances: bool = MinInstancesOption(
272
306
  default=False,
273
307
  help=f"Reset the MIN_INSTANCES property - {_MIN_INSTANCES_HELP}",
@@ -301,7 +335,7 @@ def unset_property(
301
335
  Resets one or more properties for the service to their default value(s).
302
336
  """
303
337
  cursor = ServiceManager().unset_property(
304
- service_name=name,
338
+ service_name=name.identifier,
305
339
  min_instances=min_instances,
306
340
  max_instances=max_instances,
307
341
  query_warehouse=query_warehouse,
@@ -19,15 +19,15 @@ from pathlib import Path
19
19
  from typing import List, Optional
20
20
 
21
21
  import yaml
22
- from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB, ObjectType
23
- from snowflake.cli.api.secure_path import SecurePath
24
- from snowflake.cli.api.sql_execution import SqlExecutionMixin
25
- from snowflake.cli.plugins.object.common import Tag
26
- from snowflake.cli.plugins.spcs.common import (
22
+ from snowflake.cli._plugins.object.common import Tag
23
+ from snowflake.cli._plugins.spcs.common import (
27
24
  NoPropertiesProvidedError,
28
25
  handle_object_already_exists,
29
26
  strip_empty_lines,
30
27
  )
28
+ from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB, ObjectType
29
+ from snowflake.cli.api.secure_path import SecurePath
30
+ from snowflake.cli.api.sql_execution import SqlExecutionMixin
31
31
  from snowflake.connector.cursor import SnowflakeCursor
32
32
  from snowflake.connector.errors import ProgrammingError
33
33
 
@@ -85,6 +85,44 @@ class ServiceManager(SqlExecutionMixin):
85
85
  except ProgrammingError as e:
86
86
  handle_object_already_exists(e, ObjectType.SERVICE, service_name)
87
87
 
88
+ def execute_job(
89
+ self,
90
+ job_service_name: str,
91
+ compute_pool: str,
92
+ spec_path: Path,
93
+ external_access_integrations: Optional[List[str]],
94
+ query_warehouse: Optional[str],
95
+ comment: Optional[str],
96
+ ) -> SnowflakeCursor:
97
+ spec = self._read_yaml(spec_path)
98
+ query = f"""\
99
+ EXECUTE JOB SERVICE
100
+ IN COMPUTE POOL {compute_pool}
101
+ FROM SPECIFICATION $$
102
+ {spec}
103
+ $$
104
+ NAME = {job_service_name}
105
+ """.splitlines()
106
+
107
+ if external_access_integrations:
108
+ external_access_integration_list = ",".join(
109
+ f"{e}" for e in external_access_integrations
110
+ )
111
+ query.append(
112
+ f"EXTERNAL_ACCESS_INTEGRATIONS = ({external_access_integration_list})"
113
+ )
114
+
115
+ if query_warehouse:
116
+ query.append(f"QUERY_WAREHOUSE = {query_warehouse}")
117
+
118
+ if comment:
119
+ query.append(f"COMMENT = {comment}")
120
+
121
+ try:
122
+ return self._execute_query(strip_empty_lines(query))
123
+ except ProgrammingError as e:
124
+ handle_object_already_exists(e, ObjectType.SERVICE, job_service_name)
125
+
88
126
  def _read_yaml(self, path: Path) -> str:
89
127
  # TODO(aivanou): Add validation towards schema
90
128
  with SecurePath(path).open("r", read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as fh:
@@ -17,43 +17,46 @@ from __future__ import annotations
17
17
  from pathlib import Path
18
18
  from typing import List, Optional
19
19
 
20
- import typer
20
+ from snowflake.cli._plugins.sql.manager import SqlManager
21
21
  from snowflake.cli.api.commands.decorators import with_project_definition
22
22
  from snowflake.cli.api.commands.flags import (
23
- parse_key_value_variables,
24
23
  variables_option,
25
24
  )
25
+ from snowflake.cli.api.commands.overrideable_parameter import OverrideableOption
26
26
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
27
+ from snowflake.cli.api.commands.utils import parse_key_value_variables
27
28
  from snowflake.cli.api.output.types import CommandResult, MultipleResults, QueryResult
28
- from snowflake.cli.plugins.sql.manager import SqlManager
29
29
 
30
30
  # simple Typer with defaults because it won't become a command group as it contains only one command
31
31
  app = SnowTyperFactory()
32
32
 
33
+ SOURCE_EXCLUSIVE_OPTIONS_NAMES = ["query", "files", "std_in"]
34
+
35
+ SourceOption = OverrideableOption(
36
+ mutually_exclusive=SOURCE_EXCLUSIVE_OPTIONS_NAMES, show_default=False
37
+ )
38
+
33
39
 
34
40
  @app.command(name="sql", requires_connection=True, no_args_is_help=True)
35
41
  @with_project_definition(is_optional=True)
36
42
  def execute_sql(
37
- query: Optional[str] = typer.Option(
38
- None,
39
- "--query",
40
- "-q",
43
+ query: Optional[str] = SourceOption(
44
+ default=None,
45
+ param_decls=["--query", "-q"],
41
46
  help="Query to execute.",
42
47
  ),
43
- files: Optional[List[Path]] = typer.Option(
44
- None,
45
- "--filename",
46
- "-f",
48
+ files: Optional[List[Path]] = SourceOption(
49
+ default=[],
50
+ param_decls=["--filename", "-f"],
47
51
  exists=True,
48
52
  file_okay=True,
49
53
  dir_okay=False,
50
54
  readable=True,
51
55
  help="File to execute.",
52
56
  ),
53
- std_in: Optional[bool] = typer.Option(
54
- False,
55
- "--stdin",
56
- "-i",
57
+ std_in: Optional[bool] = SourceOption(
58
+ default=False,
59
+ param_decls=["--stdin", "-i"],
57
60
  help="Read the query from standard input. Use it when piping input to this command.",
58
61
  ),
59
62
  data_override: List[str] = variables_option(
@@ -70,9 +73,9 @@ def execute_sql(
70
73
  Query to execute can be specified using query option, filename option (all queries from file will be executed)
71
74
  or via stdin by piping output from other command. For example `cat my.sql | snow sql -i`.
72
75
 
73
- The command supports variable substitution that happens on client-side. Both &VARIABLE or &{ VARIABLE }
74
- syntax are supported.
76
+ The command supports variable substitution that happens on client-side.
75
77
  """
78
+
76
79
  data = {}
77
80
  if data_override:
78
81
  data = {v.key: v.value for v in parse_key_value_variables(data_override)}
@@ -22,10 +22,10 @@ from typing import Dict, Iterable, List, Tuple
22
22
 
23
23
  from click import ClickException, UsageError
24
24
  from jinja2 import UndefinedError
25
+ from snowflake.cli._plugins.sql.snowsql_templating import transpile_snowsql_templates
25
26
  from snowflake.cli.api.rendering.sql_templates import snowflake_sql_jinja_render
26
27
  from snowflake.cli.api.secure_path import UNLIMITED, SecurePath
27
28
  from snowflake.cli.api.sql_execution import SqlExecutionMixin, VerboseCursor
28
- from snowflake.cli.plugins.sql.snowsql_templating import transpile_snowsql_templates
29
29
  from snowflake.connector.cursor import SnowflakeCursor
30
30
  from snowflake.connector.util_text import split_statements
31
31
 
@@ -12,13 +12,13 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from snowflake.cli._plugins.sql import commands
15
16
  from snowflake.cli.api.plugins.command import (
16
17
  SNOWCLI_ROOT_COMMAND_PATH,
17
18
  CommandSpec,
18
19
  CommandType,
19
20
  plugin_hook_impl,
20
21
  )
21
- from snowflake.cli.plugins.sql import commands
22
22
 
23
23
 
24
24
  @plugin_hook_impl
@@ -21,16 +21,29 @@ from typing import List, Optional
21
21
 
22
22
  import click
23
23
  import typer
24
- from snowflake.cli.api.cli_global_context import cli_context
24
+ from snowflake.cli._plugins.object.command_aliases import (
25
+ add_object_command_aliases,
26
+ scope_option,
27
+ )
28
+ from snowflake.cli._plugins.stage.diff import (
29
+ DiffResult,
30
+ compute_stage_diff,
31
+ )
32
+ from snowflake.cli._plugins.stage.manager import StageManager
33
+ from snowflake.cli._plugins.stage.utils import print_diff_to_console
34
+ from snowflake.cli.api.cli_global_context import get_cli_context
35
+ from snowflake.cli.api.commands.common import OnErrorType
25
36
  from snowflake.cli.api.commands.flags import (
26
37
  ExecuteVariablesOption,
27
38
  OnErrorOption,
28
39
  PatternOption,
40
+ identifier_stage_argument,
29
41
  like_option,
30
42
  )
31
43
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
32
44
  from snowflake.cli.api.console import cli_console
33
45
  from snowflake.cli.api.constants import ObjectType
46
+ from snowflake.cli.api.identifiers import FQN
34
47
  from snowflake.cli.api.output.formats import OutputFormat
35
48
  from snowflake.cli.api.output.types import (
36
49
  CollectionResult,
@@ -40,23 +53,13 @@ from snowflake.cli.api.output.types import (
40
53
  SingleQueryResult,
41
54
  )
42
55
  from snowflake.cli.api.utils.path_utils import is_stage_path
43
- from snowflake.cli.plugins.object.command_aliases import (
44
- add_object_command_aliases,
45
- scope_option,
46
- )
47
- from snowflake.cli.plugins.stage.diff import (
48
- DiffResult,
49
- compute_stage_diff,
50
- print_diff_to_console,
51
- )
52
- from snowflake.cli.plugins.stage.manager import OnErrorType, StageManager
53
56
 
54
57
  app = SnowTyperFactory(
55
58
  name="stage",
56
59
  help="Manages stages.",
57
60
  )
58
61
 
59
- StageNameArgument = typer.Argument(..., help="Name of the stage.", show_default=False)
62
+ StageNameArgument = identifier_stage_argument(sf_object="stage", example="@my_stage")
60
63
 
61
64
  add_object_command_aliases(
62
65
  app=app,
@@ -142,17 +145,17 @@ def copy(
142
145
 
143
146
 
144
147
  @app.command("create", requires_connection=True)
145
- def stage_create(stage_name: str = StageNameArgument, **options) -> CommandResult:
148
+ def stage_create(stage_name: FQN = StageNameArgument, **options) -> CommandResult:
146
149
  """
147
150
  Creates a named stage if it does not already exist.
148
151
  """
149
- cursor = StageManager().create(stage_name=stage_name)
152
+ cursor = StageManager().create(fqn=stage_name)
150
153
  return SingleQueryResult(cursor)
151
154
 
152
155
 
153
156
  @app.command("remove", requires_connection=True)
154
157
  def stage_remove(
155
- stage_name: str = StageNameArgument,
158
+ stage_name: FQN = StageNameArgument,
156
159
  file_name: str = typer.Argument(
157
160
  ...,
158
161
  help="Name of the file to remove.",
@@ -164,7 +167,7 @@ def stage_remove(
164
167
  Removes a file from a stage.
165
168
  """
166
169
 
167
- cursor = StageManager().remove(stage_name=stage_name, path=file_name)
170
+ cursor = StageManager().remove(stage_name=stage_name.identifier, path=file_name)
168
171
  return SingleQueryResult(cursor)
169
172
 
170
173
 
@@ -186,7 +189,7 @@ def stage_diff(
186
189
  diff: DiffResult = compute_stage_diff(
187
190
  local_root=Path(folder_name), stage_fqn=stage_name
188
191
  )
189
- if cli_context.output_format == OutputFormat.JSON:
192
+ if get_cli_context().output_format == OutputFormat.JSON:
190
193
  return ObjectResult(diff.to_dict())
191
194
  else:
192
195
  print_diff_to_console(diff)