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

Fix Python SDK ingestion for featureset name that exist in multiple projects #868

Merged
merged 5 commits into from
Jul 26, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions sdk/python/feast/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,39 @@ def ingest(
Returns:
str:
ingestion id for this dataset

Examples:
>>> from feast import Client
>>>
>>> feast_client = Client(core_url="localhost:6565")
>>> fs_df = pd.DataFrame(
>>> {
>>> "datetime": [pd.datetime.now()],
>>> "driver": [1001],
>>> "rating": [4.3],
>>> }
>>> )
>>> client.ingest("project1:driver", fs_df)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project:feature_set is not a valid feature reference. It would be better to have a project key on the method, or even look at the project that the user has configured in their environment.

>>> client.ingest("driver", fs_df) # default project
>>>
>>> driver_fs = client.get_feature_set(name="driver", project="project1")
>>> driver_fs = client.get_feature_set(name="driver") # default project
>>> client.ingest(driver_fs, fs_df)
"""

if isinstance(feature_set, FeatureSet):
name = feature_set.name
project = feature_set.project
elif isinstance(feature_set, str):
name = feature_set
if len(feature_set.split(":")) == 1:
name = feature_set
project = "default"
elif len(feature_set.split(":")) == 2:
project, name = feature_set.split(":")
else:
raise Exception(
"Feature set name is invalid, should be in <project>:<feature_set> or <feature_set> format."
)
else:
raise Exception("Feature set name must be provided")

Expand All @@ -858,7 +885,9 @@ def ingest(
while True:
if timeout is not None and time.time() - current_time >= timeout:
raise TimeoutError("Timed out waiting for feature set to be ready")
fetched_feature_set: Optional[FeatureSet] = self.get_feature_set(name)
fetched_feature_set: Optional[FeatureSet] = self.get_feature_set(
name, project
)
if (
fetched_feature_set is not None
and fetched_feature_set.status == FeatureSetStatus.STATUS_READY
Expand Down