python-documentai-toolbox icon indicating copy to clipboard operation
python-documentai-toolbox copied to clipboard

Samples: Blob.from_string() is deprecated. Use Blob.from_uri() instead.

Open parthea opened this issue 7 months ago • 0 comments

See the samples test failure in PR https://github.com/googleapis/python-documentai-toolbox/pull/380

https://github.com/googleapis/python-documentai-toolbox/blob/0e59848a43b486fd61e022e48f08b93104076eb0/google/cloud/documentai_toolbox/utilities/gcs_utilities.py#L145

https://btx.cloud.google.com/invocations/41ddcb73-85dd-4eda-80d5-052e7c29805a/log

=================================== FAILURES ===================================
________________________ test_quickstart_sample_gcs_uri ________________________

capsys = <_pytest.capture.CaptureFixture object at 0x7f9fb13b9880>

    def test_quickstart_sample_gcs_uri(capsys: pytest.CaptureFixture) -> None:
        gcs_uri = (
            "gs://documentai_toolbox_samples/output/123456789/0/toolbox_invoice_test-0.json"
        )
>       quickstart_sample.quickstart_sample(gcs_uri=gcs_uri)

test_quickstart_sample.py:46: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
quickstart_sample.py:68: in quickstart_sample
    wrapped_document = document.Document.from_gcs_uri(gcs_uri=gcs_uri)
../../google/cloud/documentai_toolbox/wrappers/document.py:566: in from_gcs_uri
    blob = gcs_utilities.get_blob(gcs_uri=gcs_uri, module="get-document")
../../google/cloud/documentai_toolbox/utilities/gcs_utilities.py:145: in get_blob
    return storage.Blob.from_string(gcs_uri, _get_storage_client(module=module))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = 
uri = 'gs://documentai_toolbox_samples/output/123456789/0/toolbox_invoice_test-0.json'
client = 

    @classmethod
    def from_string(cls, uri, client=None):
        """(Deprecated) Get a constructor for blob object by URI.
    
        .. note::
           Deprecated alias for :meth:`from_uri`.
    
        .. code-block:: python
    
            from google.cloud import storage
            from google.cloud.storage.blob import Blob
            client = storage.Client()
            blob = Blob.from_string("gs://bucket/object", client=client)
    
        :type uri: str
        :param uri: The blob uri following a gs://bucket/object pattern.
          Both a bucket and object name is required to construct a blob object.
    
        :type client: :class:`~google.cloud.storage.client.Client`
        :param client:
            (Optional) The client to use.  Application code should
            *always* pass ``client``.
    
        :rtype: :class:`google.cloud.storage.blob.Blob`
        :returns: The blob object created.
        """
>       warnings.warn(_FROM_STRING_DEPRECATED, PendingDeprecationWarning, stacklevel=2)
E       PendingDeprecationWarning: Blob.from_string() is deprecated and will be removed in future. Use Blob.from_uri() instead.

.nox/py-3-8/lib/python3.8/site-packages/google/cloud/storage/blob.py:449: PendingDeprecationWarning
-------- generated xml file: /workspace/samples/snippets/sponge_log.xml --------

parthea avatar Mar 06 '25 16:03 parthea