Create fallback_template.py
Browse files- fallback_template.py +54 -0
fallback_template.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fallback_template = {
|
| 2 |
+
"function_name": "deployable_function",
|
| 3 |
+
"function_code": """def your_function_name():
|
| 4 |
+
def score(input_data):
|
| 5 |
+
original_string = input_data.get("input_data")[0].get("values")[0][0]
|
| 6 |
+
append_string = input_data.get("input_data")[0].get("values")[0][1]
|
| 7 |
+
|
| 8 |
+
hello_world_message = "Hello World + {0}".format(original_string)
|
| 9 |
+
concatenated_string = original_string + append_string
|
| 10 |
+
|
| 11 |
+
score_response = {
|
| 12 |
+
'predictions': [{'fields': ['Response_message_field', 'Random_appended_string'],
|
| 13 |
+
'values': [[hello_world_message, concatenated_string]]
|
| 14 |
+
}]
|
| 15 |
+
}
|
| 16 |
+
return score_response
|
| 17 |
+
return score""",
|
| 18 |
+
"use_cases": ["add_tags"],
|
| 19 |
+
"input_schema": [
|
| 20 |
+
{
|
| 21 |
+
"id": "1",
|
| 22 |
+
"type": "struct",
|
| 23 |
+
"fields": [
|
| 24 |
+
{
|
| 25 |
+
"name": "<variable name 1>",
|
| 26 |
+
"type": "string",
|
| 27 |
+
"nullable": False,
|
| 28 |
+
"metadata": {},
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"name": "<variable name 2>",
|
| 32 |
+
"type": "string",
|
| 33 |
+
"nullable": False,
|
| 34 |
+
"metadata": {},
|
| 35 |
+
},
|
| 36 |
+
],
|
| 37 |
+
}
|
| 38 |
+
],
|
| 39 |
+
"output_schema": [
|
| 40 |
+
{
|
| 41 |
+
"id": "1",
|
| 42 |
+
"type": "struct",
|
| 43 |
+
"fields": [
|
| 44 |
+
{
|
| 45 |
+
"name": "<output return name>",
|
| 46 |
+
"type": "string",
|
| 47 |
+
"nullable": False,
|
| 48 |
+
"metadata": {},
|
| 49 |
+
}
|
| 50 |
+
],
|
| 51 |
+
}
|
| 52 |
+
],
|
| 53 |
+
"dependencies": ["<library_to_add>"],
|
| 54 |
+
}
|