Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-928897: Calling SPROC throws error module has no attribute #1068

Closed
cedric-ejara opened this issue Oct 2, 2023 · 2 comments
Closed
Labels
question Further information is requested

Comments

@cedric-ejara
Copy link

cedric-ejara commented Oct 2, 2023

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

Python 3.10.7 (main, May 29 2023, 13:51:48) [GCC 12.2.0]

  1. What operating system and processor architecture are you using?

Linux-5.19.0-46-generic-x86_64-with-glibc2.36

  1. What are the component versions in the environment (pip freeze)?

aiohttp==3.8.5
aiosignal==1.3.1
alembic==1.12.0
amqp==5.1.1
anyio==4.0.0
apache-airflow==2.7.0
apache-airflow-providers-celery==3.3.3
apache-airflow-providers-common-sql==1.7.1
apache-airflow-providers-ftp==3.5.1
apache-airflow-providers-http==4.5.1
apache-airflow-providers-imap==3.3.1
apache-airflow-providers-slack==8.0.0
apache-airflow-providers-snowflake==5.0.0
apache-airflow-providers-sqlite==3.4.3
apispec==6.3.0
argcomplete==3.1.1
asgiref==3.7.2
asn1crypto==1.5.1
async-timeout==4.0.3
attrs==23.1.0
Babel==2.12.1
backoff==2.2.1
bcrypt==4.0.1
billiard==4.1.0
blinker==1.6.2
boto3==1.28.40
botocore==1.31.40
cachelib==0.9.0
cattrs==23.1.2
celery==5.3.4
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
clickclick==20.10.2
cloudpickle==2.0.0
colorama==0.4.6
colorlog==4.8.0
ConfigUpdater==3.1.1
connexion==2.14.2
cron-descriptor==1.4.0
croniter==1.4.1
cryptography==41.0.3
Deprecated==1.2.14
dill==0.3.7
dnspython==2.4.2
docutils==0.20.1
email-validator==1.3.1
exceptiongroup==1.1.3
filelock==3.12.3
Flask==2.2.5
Flask-AppBuilder==4.3.3
Flask-Babel==2.0.0
Flask-Caching==2.0.2
Flask-JWT-Extended==4.5.2
Flask-Limiter==3.5.0
Flask-Login==0.6.2
Flask-Session==0.5.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.1.1
flower==2.0.1
frozenlist==1.4.0
google-re2==1.1
googleapis-common-protos==1.60.0
graphviz==0.20.1
greenlet==2.0.2
grpcio==1.57.0
gunicorn==21.2.0
h11==0.14.0
httpcore==0.17.3
httpx==0.24.1
humanize==4.8.0
idna==3.4
importlib-resources==6.0.1
inflection==0.5.1
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
jmespath==1.0.1
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
kombu==5.3.2
lazy-object-proxy==1.9.0
limits==3.6.0
linkify-it-py==2.0.2
lockfile==0.12.2
Mako==1.2.4
Markdown==3.4.4
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.20.1
marshmallow-oneofschema==3.0.1
marshmallow-sqlalchemy==0.26.1
mdit-py-plugins==0.4.0
mdurl==0.1.2
multidict==6.0.4
mysqlclient==2.2.0
numpy==1.25.2
openlineage-airflow==1.1.0
openlineage-integration-common==1.1.0
openlineage-python==1.1.0
openlineage_sql==1.1.0
opentelemetry-api==1.15.0
opentelemetry-exporter-otlp==1.15.0
opentelemetry-exporter-otlp-proto-grpc==1.15.0
opentelemetry-exporter-otlp-proto-http==1.15.0
opentelemetry-proto==1.15.0
opentelemetry-sdk==1.15.0
opentelemetry-semantic-conventions==0.36b0
ordered-set==4.1.0
oscrypto==1.3.0
packaging==23.1
paramiko==3.3.1
pathspec==0.11.2
pendulum==2.1.2
platformdirs==3.8.1
pluggy==1.3.0
prison==0.2.1
prometheus-client==0.17.1
prompt-toolkit==3.0.39
protobuf==4.24.2
psutil==5.9.5
psycopg2==2.9.7
pyarrow==13.0.0
pycparser==2.21
pycryptodomex==3.18.0
pydantic==1.10.12
Pygments==2.16.1
PyJWT==2.8.0
PyMySQL==1.1.0
PyNaCl==1.5.0
pyOpenSSL==23.2.0
pytest==7.4.1
python-daemon==3.0.1
python-dateutil==2.8.2
python-nvd3==0.15.0
python-slugify==8.0.1
pytz==2023.3
pytzdata==2020.1
PyYAML==6.0.1
redis==5.0.0
referencing==0.30.2
requests==2.31.0
requests-toolbelt==1.0.0
rfc3339-validator==0.1.4
rich==13.5.2
rich-argparse==1.3.0
rpds-py==0.10.0
s3transfer==0.6.2
setproctitle==1.3.2
six==1.16.0
slack-sdk==3.21.3
sniffio==1.3.0
snowflake-connector-python==3.2.0
snowflake-snowpark-python==1.8.0
snowflake-sqlalchemy==1.5.0
sortedcontainers==2.4.0
SQLAlchemy==1.4.49
SQLAlchemy-JSONField==1.0.1.post0
SQLAlchemy-Utils==0.41.1
sqlparse==0.4.4
tabulate==0.9.0
tenacity==8.2.3
termcolor==2.3.0
text-unidecode==1.3
tomli==2.0.1
tomlkit==0.12.1
tornado==6.3.3
typing_extensions==4.7.1
tzdata==2023.3
uc-micro-py==1.0.2
unicodecsv==0.14.1
urllib3==1.26.16
vine==5.0.0
wcwidth==0.2.6
Werkzeug==2.2.3
wrapt==1.15.0
WTForms==3.0.1
yarl==1.9.2

  1. What did you do?
