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

Python CLI: DeprecationWarning on dvc.repo.Repo import #10505

Closed
hugo-ricateau opened this issue Aug 6, 2024 · 4 comments
Closed

Python CLI: DeprecationWarning on dvc.repo.Repo import #10505

hugo-ricateau opened this issue Aug 6, 2024 · 4 comments

Comments

@hugo-ricateau
Copy link

Description

Importing from dvc.repo import Repo issues a

DeprecationWarning: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.

Reproduce

from warnings import simplefilter
simplefilter('error')
from dvc.repo import Repo
---------------------------------------------------------------------------
DeprecationWarning                        Traceback (most recent call last)
Cell In[3], line 1
----> 1 from dvc.repo import Repo

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc/repo/__init__.py:63
     58             return f(repo, *args, **kwargs)
     60     return wrapper
---> 63 class Repo:
     64     DVC_DIR = ".dvc"
     66     from dvc.repo.add import add  # type: ignore[misc]

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc/repo/__init__.py:72, in Repo()
     70 from dvc.repo.diff import diff  # type: ignore[misc]
     71 from dvc.repo.du import du as _du  # type: ignore[misc]
---> 72 from dvc.repo.fetch import fetch  # type: ignore[misc]
     73 from dvc.repo.freeze import freeze, unfreeze  # type: ignore[misc]
     74 from dvc.repo.gc import gc  # type: ignore[misc]

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc/repo/fetch.py:5
      3 from dvc.exceptions import DownloadError
      4 from dvc.log import logger
----> 5 from dvc.stage.cache import RunCacheNotSupported
      6 from dvc.ui import ui
      7 from dvc_data.index import DataIndex, FileStorage

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc/stage/__init__.py:22
     20 from .imports import sync_import, update_import
     21 from .run import run_stage
---> 22 from .utils import (
     23     check_circular_dependency,
     24     check_duplicated_arguments,
     25     check_missing_outputs,
     26     check_no_externals,
     27     check_stage_path,
     28     compute_md5,
     29     fill_stage_dependencies,
     30     fill_stage_outputs,
     31     get_dump,
     32 )
     34 if TYPE_CHECKING:
     35     from dvc.dependency import ParamsDependency

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc/stage/utils.py:9
      7 from dvc.annotations import ANNOTATION_FIELDS
      8 from dvc.exceptions import InvalidArgumentError
----> 9 from dvc_data.hashfile.meta import Meta
     11 from .exceptions import (
     12     MissingDataSource,
     13     StageExternalOutputsError,
   (...)
     16     StagePathOutsideError,
     17 )
     19 if TYPE_CHECKING:

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc_data/hashfile/__init__.py:7
      4 from collections.abc import Iterator
      5 from typing import TYPE_CHECKING, Union, cast
----> 7 from .tree import Tree
      9 if TYPE_CHECKING:
     10     from .db import HashFileDB

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc_data/hashfile/tree.py:10
      7 from dvc_objects.errors import ObjectFormatError
      9 from dvc_data.compat import cached_property
---> 10 from dvc_data.hashfile.hash import DEFAULT_ALGORITHM, hash_file
     11 from dvc_data.hashfile.meta import Meta
     12 from dvc_data.hashfile.obj import HashFile

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc_data/hashfile/hash.py:12
      8 from tqdm.utils import CallbackIOWrapper
     10 from dvc_data.callbacks import TqdmCallback
---> 12 from .hash_info import HashInfo
     13 from .istextfile import DEFAULT_CHUNK_SIZE, istextblock
     14 from .meta import Meta

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/dvc_data/hashfile/hash_info.py:8
      3 from attrs import define, field
      5 HASH_DIR_SUFFIX = ".dir"
----> 8 @define(hash=True)
      9 class HashInfo:
     10     name: Optional[str] = None
     11     value: Optional[str] = None

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/attr/_next_gen.py:402, in define.<locals>.wrap(cls)
    399     return do_it(cls, auto_attribs)
    401 try:
