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

1.2.3: The test_deprecated_grabdata_args test fails #135

Open
yurivict opened this issue Dec 4, 2022 · 3 comments
Open

1.2.3: The test_deprecated_grabdata_args test fails #135

yurivict opened this issue Dec 4, 2022 · 3 comments

Comments

@yurivict
Copy link

yurivict commented Dec 4, 2022

Describe the bug

========================================================================================== FAILURES ==========================================================================================
_______________________________________________________________________________ test_deprecated_grabdata_args ________________________________________________________________________________

    def test_deprecated_grabdata_args():
        with pytest.warns(DeprecationWarning):
            import hashlib
            url = _demo_url()
            # dpath = ub.Path.appdir('ubelt/tests/test_download').ensuredir()
            # fname = basename(url)
            # fpath = join(dpath, fname)
>           got_fpath = ub.grabdata(
                url, hash_prefix='e09c80c42fda55f9d992e59ca6b3307d',
                hasher=hashlib.md5())

tests/test_download.py:383: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
ubelt/util_download.py:444: in grabdata
    stamp.renew()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ubelt.util_cache.CacheStamp object at 0x904747d00>, cfgstr = None, product = None

    def renew(self, cfgstr=None, product=None):
        """
        Recertify that the product has been recomputed by writing a new
        certificate to disk.
    
        Returns:
            None | dict: certificate information if enabled otherwise None.
    
        Example:
            >>> # Test that renew does nothing when the cacher is disabled
            >>> import ubelt as ub
            >>> dpath = ub.Path.appdir('ubelt/tests/cache-stamp-renew').ensuredir()
            >>> self = ub.CacheStamp('foo', dpath=dpath, enabled=False)
            >>> assert self.renew() is None
        """
        if not self.cacher.enabled:
            return None
        if cfgstr is not None:  # nocover
            from ubelt import schedule_deprecation
            schedule_deprecation(
                modname='ubelt',
                migration='Do not pass cfgstr to renew. Use the class depends arg',
                name='cfgstr', type='CacheStamp.renew arg',
                deprecate='1.1.0', error='1.3.0', remove='1.4.0',
            )
        if product is not None:  # nocover
            from ubelt import schedule_deprecation
            schedule_deprecation(
                modname='ubelt',
                migration='Do not pass product to renew. Use the class product arg',
                name='product', type='CacheStamp.renew arg',
                deprecate='1.1.0', error='1.3.0', remove='1.4.0',
            )
        certificate = self._new_certificate(cfgstr, product)
        err = self._check_certificate_hashes(certificate)
        if err:
>           raise RuntimeError(err)
E           RuntimeError: hash_prefix_mismatch

ubelt/util_cache.py:1211: RuntimeError
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
[cacher] ... file_10_0.txt.stamp cache miss
[cacher] stamp expired no_cert
Downloading url='http://localhost:17766/file_10_0.txt' to fpath='/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/file_10_0.txt'
 10/10... rate=129294.24 Hz, eta=0:00:00, total=0:00:00
invalid hash prefix value (expected "e09c80c42fda55f9d992e59ca6b3307d", got "22d42eb002cefa81e9ad604ea57bc01d")
====================================================================================== warnings summary ======================================================================================
../../../../../../usr/local/lib/python3.9/site-packages/pytest_freezegun.py:17
  /usr/local/lib/python3.9/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):

