Skip to content

Commit

Permalink
Keeps paths sorted and as POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-fcampbell committed Jul 11, 2024
1 parent cdca4e2 commit d67c910
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def process(

collected_output = []
collected_sql_files: List[Path] = []
for py_file, extension_fns in collected_extension_functions_by_path.items():
for py_file, extension_fns in sorted(
collected_extension_functions_by_path.items()
):
sql_file = self.generate_new_sql_file_name(
py_file=py_file,
)
Expand All @@ -222,7 +224,7 @@ def process(
file.write("\n")
insert_newline = True
file.write(
f"-- Generated by the Snowflake CLI from {relative_py_file}\n"
f"-- Generated by the Snowflake CLI from {relative_py_file.as_posix()}\n"
)
file.write(f"-- DO NOT EDIT\n")
file.write(create_stmt)
Expand Down Expand Up @@ -326,8 +328,12 @@ def collect_extension_functions(
Path, List[NativeAppExtensionFunction]
] = {}

for src_file, dest_file in bundle_map.all_mappings(
absolute=True, expand_directories=True, predicate=_is_python_file_artifact
for src_file, dest_file in sorted(
bundle_map.all_mappings(
absolute=True,
expand_directories=True,
predicate=_is_python_file_artifact,
)
):
cc.step(
"Processing Snowpark annotations from {}".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@
# name: test_process_with_collected_functions.1
'''
===== Contents of: output/deploy/__generated/__generated.sql =====
EXECUTE IMMEDIATE FROM '/__generated/stagepath/main.sql';
EXECUTE IMMEDIATE FROM '/__generated/stagepath/data.sql';
EXECUTE IMMEDIATE FROM '/__generated/stagepath/main.sql';

'''
# ---
Expand All @@ -560,7 +560,7 @@
RETURNS int
LANGUAGE PYTHON
RUNTIME_VERSION=3.11
IMPORTS=('/', '/stagepath/data.py', '/stagepath/extra_import1.zip', '/stagepath/some_dir_str', '/stagepath/withslash.py', '@dummy_stage_str')
IMPORTS=('/path/to/import1.py', '/path/to/import2.zip', '/stagepath/data.py')
PACKAGES=('package_one==1.0.2', 'package_two', 'snowflake-snowpark-python')
EXTERNAL_ACCESS_INTEGRATIONS=('integration_one', 'integration_two')
SECRETS=('key1'=secret_one, 'key2'=integration_two)
Expand All @@ -583,7 +583,7 @@
RETURNS int
LANGUAGE PYTHON
RUNTIME_VERSION=3.11
IMPORTS=('/path/to/import1.py', '/path/to/import2.zip', '/stagepath/main.py')
IMPORTS=('/', '/stagepath/data.py', '/stagepath/extra_import1.zip', '/stagepath/main.py', '/stagepath/some_dir_str', '/stagepath/withslash.py', '@dummy_stage_str')
PACKAGES=('package_one==1.0.2', 'package_two', 'snowflake-snowpark-python')
EXTERNAL_ACCESS_INTEGRATIONS=('integration_one', 'integration_two')
SECRETS=('key1'=secret_one, 'key2'=integration_two)
Expand Down
5 changes: 2 additions & 3 deletions tests/nativeapp/codegen/snowpark/test_python_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@

from tests.nativeapp.utils import assert_dir_snapshot, create_native_app_project_model
from tests.testing_utils.files_and_dirs import pushd, temp_local_dir
from tests_common import IS_WINDOWS

if IS_WINDOWS:
pytest.skip("Requires further refactor to work on Windows", allow_module_level=True)
# if IS_WINDOWS:
# pytest.skip("Requires further refactor to work on Windows", allow_module_level=True)

PROJECT_ROOT = Path("/path/to/project")

Expand Down
8 changes: 5 additions & 3 deletions tests/nativeapp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ def assert_dir_snapshot(root: Path, os_agnostic_snapshot) -> None:
assert "\n".join([_stringify_path(p) for p in all_paths]) == os_agnostic_snapshot

# Verify that each file under the directory matches expectations
for path in all_paths:
for path in sorted(all_paths):
if path.is_file():
snapshot_contents = f"===== Contents of: {path} =====\n"
snapshot_contents = f"===== Contents of: {path.as_posix()} =====\n"
snapshot_contents += path.read_text(encoding="utf-8")
assert snapshot_contents == os_agnostic_snapshot
assert (
snapshot_contents == os_agnostic_snapshot
), f"\nExpected:\n{os_agnostic_snapshot}\nGot:\n{snapshot_contents}"


def create_native_app_project_model(
Expand Down

0 comments on commit d67c910

Please sign in to comment.