Skip to content

Commit 604df9e

Browse files
authored
update numpy-flight (#93)
* Update Dockerfile * cloud build * fixing docker release * Update README.md * Update README.md * Update cloudbuild.yaml * fmt * Update server.py * cloudbuild with logging * align server with example * cloudbuild with logging * Simpler server * pyarrow dependency * Simpler server * Simpler server * mini server * explicit publication of image * updating the server * bringing back the full server * passing all tests? * logging * passing all tests? * server back on Ball problem * remove pyarrow * server back on Ball problem * Makefile pointing to demo * update of numpy-flight
1 parent 5af78f7 commit 604df9e

File tree

4 files changed

+8
-115
lines changed

4 files changed

+8
-115
lines changed

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies = [
99
"cvxpy-base>=1.6.0",
1010
"numpy>=2",
1111
"clarabel>=0.10.0",
12-
"numpy-flight>=0.0.7",
12+
"numpy-flight>=0.0.9",
1313
]
1414

1515
[project.urls]
@@ -50,6 +50,7 @@ DEP003 = ["cvx"]
5050

5151
[tool.bandit]
5252
exclude_dirs = ["tests"]
53+
exclude = ["B104"]
5354

5455
[project.scripts]
5556
#server = "cvx.ball.server:BallServer.start"

src/cvx/ball/__init__.py

-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
# Copyright 2025 Stanford University Convex Optimization Group
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.

src/cvx/ball/server.py

+2-74
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import logging
2-
31
import numpy as np
4-
from np.flight import Server
2+
from tschm.flight import Server
53

64
from cvx.ball.solver import min_circle_cvx
75

8-
logging.basicConfig(level=logging.INFO)
9-
logger = logging.getLogger(__name__)
10-
116

127
class BallServer(Server):
138
def f(self, matrices: dict[str, np.ndarray]) -> dict[str, np.ndarray]:
@@ -28,72 +23,5 @@ def f(self, matrices: dict[str, np.ndarray]) -> dict[str, np.ndarray]:
2823
return {"radius": radius, "midpoint": midpoint, "points": matrix}
2924

3025

31-
# def serve(port=8080):
32-
# # Create the server instance
33-
# location = f"grpc://0.0.0.0:{port}"
34-
# server = FlightServer(location=location)
35-
#
36-
# # Start the server
37-
# server.serve()
38-
# print(f"Flight Server is listening on port {port}...")
39-
#
40-
#
41-
# # entry point for Docker
42-
# if __name__ == "__main__": # pragma: no cover
43-
# serve()
44-
# # BallServer.start(host="0.0.0.0", port=8080) # nosec: B104
45-
46-
#
47-
# class FlightServer(pyarrow.flight.FlightServerBase):
48-
# def __init__(self, location):
49-
# super().__init__(location)
50-
# logger.info(f"Flight Server started at {location}")
51-
#
52-
# def do_get(self, context, ticket):
53-
# try:
54-
# logger.info(f"Received do_get request for ticket: {ticket}")
55-
# # Example data
56-
# data = pa.array([1, 2, 3, 4, 5])
57-
# table = pa.table({"numbers": data})
58-
# return pyarrow.flight.RecordBatchStream(table)
59-
# except Exception as e:
60-
# logger.error(f"Error in do_get: {e}")
61-
# raise
62-
#
63-
# def do_put(self, context, descriptor, reader):
64-
# try:
65-
# logger.info(f"Received do_put request for descriptor: {descriptor}")
66-
# # Read the data (for demonstration, we just log the schema)
67-
# table = reader.read_all()
68-
# logger.info(f"Received table with schema: {table.schema}")
69-
# return None
70-
# except Exception as e:
71-
# logger.error(f"Error in do_put: {e}")
72-
# raise
73-
#
74-
# def get_flight_info(self, context, descriptor):
75-
# """Provide metadata about available flights."""
76-
# key = descriptor.command
77-
# if key not in self.flights:
78-
# raise pyarrow.flight.FlightUnavailableError(f"Flight {key} not found")
79-
#
80-
# # Create a FlightInfo object with metadata
81-
# schema = self.flights[key].schema
82-
# endpoint = pyarrow.flight.FlightEndpoint(key, [self.location])
83-
# return pyarrow.flight.FlightInfo(schema, descriptor, [endpoint])
84-
85-
86-
def serve(port=8080):
87-
# Create the server instance
88-
# location = f"grpc://0.0.0.0:{port}"
89-
server = BallServer(host="0.0.0.0", port=port) # nosec:B104 # .start()
90-
# FlightServer(location=location)
91-
92-
# Start the server
93-
logger.info(f"Starting Flight Server on port {port}...")
94-
# not needed
95-
server.serve()
96-
97-
9826
if __name__ == "__main__": # pragma: no cover
99-
serve()
27+
BallServer.start()

uv.lock

+4-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)