Giter Site home page Giter Site logo

snowflake-vcrpy's Issues

Request: a more compatible, robust approach

Thanks for starting this. It's a welcome effort towards making writing tests against snowflake-connector-pythons APIs more feasible.

However, for those of us already using VCR.py, or anyone who'd want to, the current implementation creates as many problems as it solves. The underlying issue, AFAICT, is the choice to vendor VCR.py, instead of simply declaring it as a dependency. Anyone already using VCR.py will now get a second version of it, which introduces needless complexity, and has, in my experience so far, made it very tricky to actually use without breaking things. Hard-coding some config values, and exposing a different configuration API than VCR.py does, or plugins like pytest-recording do, only complicates matters.

Perhaps there's context I'm missing, but as best as I can tell, the root issue is that snowflake-connector-python takes the same approach with respect to requests and urllib3, vendoring them. VCR.py knows how to patch plain urllib3, and the versions that come packaged with botocore and requests, but doesn't know about this new variant. A robust fix for this—and robustness is certainly desirable when it comes to testing tools—would involve extending VCR.py using its public APIs, or opening a PR against it, if those APIs are too limited. (I'm assuming that, for reasons, snowflake-connector-python won't switch to using a standard version of requests or urllib3 anytime soon.)

Again, this is a welcome effort, but its real world utility will greatly limited if it doesn't integrate well with the popular tools on which its based.

Support snowflake.connector.pandas_tools.write_pandas

Use of snowflake.connector.pandas_tools.write_pandas fails with:

  File "./.venv/lib/python3.11/site-packages/snowflakeutils/table.py", line 329, in write_as_dataframe
    res = snowflake.connector.pandas_tools.write_pandas(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/pandas_tools.py", line 344, in write_pandas
    cursor.execute(upload_sql, _is_internal=True)
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/cursor.py", line 1098, in execute
    sf_file_transfer_agent.execute()
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/file_transfer_agent.py", line 398, in execute
    self._transfer_accelerate_config()
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/file_transfer_agent.py", line 697, in _transfer_accelerate_config
    client = self._create_file_transfer_client(self._file_metadata[0])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/file_transfer_agent.py", line 676, in _create_file_transfer_client
    return SnowflakeS3RestClient(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/s3_storage_client.py", line 90, in __init__
    self.transfer_accelerate_config(use_accelerate_endpoint)
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/s3_storage_client.py", line 106, in transfer_accelerate_config
    use_accelerate_endpoint = self._get_bucket_accelerate_config(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/s3_storage_client.py", line 572, in _get_bucket_accelerate_config
    response = self._send_request_with_authentication_and_retry(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/s3_storage_client.py", line 362, in _send_request_with_authentication_and_retry
    return self._send_request_with_retry(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/storage_client.py", line 287, in _send_request_with_retry
    response = session.request(verb, url, **rest_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/vendored/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/vendored/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/vendored/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/connector/vendored/urllib3/connectionpool.py", line 458, in _make_request
    httplib_response = conn.getresponse(buffering=True)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/vcrpy/_vendored/vcrpy/stubs/__init__.py", line 223, in getresponse
    if self.cassette.can_play_response_for(self._vcr_request):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/vcrpy/_vendored/vcrpy/cassette.py", line 269, in can_play_response_for
    request = self._before_record_request(request)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/vcrpy/_vendored/vcrpy/config.py", line 226, in before_record_request
    request = function(request)
              ^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.11/site-packages/snowflake/vcrpy/snowflake_vcrpy_pytest_plugin.py", line 41, in _process_request_recording
    code = request.uri.split("/results/")[1].split("/")[0]

Assumed AWS request URI causes problems.

Hey,

I just found this package and it seems like a very nice one. I decided to test it out since currently a lot of my time goes to waiting for tests to pass. I think this package seems very good.

However, I ran into a problem. The package seems to assume a certain format for the result id from aws requests which, at least for my code, does not hold. I get a IndexError: list index out of range error on line this line code = request.uri.split("/results/")[1].split("/")[0] of the def _process_request_recording(request): function of snowflake_vcrpy_pytest_plugin.py (link to line). I was able to simply comment out that line and the one that depends on it to get everything running (no clue what the implications are).

The request.uristring is https://00000000-0000-0000-0000-000000000000.amazonaws.com/?accelerate

Edit: This seems to have been introduced in the latest commit to the package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.