From 4753ff4c38ec0e20677c95bf0521104faf4506bd Mon Sep 17 00:00:00 2001 From: Bruno Dufour Date: Fri, 6 Dec 2024 13:56:20 -0500 Subject: [PATCH] Completed renaming --- .../codegen/artifact_processor_registrar.py | 4 +-- .../nativeapp/entities/application_package.py | 6 ++-- .../codegen/snowpark/test_python_processor.py | 8 ++--- .../templating/test_templates_processor.py | 4 +-- .../codegen/test_processor_registrar.py | 36 +++++++++---------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/snowflake/cli/_plugins/nativeapp/codegen/artifact_processor_registrar.py b/src/snowflake/cli/_plugins/nativeapp/codegen/artifact_processor_registrar.py index 6ef844d3a5..dfc5dfb21d 100644 --- a/src/snowflake/cli/_plugins/nativeapp/codegen/artifact_processor_registrar.py +++ b/src/snowflake/cli/_plugins/nativeapp/codegen/artifact_processor_registrar.py @@ -83,9 +83,9 @@ def _assert_absolute_paths(processor_ctx: ArtifactProcessorContext): path = getattr(processor_ctx, f"{name.lower()}_root") assert path.is_absolute(), f"{name} root {path} must be an absolute path." - def compile_artifacts(self): + def process_artifacts(self): """ - Go through every artifact object in the project definition of a native app, and execute processors in order of specification for each of the artifact object. + Go through every artifact object in the project definition of an entity, and execute processors in order of specification for each of the artifact object. May have side-effects on the filesystem by either directly editing source files or the deploy root. """ metrics = get_cli_context().metrics diff --git a/src/snowflake/cli/_plugins/nativeapp/entities/application_package.py b/src/snowflake/cli/_plugins/nativeapp/entities/application_package.py index 9fc2da972c..87711cc5ee 100644 --- a/src/snowflake/cli/_plugins/nativeapp/entities/application_package.py +++ b/src/snowflake/cli/_plugins/nativeapp/entities/application_package.py @@ -526,7 +526,7 @@ def action_version_drop( def _bundle(self): model = self._entity_model bundle_map = build_bundle(self.project_root, self.deploy_root, model.artifacts) - bundle_context = ArtifactProcessorContext( + processor_ctx = ArtifactProcessorContext( package_name=self.name, artifacts=model.artifacts, project_root=self.project_root, @@ -534,8 +534,8 @@ def _bundle(self): deploy_root=self.deploy_root, generated_root=self.generated_root, ) - compiler = ArtifactProcessorRegistrar(bundle_context) - compiler.compile_artifacts() + registrar = ArtifactProcessorRegistrar(processor_ctx) + registrar.process_artifacts() return bundle_map def _deploy( diff --git a/tests/nativeapp/codegen/snowpark/test_python_processor.py b/tests/nativeapp/codegen/snowpark/test_python_processor.py index ec750c9a89..509266b38c 100644 --- a/tests/nativeapp/codegen/snowpark/test_python_processor.py +++ b/tests/nativeapp/codegen/snowpark/test_python_processor.py @@ -52,7 +52,7 @@ # -------------------------------------------------------- -def _get_bundle_context( +def _get_processor_context( pkg_model: ApplicationPackageEntityModel, project_root: Path | None = None ): project_root = project_root or Path().resolve() @@ -372,7 +372,7 @@ def test_process_no_collected_functions( {"src": "a/b/c/*.py", "dest": "stagepath/", "processors": ["SNOWPARK"]} ] mock_sandbox.side_effect = [None, []] - project_context = _get_bundle_context(pkg_model, local_path) + project_context = _get_processor_context(pkg_model, local_path) processor = SnowparkAnnotationProcessor(project_context) processor.process( artifact_to_process=pkg_model.artifacts[0], @@ -423,7 +423,7 @@ def test_process_with_collected_functions( [native_app_extension_function_raw_data], [imports_variation], ] - project_context = _get_bundle_context(pkg_model, local_path) + project_context = _get_processor_context(pkg_model, local_path) processor_context = copy.copy(project_context) processor_context.generated_root = ( project_context.generated_root / "snowpark" @@ -487,7 +487,7 @@ def test_package_normalization( ] native_app_extension_function_raw_data["packages"] = package_decl mock_sandbox.side_effect = [[native_app_extension_function_raw_data]] - project_context = _get_bundle_context(pkg_model) + project_context = _get_processor_context(pkg_model) processor_context = copy.copy(project_context) processor_context.generated_root = ( project_context.generated_root / "snowpark" diff --git a/tests/nativeapp/codegen/templating/test_templates_processor.py b/tests/nativeapp/codegen/templating/test_templates_processor.py index 6c1dcf17bb..aed425aa8e 100644 --- a/tests/nativeapp/codegen/templating/test_templates_processor.py +++ b/tests/nativeapp/codegen/templating/test_templates_processor.py @@ -68,7 +68,7 @@ def bundle_files( artifact_to_process = PathMapping(src="src/*", dest="./", processors=["templates"]) - bundle_context = ArtifactProcessorContext( + processor_context = ArtifactProcessorContext( package_name="test_package_name", project_root=project_root, artifacts=[artifact_to_process], @@ -77,7 +77,7 @@ def bundle_files( deploy_root=deploy_root, ) - return BundleResult(artifact_to_process, bundle_context, output_files) + return BundleResult(artifact_to_process, processor_context, output_files) @mock.patch(CLI_GLOBAL_TEMPLATE_CONTEXT, {}) diff --git a/tests/nativeapp/codegen/test_processor_registrar.py b/tests/nativeapp/codegen/test_processor_registrar.py index 36f9072d9a..261b934dd9 100644 --- a/tests/nativeapp/codegen/test_processor_registrar.py +++ b/tests/nativeapp/codegen/test_processor_registrar.py @@ -63,7 +63,7 @@ def test_proj_def(): ) -def _get_bundle_context(pkg_model: ApplicationPackageEntityModel): +def _get_processor_context(pkg_model: ApplicationPackageEntityModel): project_root = Path().resolve() return ArtifactProcessorContext( package_name=pkg_model.fqn.name, @@ -78,28 +78,28 @@ def _get_bundle_context(pkg_model: ApplicationPackageEntityModel): @pytest.fixture() -def test_compiler(test_proj_def): +def test_registrar(test_proj_def): return ArtifactProcessorRegistrar( - _get_bundle_context(test_proj_def.entities["pkg"]) + _get_processor_context(test_proj_def.entities["pkg"]) ) @pytest.mark.parametrize("name", ["Project", "Deploy", "Bundle", "Generated"]) -def test_compiler_requires_absolute_paths(test_proj_def, name): - bundle_context = _get_bundle_context(test_proj_def.entities["pkg"]) +def test_requires_absolute_paths(test_proj_def, name): + processor_context = _get_processor_context(test_proj_def.entities["pkg"]) path = Path() - setattr(bundle_context, f"{name.lower()}_root", path) + setattr(processor_context, f"{name.lower()}_root", path) with pytest.raises( AssertionError, match=re.escape(rf"{name} root {path} must be an absolute path."), ): - ArtifactProcessorRegistrar(bundle_context) + ArtifactProcessorRegistrar(processor_context) -def test_try_create_processor_returns_none(test_proj_def, test_compiler): +def test_try_create_processor_returns_none(test_proj_def, test_registrar): artifact_to_process = test_proj_def.entities["pkg"].artifacts[2] - result = test_compiler._try_create_processor( # noqa: SLF001 + result = test_registrar._try_create_processor( # noqa: SLF001 processor_mapping=artifact_to_process.processors[0], ) assert result is None @@ -110,22 +110,22 @@ def test_try_create_processor_returns_none(test_proj_def, test_compiler): [3, 4], ) def test_try_create_processor_returns_processor( - artifact_index, test_proj_def, test_compiler + artifact_index, test_proj_def, test_registrar ): mapping = test_proj_def.entities["pkg"].artifacts[artifact_index] - result = test_compiler._try_create_processor( # noqa: SLF001 + result = test_registrar._try_create_processor( # noqa: SLF001 processor_mapping=mapping.processors[0], ) assert isinstance(result, SnowparkAnnotationProcessor) -def test_find_and_execute_processors_exception(test_proj_def, test_compiler): +def test_find_and_execute_processors_exception(test_proj_def, test_registrar): pkg_model = test_proj_def.entities["pkg"] pkg_model.artifacts = [{"dest": "./", "src": "app/*", "processors": ["DUMMY"]}] - test_compiler = ArtifactProcessorRegistrar(_get_bundle_context(pkg_model)) + test_registrar = ArtifactProcessorRegistrar(_get_processor_context(pkg_model)) with pytest.raises(UnsupportedArtifactProcessorError): - test_compiler.compile_artifacts() + test_registrar.process_artifacts() class TestProcessor(ArtifactProcessor): @@ -148,13 +148,13 @@ def process( assert False # never invoked -def test_skips_disabled_processors(test_proj_def, test_compiler): +def test_skips_disabled_processors(test_proj_def, test_registrar): pkg_model = test_proj_def.entities["pkg"] pkg_model.artifacts = [ {"dest": "./", "src": "app/*", "processors": ["test_processor"]} ] - test_compiler = ArtifactProcessorRegistrar(_get_bundle_context(pkg_model)) - test_compiler.register(TestProcessor) + test_registrar = ArtifactProcessorRegistrar(_get_processor_context(pkg_model)) + test_registrar.register(TestProcessor) # TestProcessor is never invoked, otherwise calling its methods will make the test fail - test_compiler.compile_artifacts() + test_registrar.process_artifacts()