Skip to content

Commit

Permalink
Bump fxnc
Browse files Browse the repository at this point in the history
  • Loading branch information
olokobayusuf committed May 4, 2024
1 parent 28d3f7f commit 52e3b48
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
17 changes: 14 additions & 3 deletions fxn/services/prediction/fxnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fxn/services/prediction/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/edge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ():
Expand Down

0 comments on commit 52e3b48

Please sign in to comment.