From e7d4f5b24e22f93ce24b161ae85fa7f822ee5351 Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:41:45 +0545 Subject: [PATCH] tests: filter warnings (#9115) --- dvc/dependency/param.py | 8 ++++---- dvc/render/match.py | 2 +- dvc/repo/plots/__init__.py | 18 +++++++++--------- dvc/utils/strictyaml.py | 2 +- pyproject.toml | 25 +++++++++++++++++++++++-- tests/integration/plots/test_plots.py | 18 +++++++++--------- tests/utils/plots.py | 6 +++--- 7 files changed, 50 insertions(+), 29 deletions(-) diff --git a/dvc/dependency/param.py b/dvc/dependency/param.py index 6fc4d60de..7ea313c6e 100644 --- a/dvc/dependency/param.py +++ b/dvc/dependency/param.py @@ -4,7 +4,7 @@ import typing from collections import defaultdict from typing import Dict -import dpath.util +import dpath from voluptuous import Any from dvc.exceptions import DvcException @@ -87,17 +87,17 @@ class ParamsDependency(Dependency): if flatten: for param in self.params: try: - ret[param] = dpath.util.get(config, param, separator=".") + ret[param] = dpath.get(config, param, separator=".") except KeyError: continue return ret - from dpath.util import merge + from dpath import merge for param in self.params: merge( ret, - dpath.util.search(config, param, separator="."), + dpath.search(config, param, separator="."), separator=".", ) return ret diff --git a/dvc/render/match.py b/dvc/render/match.py index ad3d3b2ba..14acf367b 100644 --- a/dvc/render/match.py +++ b/dvc/render/match.py @@ -1,8 +1,8 @@ from collections import defaultdict from typing import TYPE_CHECKING, Dict, List, Optional +import dpath import dpath.options -import dpath.util from funcy import last from dvc.repo.plots import infer_data_sources diff --git a/dvc/repo/plots/__init__.py b/dvc/repo/plots/__init__.py index cfcb87358..0349382b5 100644 --- a/dvc/repo/plots/__init__.py +++ b/dvc/repo/plots/__init__.py @@ -18,8 +18,8 @@ from typing import ( Union, ) +import dpath import dpath.options -import dpath.util from funcy import distinct, first, project from dvc.exceptions import DvcException @@ -389,7 +389,7 @@ def _collect_output_plots(repo, targets, props, onerror: Optional[Callable] = No onerror=onerror, ) - dpath.util.merge( + dpath.merge( result, {"": unpacked}, ) @@ -436,13 +436,13 @@ def _resolve_definitions( props={**plot_props, **props}, onerror=onerror, ) - dpath.util.merge( + dpath.merge( result, unpacked, ) elif _matches(targets, config_path, plot_id): adjusted_props = _adjust_sources(fs, plot_props, config_dir) - dpath.util.merge(result, {"data": {plot_id: {**adjusted_props, **props}}}) + dpath.merge(result, {"data": {plot_id: {**adjusted_props, **props}}}) return result @@ -471,7 +471,7 @@ def _collect_pipeline_files(repo, targets: List[str], props, onerror=None): dvcfile_defs_dict, onerror=onerror, ) - dpath.util.merge( + dpath.merge( result, {dvcfile_path: resolved}, ) @@ -495,13 +495,13 @@ def _collect_definitions( fs = DVCFileSystem(repo=repo) if not config_files: - dpath.util.merge( + dpath.merge( result, _collect_pipeline_files(repo, targets, props, onerror=onerror), ) if targets or (not targets and not config_files): - dpath.util.merge( + dpath.merge( result, _collect_output_plots(repo, targets, props, onerror=onerror), ) @@ -518,7 +518,7 @@ def _collect_definitions( definitions, onerror=onerror, ) - dpath.util.merge( + dpath.merge( result, {path: resolved}, ) @@ -526,7 +526,7 @@ def _collect_definitions( for target in targets: if not result or fs.exists(target): unpacked = unpack_if_dir(fs, target, props=props, onerror=onerror) - dpath.util.merge(result[""], unpacked) + dpath.merge(result[""], unpacked) return dict(result) diff --git a/dvc/utils/strictyaml.py b/dvc/utils/strictyaml.py index cfa8cfa6a..a99e0569f 100644 --- a/dvc/utils/strictyaml.py +++ b/dvc/utils/strictyaml.py @@ -169,7 +169,7 @@ def determine_linecol( number of steps upward to just 5. If it does not find any linecols, it'll abort. """ - from dpath.util import get + from dpath import get step = 1 line, col = None, None diff --git a/pyproject.toml b/pyproject.toml index 44ac52bbf..b17ea547c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,7 @@ dependencies = [ "colorama>=0.3.9", "configobj>=5.0.6", "distro>=1.3", - "dpath<3,>=2.0.2", + "dpath<3,>=2.1.0", "dvc-data>=0.42.1,<0.43", "dvc-http", "dvc-render>=0.1.2", @@ -132,7 +132,28 @@ profile = "black" [tool.pytest.ini_options] addopts = "-ra --cov-config pyproject.toml" -filterwarnings = ["error::pytest_mock.PytestMockWarning"] +filterwarnings = [ + "error::pytest_mock.PytestMockWarning", + # remove when aiobotocore supports botocore>=1.29.13 + "ignore:'cgi' is deprecated and slated for removal in Python 3.13:DeprecationWarning", + # also relates to botocore, but looks like it's not going to be fixed + # https://github.com/boto/botocore/issues/2744 + "ignore:'urllib3.contrib.pyopenssl' module is deprecated:DeprecationWarning", + # ruamel.yaml: https://sourceforge.net/p/ruamel-yaml/tickets/452/ + # google.cloud: https://github.com/googleapis/python-storage/issues/1000 + # google.logging: https://github.com/googleapis/python-logging/issues/730 + # Also happens with `zc.lockfile`. + "ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning", + # see https://github.com/celery/kombu/issues/1339 + # and https://github.com/celery/celery/issues/7528 + # drop when celery==5.3 && kombu==5.3 releases + "ignore:SelectableGroups dict interface is deprecated:DeprecationWarning", + # see https://github.com/networkx/networkx/issues/5723. + "ignore:nx.nx_pydot.* depends on the pydot package, which has.*known issues and is not actively maintained:DeprecationWarning", + # remove when new version of pytest-cov gets released + # https://github.com/pytest-dev/pytest-cov/issues/557 + "ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated:DeprecationWarning", +] log_level = "debug" markers = [ "needs_internet: Might need network access for the tests", diff --git a/tests/integration/plots/test_plots.py b/tests/integration/plots/test_plots.py index 4a5c07d2e..c8db3923e 100644 --- a/tests/integration/plots/test_plots.py +++ b/tests/integration/plots/test_plots.py @@ -5,7 +5,7 @@ from typing import Dict, List from urllib.parse import urlparse from urllib.request import url2pathname -import dpath.util +import dpath import pytest from bs4 import BeautifulSoup from funcy import first @@ -124,9 +124,9 @@ def verify_vega( tmp1 = deepcopy(html_template) tmp2 = deepcopy(filled_template) tmp3 = deepcopy(split_template) - dpath.util.set(tmp1, path, {}) - dpath.util.set(tmp2, path, {}) - dpath.util.set(tmp3, path, {}) + dpath.set(tmp1, path, {}) + dpath.set(tmp2, path, {}) + dpath.set(tmp3, path, {}) assert tmp1 == tmp2 == tmp3 @@ -140,17 +140,17 @@ def verify_vega_props(plot_id, json_result, title, x, y, **kwargs): assert len(data) == 1 data = first(data) - assert dpath.util.get(data, ["content", "title"]) == title + assert dpath.get(data, ["content", "title"]) == title try: # TODO confusion_matrix_plot - need to find better way of asserting # encoding as its place is not constant in vega - plot_x = dpath.util.get(data, ["content", "spec", "encoding", "x", "field"]) - plot_y = dpath.util.get(data, ["content", "spec", "encoding", "y", "field"]) + plot_x = dpath.get(data, ["content", "spec", "encoding", "x", "field"]) + plot_y = dpath.get(data, ["content", "spec", "encoding", "y", "field"]) except KeyError: # default plot - plot_x = dpath.util.get(data, ["content", "layer", 0, "encoding", "x", "field"]) - plot_y = dpath.util.get(data, ["content", "layer", 0, "encoding", "y", "field"]) + plot_x = dpath.get(data, ["content", "layer", 0, "encoding", "x", "field"]) + plot_y = dpath.get(data, ["content", "layer", 0, "encoding", "y", "field"]) assert plot_x == x assert plot_y == y diff --git a/tests/utils/plots.py b/tests/utils/plots.py index cf9155154..72a5de890 100644 --- a/tests/utils/plots.py +++ b/tests/utils/plots.py @@ -1,9 +1,9 @@ -import dpath.util +import dpath dpath.options.ALLOW_EMPTY_STRING_KEYS = True def get_plot(plots_data, revision, typ="sources", file=None, endkey="data"): if file is not None: - return dpath.util.get(plots_data, [revision, typ, "data", file, endkey]) - return dpath.util.get(plots_data, [revision, typ, endkey]) + return dpath.get(plots_data, [revision, typ, "data", file, endkey]) + return dpath.get(plots_data, [revision, typ, endkey])