Skip to content

Commit

Permalink
chore: Fix typing (#2534)
Browse files Browse the repository at this point in the history
* Remove Array, Float32, etc. as top-level imports

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Fix type imports in docs

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Fix type imports in templates

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Fix type imports in tests

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Fix doctests

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Format

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 authored Apr 14, 2022
1 parent eefc34a commit fbdd5fc
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 73 deletions.
15 changes: 10 additions & 5 deletions docs/getting-started/concepts/feature-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ A feature view is an object that represents a logical group of time-series featu
{% tabs %}
{% tab title="driver_trips_feature_view.py" %}
```python
from feast import BigQuerySource, FeatureView, Field, Float32, Int64
from feast import BigQuerySource, FeatureView, Field
from feast.types import Float32, Int64

driver_stats_fv = FeatureView(
name="driver_activity",
Expand Down Expand Up @@ -41,7 +42,8 @@ If a feature view contains features that are not related to a specific entity, t
{% tabs %}
{% tab title="global_stats.py" %}
```python
from feast import BigQuerySource, FeatureView, Field, Int64
from feast import BigQuerySource, FeatureView, Field
from feast.types import Int64

global_stats_fv = FeatureView(
name="global_stats",
Expand Down Expand Up @@ -74,7 +76,8 @@ It is suggested that you dynamically specify the new FeatureView name using `.wi
{% tabs %}
{% tab title="location_stats_feature_view.py" %}
```python
from feast import BigQuerySource, Entity, FeatureView, Field, Int32, ValueType
from feast import BigQuerySource, Entity, FeatureView, Field, ValueType
from feast.types import Int32

location = Entity(name="location", join_key="location_id", value_type=ValueType.INT64)

Expand Down Expand Up @@ -121,7 +124,8 @@ A feature is an individual measurable property. It is typically a property obser
Features are defined as part of feature views. Since Feast does not transform data, a feature is essentially a schema that only contains a name and a type:

```python
from feast import Field, Float32
from feast import Field
from feast.types import Float32

trips_today = Field(
name="trips_today",
Expand All @@ -138,7 +142,8 @@ Feature names must be unique within a [feature view](feature-view.md#feature-vie
On demand feature views allows users to use existing features and request time data (features only available at request time) to transform and create new features. Users define python transformation logic which is executed in both historical retrieval and online retrieval paths:

```python
from feast import Field, Float64, RequestSource
from feast import Field, RequestSource
from feast.types import Float64

# Define a request data source which encodes features / information only
# available at request time (e.g. part of the user initiated HTTP request)
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started/concepts/point-in-time-joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Feature values in Feast are modeled as time-series records. Below is an example
The above table can be registered with Feast through the following feature view:

```python
from feast import FeatureView, Field, FileSource, Float32, Int64
from feast import FeatureView, Field, FileSource
from feast.types import Float32, Int64

driver_stats_fv = FeatureView(
name="driver_hourly_stats",
Expand Down
6 changes: 4 additions & 2 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ online_store:

from datetime import timedelta

from feast import Entity, FeatureView, Field, FileSource, Float32, Int64, ValueType
from feast import Entity, FeatureView, Field, FileSource, ValueType
from feast.types import Float32, Int64

# Read data from parquet files. Parquet is convenient for local development mode. For
# production, you can use your favorite DWH, such as BigQuery. See Feast documentation
Expand Down Expand Up @@ -151,7 +152,8 @@ feast apply

from datetime import timedelta

from feast import Entity, FeatureView, Field, FileSource, Float32, Int64, ValueType
from feast import Entity, FeatureView, Field, FileSource, ValueType
from feast.types import Float32, Int64

# Read data from parquet files. Parquet is convenient for local development mode. For
# production, you can use your favorite DWH, such as BigQuery. See Feast documentation
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/alpha-on-demand-feature-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ See [https://github.com/feast-dev/on-demand-feature-views-demo](https://github.c
We register `RequestDataSource` inputs and the transform in `on_demand_feature_view`:

```python
from feast import Field, Float64, RequestSource
from feast import Field, RequestSource
from feast.types import Float64

# Define a request data source which encodes features / information only
# available at request time (e.g. part of the user initiated HTTP request)
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/data-sources/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ When using a PushSource as a stream source in the definition of a feature view,
### Defining a push source

```python
from feast import PushSource, ValueType, BigQuerySource, FeatureView, Feature, Field, Int64
from feast import PushSource, ValueType, BigQuerySource, FeatureView, Feature, Field
from feast.types import Int64

push_source = PushSource(
name="push_source",
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/feature-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ A feature repository can also contain one or more Python files that contain feat
```python
from datetime import timedelta
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, Float32, String, ValueType
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, ValueType
from feast.types import Float32, String
driver_locations_source = BigQuerySource(
table_ref="rh_prod.ride_hailing_co.drivers",
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/feature-repository/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ A feature repository can also contain one or more Python files that contain feat
```python
from datetime import timedelta
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, Float32, String, ValueType
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, ValueType
from feast.types import Float32, String
driver_locations_source = BigQuerySource(
table_ref="rh_prod.ride_hailing_co.drivers",
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorials/validating-historical-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ pyarrow.parquet.write_table(entities_2019_table, "entities.parquet")
import pyarrow.parquet
import pandas as pd

from feast import FeatureView, Entity, FeatureStore, Field, Float64, Int64
from feast import FeatureView, Entity, FeatureStore, Field
from feast.types import Float64, Int64
from feast.value_type import ValueType
from feast.data_format import ParquetFormat
from feast.on_demand_feature_view import on_demand_feature_view
Expand Down
23 changes: 0 additions & 23 deletions sdk/python/feast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
from .on_demand_feature_view import OnDemandFeatureView
from .repo_config import RepoConfig
from .request_feature_view import RequestFeatureView
from .types import (
Array,
Bool,
Bytes,
Float32,
Float64,
Int32,
Int64,
Invalid,
String,
UnixTimestamp,
)
from .value_type import ValueType

logging.basicConfig(
Expand Down Expand Up @@ -62,15 +50,4 @@
"RequestFeatureView",
"SnowflakeSource",
"PushSource",
# Types
"Array",
"Invalid",
"Bytes",
"String",
"Bool",
"Int32",
"Int64",
"Float32",
"Float64",
"UnixTimestamp",
]
3 changes: 2 additions & 1 deletion sdk/python/feast/templates/aws/driver_repo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

from feast import Entity, FeatureView, Field, Float32, Int64, RedshiftSource, ValueType
from feast import Entity, FeatureView, Field, RedshiftSource, ValueType
from feast.types import Float32, Int64

# Define an entity for the driver. Entities can be thought of as primary keys used to
# retrieve features. Entities are also used to join multiple tables/views during the
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/templates/gcp/driver_repo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

from feast import BigQuerySource, Entity, FeatureView, Field, Float32, Int64, ValueType
from feast import BigQuerySource, Entity, FeatureView, Field, ValueType
from feast.types import Float32, Int64

# Define an entity for the driver. Entities can be thought of as primary keys used to
# retrieve features. Entities are also used to join multiple tables/views during the
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/templates/local/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from datetime import timedelta

from feast import Entity, FeatureView, Field, FileSource, Float32, Int64, ValueType
from feast import Entity, FeatureView, Field, FileSource, ValueType
from feast.types import Float32, Int64

# Read data from parquet files. Parquet is convenient for local development mode. For
# production, you can use your favorite DWH, such as BigQuery. See Feast documentation
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/templates/snowflake/driver_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import yaml

from feast import Entity, FeatureView, Field, Float32, Int64, SnowflakeSource
from feast import Entity, FeatureView, Field, SnowflakeSource
from feast.types import Float32, Int64

# Define an entity for the driver. Entities can be thought of as primary keys used to
# retrieve features. Entities are also used to join multiple tables/views during the
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/templates/spark/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from datetime import timedelta
from pathlib import Path

from feast import Entity, FeatureView, Field, Float32, Int64, ValueType
from feast import Entity, FeatureView, Field, ValueType
from feast.infra.offline_stores.contrib.spark_offline_store.spark_source import (
SparkSource,
)
from feast.types import Float32, Int64

# Constants related to the generated data sets
CURRENT_DIR = Path(__file__).parent
Expand Down
12 changes: 2 additions & 10 deletions sdk/python/tests/doctest/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@ def setup_feature_store():
"""Prepares the local environment for a FeatureStore docstring test."""
from datetime import datetime, timedelta

from feast import (
Entity,
FeatureStore,
FeatureView,
Field,
FileSource,
Float32,
Int64,
ValueType,
)
from feast import Entity, FeatureStore, FeatureView, Field, FileSource, ValueType
from feast.repo_operations import init_repo
from feast.types import Float32, Int64

init_repo("feature_repo", "local")
fs = FeatureStore(repo_path="feature_repo")
Expand Down
4 changes: 1 addition & 3 deletions sdk/python/tests/example_repos/example_feature_repo_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
FeatureService,
FeatureView,
Field,
Float32,
Int64,
PushSource,
String,
ValueType,
)
from feast.types import Float32, Int64, String

driver_locations_source = BigQuerySource(
table="feast-oss.public.drivers",
Expand Down
12 changes: 2 additions & 10 deletions sdk/python/tests/example_repos/example_feature_repo_2.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
from datetime import timedelta

from feast import (
Entity,
FeatureView,
Field,
FileSource,
Float32,
Int32,
Int64,
ValueType,
)
from feast import Entity, FeatureView, Field, FileSource, ValueType
from feast.types import Float32, Int32, Int64

driver_hourly_stats = FileSource(
path="%PARQUET_PATH%", # placeholder to be replaced by the test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

from feast import Entity, FeatureView, Field, FileSource, Float32, Int64, ValueType
from feast import Entity, FeatureView, Field, FileSource, ValueType
from feast.types import Float32, Int64

driver_hourly_stats = FileSource(
path="%PARQUET_PATH%", # placeholder to be replaced by the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
import pandas as pd

from feast import (
Array,
Feature,
FeatureView,
Field,
Float32,
Float64,
Int32,
OnDemandFeatureView,
PushSource,
ValueType,
)
from feast.data_source import DataSource, RequestSource
from feast.types import FeastType
from feast.types import Array, FeastType, Float32, Float64, Int32
from tests.integration.feature_repos.universal.entities import location


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import requests
from botocore.exceptions import BotoCoreError

from feast import Entity, FeatureService, FeatureView, Field, String, ValueType
from feast import Entity, FeatureService, FeatureView, Field, ValueType
from feast.errors import (
FeatureNameCollisionError,
RequestDataNotFoundInEntityRowsException,
)
from feast.online_response import TIMESTAMP_POSTFIX
from feast.types import String
from feast.wait import wait_retry_backoff
from tests.integration.feature_repos.repo_configuration import (
Environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import pandas as pd
import pytest

from feast import Field, Float64
from feast import Field
from feast.errors import SpecifiedFeaturesNotPresentError
from feast.infra.offline_stores.file_source import FileSource
from feast.types import Float64
from tests.integration.feature_repos.universal.entities import customer, driver, item
from tests.integration.feature_repos.universal.feature_views import (
conv_rate_plus_100_feature_view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import pytest

from feast import BigQuerySource, FeatureView, Field, Float32, String
from feast import BigQuerySource, FeatureView, Field
from feast.types import Float32, String
from tests.utils.cli_utils import CliRunner, get_example_repo
from tests.utils.online_read_write_test import basic_rw_test

Expand Down

0 comments on commit fbdd5fc

Please sign in to comment.