GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feast/sdk/python/feast/transformation_server.py at master · feast-dev/feast

Expand file tree

/

transformation_server.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
78 lines (64 loc) · 2.6 KB
/

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()
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.