Skip to content

Commit

Permalink
fix file upload and .so detection (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jhollan authored Nov 3, 2022
1 parent 903d805 commit 21ffe5b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
21 changes: 11 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/snowcli/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.1.6"
VERSION = "0.1.7"
17 changes: 10 additions & 7 deletions src/snowcli/cli/snowpark_shared.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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"]}')

Expand Down
6 changes: 3 additions & 3 deletions src/snowcli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!)...')
Expand Down

0 comments on commit 21ffe5b

Please sign in to comment.