From db6fb8ad7ea2e071e1e11205f23d251093496c96 Mon Sep 17 00:00:00 2001 From: Danny Chiao Date: Thu, 7 Sep 2023 02:09:31 -0700 Subject: [PATCH] fix: Fix warnings from deprecated paths and update default log level (#3757) --- sdk/python/feast/cli.py | 6 ++-- .../feast/infra/offline_stores/file_source.py | 2 +- sdk/python/feast/proto_json.py | 8 ++--- sdk/python/feast/ui_server.py | 31 ++++++++++--------- .../requirements/py3.10-ci-requirements.txt | 3 ++ .../requirements/py3.10-requirements.txt | 6 +++- .../requirements/py3.8-ci-requirements.txt | 4 ++- .../requirements/py3.8-requirements.txt | 7 +++-- .../requirements/py3.9-ci-requirements.txt | 7 ++++- .../requirements/py3.9-requirements.txt | 10 ++++-- setup.py | 2 ++ 11 files changed, 56 insertions(+), 30 deletions(-) diff --git a/sdk/python/feast/cli.py b/sdk/python/feast/cli.py index 8c2c326b595..53c346b6eb7 100644 --- a/sdk/python/feast/cli.py +++ b/sdk/python/feast/cli.py @@ -18,10 +18,10 @@ from typing import List, Optional import click -import pkg_resources import yaml from colorama import Fore, Style from dateutil import parser +from importlib_metadata import version as importlib_version from pygments import formatters, highlight, lexers from feast import utils @@ -68,7 +68,7 @@ def format_options(self, ctx: click.Context, formatter: click.HelpFormatter): ) @click.option( "--log-level", - default="info", + default="warning", help="The logging level. One of DEBUG, INFO, WARNING, ERROR, and CRITICAL (case-insensitive).", ) @click.option( @@ -122,7 +122,7 @@ def version(): """ Display Feast SDK version """ - print(f'Feast SDK Version: "{pkg_resources.get_distribution("feast")}"') + print(f'Feast SDK Version: "{importlib_version("feast")}"') @cli.command() diff --git a/sdk/python/feast/infra/offline_stores/file_source.py b/sdk/python/feast/infra/offline_stores/file_source.py index d8522fb4456..ac824b359f4 100644 --- a/sdk/python/feast/infra/offline_stores/file_source.py +++ b/sdk/python/feast/infra/offline_stores/file_source.py @@ -158,7 +158,7 @@ def get_table_column_names_and_types( # Adding support for different file format path # based on S3 filesystem if filesystem is None: - schema = ParquetDataset(path).schema + schema = ParquetDataset(path, use_legacy_dataset=False).schema if hasattr(schema, "names") and hasattr(schema, "types"): # Newer versions of pyarrow doesn't have this method, # but this field is good enough. diff --git a/sdk/python/feast/proto_json.py b/sdk/python/feast/proto_json.py index a0a4dce86bc..41d2afa55a7 100644 --- a/sdk/python/feast/proto_json.py +++ b/sdk/python/feast/proto_json.py @@ -1,13 +1,13 @@ import uuid from typing import Any, Callable, Type -import pkg_resources from google.protobuf.json_format import ( # type: ignore _WKTJSONMETHODS, ParseError, _Parser, _Printer, ) +from importlib_metadata import version as importlib_version from packaging import version from feast.protos.feast.serving.ServingService_pb2 import FeatureList @@ -118,7 +118,7 @@ def from_json_object_updated( # https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the # parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions. - current_version = pkg_resources.get_distribution("protobuf").version + current_version = importlib_version("protobuf") if version.parse(current_version) < version.parse("3.20"): _patch_proto_json_encoding(Value, to_json_object, from_json_object) else: @@ -168,7 +168,7 @@ def from_json_object( # https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the # parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions. - current_version = pkg_resources.get_distribution("protobuf").version + current_version = importlib_version("protobuf") if version.parse(current_version) < version.parse("3.20"): _patch_proto_json_encoding(RepeatedValue, to_json_object, from_json_object) else: @@ -221,7 +221,7 @@ def from_json_object_updated( # https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the # parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions. - current_version = pkg_resources.get_distribution("protobuf").version + current_version = importlib_version("protobuf") if version.parse(current_version) < version.parse("3.20"): _patch_proto_json_encoding(FeatureList, to_json_object, from_json_object) else: diff --git a/sdk/python/feast/ui_server.py b/sdk/python/feast/ui_server.py index e750f280ad7..9950eea070f 100644 --- a/sdk/python/feast/ui_server.py +++ b/sdk/python/feast/ui_server.py @@ -2,7 +2,7 @@ import threading from typing import Callable, Optional -import pkg_resources +import importlib_resources import uvicorn from fastapi import FastAPI, Response from fastapi.middleware.cors import CORSMiddleware @@ -51,20 +51,21 @@ def shutdown_event(): async_refresh() - ui_dir = pkg_resources.resource_filename(__name__, "ui/build/") - # Initialize with the projects-list.json file - with open(ui_dir + "projects-list.json", mode="w") as f: - projects_dict = { - "projects": [ - { - "name": "Project", - "description": "Test project", - "id": project_id, - "registryPath": f"{root_path}/registry", - } - ] - } - f.write(json.dumps(projects_dict)) + ui_dir_ref = importlib_resources.files(__name__) / "ui/build/" + with importlib_resources.as_file(ui_dir_ref) as ui_dir: + # Initialize with the projects-list.json file + with ui_dir.joinpath("projects-list.json").open(mode="w") as f: + projects_dict = { + "projects": [ + { + "name": "Project", + "description": "Test project", + "id": project_id, + "registryPath": f"{root_path}/registry", + } + ] + } + f.write(json.dumps(projects_dict)) @app.get("/registry") def read_registry(): diff --git a/sdk/python/requirements/py3.10-ci-requirements.txt b/sdk/python/requirements/py3.10-ci-requirements.txt index a59553b4ac8..3192a154729 100644 --- a/sdk/python/requirements/py3.10-ci-requirements.txt +++ b/sdk/python/requirements/py3.10-ci-requirements.txt @@ -366,7 +366,10 @@ imagesize==1.4.1 importlib-metadata==6.8.0 # via # dask + # feast (setup.py) # great-expectations +importlib-resources==6.0.1 + # via feast (setup.py) iniconfig==2.0.0 # via pytest ipykernel==6.25.2 diff --git a/sdk/python/requirements/py3.10-requirements.txt b/sdk/python/requirements/py3.10-requirements.txt index 4140bea9d0f..0ebc485d6d5 100644 --- a/sdk/python/requirements/py3.10-requirements.txt +++ b/sdk/python/requirements/py3.10-requirements.txt @@ -82,7 +82,11 @@ idna==3.4 # httpx # requests importlib-metadata==6.8.0 - # via dask + # via + # dask + # feast (setup.py) +importlib-resources==6.0.1 + # via feast (setup.py) jinja2==3.1.2 # via feast (setup.py) jsonschema==4.19.0 diff --git a/sdk/python/requirements/py3.8-ci-requirements.txt b/sdk/python/requirements/py3.8-ci-requirements.txt index b24172e890f..a5acaf55d4f 100644 --- a/sdk/python/requirements/py3.8-ci-requirements.txt +++ b/sdk/python/requirements/py3.8-ci-requirements.txt @@ -370,6 +370,7 @@ importlib-metadata==6.8.0 # via # build # dask + # feast (setup.py) # great-expectations # jupyter-client # jupyter-lsp @@ -379,6 +380,7 @@ importlib-metadata==6.8.0 # sphinx importlib-resources==6.0.1 # via + # feast (setup.py) # jsonschema # jsonschema-specifications # jupyterlab @@ -533,7 +535,7 @@ mypy-extensions==1.0.0 # via # black # mypy -mypy-protobuf==3.1 +mypy-protobuf==3.1.0 # via feast (setup.py) mysqlclient==2.2.0 # via feast (setup.py) diff --git a/sdk/python/requirements/py3.8-requirements.txt b/sdk/python/requirements/py3.8-requirements.txt index 636f886133d..cccff07b7dd 100644 --- a/sdk/python/requirements/py3.8-requirements.txt +++ b/sdk/python/requirements/py3.8-requirements.txt @@ -82,9 +82,12 @@ idna==3.4 # httpx # requests importlib-metadata==6.8.0 - # via dask + # via + # dask + # feast (setup.py) importlib-resources==6.0.1 # via + # feast (setup.py) # jsonschema # jsonschema-specifications jinja2==3.1.2 @@ -105,7 +108,7 @@ mypy==1.5.1 # via sqlalchemy mypy-extensions==1.0.0 # via mypy -mypy-protobuf==3.1 +mypy-protobuf==3.1.0 # via feast (setup.py) numpy==1.24.4 # via diff --git a/sdk/python/requirements/py3.9-ci-requirements.txt b/sdk/python/requirements/py3.9-ci-requirements.txt index ad19f9e8bde..121a768abc1 100644 --- a/sdk/python/requirements/py3.9-ci-requirements.txt +++ b/sdk/python/requirements/py3.9-ci-requirements.txt @@ -367,6 +367,7 @@ importlib-metadata==6.8.0 # via # build # dask + # feast (setup.py) # great-expectations # jupyter-client # jupyter-lsp @@ -374,6 +375,8 @@ importlib-metadata==6.8.0 # jupyterlab-server # nbconvert # sphinx +importlib-resources==6.0.1 + # via feast (setup.py) iniconfig==2.0.0 # via pytest ipykernel==6.25.2 @@ -1080,7 +1083,9 @@ xmltodict==0.13.0 yarl==1.9.2 # via aiohttp zipp==3.16.2 - # via importlib-metadata + # via + # importlib-metadata + # importlib-resources # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/sdk/python/requirements/py3.9-requirements.txt b/sdk/python/requirements/py3.9-requirements.txt index 7d30fd3452b..a95bcd3524f 100644 --- a/sdk/python/requirements/py3.9-requirements.txt +++ b/sdk/python/requirements/py3.9-requirements.txt @@ -82,7 +82,11 @@ idna==3.4 # httpx # requests importlib-metadata==6.8.0 - # via dask + # via + # dask + # feast (setup.py) +importlib-resources==6.0.1 + # via feast (setup.py) jinja2==3.1.2 # via feast (setup.py) jsonschema==4.19.0 @@ -214,7 +218,9 @@ watchfiles==0.20.0 websockets==11.0.3 # via uvicorn zipp==3.16.2 - # via importlib-metadata + # via + # importlib-metadata + # importlib-resources # The following packages are considered to be unsafe in a requirements file: # setuptools diff --git a/setup.py b/setup.py index 5ca8fab5df4..2c5a4052dfc 100644 --- a/setup.py +++ b/setup.py @@ -80,6 +80,8 @@ # FastAPI does not correctly pull starlette dependency on httpx see thread(https://github.com/tiangolo/fastapi/issues/5656). "httpx>=0.23.3", "pyOpenSSL" + "importlib-resources>=6.0.0,<7", + "importlib_metadata>=6.8.0,<7" ] GCP_REQUIRED = [