Skip to content

Conversation

@sfc-gh-pvarshney
Copy link

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-2020306

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
    • If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: AST Support Guidelines
  3. Please describe how your code solves the related issue.

Support to track sessions created by snowflake notebooks.

#cursor

Testing

(snowpark-dev) pvarshney@L2J7XTW35F unit % python -m pytest test_server_connection.py
=========================================== test session starts ============================================
platform darwin -- Python 3.9.23, pytest-7.4.4, pluggy-1.6.0
rootdir: /Users/pvarshney/projects/snowpark-python
configfile: tox.ini
plugins: anyio-4.9.0, assume-2.4.3, xdist-3.8.0, timeout-2.4.0, cov-6.2.1
timeout: 1200.0s
timeout method: signal
timeout func_only: False
collected 10 items                                                                                         

test_server_connection.py::test_wrap_exception PASSED                                                [ 10%]
test_server_connection.py::test_upload_stream_exceptions 
---------------------------------------------- live log call -----------------------------------------------
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:145 Uploading stream to stage
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:145 Uploading stream to stage
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:145 Uploading stream to stage
PASSED                                                                                               [ 20%]
test_server_connection.py::test_run_query_exceptions 
---------------------------------------------- live log call -----------------------------------------------
ERROR    snowflake.snowpark._internal.server_connection:server_connection.py:525 Failed to execute query fake query
fake exception
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:514 Execute query [queryID: fake id] fake query
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:514 Execute query [queryID: fake id] fake query
PASSED                                                                                               [ 30%]
test_server_connection.py::test_get_result_set_exception 
---------------------------------------------- live log call -----------------------------------------------
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:514 Execute query [queryID: <MagicMock name='mock.cursor().execute().sfqid' id='5285276400'>] fake query 1
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:519 Execute async query [queryID: <MagicMock name='mock.cursor().execute_async().__getitem__()' id='5285408336'>] fake query 1;fake query 2
PASSED                                                                                               [ 40%]
test_server_connection.py::test_run_query_when_ignore_results_true 
---------------------------------------------- live log call -----------------------------------------------
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:514 Execute query [queryID: ignore_results is True] select * from fake_table
DEBUG    snowflake.snowpark._internal.server_connection:server_connection.py:514 Execute query [queryID: ignore_results is True] select * from fake_table
PASSED                                                                                               [ 50%]
test_server_connection.py::test_snowbook_detection_adds_notebook_application PASSED                  [ 60%]
test_server_connection.py::test_snowbook_detection_without_snowbook PASSED                           [ 70%]
test_server_connection.py::test_snowbook_detection_with_multiple_applications PASSED                 [ 80%]
test_server_connection.py::test_env_var_partner_takes_precedence PASSED                              [ 90%]
test_server_connection.py::test_existing_application_param_not_overwritten PASSED                    [100%]

============================================= warnings summary =============================================
../../src/snowflake/snowpark/session.py:38
  /Users/pvarshney/projects/snowpark-python/src/snowflake/snowpark/session.py:38: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../../../../miniconda/envs/snowpark-dev/lib/python3.9/site-packages/pkg_resources/__init__.py:3147
  /Users/pvarshney/miniconda/envs/snowpark-dev/lib/python3.9/site-packages/pkg_resources/__init__.py:3147: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('snowflake')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../../../miniconda/envs/snowpark-dev/lib/python3.9/site-packages/pkg_resources/__init__.py:3147
  /Users/pvarshney/miniconda/envs/snowpark-dev/lib/python3.9/site-packages/pkg_resources/__init__.py:3147: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================== 10 passed, 3 warnings in 0.32s ======================================
(snowpark-dev) pvarshney@L2J7XTW35F unit % 

@sfc-gh-pvarshney sfc-gh-pvarshney added NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md NO-PANDAS-CHANGEDOC-UPDATES This PR does not update Snowpark pandas docs labels Jul 7, 2025
@sfc-gh-pvarshney sfc-gh-pvarshney requested review from a team as code owners July 7, 2025 17:23
@github-actions
Copy link

github-actions bot commented Jul 7, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sfc-gh-pvarshney
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@sfc-gh-pvarshney sfc-gh-pvarshney force-pushed the pvarshney-SNOW-2020306-add-tracking-for-notebook-application branch 2 times, most recently from c450ee3 to 3029715 Compare July 14, 2025 15:20
@sfc-gh-jkew
Copy link
Contributor

This is great - would "application" show up in our telemetry data as well, like along w/ the python version; or is it something we just want to only have associated with the session?

It looks like since telemetry is setup in the same block that might be a useful followon

@sfc-gh-pvarshney sfc-gh-pvarshney force-pushed the pvarshney-SNOW-2020306-add-tracking-for-notebook-application branch from 3029715 to 9a7fc7d Compare July 22, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md NO-PANDAS-CHANGEDOC-UPDATES This PR does not update Snowpark pandas docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants