snowflake-cli-labs 2.8.0rc0__py3-none-any.whl → 3.0.0rc0__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 (220) 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 +12 -12
  4. snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +13 -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 → _app}/snow_connector.py +6 -6
  16. snowflake/cli/{app → _app}/telemetry.py +4 -5
  17. snowflake/cli/{plugins → _plugins}/connection/commands.py +22 -5
  18. snowflake/cli/_plugins/connection/plugin_spec.py +30 -0
  19. snowflake/cli/{plugins → _plugins}/connection/util.py +16 -0
  20. snowflake/cli/{plugins → _plugins}/cortex/commands.py +54 -49
  21. snowflake/cli/{plugins → _plugins}/cortex/constants.py +1 -1
  22. snowflake/cli/{plugins → _plugins}/cortex/manager.py +5 -5
  23. snowflake/cli/{plugins → _plugins}/cortex/plugin_spec.py +1 -1
  24. snowflake/cli/{plugins → _plugins}/git/commands.py +32 -20
  25. snowflake/cli/{plugins → _plugins}/git/manager.py +6 -5
  26. snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
  27. snowflake/cli/{plugins → _plugins}/init/commands.py +10 -6
  28. snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
  29. snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +14 -0
  30. snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
  31. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +3 -3
  32. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +16 -18
  33. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/native_app_setup_processor.py +24 -28
  34. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +4 -4
  35. snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +20 -24
  36. snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +171 -42
  37. snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
  38. snowflake/cli/{plugins → _plugins}/nativeapp/init.py +1 -1
  39. snowflake/cli/_plugins/nativeapp/manager.py +601 -0
  40. snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
  41. snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +34 -11
  42. snowflake/cli/{plugins → _plugins}/nativeapp/run_processor.py +25 -23
  43. snowflake/cli/{plugins → _plugins}/nativeapp/teardown_processor.py +8 -8
  44. snowflake/cli/{plugins → _plugins}/nativeapp/v2_conversions/v2_to_v1_decorator.py +47 -28
  45. snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +15 -12
  46. snowflake/cli/{plugins → _plugins}/nativeapp/version/version_processor.py +22 -20
  47. snowflake/cli/{plugins → _plugins}/notebook/commands.py +8 -6
  48. snowflake/cli/{plugins → _plugins}/notebook/manager.py +14 -14
  49. snowflake/cli/{plugins → _plugins}/notebook/plugin_spec.py +1 -1
  50. snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -1
  51. snowflake/cli/{plugins → _plugins}/object/command_aliases.py +6 -5
  52. snowflake/cli/{plugins → _plugins}/object/commands.py +16 -10
  53. snowflake/cli/{plugins → _plugins}/object/manager.py +7 -6
  54. snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
  55. snowflake/cli/_plugins/snowpark/commands.py +510 -0
  56. snowflake/cli/_plugins/snowpark/common.py +252 -0
  57. snowflake/cli/{plugins → _plugins}/snowpark/models.py +0 -7
  58. snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +1 -1
  59. snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
  60. snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +4 -3
  61. snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
  62. snowflake/cli/{plugins/nativeapp → _plugins/snowpark}/plugin_spec.py +1 -1
  63. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +109 -0
  64. snowflake/cli/{plugins → _plugins}/snowpark/snowpark_shared.py +0 -36
  65. snowflake/cli/{plugins → _plugins}/snowpark/zipper.py +16 -8
  66. snowflake/cli/{plugins → _plugins}/spcs/__init__.py +5 -7
  67. snowflake/cli/{plugins → _plugins}/spcs/compute_pool/commands.py +29 -28
  68. snowflake/cli/{plugins → _plugins}/spcs/compute_pool/manager.py +3 -3
  69. snowflake/cli/{plugins → _plugins}/spcs/image_registry/commands.py +3 -3
  70. snowflake/cli/{plugins → _plugins}/spcs/image_repository/commands.py +25 -19
  71. snowflake/cli/{plugins → _plugins}/spcs/image_repository/manager.py +1 -1
  72. snowflake/cli/{plugins → _plugins}/spcs/plugin_spec.py +1 -1
  73. snowflake/cli/{plugins → _plugins}/spcs/services/commands.py +66 -32
  74. snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
  75. snowflake/cli/{plugins → _plugins}/sql/commands.py +19 -15
  76. snowflake/cli/{plugins → _plugins}/sql/manager.py +1 -1
  77. snowflake/cli/{plugins → _plugins}/sql/plugin_spec.py +1 -1
  78. snowflake/cli/{plugins → _plugins}/stage/commands.py +20 -17
  79. snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
  80. snowflake/cli/{plugins → _plugins}/stage/manager.py +8 -6
  81. snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
  82. snowflake/cli/_plugins/stage/utils.py +54 -0
  83. snowflake/cli/_plugins/streamlit/commands.py +242 -0
  84. snowflake/cli/{plugins → _plugins}/streamlit/manager.py +47 -70
  85. snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
  86. snowflake/cli/_plugins/workspace/action_context.py +11 -0
  87. snowflake/cli/_plugins/workspace/commands.py +113 -0
  88. snowflake/cli/_plugins/workspace/manager.py +57 -0
  89. snowflake/cli/{plugins → _plugins}/workspace/plugin_spec.py +1 -1
  90. snowflake/cli/api/cli_global_context.py +34 -7
  91. snowflake/cli/api/commands/common.py +25 -0
  92. snowflake/cli/api/commands/decorators.py +4 -3
  93. snowflake/cli/api/commands/experimental_behaviour.py +2 -3
  94. snowflake/cli/api/commands/flags.py +73 -174
  95. snowflake/cli/api/commands/overrideable_parameter.py +143 -0
  96. snowflake/cli/api/commands/snow_typer.py +5 -4
  97. snowflake/cli/api/commands/typer_pre_execute.py +3 -3
  98. snowflake/cli/api/commands/utils.py +18 -0
  99. snowflake/cli/api/config.py +1 -1
  100. snowflake/cli/api/console/abc.py +5 -2
  101. snowflake/cli/api/entities/application_entity.py +12 -0
  102. snowflake/cli/api/entities/application_package_entity.py +260 -0
  103. snowflake/cli/api/entities/common.py +47 -0
  104. snowflake/cli/api/entities/snowpark_entity.py +29 -0
  105. snowflake/cli/api/entities/streamlit_entity.py +12 -0
  106. snowflake/cli/api/entities/utils.py +321 -0
  107. snowflake/cli/api/exceptions.py +19 -3
  108. snowflake/cli/api/feature_flags.py +2 -1
  109. snowflake/cli/api/identifiers.py +41 -9
  110. snowflake/cli/api/project/definition.py +13 -5
  111. snowflake/cli/api/project/definition_manager.py +12 -1
  112. snowflake/cli/api/project/errors.py +16 -1
  113. snowflake/cli/api/project/project_verification.py +3 -3
  114. snowflake/cli/api/project/schemas/entities/{application_entity.py → application_entity_model.py} +21 -9
  115. snowflake/cli/api/project/schemas/entities/{application_package_entity.py → application_package_entity_model.py} +26 -15
  116. snowflake/cli/api/project/schemas/entities/common.py +80 -6
  117. snowflake/cli/api/project/schemas/entities/entities.py +38 -8
  118. snowflake/cli/api/project/schemas/entities/snowpark_entity.py +176 -0
  119. snowflake/cli/api/project/schemas/entities/streamlit_entity_model.py +73 -0
  120. snowflake/cli/api/project/schemas/identifier_model.py +10 -1
  121. snowflake/cli/api/project/schemas/native_app/application.py +8 -9
  122. snowflake/cli/api/project/schemas/native_app/package.py +7 -1
  123. snowflake/cli/api/project/schemas/project_definition.py +97 -23
  124. snowflake/cli/api/project/schemas/updatable_model.py +11 -3
  125. snowflake/cli/api/project/util.py +23 -6
  126. snowflake/cli/api/rendering/jinja.py +28 -8
  127. snowflake/cli/api/rendering/sql_templates.py +41 -12
  128. snowflake/cli/api/secure_path.py +3 -0
  129. snowflake/cli/api/sql_execution.py +35 -19
  130. snowflake/cli/api/utils/definition_rendering.py +14 -2
  131. {snowflake_cli_labs-2.8.0rc0.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/METADATA +12 -12
  132. snowflake_cli_labs-3.0.0rc0.dist-info/RECORD +234 -0
  133. snowflake_cli_labs-3.0.0rc0.dist-info/entry_points.txt +2 -0
  134. snowflake/cli/api/commands/project_initialisation.py +0 -65
  135. snowflake/cli/app/build_and_push.sh +0 -8
  136. snowflake/cli/plugins/nativeapp/manager.py +0 -819
  137. snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
  138. snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
  139. snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
  140. snowflake/cli/plugins/snowpark/commands.py +0 -548
  141. snowflake/cli/plugins/snowpark/common.py +0 -307
  142. snowflake/cli/plugins/snowpark/manager.py +0 -109
  143. snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
  144. snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
  145. snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
  146. snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
  147. snowflake/cli/plugins/streamlit/commands.py +0 -186
  148. snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
  149. snowflake/cli/plugins/workspace/commands.py +0 -35
  150. snowflake/cli/templates/default_snowpark/.gitignore +0 -4
  151. snowflake/cli/templates/default_snowpark/app/__init__.py +0 -0
  152. snowflake/cli/templates/default_snowpark/app/common.py +0 -2
  153. snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
  154. snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
  155. snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
  156. snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
  157. snowflake/cli/templates/default_streamlit/.gitignore +0 -4
  158. snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
  159. snowflake/cli/templates/default_streamlit/environment.yml +0 -6
  160. snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
  161. snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
  162. snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
  163. snowflake_cli_labs-2.8.0rc0.dist-info/RECORD +0 -240
  164. snowflake_cli_labs-2.8.0rc0.dist-info/entry_points.txt +0 -2
  165. /snowflake/cli/{app → _app}/__init__.py +0 -0
  166. /snowflake/cli/{app → _app}/api_impl/__init__.py +0 -0
  167. /snowflake/cli/{app → _app}/api_impl/plugin/__init__.py +0 -0
  168. /snowflake/cli/{app → _app}/api_impl/plugin/plugin_config_provider_impl.py +0 -0
  169. /snowflake/cli/{app → _app}/commands_registration/__init__.py +0 -0
  170. /snowflake/cli/{app → _app}/commands_registration/threadsafe.py +0 -0
  171. /snowflake/cli/{app → _app}/constants.py +0 -0
  172. /snowflake/cli/{app → _app}/dev/__init__.py +0 -0
  173. /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
  174. /snowflake/cli/{app → _app}/dev/docs/__init__.py +0 -0
  175. /snowflake/cli/{app → _app}/dev/docs/project_definition_generate_json_schema.py +0 -0
  176. /snowflake/cli/{app → _app}/dev/docs/template_utils.py +0 -0
  177. /snowflake/cli/{app → _app}/dev/docs/templates/definition_description.rst.jinja2 +0 -0
  178. /snowflake/cli/{app → _app}/dev/docs/templates/overview.rst.jinja2 +0 -0
  179. /snowflake/cli/{app → _app}/dev/pycharm_remote_debug.py +0 -0
  180. /snowflake/cli/{app → _app}/loggers.py +0 -0
  181. /snowflake/cli/{plugins → _plugins}/__init__.py +0 -0
  182. /snowflake/cli/{plugins → _plugins}/connection/__init__.py +0 -0
  183. /snowflake/cli/{plugins → _plugins}/cortex/__init__.py +0 -0
  184. /snowflake/cli/{plugins → _plugins}/cortex/types.py +0 -0
  185. /snowflake/cli/{plugins → _plugins}/git/__init__.py +0 -0
  186. /snowflake/cli/{plugins → _plugins}/init/__init__.py +0 -0
  187. /snowflake/cli/{plugins → _plugins}/nativeapp/__init__.py +0 -0
  188. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/__init__.py +0 -0
  189. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
  190. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +0 -0
  191. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
  192. /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +0 -0
  193. /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
  194. /snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +0 -0
  195. /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
  196. /snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +0 -0
  197. /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
  198. /snowflake/cli/{plugins → _plugins}/nativeapp/version/__init__.py +0 -0
  199. /snowflake/cli/{plugins → _plugins}/notebook/__init__.py +0 -0
  200. /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
  201. /snowflake/cli/{plugins → _plugins}/object/__init__.py +0 -0
  202. /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
  203. /snowflake/cli/{plugins → _plugins}/snowpark/__init__.py +0 -0
  204. /snowflake/cli/{plugins → _plugins}/snowpark/package/__init__.py +0 -0
  205. /snowflake/cli/{plugins → _plugins}/snowpark/package/utils.py +0 -0
  206. /snowflake/cli/{plugins → _plugins}/spcs/common.py +0 -0
  207. /snowflake/cli/{plugins → _plugins}/spcs/compute_pool/__init__.py +0 -0
  208. /snowflake/cli/{plugins → _plugins}/spcs/image_registry/__init__.py +0 -0
  209. /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
  210. /snowflake/cli/{plugins → _plugins}/spcs/image_repository/__init__.py +0 -0
  211. /snowflake/cli/{plugins/spcs/jobs → _plugins/spcs/services}/__init__.py +0 -0
  212. /snowflake/cli/{plugins/spcs/services → _plugins/sql}/__init__.py +0 -0
  213. /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
  214. /snowflake/cli/{plugins/sql → _plugins/stage}/__init__.py +0 -0
  215. /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
  216. /snowflake/cli/{plugins/stage → _plugins/streamlit}/__init__.py +0 -0
  217. /snowflake/cli/{plugins/streamlit → _plugins/workspace}/__init__.py +0 -0
  218. /snowflake/cli/{plugins/workspace → api/project/schemas/entities}/__init__.py +0 -0
  219. {snowflake_cli_labs-2.8.0rc0.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/WHEEL +0 -0
  220. {snowflake_cli_labs-2.8.0rc0.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/licenses/LICENSE +0 -0
@@ -16,22 +16,22 @@ from __future__ import annotations
16
16
 
17
17
  from typing import Dict, Optional
18
18
 
19
- from snowflake.cli.api.console import cli_console as cc
20
- from snowflake.cli.api.project.schemas.native_app.path_mapping import (
21
- ProcessorMapping,
22
- )
23
- from snowflake.cli.plugins.nativeapp.codegen.artifact_processor import (
19
+ from snowflake.cli._plugins.nativeapp.bundle_context import BundleContext
20
+ from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
24
21
  ArtifactProcessor,
25
22
  UnsupportedArtifactProcessorError,
26
23
  )
27
- from snowflake.cli.plugins.nativeapp.codegen.setup.native_app_setup_processor import (
24
+ from snowflake.cli._plugins.nativeapp.codegen.setup.native_app_setup_processor import (
28
25
  NativeAppSetupProcessor,
29
26
  )
30
- from snowflake.cli.plugins.nativeapp.codegen.snowpark.python_processor import (
27
+ from snowflake.cli._plugins.nativeapp.codegen.snowpark.python_processor import (
31
28
  SnowparkAnnotationProcessor,
32
29
  )
33
- from snowflake.cli.plugins.nativeapp.feature_flags import FeatureFlag
34
- from snowflake.cli.plugins.nativeapp.project_model import NativeAppProjectModel
30
+ from snowflake.cli._plugins.nativeapp.feature_flags import FeatureFlag
31
+ from snowflake.cli.api.console import cli_console as cc
32
+ from snowflake.cli.api.project.schemas.native_app.path_mapping import (
33
+ ProcessorMapping,
34
+ )
35
35
 
36
36
  SNOWPARK_PROCESSOR = "snowpark"
37
37
  NA_SETUP_PROCESSOR = "native-app-setup"
@@ -53,9 +53,9 @@ class NativeAppCompiler:
53
53
 
54
54
  def __init__(
55
55
  self,
56
- na_project: NativeAppProjectModel,
56
+ bundle_ctx: BundleContext,
57
57
  ):
58
- self._na_project = na_project
58
+ self._bundle_ctx = bundle_ctx
59
59
  # dictionary of all processors created and shared between different artifact objects.
60
60
  self.cached_processors: Dict[str, ArtifactProcessor] = {}
61
61
 
@@ -69,12 +69,12 @@ class NativeAppCompiler:
69
69
  return
70
70
 
71
71
  with cc.phase("Invoking artifact processors"):
72
- if self._na_project.generated_root.exists():
72
+ if self._bundle_ctx.generated_root.exists():
73
73
  raise ClickException(
74
- f"Path {self._na_project.generated_root} already exists. Please choose a different name for your generated directory in the project definition file."
74
+ f"Path {self._bundle_ctx.generated_root} already exists. Please choose a different name for your generated directory in the project definition file."
75
75
  )
76
76
 
77
- for artifact in self._na_project.artifacts:
77
+ for artifact in self._bundle_ctx.artifacts:
78
78
  for processor in artifact.processors:
79
79
  if self._is_enabled(processor):
80
80
  artifact_processor = self._try_create_processor(
@@ -110,15 +110,13 @@ class NativeAppCompiler:
110
110
  # No registered processor with the specified name
111
111
  return None
112
112
 
113
- current_processor = processor_factory(
114
- na_project=self._na_project,
115
- )
113
+ current_processor = processor_factory(self._bundle_ctx)
116
114
  self.cached_processors[processor_name] = current_processor
117
115
 
118
116
  return current_processor
119
117
 
120
118
  def _should_invoke_processors(self):
121
- for artifact in self._na_project.artifacts:
119
+ for artifact in self._bundle_ctx.artifacts:
122
120
  for processor in artifact.processors:
123
121
  if self._is_enabled(processor):
124
122
  return True
@@ -20,34 +20,30 @@ from pathlib import Path
20
20
  from typing import List, Optional
21
21
 
22
22
  from click import ClickException
23
- from snowflake.cli.api.console import cli_console as cc
24
- from snowflake.cli.api.project.schemas.native_app.path_mapping import (
25
- PathMapping,
26
- ProcessorMapping,
27
- )
28
- from snowflake.cli.plugins.nativeapp.artifacts import BundleMap, find_setup_script_file
29
- from snowflake.cli.plugins.nativeapp.codegen.artifact_processor import (
23
+ from snowflake.cli._plugins.nativeapp.artifacts import BundleMap, find_setup_script_file
24
+ from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
30
25
  ArtifactProcessor,
31
26
  is_python_file_artifact,
32
27
  )
33
- from snowflake.cli.plugins.nativeapp.codegen.sandbox import (
28
+ from snowflake.cli._plugins.nativeapp.codegen.sandbox import (
34
29
  ExecutionEnvironmentType,
35
30
  SandboxEnvBuilder,
36
31
  execute_script_in_sandbox,
37
32
  )
38
- from snowflake.cli.plugins.nativeapp.project_model import NativeAppProjectModel
39
- from snowflake.cli.plugins.stage.diff import to_stage_path
33
+ from snowflake.cli._plugins.stage.diff import to_stage_path
34
+ from snowflake.cli.api.console import cli_console as cc
35
+ from snowflake.cli.api.project.schemas.native_app.path_mapping import (
36
+ PathMapping,
37
+ ProcessorMapping,
38
+ )
40
39
 
41
40
  DEFAULT_TIMEOUT = 30
42
41
  DRIVER_PATH = Path(__file__).parent / "setup_driver.py.source"
43
42
 
44
43
 
45
44
  class NativeAppSetupProcessor(ArtifactProcessor):
46
- def __init__(
47
- self,
48
- na_project: NativeAppProjectModel,
49
- ):
50
- super().__init__(na_project=na_project)
45
+ def __init__(self, *args, **kwargs):
46
+ super().__init__(*args, **kwargs)
51
47
 
52
48
  def process(
53
49
  self,
@@ -59,8 +55,8 @@ class NativeAppSetupProcessor(ArtifactProcessor):
59
55
  Processes a Python setup script and generates the corresponding SQL commands.
60
56
  """
61
57
  bundle_map = BundleMap(
62
- project_root=self._na_project.project_root,
63
- deploy_root=self._na_project.deploy_root,
58
+ project_root=self._bundle_ctx.project_root,
59
+ deploy_root=self._bundle_ctx.deploy_root,
64
60
  )
65
61
  bundle_map.add(artifact_to_process)
66
62
 
@@ -73,7 +69,7 @@ class NativeAppSetupProcessor(ArtifactProcessor):
73
69
  absolute=True, expand_directories=True, predicate=is_python_file_artifact
74
70
  ):
75
71
  cc.message(
76
- f"Found Python setup file: {src_file.relative_to(self._na_project.project_root)}"
72
+ f"Found Python setup file: {src_file.relative_to(self._bundle_ctx.project_root)}"
77
73
  )
78
74
  files_to_process.append(src_file)
79
75
 
@@ -85,9 +81,9 @@ class NativeAppSetupProcessor(ArtifactProcessor):
85
81
  cc.step(f"Processing {file_count} setup file{'s' if file_count > 1 else ''}")
86
82
 
87
83
  env_vars = {
88
- "_SNOWFLAKE_CLI_PROJECT_PATH": str(self._na_project.project_root),
84
+ "_SNOWFLAKE_CLI_PROJECT_PATH": str(self._bundle_ctx.project_root),
89
85
  "_SNOWFLAKE_CLI_SETUP_FILES": os.pathsep.join(map(str, py_files)),
90
- "_SNOWFLAKE_CLI_APP_NAME": str(self._na_project.package_name),
86
+ "_SNOWFLAKE_CLI_APP_NAME": str(self._bundle_ctx.package_name),
91
87
  "_SNOWFLAKE_CLI_SQL_DEST_DIR": str(self.generated_root),
92
88
  }
93
89
 
@@ -95,7 +91,7 @@ class NativeAppSetupProcessor(ArtifactProcessor):
95
91
  result = execute_script_in_sandbox(
96
92
  script_source=DRIVER_PATH.read_text(),
97
93
  env_type=ExecutionEnvironmentType.VENV,
98
- cwd=self._na_project.bundle_root,
94
+ cwd=self._bundle_ctx.bundle_root,
99
95
  timeout=DEFAULT_TIMEOUT,
100
96
  path=self.sandbox_root,
101
97
  env_vars=env_vars,
@@ -123,7 +119,7 @@ class NativeAppSetupProcessor(ArtifactProcessor):
123
119
 
124
120
  cc.step("Patching setup script")
125
121
  setup_file_path = find_setup_script_file(
126
- deploy_root=self._na_project.deploy_root
122
+ deploy_root=self._bundle_ctx.deploy_root
127
123
  )
128
124
  with self.edit_file(setup_file_path) as f:
129
125
  new_contents = [f.contents]
@@ -132,30 +128,30 @@ class NativeAppSetupProcessor(ArtifactProcessor):
132
128
  schemas_file = generated_root / sql_file_mappings["schemas"]
133
129
  new_contents.insert(
134
130
  0,
135
- f"EXECUTE IMMEDIATE FROM '/{to_stage_path(schemas_file.relative_to(self._na_project.deploy_root))}';",
131
+ f"EXECUTE IMMEDIATE FROM '/{to_stage_path(schemas_file.relative_to(self._bundle_ctx.deploy_root))}';",
136
132
  )
137
133
 
138
134
  if sql_file_mappings["compute_pools"]:
139
135
  compute_pools_file = generated_root / sql_file_mappings["compute_pools"]
140
136
  new_contents.append(
141
- f"EXECUTE IMMEDIATE FROM '/{to_stage_path(compute_pools_file.relative_to(self._na_project.deploy_root))}';"
137
+ f"EXECUTE IMMEDIATE FROM '/{to_stage_path(compute_pools_file.relative_to(self._bundle_ctx.deploy_root))}';"
142
138
  )
143
139
 
144
140
  if sql_file_mappings["services"]:
145
141
  services_file = generated_root / sql_file_mappings["services"]
146
142
  new_contents.append(
147
- f"EXECUTE IMMEDIATE FROM '/{to_stage_path(services_file.relative_to(self._na_project.deploy_root))}';"
143
+ f"EXECUTE IMMEDIATE FROM '/{to_stage_path(services_file.relative_to(self._bundle_ctx.deploy_root))}';"
148
144
  )
149
145
 
150
146
  f.edited_contents = "\n".join(new_contents)
151
147
 
152
148
  @property
153
149
  def sandbox_root(self):
154
- return self._na_project.bundle_root / "setup_py_venv"
150
+ return self._bundle_ctx.bundle_root / "setup_py_venv"
155
151
 
156
152
  @property
157
153
  def generated_root(self):
158
- return self._na_project.generated_root / "setup_py"
154
+ return self._bundle_ctx.generated_root / "setup_py"
159
155
 
160
156
  def _create_or_update_sandbox(self):
161
157
  sandbox_root = self.sandbox_root
@@ -164,7 +160,7 @@ class NativeAppSetupProcessor(ArtifactProcessor):
164
160
  cc.step("Virtual environment found")
165
161
  else:
166
162
  cc.step(
167
- f"Creating virtual environment in {sandbox_root.relative_to(self._na_project.project_root)}"
163
+ f"Creating virtual environment in {sandbox_root.relative_to(self._bundle_ctx.project_root)}"
168
164
  )
169
165
  env_builder.ensure_created()
170
166
 
@@ -23,6 +23,10 @@ from typing import (
23
23
  )
24
24
 
25
25
  from click.exceptions import ClickException
26
+ from snowflake.cli._plugins.nativeapp.codegen.snowpark.models import (
27
+ ExtensionFunctionTypeEnum,
28
+ NativeAppExtensionFunction,
29
+ )
26
30
  from snowflake.cli.api.project.schemas.snowpark.argument import Argument
27
31
  from snowflake.cli.api.project.util import (
28
32
  is_valid_identifier,
@@ -30,10 +34,6 @@ from snowflake.cli.api.project.util import (
30
34
  to_identifier,
31
35
  to_string_literal,
32
36
  )
33
- from snowflake.cli.plugins.nativeapp.codegen.snowpark.models import (
34
- ExtensionFunctionTypeEnum,
35
- NativeAppExtensionFunction,
36
- )
37
37
 
38
38
  ASTDefNode = Union[ast.FunctionDef, ast.ClassDef]
39
39
 
@@ -21,26 +21,20 @@ from textwrap import dedent
21
21
  from typing import Any, Dict, List, Optional, Set
22
22
 
23
23
  from pydantic import ValidationError
24
- from snowflake.cli.api.console import cli_console as cc
25
- from snowflake.cli.api.project.schemas.native_app.path_mapping import (
26
- PathMapping,
27
- ProcessorMapping,
28
- )
29
- from snowflake.cli.api.rendering.jinja import jinja_render_from_file
30
- from snowflake.cli.plugins.nativeapp.artifacts import (
24
+ from snowflake.cli._plugins.nativeapp.artifacts import (
31
25
  BundleMap,
32
26
  find_setup_script_file,
33
27
  )
34
- from snowflake.cli.plugins.nativeapp.codegen.artifact_processor import (
28
+ from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
35
29
  ArtifactProcessor,
36
30
  is_python_file_artifact,
37
31
  )
38
- from snowflake.cli.plugins.nativeapp.codegen.sandbox import (
32
+ from snowflake.cli._plugins.nativeapp.codegen.sandbox import (
39
33
  ExecutionEnvironmentType,
40
34
  SandboxExecutionError,
41
35
  execute_script_in_sandbox,
42
36
  )
43
- from snowflake.cli.plugins.nativeapp.codegen.snowpark.extension_function_utils import (
37
+ from snowflake.cli._plugins.nativeapp.codegen.snowpark.extension_function_utils import (
44
38
  deannotate_module_source,
45
39
  ensure_all_string_literals,
46
40
  ensure_string_literal,
@@ -49,12 +43,17 @@ from snowflake.cli.plugins.nativeapp.codegen.snowpark.extension_function_utils i
49
43
  get_sql_argument_signature,
50
44
  get_sql_object_type,
51
45
  )
52
- from snowflake.cli.plugins.nativeapp.codegen.snowpark.models import (
46
+ from snowflake.cli._plugins.nativeapp.codegen.snowpark.models import (
53
47
  ExtensionFunctionTypeEnum,
54
48
  NativeAppExtensionFunction,
55
49
  )
56
- from snowflake.cli.plugins.nativeapp.project_model import NativeAppProjectModel
57
- from snowflake.cli.plugins.stage.diff import to_stage_path
50
+ from snowflake.cli._plugins.stage.diff import to_stage_path
51
+ from snowflake.cli.api.console import cli_console as cc
52
+ from snowflake.cli.api.project.schemas.native_app.path_mapping import (
53
+ PathMapping,
54
+ ProcessorMapping,
55
+ )
56
+ from snowflake.cli.api.rendering.jinja import jinja_render_from_file
58
57
 
59
58
  DEFAULT_TIMEOUT = 30
60
59
  TEMPLATE_PATH = Path(__file__).parent / "callback_source.py.jinja"
@@ -163,11 +162,8 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
163
162
  and generate SQL code for creation of extension functions based on those discovered objects.
164
163
  """
165
164
 
166
- def __init__(
167
- self,
168
- na_project: NativeAppProjectModel,
169
- ):
170
- super().__init__(na_project=na_project)
165
+ def __init__(self, *args, **kwargs):
166
+ super().__init__(*args, **kwargs)
171
167
 
172
168
  def process(
173
169
  self,
@@ -181,8 +177,8 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
181
177
  """
182
178
 
183
179
  bundle_map = BundleMap(
184
- project_root=self._na_project.project_root,
185
- deploy_root=self._na_project.deploy_root,
180
+ project_root=self._bundle_ctx.project_root,
181
+ deploy_root=self._bundle_ctx.deploy_root,
186
182
  )
187
183
  bundle_map.add(artifact_to_process)
188
184
 
@@ -235,7 +231,7 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
235
231
 
236
232
  @property
237
233
  def _generated_root(self):
238
- return self._na_project.generated_root / "snowpark"
234
+ return self._bundle_ctx.generated_root / "snowpark"
239
235
 
240
236
  def _normalize_imports(
241
237
  self,
@@ -315,7 +311,7 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
315
311
  self, bundle_map: BundleMap, processor_mapping: Optional[ProcessorMapping]
316
312
  ) -> Dict[Path, List[NativeAppExtensionFunction]]:
317
313
  kwargs = (
318
- _determine_virtual_env(self._na_project.project_root, processor_mapping)
314
+ _determine_virtual_env(self._bundle_ctx.project_root, processor_mapping)
319
315
  if processor_mapping is not None
320
316
  else {}
321
317
  )
@@ -338,7 +334,7 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
338
334
  )
339
335
  collected_extension_function_json = _execute_in_sandbox(
340
336
  py_file=str(dest_file.resolve()),
341
- deploy_root=self._na_project.deploy_root,
337
+ deploy_root=self._bundle_ctx.deploy_root,
342
338
  kwargs=kwargs,
343
339
  )
344
340
 
@@ -369,7 +365,7 @@ class SnowparkAnnotationProcessor(ArtifactProcessor):
369
365
  """
370
366
  Generates a SQL filename for the generated root from the python file, and creates its parent directories.
371
367
  """
372
- relative_py_file = py_file.relative_to(self._na_project.deploy_root)
368
+ relative_py_file = py_file.relative_to(self._bundle_ctx.deploy_root)
373
369
  sql_file = Path(self._generated_root, relative_py_file.with_suffix(".sql"))
374
370
  if sql_file.exists():
375
371
  cc.warning(
@@ -14,60 +14,63 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
+ import itertools
17
18
  import logging
19
+ from enum import Enum
18
20
  from pathlib import Path
19
21
  from textwrap import dedent
20
- from typing import List, Optional
22
+ from typing import Generator, Iterable, List, Optional, cast
21
23
 
22
24
  import typer
23
- from click import ClickException
24
- from snowflake.cli.api.cli_global_context import cli_context
25
- from snowflake.cli.api.commands.decorators import (
26
- with_project_definition,
27
- )
28
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
29
- from snowflake.cli.api.output.formats import OutputFormat
30
- from snowflake.cli.api.output.types import (
31
- CollectionResult,
32
- CommandResult,
33
- MessageResult,
34
- ObjectResult,
35
- StreamResult,
36
- )
37
- from snowflake.cli.api.project.project_verification import assert_project_type
38
- from snowflake.cli.api.secure_path import SecurePath
39
- from snowflake.cli.plugins.nativeapp.common_flags import (
25
+ from snowflake.cli._plugins.nativeapp.common_flags import (
40
26
  ForceOption,
41
27
  InteractiveOption,
42
28
  ValidateOption,
43
29
  )
44
- from snowflake.cli.plugins.nativeapp.init import (
30
+ from snowflake.cli._plugins.nativeapp.init import (
45
31
  OFFICIAL_TEMPLATES_GITHUB_URL,
46
32
  nativeapp_init,
47
33
  )
48
- from snowflake.cli.plugins.nativeapp.manager import NativeAppManager
49
- from snowflake.cli.plugins.nativeapp.policy import (
34
+ from snowflake.cli._plugins.nativeapp.manager import NativeAppManager
35
+ from snowflake.cli._plugins.nativeapp.policy import (
50
36
  AllowAlwaysPolicy,
51
37
  AskAlwaysPolicy,
52
38
  DenyAlwaysPolicy,
53
39
  )
54
- from snowflake.cli.plugins.nativeapp.run_processor import NativeAppRunProcessor
55
- from snowflake.cli.plugins.nativeapp.teardown_processor import (
40
+ from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
41
+ from snowflake.cli._plugins.nativeapp.teardown_processor import (
56
42
  NativeAppTeardownProcessor,
57
43
  )
58
- from snowflake.cli.plugins.nativeapp.utils import (
44
+ from snowflake.cli._plugins.nativeapp.utils import (
59
45
  get_first_paragraph_from_markdown_file,
60
46
  shallow_git_clone,
61
47
  )
62
- from snowflake.cli.plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
48
+ from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
63
49
  nativeapp_definition_v2_to_v1,
64
50
  )
65
- from snowflake.cli.plugins.nativeapp.version.commands import app as versions_app
66
- from snowflake.cli.plugins.stage.diff import (
51
+ from snowflake.cli._plugins.nativeapp.version.commands import app as versions_app
52
+ from snowflake.cli._plugins.stage.diff import (
67
53
  DiffResult,
68
54
  compute_stage_diff,
69
- print_diff_to_console,
70
55
  )
56
+ from snowflake.cli._plugins.stage.utils import print_diff_to_console
57
+ from snowflake.cli.api.cli_global_context import get_cli_context
58
+ from snowflake.cli.api.commands.decorators import (
59
+ with_project_definition,
60
+ )
61
+ from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
62
+ from snowflake.cli.api.exceptions import IncompatibleParametersError
63
+ from snowflake.cli.api.output.formats import OutputFormat
64
+ from snowflake.cli.api.output.types import (
65
+ CollectionResult,
66
+ CommandResult,
67
+ MessageResult,
68
+ ObjectResult,
69
+ StreamResult,
70
+ )
71
+ from snowflake.cli.api.project.project_verification import assert_project_type
72
+ from snowflake.cli.api.secure_path import SecurePath
73
+ from typing_extensions import Annotated
71
74
 
72
75
  app = SnowTyperFactory(
73
76
  name="app",
@@ -83,6 +86,7 @@ def app_init(
83
86
  path: str = typer.Argument(
84
87
  ...,
85
88
  help=f"""Directory to be initialized with the Snowflake Native App project. This directory must not already exist.""",
89
+ show_default=False,
86
90
  ),
87
91
  name: str = typer.Option(
88
92
  None,
@@ -166,6 +170,7 @@ def app_bundle(
166
170
 
167
171
  assert_project_type("native_app")
168
172
 
173
+ cli_context = get_cli_context()
169
174
  manager = NativeAppManager(
170
175
  project_definition=cli_context.project_definition.native_app,
171
176
  project_root=cli_context.project_root,
@@ -185,6 +190,7 @@ def app_diff(
185
190
  """
186
191
  assert_project_type("native_app")
187
192
 
193
+ cli_context = get_cli_context()
188
194
  manager = NativeAppManager(
189
195
  project_definition=cli_context.project_definition.native_app,
190
196
  project_root=cli_context.project_root,
@@ -243,6 +249,7 @@ def app_run(
243
249
  else:
244
250
  policy = DenyAlwaysPolicy()
245
251
 
252
+ cli_context = get_cli_context()
246
253
  processor = NativeAppRunProcessor(
247
254
  project_definition=cli_context.project_definition.native_app,
248
255
  project_root=cli_context.project_root,
@@ -276,6 +283,7 @@ def app_open(
276
283
 
277
284
  assert_project_type("native_app")
278
285
 
286
+ cli_context = get_cli_context()
279
287
  manager = NativeAppManager(
280
288
  project_definition=cli_context.project_definition.native_app,
281
289
  project_root=cli_context.project_root,
@@ -308,6 +316,7 @@ def app_teardown(
308
316
 
309
317
  assert_project_type("native_app")
310
318
 
319
+ cli_context = get_cli_context()
311
320
  processor = NativeAppTeardownProcessor(
312
321
  project_definition=cli_context.project_definition.native_app,
313
322
  project_root=cli_context.project_root,
@@ -362,8 +371,9 @@ def app_deploy(
362
371
  recursive = False
363
372
 
364
373
  if has_paths and prune:
365
- raise ClickException("--prune cannot be used when paths are also specified")
374
+ raise IncompatibleParametersError(["paths", "--prune"])
366
375
 
376
+ cli_context = get_cli_context()
367
377
  manager = NativeAppManager(
368
378
  project_definition=cli_context.project_definition.native_app,
369
379
  project_root=cli_context.project_root,
@@ -393,6 +403,7 @@ def app_validate(**options):
393
403
 
394
404
  assert_project_type("native_app")
395
405
 
406
+ cli_context = get_cli_context()
396
407
  manager = NativeAppManager(
397
408
  project_definition=cli_context.project_definition.native_app,
398
409
  project_root=cli_context.project_root,
@@ -404,26 +415,144 @@ def app_validate(**options):
404
415
  return MessageResult("Snowflake Native App validation succeeded.")
405
416
 
406
417
 
407
- @app.command("events", hidden=True, requires_connection=True)
418
+ class RecordType(Enum):
419
+ LOG = "log"
420
+ SPAN = "span"
421
+ SPAN_EVENT = "span_event"
422
+
423
+
424
+ # The default number of lines to print before streaming when running
425
+ # snow app events --follow
426
+ DEFAULT_EVENT_FOLLOW_LAST = 20
427
+
428
+
429
+ @app.command("events", requires_connection=True)
408
430
  @with_project_definition()
409
431
  @nativeapp_definition_v2_to_v1
410
- def app_events(**options):
411
- """Fetches events for this app from the event table configured in Snowflake."""
432
+ def app_events(
433
+ since: str = typer.Option(
434
+ default="",
435
+ help="Fetch events that are newer than this time ago, in Snowflake interval syntax.",
436
+ ),
437
+ until: str = typer.Option(
438
+ default="",
439
+ help="Fetch events that are older than this time ago, in Snowflake interval syntax.",
440
+ ),
441
+ record_types: Annotated[
442
+ list[RecordType], typer.Option(case_sensitive=False)
443
+ ] = typer.Option(
444
+ [],
445
+ "--type",
446
+ help="Restrict results to specific record type. Can be specified multiple times.",
447
+ ),
448
+ scopes: Annotated[list[str], typer.Option()] = typer.Option(
449
+ [],
450
+ "--scope",
451
+ help="Restrict results to a specific scope name. Can be specified multiple times.",
452
+ ),
453
+ consumer_org: str = typer.Option(
454
+ default="", help="The name of the consumer organization."
455
+ ),
456
+ consumer_account: str = typer.Option(
457
+ default="",
458
+ help="The name of the consumer account in the organization.",
459
+ ),
460
+ consumer_app_hash: str = typer.Option(
461
+ default="",
462
+ help="The SHA-1 hash of the consumer application name",
463
+ ),
464
+ first: int = typer.Option(
465
+ default=-1,
466
+ show_default=False,
467
+ help="Fetch only the first N events. Cannot be used with --last.",
468
+ ),
469
+ last: int = typer.Option(
470
+ default=-1,
471
+ show_default=False,
472
+ help="Fetch only the last N events. Cannot be used with --first.",
473
+ ),
474
+ follow: bool = typer.Option(
475
+ False,
476
+ "--follow",
477
+ "-f",
478
+ help=(
479
+ f"Continue polling for events. Implies --last {DEFAULT_EVENT_FOLLOW_LAST} "
480
+ f"unless overridden or the --since flag is used."
481
+ ),
482
+ ),
483
+ follow_interval: int = typer.Option(
484
+ 10,
485
+ help=f"Polling interval in seconds when using the --follow flag.",
486
+ ),
487
+ **options,
488
+ ):
489
+ """Fetches events for this app from the event table configured in Snowflake.
490
+
491
+ By default, this command will fetch events generated by an app installed in the
492
+ current connection's account. To fetch events generated by an app installed
493
+ in a consumer account, use the --consumer-org and --consumer-account options.
494
+ This requires event sharing to be set up to route events to the provider account:
495
+ https://docs.snowflake.com/en/developer-guide/native-apps/setting-up-logging-and-events
496
+ """
497
+ if first >= 0 and last >= 0:
498
+ raise IncompatibleParametersError(["--first", "--last"])
499
+
500
+ if (consumer_org and not consumer_account) or (
501
+ consumer_account and not consumer_org
502
+ ):
503
+ raise IncompatibleParametersError(["--consumer-org", "--consumer-account"])
504
+
505
+ if follow:
506
+ if until:
507
+ raise IncompatibleParametersError(["--follow", "--until"])
508
+ if first >= 0:
509
+ raise IncompatibleParametersError(["--follow", "--first"])
510
+
412
511
  assert_project_type("native_app")
413
512
 
513
+ record_type_names = [r.name for r in record_types]
414
514
  manager = NativeAppManager(
415
- project_definition=cli_context.project_definition.native_app,
416
- project_root=cli_context.project_root,
515
+ project_definition=get_cli_context().project_definition.native_app,
516
+ project_root=get_cli_context().project_root,
417
517
  )
418
- events = manager.get_events()
419
- if not events:
420
- return MessageResult("No events found.")
421
-
422
- def g():
423
- for event in events:
424
- yield EventResult(event)
518
+ if follow:
519
+ if last == -1 and not since:
520
+ # If we don't have a value for --last or --since, assume a value
521
+ # for --last so we at least print something before starting the stream
522
+ last = DEFAULT_EVENT_FOLLOW_LAST
523
+ stream: Iterable[CommandResult] = (
524
+ EventResult(event)
525
+ for event in manager.stream_events(
526
+ since=since,
527
+ last=last,
528
+ interval_seconds=follow_interval,
529
+ record_types=record_type_names,
530
+ scopes=scopes,
531
+ consumer_org=consumer_org,
532
+ consumer_account=consumer_account,
533
+ consumer_app_hash=consumer_app_hash,
534
+ )
535
+ )
536
+ # Append a newline at the end to make the CLI output clean when we hit Ctrl-C
537
+ stream = itertools.chain(stream, [MessageResult("")])
538
+ else:
539
+ stream = (
540
+ EventResult(event)
541
+ for event in manager.get_events(
542
+ since=since,
543
+ until=until,
544
+ record_types=record_type_names,
545
+ scopes=scopes,
546
+ first=first,
547
+ last=last,
548
+ consumer_org=consumer_org,
549
+ consumer_account=consumer_account,
550
+ consumer_app_hash=consumer_app_hash,
551
+ )
552
+ )
425
553
 
426
- return StreamResult(g())
554
+ # Cast the stream to a Generator since that's what StreamResult wants
555
+ return StreamResult(cast(Generator[CommandResult, None, None], stream))
427
556
 
428
557
 
429
558
  class EventResult(ObjectResult, MessageResult):
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  import typer
16
- from snowflake.cli.plugins.nativeapp.utils import is_tty_interactive
16
+ from snowflake.cli._plugins.nativeapp.utils import is_tty_interactive
17
17
 
18
18
 
19
19
  def interactive_callback(val):