tests/test_pathlib.py::test_move_meta
tests/test_pathlib.py::test_move_basic
tests/test_pathlib.py::test_move_dir_to_existing_dir_noconflict
tests/test_pathlib.py::test_move_dir_to_existing_dir_withconflict
tests/test_pathlib.py::test_move_dir_to_non_existing
tests/test_pathlib.py::test_move_to_nested_non_existing
  /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.3/ubelt/util_path.py:1384: UserWarning: The ub.Path.move function is experimental and may change! Do not rely on this behavior yet!
    warnings.warn('The ub.Path.move function is experimental and may change! '

tests/test_pathlib.py::test_copy_dir_to_existing_dir_withconflict
tests/test_pathlib.py::test_copy_meta
tests/test_pathlib.py::test_copy_basic
tests/test_pathlib.py::test_copy_to_nested_non_existing_with_different_symlink_flags
tests/test_pathlib.py::test_copy_dir_to_non_existing
tests/test_pathlib.py::test_copy_dir_to_existing_dir_noconflict
  /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.3/ubelt/util_path.py:1291: UserWarning: The ub.Path.copy function is experimental and may change, in corner cases. Primary cases seem stable.
    warnings.warn('The ub.Path.copy function is experimental and may change, '

tests/test_indexable.py::test_indexable_walker_map_patterns
  /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.3/ubelt/util_indexable.py:506: DeprecationWarning: The "indexable_allclose" function was deprecated, will cause an error and will be removed. The current version is 1.2.3. Use `ub.IndexableWalker(items1).allclose(ub.IndexableWalker(items2))` instead
    ub.schedule_deprecation(

tests/test_path.py::test_tempdir
tests/test_import.py::test_import_modpath_basic
tests/test_import.py::test_package_submodules
tests/test_import.py::test_import_modpath_package
tests/test_import.py::test_modpath_to_modname
tests/test_import.py::test_modname_to_modpath_package
tests/test_import.py::test_modname_to_modpath_single
tests/test_import.py::test_modname_to_modpath_namespace
  /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.3/ubelt/util_path.py:368: DeprecationWarning: The "TempDir" class was deprecated in 1.2.0, will cause an error in 1.4.0 and will be removed in 1.5.0. The current version is 1.2.3. Use tempfile instead
    ub.schedule_deprecation(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
SKIPPED [1] tests/test_futures.py:42: long test, demos that timeout does not work with SerialExecutor
SKIPPED [1] tests/test_editable_modules.py:415: UBELT_DO_EDITABLE_TESTS is not enabled
SKIPPED [1] tests/test_hash.py:435: blake3 is not available
SKIPPED [1] tests/test_download.py:256: This takes a long time to timeout and I dont understand why
=================================================================== 1 failed, 202 passed, 4 skipped, 22 warnings in 5.90s ====================================================================

Desktop (please complete the following information):

  • OS: FreeBSD 13.1
  • Ubelt version 1.2.3
  • Python version 3.9
@Erotemic
Copy link
Owner

Erotemic commented Dec 5, 2022

Can you cat out the contents of: /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/file_10_0.txt?

On my machine I see:

(pyenv3.10.5) joncrall@toothbrush:~/.cache/ubelt$ md5sum file_10_0.txt
e09c80c42fda55f9d992e59ca6b3307d  file_10_0.txt
(pyenv3.10.5) joncrall@toothbrush:~/.cache/ubelt$ cat file_10_0.txt
aaaaaaaaaa(pyenv3.10.5) joncrall@toothbrush:~/.cache/ubelt$ 

which is what I would expect.

EDIT: or actually cat out cat file_10_0.txt* so all the other metadata is listed.

for fpath in file_10_0.txt*
do
    echo "----"
    echo "fpath=$fpath"
    cat $fpath
    echo "----"
done
----
fpath=file_10_0.txt
aaaaaaaaaa----
----
fpath=file_10_0.txt.stamp_.json
{"timestamp": "2022-12-05T113157.4466-5", "expires": null, "product": ["/home/joncrall/.cache/ubelt/file_10_0.txt"], "mtime": [1670257917.4454195], "size": [10], "hasher": "sha512", "hash": ["4714870aff6c97ca09d135834fdb58a6389a50c11fef8ec4afef466fb60a23ac6b7a9c92658f14df4993d6b40a4e4d8424196afc347e97640d68de61e1cf14b0"]}----
----
fpath=file_10_0.txt.stamp_.json.meta


saving 2022-12-05T113157-5
file_10_0.txt.stamp


None
----
----
fpath=file_10_0.txt.stamp_md5.json
{"timestamp": "2022-12-05T113157.4539-5", "expires": null, "product": ["/home/joncrall/.cache/ubelt/file_10_0.txt"], "mtime": [1670257917.4454195], "size": [10], "hasher": "md5", "hash": ["e09c80c42fda55f9d992e59ca6b3307d"]}----
----
fpath=file_10_0.txt.stamp_md5.json.meta


saving 2022-12-05T113157-5
file_10_0.txt.stamp
md5
md5
None
----

@yurivict
Copy link
Author

yurivict commented Mar 2, 2023

$ sh x
----
fpath=./work-py39/.cache/ubelt/file_10_0.txt
aaaaaaaaaa----
----
fpath=./work-py39/.cache/ubelt/file_10_0.txt.stamp_.json
{"timestamp": "2023-03-01T222407.2808-8", "expires": null, "product": ["/usr/ports/devel/py-ubelt/work-py39/.cache/ubelt/file_10_0.txt"], "mtime": [1677738247.280418], "size": [10], "hasher": "sha512", "hash": ["4714870aff6c97ca09d135834fdb58a6389a50c11fef8ec4afef466fb60a23ac6b7a9c92658f14df4993d6b40a4e4d8424196afc347e97640d68de61e1cf14b0"]}----
----
fpath=./work-py39/.cache/ubelt/file_10_0.txt.stamp_.json.meta


saving 2023-03-01T222407-8
file_10_0.txt.stamp


None
----

@Erotemic
Copy link
Owner

Erotemic commented Jun 9, 2024

Is this still an issue? Now that 1.3 is out, this test now only tests that a RuntimeError is raised when using a hashlib object as an argument, so the error cited in this issue should no longer be possible. However, I'm not sure if it is indicative of an underlying problem or not.

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

No branches or pull requests

2 participants