Skip to content

Commit 68a8737

Browse files
authored
fix: Fix warnings from deprecated paths and update default log level (feast-dev#3757)
1 parent a8aeee9 commit 68a8737

11 files changed

+56
-30
lines changed

sdk/python/feast/cli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from typing import List, Optional
1919

2020
import click
21-
import pkg_resources
2221
import yaml
2322
from colorama import Fore, Style
2423
from dateutil import parser
24+
from importlib_metadata import version as importlib_version
2525
from pygments import formatters, highlight, lexers
2626

2727
from feast import utils
@@ -68,7 +68,7 @@ def format_options(self, ctx: click.Context, formatter: click.HelpFormatter):
6868
)
6969
@click.option(
7070
"--log-level",
71-
default="info",
71+
default="warning",
7272
help="The logging level. One of DEBUG, INFO, WARNING, ERROR, and CRITICAL (case-insensitive).",
7373
)
7474
@click.option(
@@ -122,7 +122,7 @@ def version():
122122
"""
123123
Display Feast SDK version
124124
"""
125-
print(f'Feast SDK Version: "{pkg_resources.get_distribution("feast")}"')
125+
print(f'Feast SDK Version: "{importlib_version("feast")}"')
126126

127127

128128
@cli.command()

sdk/python/feast/infra/offline_stores/file_source.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def get_table_column_names_and_types(
158158
# Adding support for different file format path
159159
# based on S3 filesystem
160160
if filesystem is None:
161-
schema = ParquetDataset(path).schema
161+
schema = ParquetDataset(path, use_legacy_dataset=False).schema
162162
if hasattr(schema, "names") and hasattr(schema, "types"):
163163
# Newer versions of pyarrow doesn't have this method,
164164
# but this field is good enough.

sdk/python/feast/proto_json.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import uuid
22
from typing import Any, Callable, Type
33

4-
import pkg_resources
54
from google.protobuf.json_format import ( # type: ignore
65
_WKTJSONMETHODS,
76
ParseError,
87
_Parser,
98
_Printer,
109
)
10+
from importlib_metadata import version as importlib_version
1111
from packaging import version
1212

1313
from feast.protos.feast.serving.ServingService_pb2 import FeatureList
@@ -118,7 +118,7 @@ def from_json_object_updated(
118118

119119
# https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the
120120
# parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions.
121-
current_version = pkg_resources.get_distribution("protobuf").version
121+
current_version = importlib_version("protobuf")
122122
if version.parse(current_version) < version.parse("3.20"):
123123
_patch_proto_json_encoding(Value, to_json_object, from_json_object)
124124
else:
@@ -168,7 +168,7 @@ def from_json_object(
168168

169169
# https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the
170170
# parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions.
171-
current_version = pkg_resources.get_distribution("protobuf").version
171+
current_version = importlib_version("protobuf")
172172
if version.parse(current_version) < version.parse("3.20"):
173173
_patch_proto_json_encoding(RepeatedValue, to_json_object, from_json_object)
174174
else:
@@ -221,7 +221,7 @@ def from_json_object_updated(
221221

222222
# https://github.com/feast-dev/feast/issues/2484 Certain feast users need a higher version of protobuf but the
223223
# parameters of `from_json_object` changes in feast 3.20.1. This change gives users flexibility to use earlier versions.
224-
current_version = pkg_resources.get_distribution("protobuf").version
224+
current_version = importlib_version("protobuf")
225225
if version.parse(current_version) < version.parse("3.20"):
226226
_patch_proto_json_encoding(FeatureList, to_json_object, from_json_object)
227227
else:

sdk/python/feast/ui_server.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import threading
33
from typing import Callable, Optional
44

5-
import pkg_resources
5+
import importlib_resources
66
import uvicorn
77
from fastapi import FastAPI, Response
88
from fastapi.middleware.cors import CORSMiddleware
@@ -51,20 +51,21 @@ def shutdown_event():
5151

5252
async_refresh()
5353

54-
ui_dir = pkg_resources.resource_filename(__name__, "ui/build/")
55-
# Initialize with the projects-list.json file
56-
with open(ui_dir + "projects-list.json", mode="w") as f:
57-
projects_dict = {
58-
"projects": [
59-
{
60-
"name": "Project",
61-
"description": "Test project",
62-
"id": project_id,
63-
"registryPath": f"{root_path}/registry",
64-
}
65-
]
66-
}
67-
f.write(json.dumps(projects_dict))
54+
ui_dir_ref = importlib_resources.files(__name__) / "ui/build/"
55+
with importlib_resources.as_file(ui_dir_ref) as ui_dir:
56+
# Initialize with the projects-list.json file
57+
with ui_dir.joinpath("projects-list.json").open(mode="w") as f:
58+
projects_dict = {
59+
"projects": [
60+
{
61+
"name": "Project",
62+
"description": "Test project",
63+
"id": project_id,
64+
"registryPath": f"{root_path}/registry",
65+
}
66+
]
67+
}
68+
f.write(json.dumps(projects_dict))
6869

6970
@app.get("/registry")
7071
def read_registry():

sdk/python/requirements/py3.10-ci-requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ imagesize==1.4.1
366366
importlib-metadata==6.8.0
367367
# via
368368
# dask
369+
# feast (setup.py)
369370
# great-expectations
371+
importlib-resources==6.0.1
372+
# via feast (setup.py)
370373
iniconfig==2.0.0
371374
# via pytest
372375
ipykernel==6.25.2

sdk/python/requirements/py3.10-requirements.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ idna==3.4
8282
# httpx
8383
# requests
8484
importlib-metadata==6.8.0
85-
# via dask
85+
# via
86+
# dask
87+
# feast (setup.py)
88+
importlib-resources==6.0.1
89+
# via feast (setup.py)
8690
jinja2==3.1.2
8791
# via feast (setup.py)
8892
jsonschema==4.19.0

sdk/python/requirements/py3.8-ci-requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ importlib-metadata==6.8.0
370370
# via
371371
# build
372372
# dask
373+
# feast (setup.py)
373374
# great-expectations
374375
# jupyter-client
375376
# jupyter-lsp
@@ -379,6 +380,7 @@ importlib-metadata==6.8.0
379380
# sphinx
380381
importlib-resources==6.0.1
381382
# via
383+
# feast (setup.py)
382384
# jsonschema
383385
# jsonschema-specifications
384386
# jupyterlab
@@ -533,7 +535,7 @@ mypy-extensions==1.0.0
533535
# via
534536
# black
535537
# mypy
536-
mypy-protobuf==3.1
538+
mypy-protobuf==3.1.0
537539
# via feast (setup.py)
538540
mysqlclient==2.2.0
539541
# via feast (setup.py)

sdk/python/requirements/py3.8-requirements.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ idna==3.4
8282
# httpx
8383
# requests
8484
importlib-metadata==6.8.0
85-
# via dask
85+
# via
86+
# dask
87+
# feast (setup.py)
8688
importlib-resources==6.0.1
8789
# via
90+
# feast (setup.py)
8891
# jsonschema
8992
# jsonschema-specifications
9093
jinja2==3.1.2
@@ -105,7 +108,7 @@ mypy==1.5.1
105108
# via sqlalchemy
106109
mypy-extensions==1.0.0
107110
# via mypy
108-
mypy-protobuf==3.1
111+
mypy-protobuf==3.1.0
109112
# via feast (setup.py)
110113
numpy==1.24.4
111114
# via

sdk/python/requirements/py3.9-ci-requirements.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,16 @@ importlib-metadata==6.8.0
367367
# via
368368
# build
369369
# dask
370+
# feast (setup.py)
370371
# great-expectations
371372
# jupyter-client
372373
# jupyter-lsp
373374
# jupyterlab
374375
# jupyterlab-server
375376
# nbconvert
376377
# sphinx
378+
importlib-resources==6.0.1
379+
# via feast (setup.py)
377380
iniconfig==2.0.0
378381
# via pytest
379382
ipykernel==6.25.2
@@ -1080,7 +1083,9 @@ xmltodict==0.13.0
10801083
yarl==1.9.2
10811084
# via aiohttp
10821085
zipp==3.16.2
1083-
# via importlib-metadata
1086+
# via
1087+
# importlib-metadata
1088+
# importlib-resources
10841089

10851090
# The following packages are considered to be unsafe in a requirements file:
10861091
# pip

sdk/python/requirements/py3.9-requirements.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ idna==3.4
8282
# httpx
8383
# requests
8484
importlib-metadata==6.8.0
85-
# via dask
85+
# via
86+
# dask
87+
# feast (setup.py)
88+
importlib-resources==6.0.1
89+
# via feast (setup.py)
8690
jinja2==3.1.2
8791
# via feast (setup.py)
8892
jsonschema==4.19.0
@@ -214,7 +218,9 @@ watchfiles==0.20.0
214218
websockets==11.0.3
215219
# via uvicorn
216220
zipp==3.16.2
217-
# via importlib-metadata
221+
# via
222+
# importlib-metadata
223+
# importlib-resources
218224

219225
# The following packages are considered to be unsafe in a requirements file:
220226
# setuptools

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
"bowler", # Needed for automatic repo upgrades
8080
# FastAPI does not correctly pull starlette dependency on httpx see thread(https://github.com/tiangolo/fastapi/issues/5656).
8181
"httpx>=0.23.3",
82+
"importlib-resources>=6.0.0,<7",
83+
"importlib_metadata>=6.8.0,<7"
8284
]
8385

8486
GCP_REQUIRED = [

0 commit comments

Comments
 (0)