--> 402     return do_it(cls, True)
    403 except UnannotatedAttributeError:
    404     return do_it(cls, False)

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/attr/_next_gen.py:348, in define.<locals>.do_it(cls, auto_attribs)
    347 def do_it(cls, auto_attribs):
--> 348     return attrs(
    349         maybe_cls=cls,
    350         these=these,
    351         repr=repr,
    352         hash=hash,
    353         unsafe_hash=unsafe_hash,
    354         init=init,
    355         slots=slots,
    356         frozen=frozen,
    357         weakref_slot=weakref_slot,
    358         str=str,
    359         auto_attribs=auto_attribs,
    360         kw_only=kw_only,
    361         cache_hash=cache_hash,
    362         auto_exc=auto_exc,
    363         eq=eq,
    364         order=order,
    365         auto_detect=auto_detect,
    366         collect_by_mro=True,
    367         getstate_setstate=getstate_setstate,
    368         on_setattr=on_setattr,
    369         field_transformer=field_transformer,
    370         match_args=match_args,
    371     )

File ~/.pyenv/versions/3.11.6/envs/ds/lib/python3.11/site-packages/attr/_make.py:1291, in attrs(maybe_cls, these, repr_ns, repr, cmp, hash, init, slots, frozen, weakref_slot, str, auto_attribs, kw_only, cache_hash, auto_exc, eq, order, auto_detect, collect_by_mro, getstate_setstate, on_setattr, field_transformer, match_args, unsafe_hash)
   1288 if hash is not None:
   1289     import warnings
-> 1291     warnings.warn(
   1292         DeprecationWarning(
   1293             "The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025."
   1294         ),
   1295         stacklevel=2,
   1296     )
   1297 if unsafe_hash is not None:
   1298     hash = unsafe_hash

DeprecationWarning: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.

Expected

A clean import.

Environment information

Output of dvc doctor:

$ dvc doctor
DVC version: 3.53.1 (pip)
-------------------------
Platform: Python 3.11.6 on Linux-5.4.0-182-generic-x86_64-with-glibc2.31
Subprojects:
	dvc_data = 3.15.1
	dvc_objects = 5.1.0
	dvc_render = 1.0.2
	dvc_task = 0.4.0
	scmrepo = 3.3.7
Supports:
	http (aiohttp = 3.10.1, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.10.1, aiohttp-retry = 2.8.3),
	s3 (s3fs = 2024.6.1, boto3 = 1.34.131),
	ssh (sshfs = 2024.6.0)
Config:
	Global: /home/hugo/.config/dvc
	System: /etc/xdg/dvc
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: s3
Workspace directory: ext4 on /dev/mapper/ubuntu--vg-ubuntu--lv
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/52ddbaa0d2b087b8b0e593aa20cf85f3
@skshetry
Copy link
Member

skshetry commented Aug 6, 2024

Thank you for the report. This has been fixed by iterative/dvc-data#539, and released in dvc-data==3.15.2.

@skshetry skshetry closed this as completed Aug 6, 2024
@hugo-ricateau
Copy link
Author

Oh sorry... I missed the existing issue as already closed.

@skshetry, do you know when dvc-data==3.15.2 will be released (included in dvc)?

@skshetry
Copy link
Member

skshetry commented Aug 6, 2024

Oh sorry... I missed the existing issue as already closed.

@skshetry, do you know when dvc-data==3.15.2 will be released (included in dvc)?

DVC only pins the minor version of dvc-data, so it does not need any adjustment in dvc side.

"dvc-data>=3.15,<3.16",

You can either do pip install dvc-data -U or pip install dvc -U, and the new version should get installed.

@hugo-ricateau
Copy link
Author

hugo-ricateau commented Aug 6, 2024

I did pip install --upgrade dvc and pip freeze still pins dvc-data==3.15.1; however pip install --upgrade dvc-data actually upgrades to dvc-data-3.15.2. This is actually due to the default pip upgrade-strategy; adding the --upgrade-strategy eager option indeed upgrades dvc-data (as well as many other dependencies).

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