FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feast/sdk/python/feast/transformation_server.py at apply-progress · feast-dev/feast · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
feast-dev
/
feast
Public
Notifications
You must be signed in to change notification settings
Fork
1.4k
Star
7.2k
Code
Issues
218
Pull requests
191
Discussions
Actions
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
transformation_server.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
78 lines (64 loc) · 2.6 KB
Breadcrumbs
feast
/
sdk
/
python
/
feast
/
transformation_server.py
Copy path
File metadata and controls
78 lines (64 loc) · 2.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import
logging
import
sys
from
concurrent
import
futures
import
grpc
import
pyarrow
as
pa
from
grpc_reflection
.
v1alpha
import
reflection
from
feast
.
errors
import
OnDemandFeatureViewNotFoundException
from
feast
.
feature_store
import
FeatureStore
from
feast
.
protos
.
feast
.
serving
.
TransformationService_pb2
import
(
DESCRIPTOR
,
TRANSFORMATION_SERVICE_TYPE_PYTHON
,
GetTransformationServiceInfoResponse
,
TransformFeaturesResponse
,
ValueType
,
)
from
feast
.
protos
.
feast
.
serving
.
TransformationService_pb2_grpc
import
(
TransformationServiceServicer
,
add_TransformationServiceServicer_to_server
,
)
from
feast
.
version
import
get_version
log
=
logging
.
getLogger
(
__name__
)
class
TransformationServer
(
TransformationServiceServicer
):
def
__init__
(
self
,
fs
:
FeatureStore
)
->
None
:
super
().
__init__
()
self
.
fs
=
fs
def
GetTransformationServiceInfo
(
self
,
request
,
context
):
response
=
GetTransformationServiceInfoResponse
(
type
=
TRANSFORMATION_SERVICE_TYPE_PYTHON
,
transformation_service_type_details
=
f"Python:
{
sys
.
version
}
, Feast:
{
get_version
()
}
"
,
)
return
response
def
TransformFeatures
(
self
,
request
,
context
):
try
:
odfv
=
self
.
fs
.
get_on_demand_feature_view
(
request
.
on_demand_feature_view_name
)
except
OnDemandFeatureViewNotFoundException
:
context
.
set_code
(
grpc
.
StatusCode
.
INVALID_ARGUMENT
)
raise
df
=
pa
.
ipc
.
open_file
(
request
.
transformation_input
.
arrow_value
).
read_all
()
if
odfv
.
mode
!=
"pandas"
:
raise
Exception
(
f'OnDemandFeatureView mode "
{
odfv
.
mode
}
" not supported by TransformationServer.'
)
result_arrow
=
odfv
.
transform_arrow
(
df
,
True
)
sink
=
pa
.
BufferOutputStream
()
writer
=
pa
.
ipc
.
new_file
(
sink
,
result_arrow
.
schema
)
writer
.
write_table
(
result_arrow
)
writer
.
close
()
buf
=
sink
.
getvalue
().
to_pybytes
()
return
TransformFeaturesResponse
(
transformation_output
=
ValueType
(
arrow_value
=
buf
)
)
def
start_server
(
store
:
FeatureStore
,
port
:
int
):
server
=
grpc
.
server
(
futures
.
ThreadPoolExecutor
(
max_workers
=
10
))
add_TransformationServiceServicer_to_server
(
TransformationServer
(
store
),
server
)
service_names_available_for_reflection
=
(
DESCRIPTOR
.
services_by_name
[
"TransformationService"
].
full_name
,
reflection
.
SERVICE_NAME
,
)
reflection
.
enable_server_reflection
(
service_names_available_for_reflection
,
server
)
server
.
add_insecure_port
(
f"[::]:
{
port
}
"
)
server
.
start
()
server
.
wait_for_termination
()
Back
|
FazBrowse Home
|
New Git URL