================================
sproc.py file
def main(session: snowpark.Session) -> int:
    print(session)
    print("testing " + str("testing"))
    return 1
===============================

sproc_file_path = os.path.join(transform_sproc_path, table["schema_table"].replace(".", "/"), "sproc.py")
sproc_name: str = 'sproc'

session.add_packages('snowflake-snowpark-python')

# create temp stage and put file
session.sql(f"CREATE TEMPORARY STAGE IF NOT EXISTS sproc_store").collect()
session.file.put(sproc_file_path, "@sproc_store", auto_compress=False)

my_sproc: StoredProcedure = session.sproc.register_from_file(
    file_path=f"@sproc_store/sproc.py",
    func_name=sproc_name,
    return_type=T.IntegerType(),
    input_types=[],
    name=sproc_name,
    replace=True,
    # stage_location="@sproc_store",
    is_permanent=False
)

# self.snowpark_session.call(f'@sproc_store/{sproc_name}')
my_sproc()
  1. What did you expect to see?

    I am expecting snowflake to run the sproc function and give me result.

  2. Can you set logging to DEBUG and collect the logs?

snowflake.snowpark.exceptions.SnowparkSQLException: (1304): 01af60bf-0302-dc21-0001-330e0198d13a: 100357 (P0000): 01af60bf-0302-dc21-0001-330e0198d13a: Python Interpreter Error:
AttributeError: module 'sproc' has no attribute 'sproc' in function SPROC with handler sproc.sproc

@cedric-ejara cedric-ejara added bug Something isn't working needs triage Initial RCA is required labels Oct 2, 2023
@github-actions github-actions bot changed the title Calling SPROC in Snowpark SNOW-928897: Calling SPROC in Snowpark Oct 2, 2023
@cedric-ejara cedric-ejara changed the title SNOW-928897: Calling SPROC in Snowpark SNOW-928897: Calling SPROC throws error module has no attribute Oct 2, 2023
@sfc-gh-stan
Copy link
Collaborator

Hi @cedric-ejara , the function name is the name of the handler function defined in sproc.py. The error message here means it is trying to find a handler function called sproc in sproc.py.

@sfc-gh-stan sfc-gh-stan added question Further information is requested and removed needs triage Initial RCA is required bug Something isn't working labels Oct 2, 2023
@cedric-ejara
Copy link
Author

@sfc-gh-stan thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants