-
Notifications
You must be signed in to change notification settings - Fork 1k
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: Update file api #2470
Merged
Merged
fix: Update file api #2470
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fc0d160
Update file
kevjumba d79d9d8
Fix
kevjumba 13adf24
Fix
kevjumba 9d5fe71
Lint
kevjumba 3c91830
Update the schema
kevjumba aad3322
Fix lint
kevjumba c59a7d6
Fix lint
kevjumba 3727bd2
Fix unit tests
kevjumba 4f6ffef
Keep file_url param
kevjumba 291463a
Fix
kevjumba 64c740b
Fix lint
kevjumba bab7542
Fix
kevjumba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import warnings | ||
from typing import Callable, Dict, Iterable, Optional, Tuple | ||
|
||
from pyarrow._fs import FileSystem | ||
|
@@ -60,7 +61,7 @@ def __init__( | |
) | ||
self.file_options = FileOptions( | ||
file_format=file_format, | ||
file_url=path, | ||
uri=path, | ||
s3_endpoint_override=s3_endpoint_override, | ||
) | ||
|
||
|
@@ -85,7 +86,6 @@ def __eq__(self, other): | |
|
||
return ( | ||
self.name == other.name | ||
and self.file_options.file_url == other.file_options.file_url | ||
and self.file_options.file_format == other.file_options.file_format | ||
and self.event_timestamp_column == other.event_timestamp_column | ||
and self.created_timestamp_column == other.created_timestamp_column | ||
|
@@ -102,15 +102,15 @@ def path(self): | |
""" | ||
Returns the path of this file data source. | ||
""" | ||
return self.file_options.file_url | ||
return self.file_options.uri | ||
|
||
@staticmethod | ||
def from_proto(data_source: DataSourceProto): | ||
return FileSource( | ||
name=data_source.name, | ||
field_mapping=dict(data_source.field_mapping), | ||
file_format=FileFormat.from_proto(data_source.file_options.file_format), | ||
path=data_source.file_options.file_url, | ||
path=data_source.file_options.uri, | ||
event_timestamp_column=data_source.event_timestamp_column, | ||
created_timestamp_column=data_source.created_timestamp_column, | ||
date_partition_column=data_source.date_partition_column, | ||
|
@@ -180,19 +180,20 @@ class FileOptions: | |
def __init__( | ||
self, | ||
file_format: Optional[FileFormat], | ||
file_url: Optional[str], | ||
s3_endpoint_override: Optional[str], | ||
uri: Optional[str], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wanted to confirm that this is not user facing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup isn't called anymore but maybe @adchia can also confirm? |
||
): | ||
""" | ||
FileOptions initialization method | ||
|
||
Args: | ||
file_format (FileFormat, optional): file source format eg. parquet | ||
file_url (str, optional): file source url eg. s3:// or local file | ||
s3_endpoint_override (str, optional): custom s3 endpoint (used only with s3 file_url) | ||
s3_endpoint_override (str, optional): custom s3 endpoint (used only with s3 uri) | ||
uri (str, optional): file source url eg. s3:// or local file | ||
|
||
""" | ||
self._file_format = file_format | ||
self._file_url = file_url | ||
self._uri = uri | ||
self._s3_endpoint_override = s3_endpoint_override | ||
|
||
@property | ||
|
@@ -210,18 +211,18 @@ def file_format(self, file_format): | |
self._file_format = file_format | ||
|
||
@property | ||
def file_url(self): | ||
def uri(self): | ||
""" | ||
Returns the file url of this file | ||
""" | ||
return self._file_url | ||
return self.uri | ||
|
||
@file_url.setter | ||
def file_url(self, file_url): | ||
@uri.setter | ||
def uri(self, uri): | ||
""" | ||
Sets the file url of this file | ||
""" | ||
self._file_url = file_url | ||
self._uri = uri | ||
|
||
@property | ||
def s3_endpoint_override(self): | ||
|
@@ -250,7 +251,7 @@ def from_proto(cls, file_options_proto: DataSourceProto.FileOptions): | |
""" | ||
file_options = cls( | ||
file_format=FileFormat.from_proto(file_options_proto.file_format), | ||
file_url=file_options_proto.file_url, | ||
uri=file_options_proto.uri, | ||
s3_endpoint_override=file_options_proto.s3_endpoint_override, | ||
) | ||
return file_options | ||
|
@@ -267,7 +268,7 @@ def to_proto(self) -> DataSourceProto.FileOptions: | |
file_format=( | ||
None if self.file_format is None else self.file_format.to_proto() | ||
), | ||
file_url=self.file_url, | ||
uri=self.uri, | ||
s3_endpoint_override=self.s3_endpoint_override, | ||
) | ||
|
||
|
@@ -286,16 +287,27 @@ def __init__( | |
s3_endpoint_override: Optional[str] = None, | ||
): | ||
self.file_options = FileOptions( | ||
file_url=path, | ||
file_format=file_format, | ||
s3_endpoint_override=s3_endpoint_override, | ||
uri=path, | ||
) | ||
|
||
@staticmethod | ||
def from_proto(storage_proto: SavedDatasetStorageProto) -> SavedDatasetStorage: | ||
file_options = FileOptions.from_proto(storage_proto.file_storage) | ||
if file_options.uri: | ||
path = file_options.uri | ||
else: | ||
path = file_options.file_url | ||
if path: | ||
warnings.warn( | ||
( | ||
"FileSource Proto is replacing the file_url field in FileOptions with uri soon." | ||
"Feast 0.23+ will no longer support file_url. Please change to using uri in your protos." | ||
), | ||
) | ||
return SavedDatasetFileStorage( | ||
path=file_options.file_url, | ||
path=path, | ||
file_format=file_options.file_format, | ||
s3_endpoint_override=file_options.s3_endpoint_override, | ||
) | ||
|
@@ -305,7 +317,7 @@ def to_proto(self) -> SavedDatasetStorageProto: | |
|
||
def to_data_source(self) -> DataSource: | ||
return FileSource( | ||
path=self.file_options.file_url, | ||
path=self.file_options.uri, | ||
file_format=self.file_options.file_format, | ||
s3_endpoint_override=self.file_options.s3_endpoint_override, | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should change this in place; serialized protobufs only use the index number not the field name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn't know that but that makes a lot of sense! Thanks for the suggestion that makes the update so much easier.