From 21ffe5b80ee027b3c09874bcaa164d343462c1c1 Mon Sep 17 00:00:00 2001 From: Jeff Hollan <105808548+sfc-gh-jhollan@users.noreply.github.com> Date: Thu, 3 Nov 2022 15:01:26 -0400 Subject: [PATCH] fix file upload and .so detection (#38) --- requirements.txt | 21 +++++++++++---------- src/snowcli/__about__.py | 2 +- src/snowcli/cli/snowpark_shared.py | 17 ++++++++++------- src/snowcli/utils.py | 6 +++--- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4589178d61..7ff05dc9e9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,20 +1,21 @@ click asn1crypto==1.5.1 -certifi==2022.6.15 +certifi==2022.9.24 cffi==1.15.1 -charset-normalizer==2.1.0 -cryptography==36.0.2 -idna==3.3 +charset-normalizer==2.1.1 +cryptography==38.0.1 +filelock==3.8.0 +idna==3.4 oscrypto==1.3.0 pycparser==2.21 pycryptodomex==3.15.0 -PyJWT==2.4.0 -pyOpenSSL==22.0.0 -pytz==2022.1 +PyJWT==2.6.0 +pyOpenSSL==22.1.0 +pytz==2022.5 requests==2.28.1 -typing_extensions==4.3.0 -urllib3==1.26.11 -snowflake-connector-python==2.7.11 +typing_extensions==4.4.0 +urllib3==1.26.12 +snowflake-connector-python==2.8.1 pyyaml toml requirements-parser diff --git a/src/snowcli/__about__.py b/src/snowcli/__about__.py index f6816e0db2..8d91de25bb 100644 --- a/src/snowcli/__about__.py +++ b/src/snowcli/__about__.py @@ -1 +1 @@ -VERSION = "0.1.6" +VERSION = "0.1.7" diff --git a/src/snowcli/cli/snowpark_shared.py b/src/snowcli/cli/snowpark_shared.py index 38ede36804..8ab85df29d 100644 --- a/src/snowcli/cli/snowpark_shared.py +++ b/src/snowcli/cli/snowpark_shared.py @@ -1,13 +1,16 @@ -import click import os -from pathlib import Path import tempfile -from rich import print +from pathlib import Path + +import click import typer +from rich import print -from snowcli import utils, config +from snowcli import config, utils from snowcli.config import AppConfig -from snowcli.utils import print_db_cursor, generate_deploy_stage_name, print_list_tuples +from snowcli.utils import (generate_deploy_stage_name, print_db_cursor, + print_list_tuples) + def snowpark_create(type: str, environment: str, name: str, file: Path, handler: str, input_parameters: str, return_type: str, overwrite: bool, execute_as_caller: bool = False): env_conf = AppConfig().config.get(environment) @@ -23,7 +26,7 @@ def snowpark_create(type: str, environment: str, name: str, file: Path, handler: with tempfile.TemporaryDirectory() as temp_dir: temp_app_zip_path = utils.prepareAppZip(file, temp_dir) config.snowflake_connection.uploadFileToStage( - file_path=temp_app_zip_path, destination_stage=deploy_dict['stage'], path=deploy_dict['directory'], overwrite=overwrite, role=env_conf['role']) + file_path=temp_app_zip_path, destination_stage=deploy_dict['stage'], path=deploy_dict['directory'], database=env_conf['database'], schema=env_conf['schema'], overwrite=overwrite, role=env_conf['role']) packages = utils.getSnowflakePackages() print(f'Creating {type}...') match type: @@ -95,7 +98,7 @@ def snowpark_update(type: str, environment: str, name: str, file: Path, handler: with tempfile.TemporaryDirectory() as temp_dir: temp_app_zip_path = utils.prepareAppZip(file, temp_dir) deploy_response = config.snowflake_connection.uploadFileToStage( - file_path=temp_app_zip_path, destination_stage=deploy_dict['stage'], path=deploy_dict['directory'], overwrite=True, role=env_conf['role']) + file_path=temp_app_zip_path, destination_stage=deploy_dict['stage'], path=deploy_dict['directory'], database=env_conf['database'], schema=env_conf['schema'], overwrite=True, role=env_conf['role']) print( f'{deploy_response} uploaded to stage {deploy_dict["full_path"]}') diff --git a/src/snowcli/utils.py b/src/snowcli/utils.py index 86b957f2a6..1155a0a349 100644 --- a/src/snowcli/utils.py +++ b/src/snowcli/utils.py @@ -75,13 +75,13 @@ def installPackages(file_name: str) -> bool: os.system(f'pip install -t .packages/ -r {file_name}') click.echo('Checking to see if packages have native libaries...\n') # use glob to see if any files in packages have a .so extension - if glob.glob('.packages/*.so'): - for path in glob.glob('.packages/*.so'): + if glob.glob('.packages/**/*.so'): + for path in glob.glob('.packages/**/*.so'): click.echo(f'Potential native library: {path}') if click.confirm('\n\nWARNING! Some packages appear to have native libraries!\nContinue with package installation?', default=False): return True else: - shutil.rmtree('packages') + shutil.rmtree('.packages') return False else: click.echo('No native libraries found in packages (Good news!)...')