Compare commits

..

No commits in common. "repeat-v1-post-processing" and "main" have entirely different histories.

6 changed files with 23 additions and 89 deletions

View File

@ -1,10 +1 @@
## Overview **Hello world!!!**
This block (`block.py`) is responsible for assigning grade for the passed in probability.
## Key Inputs & Outputs
- **Request**: Refer to `request_schema.json` for detailed input fields and validation rules.
- **Response**: Refer to `response_schema.json` for the returned structure and data types.
## Implementation Details
- All core logic resides in `block.py` within the `__main__` function.
- Example usage and validation are demonstrated in `test_block.py`.

View File

@ -1,44 +1,21 @@
import logging @flowx_block
def example_function(request: dict) -> dict:
# Configure logging # Processing logic here...
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s - %(message)s",
)
logger = logging.getLogger(__name__)
def __main__(probability:float): return {
logger.info("Received input: probability=%.8f", float(probability)) "meta_info": [
{
if not isinstance(probability, (int, float)): "name": "created_date",
logger.error("Invalid input type: probability=%s", type(probability).__name__) "type": "string",
raise ValueError("Input probability must be a number (int or float)") "value": "2024-11-05"
}
if probability <= 0.3200099998: ],
bin = "1" "fields": [
elif 0.3200099998 < probability <= 0.4459999998: {
bin = "2" "name": "",
elif 0.4459999998 < probability <= 0.5394999999: "type": "",
bin = "3" "value": ""
elif 0.5394999999 < probability <= 0.6186978508: }
bin = "4" ]
elif 0.6186978508 < probability <= 0.6350320994: }
bin = "5"
elif 0.6350320994 < probability <= 0.6553314835:
bin = "6"
elif 0.6553314835 < probability <= 0.6759955555:
bin = "7"
elif 0.6759955555 < probability <= 0.7399999999:
bin = "8"
elif 0.7399999999 < probability <= 0.7899992753:
bin = "9"
elif 0.7899992753 < probability <= 0.8199900001:
bin = "10"
elif 0.8199900001 < probability <= 0.8400000009:
bin = "11"
else:
bin = "12"
logger.info(f"Repeat V1 Bin: {bin}")
return {"bin":bin}

View File

@ -1,11 +1 @@
{ {}
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"probability": {
"type": "number",
"description": "Model predicted score."
}
},
"required": []
}

View File

@ -1 +1 @@
jsonschema==4.23.0 {}

View File

@ -1,10 +1 @@
{ {}
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"bin": {
"type": "string",
"description": "Bin for the given input float."
}
}
}

View File

@ -1,15 +0,0 @@
import unittest
from block import __main__
class TestBlock(unittest.TestCase):
def test_main_success(self):
result = __main__(probability=0.2707298696)
self.assertEqual(result, {"bin": "1"})
def test_main_invalid_input(self):
with self.assertRaises(ValueError):
__main__(probability="0.27") # Invalid input type (string)
if __name__ == "__main__":
unittest.main()