From 52e3b483db08ef7218859fa36192e2df08209c9d Mon Sep 17 00:00:00 2001 From: Yusuf Olokoba Date: Fri, 3 May 2024 23:02:33 -0400 Subject: [PATCH] Bump `fxnc` --- Changelog.md | 2 +- fxn/services/prediction/fxnc.py | 17 ++++++++++++++--- fxn/services/prediction/service.py | 2 +- test/edge_test.py | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index dcd2a7a..d57e337 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,5 @@ ## 0.0.35 -*INCOMPLETE* ++ Updated to Function C 0.0.18. ## 0.0.34 + Fixed `fxn` import error caused by `fxn.predictions.stream` function. diff --git a/fxn/services/prediction/fxnc.py b/fxn/services/prediction/fxnc.py index 0d83878..4339537 100644 --- a/fxn/services/prediction/fxnc.py +++ b/fxn/services/prediction/fxnc.py @@ -55,12 +55,14 @@ class FXNValue(Structure): pass class FXNValueMap(Structure): pass class FXNConfiguration(Structure): pass class FXNPrediction(Structure): pass +class FXNPredictionStream(Structure): pass class FXNPredictor(Structure): pass FXNValueRef = POINTER(FXNValue) FXNValueMapRef = POINTER(FXNValueMap) FXNConfigurationRef = POINTER(FXNConfiguration) FXNPredictionRef = POINTER(FXNPrediction) +FXNPredictionStreamRef = POINTER(FXNPredictionStream) FXNPredictorRef = POINTER(FXNPredictor) def load_fxnc (path: Path) -> CDLL: @@ -171,15 +173,24 @@ def load_fxnc (path: Path) -> CDLL: # FXNPredictionGetLogLength fxnc.FXNPredictionGetLogLength.argtypes = [FXNPredictionRef, POINTER(c_int32)] fxnc.FXNPredictionGetLogLength.restype = FXNStatus + # FXNPredictionStreamRelease + fxnc.FXNPredictionStreamRelease.argtypes = [FXNPredictionStreamRef] + fxnc.FXNPredictionStreamRelease.restype = FXNStatus + # FXNPredictionStreamReadNext + fxnc.FXNPredictionStreamReadNext.argtypes = [FXNPredictionStreamRef, POINTER(FXNPredictionRef)] + fxnc.FXNPredictionStreamReadNext.restype = FXNStatus # FXNPredictorCreate fxnc.FXNPredictorCreate.argtypes = [FXNConfigurationRef, POINTER(FXNPredictorRef)] fxnc.FXNPredictorCreate.restype = FXNStatus # FXNPredictorRelease fxnc.FXNPredictorRelease.argtypes = [FXNPredictorRef] fxnc.FXNPredictorRelease.restype = FXNStatus - # FXNPredictorPredict - fxnc.FXNPredictorPredict.argtypes = [FXNPredictorRef, FXNValueMapRef, POINTER(FXNPredictionRef)] - fxnc.FXNPredictorPredict.restype = FXNStatus + # FXNPredictorCreatePrediction + fxnc.FXNPredictorCreatePrediction.argtypes = [FXNPredictorRef, FXNValueMapRef, POINTER(FXNPredictionRef)] + fxnc.FXNPredictorCreatePrediction.restype = FXNStatus + # FXNPredictorStreamPrediction + fxnc.FXNPredictorStreamPrediction.argtypes = [FXNPredictionRef, FXNValueMapRef, POINTER(FXNPredictionStreamRef)] + fxnc.FXNPredictorStreamPrediction.restype = FXNStatus # FXNGetVersion fxnc.FXNGetVersion.argtypes = [] fxnc.FXNGetVersion.restype = c_char_p diff --git a/fxn/services/prediction/service.py b/fxn/services/prediction/service.py index 2dc02f7..af98c72 100644 --- a/fxn/services/prediction/service.py +++ b/fxn/services/prediction/service.py @@ -371,7 +371,7 @@ def __predict (self, *, tag: str, predictor, inputs: Dict[str, Any]) -> Predicti value = to_fxn_value(fxnc, value, copy=False) fxnc.FXNValueMapSetValue(input_map, name.encode(), value) # Predict - status = fxnc.FXNPredictorPredict(predictor, input_map, byref(prediction)) + status = fxnc.FXNPredictorCreatePrediction(predictor, input_map, byref(prediction)) assert status.value == FXNStatus.OK, f"Failed to create {tag} prediction with status: {status.value}" # Marshal prediction id = create_string_buffer(256) diff --git a/test/edge_test.py b/test/edge_test.py index 9fb0f90..ae7a918 100644 --- a/test/edge_test.py +++ b/test/edge_test.py @@ -16,7 +16,7 @@ def test_load_fxnc (): def test_edge_math_prediction (): fxn = Function() - prediction = fxn.predictions.create(tag="@fxn/math", inputs={ "radius": 4 }) + prediction = fxn.predictions.create(tag="@yusuf/math", inputs={ "radius": 4 }) assert prediction is not None def test_edge_ml_prediction ():