Represent a Vector<ManagedAddress> output in Mandos? - elrond

I am writing a mandos json test.
This is my method.
It returns a vector with addresses. I know with good probability this method works, I just need to test it, (I don't know how to write the test).
#[storage_mapper("match_id_to_address_map")]
#[view(getMatchIdToAddressMap)]
fn match_id_to_address_map(&self, match_id: u32) -> SingleValueMapper<Vec<ManagedAddress>>;
I want to write a test that makes sure it returns a vector with 2 addresses.
this is my mandos test:
{
"name": "new user with auto match",
"steps": [
// snipped for readability
{
"step": "scCall",
"txId": "9",
"tx": {
"from": "address:user_one",
"to": "sc:waiting_room",
"function": "getMatchIdToAddressMap",
"arguments": [
"1"
],
"gasLimit": "100000000",
"gasPrice": "1"
},
"expect": {
"out": [
"u64:0|address:owner|address:user_one" // <- !!! IDK what to do here !!!
],
"status": "",
"logs": [],
"gas": "*",
"refund": "*"
}
}
]
}
this is my error output:
Command line: ['/home/dan/elrondsdk/vmtools/mandos-test', '/home/dan/Elrond/SmartContracts/rooms/mandos']
Output: Scenario: deploy_and_wait.scen.json ... ok
Scenario: duplicate_wait.scen.json ... ok
Scenario: new_address_and_match.scen.json ... FAIL: result mismatch. Tx 9. Want: ["u64:0|address:owner|address:user_one"]. Have: [0x6f776e65725f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f757365725f6f6e655f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f5f]
Done. Passed: 2. Failed: 1. Skipped: 0.
ERROR: some tests failed

The actual decoded hex equals to
owner___________________________user_one________________________
We can see that the u64:0 isn't represented.
I don't have the answer, but I have a lead.
Look at the serialization documentation and replace u64:0 with the top level-encoding
The doc: https://docs.elrond.com/developers/developer-reference/elrond-serialization-format/

Related

IBM Speech To Text - Get alternative with highest confidence and keyword found as first result

I'm using IBM Speech to Text. The results are OK, but I'm wondering why they are not sorted by highest confidence first. Is there a parameter returning this sorted, so that I could just pick the first alternative? Best would be to only return a result if also the passed keyword is also found.
There is a max_alternatives parameter defaulting to 1, but also when specifying this explicitly, more than one alternative is returned.
I'm currently sorting the response manually and I need no code sample for accomplishing this.
JSON example:
"result": {
"result_index": 0,
"results": [
{
"final": true,
"alternatives": [
{
"transcript": "l\u00f6schen es tut echte betroffen ",
"confidence": 0.71
}
],
"keywords_result": {}
},
{
"final": true,
"alternatives": [
{
"transcript": "sie sp\u00fcren dass eine \u00e4ra zu ende ",
"confidence": 0.91
}
],
"keywords_result": {}
},
{
"final": true,
"alternatives": [
{
"transcript": "auto fahre eins zwei drei vier ",
"confidence": 0.95
}
],
"keywords_result": {
"auto": [
{
"start_time": 6.31,
"end_time": 7.19,
"confidence": 0.99,
"normalized_text": "auto"
}
]
}
}
]
},
...
The issue was the end_of_phrase_silence_time. When a default 0.8 silence period is detected, the speech is split into an additional phrase. So what I have seen is not a different recognition result, but an existing phrase in the audio recording mentioned before. See the parameter end_of_phrase_silence_time

Failed to run the pipeline (Pipeline) - Azure Data Factory

For testing purposes I'm trying to execute this simple pipeline (nothing sophisticated).
However, I'm getting this error:
{"code":"BadRequest","message":null,"target":"pipeline//runid/cb841f14-6fdd-43aa-a9c1-4619dab28cdd","details":null,"error":null}
The goal is to see if two variables are getting the right values (we have been facing some issues in our production environment).
This is the json with the definition of the pipeline:
{
"name": "GeneralTest",
"properties": {
"activities": [
{
"name": "Set variable1",
"type": "SetVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "start_time",
"value": {
"value": "#utcnow()",
"type": "Expression"
}
}
},
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [
{
"activity": "Set variable1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 5
}
},
{
"name": "Set variable2",
"description": "",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Wait1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "end_time ",
"value": {
"value": "#utcnow()",
"type": "Expression"
}
}
}
],
"variables": {
"start_time": {
"type": "String"
},
"end_time ": {
"type": "String"
}
},
"folder": {
"name": "Old Pipelines"
},
"annotations": []
}
}
What am I missing, or what could be the problem with this process?
You are having a "blank space" after the variable name end_time like "end_time "
You can see the difference in my repro:
MyCode VS YourCode
Clearing that would make the execution just fine.
I faced a similar issue when doing a Debug run of one of my pipelines. The error messages for these types of errors are not helpful when running in Debug mode.
What I have found is that if you publish the pipeline and then Trigger a Pipeline Run (instead of a Debug run), you can then go to Monitor Pipeline Runs and it will show you a more useful error message.
Apart from possible blank spaces in variable or parameter names, Data Factory doesn't like hyphens, but only in parameter names, variables are fine.
Validation passes, but then in debug time you get the same cryptic error
I ran into this same error message in Data Factory today on the Copy activity. Everything passed validation but this error would pop on each debug run.
I have parameters configured on my dataset connections so that I can use dynamic queries against the data sources. In this case, I was using explicit queries, so the parameters appeared irrelevant. I tried with both blank values and value is null. Both failed the same way.
I tried with stupid but real text values and it worked! The pipeline isn't leveraging the stupid values for any work, so their content doesn't matter, but some portion of the engine needs a non-null value in the parameters in order to execute.

Sending values between cards with BotFramework Composer

Good morning!
I am starting with BotFramework Composer tool using the template RespondingWithCardsSample and I am having problems testing the send of value from one card to another.
On the one hand, I have edited the AdaptivecardJson card with the following basic code.
#adaptivecardjson
- ```
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Input.ChoiceSet",
"placeholder": "Adults",
"choices": [
{
"title": "1",
"value": "1"
},
{
"title": "2",
"value": "2"
},
{
"title": "3",
"value": "3"
},
{
"title": "4",
"value": "4"
}
],
"id": "InputAdultos"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Send"
}
]
}
This card simply contains an input text indicating the number of adults, the send button and inflates the following card:
#AdaptiveCard
[Activity
Attachments = #{json(adaptivecardjson())}
]
Finally, I created another card which simply writes the number of adults received:
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is #{InputAdults}
]
But I just didn't understand how it works and it gives me the following error:
common.lg: Error occurs when evaluating expression bfdactivity-028800 (): Error occurs when evaluating expression HeroCardAdults (): Specified argument was out of the range of valid values.
Parameter name: ‘inputadults’ does not match memory scopes: user, conversation, turn, settings, dialog, class, this
Has it happened to someone else?
Thanks!
Change your template to
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is {InputAdults}
]
or if you want to use memory scopes, set your value to dialog.InputAdults and use this template
# HeroCardAdults
[HeroCard
text = The number of adults is {dialog.InputAdults}
]

Dialogflow V2 API says my Webhook response was empty

I am trying to use the Dialogflow V2 API to add two numbers, to do this I have setup a web server with HTTPS access to complete the request. in the Diagnostic Info screen in the Dialogflow console I can see the Fulfilment Response from my remote server:
{
"fulfillmentText": "the sum of 5 and 9 is 14",
"fulfillmentMessages": [
{
"text": {
"text": [
"the sum of 5 and 9 is 14"
]
}
}
],
"source": "-------.com",
"payload": {
"google": {
"expectUserResponse": 1,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "the sum of 5 and 9 is 14"
}
}
]
}
},
"facebook": {
"text": "the sum of 5 and 9 is 14"
},
"slack": {
"text": "the sum of 5 and 9 is 14"
}
},
"outputContexts": [
{
"name": "-----892446d1-----",
"lifespanCount": 1,
"parameters": {
"number": 5,
"number1": 9
}
}
]
}
Which has been adapted from the example given in the docs: https://dialogflow.com/docs/intro/fulfillment but in the Raw API response I see:
"webhookStatus": {
"code": 3,
"message": "Webhook call failed. Error: Webhook response was empty."
}
Clearly the response is not empty as it can be seen in the Diagnostic Info. Has anyone any ideas as to what is causing this?
Thanks
We can find definition of the codes in google.rpc package error codes,
"code": 3
means "INVALID_ARGUMENT"
// The client specified an invalid argument. Note that this differs
// from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
// that are problematic regardless of the state of the system //
(e.g., a malformed file name).
For example according to request format "parameters" field in "outputContexts" should have format "param": "param value", in your request it looks like "param": param value.
Please check all arguments in your request.

Getting started with Step Functions and I can't get Choice to work correctly

I'm doctoring up my first step function, and as a newb into this I am struggling to make this work right. The documentation on AWS is helpful but lacks examples of what I am trying understand. I found a couple similar issues on the site here, but they didn't really answer my question either.
I have a test Step Function that works really simply. I have a small Lambda function that kicks out a single line JSON with a "Count" from a request in a DynamoDB:
def lambda_handler(event, context):
"""lambda_handler
Keyword arguments:
event -- dict -- A dict of parameters to be validated.
context --
Return:
json object with the hubID from DynamoDB of the new hub.
Exceptions:
None
"""
# Prep the Boto3 resources needed
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('TransitHubs')
# By default we assume there are no new hubs
newhub = { 'Count' : 0 }
# Query the DynamoDB to see if the name exists or not:
response = table.query(
IndexName='Status-index',
KeyConditionExpression=Key('Status').eq("NEW"),
Limit=1
)
if response['Count']:
newhub['Count'] = response['Count']
return json.dumps(newhub)
A normal output would be:
{ "Count": 1 }
And then I create this Step Function:
{
"StartAt": "Task",
"States": {
"Task": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-west-2:OMGSUPERSECRET:function:LaunchNode-get_new_hubs",
"TimeoutSeconds": 60,
"Next": "Choice"
},
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.Count",
"NumericEquals": 0,
"Next": "Failed"
},
{
"Variable": "$.Count",
"NumericEquals": 1,
"Next": "Succeed"
}
]
},
"Succeed": {
"Type": "Succeed"
},
"Failed": {
"Type": "Fail"
}
}
}
So I kick off the State Function and I get this output:
TaskStateExited
{
"name": "Task",
"output": {
"Count": 1
}
}
ChoiceStateEntered
{
"name": "Choice",
"input": {
"Count": 1
}
}
ExecutionFailed
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'Choice' (entered at the event id #7). Invalid path '$.Count': The choice state's condition path references an invalid value."
}
So my question: I don't get why this is failing with that error message. Shouldn't Choice just pick up that value from the JSON? Isn't the default "$" input the "input" path?
I have figured out what the issue is, and here it is:
In my Python code, I was attempting to json.dumps(newhub) for the response thinking that what I needed was a string output representing the json formatted response. But it appears that is incorrect. When I alter the code to be simply "return newhub" and return the DICT, the step-functions process accepts that correctly. I'm assuming it parses the DICT to JSON for me? But the output difference is clearly obvious:
old Task output from above returning json.dumps(newhub):
{
"name": "Task",
"output": {
"Count": 1
}
}
new Task output from above returning newhub:
{
"Count": 1
}
And the Choice now correctly matches the Count variable in my output.
In case this is helpful for someone else. I also experienced the kind of error you did ( you had the below... just copy-pasting yours... )
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'Choice' (entered at the event id #7). Invalid path '$.Count': The choice state's condition path references an invalid value."
}
But my problem turned out when I was missing the "Count" key all together.
But I did not want verbose payloads.
But per reading these docs I discovered I can also do...
"Choice": {
"Type": "Choice",
"Choices": [
{
"And": [
{
"Variable": "$.Count",
"IsPresent": true
},
{
"Variable": "$.Count",
"NumericEquals": 0,
}
],
"Next": "Failed"
},
{
"And": [
{
"Variable": "$.Count",
"IsPresent": true
},
{
"Variable": "$.Count",
"NumericEquals": 1,
}
],
"Next": "Succeed"
}
]
},
even I was facing the same issue. Give the ResultPath as InputPath and give the choice value as .value name
{
"Comment": "Step function to execute lengthy synchronous requests",
"StartAt": "StartProcessing",
"States": {
"StartProcessing": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:703569030910:function:shravanthDemo-shravanthGetItems-GHF7ZA1p6auQ",
"InputPath": "$.lambda",
"ResultPath": "$.lambda",
"Next": "VerifyProcessor"
},
"VerifyProcessor": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.lambda.cursor",
"IsNull": false,
"Next": "StartProcessing"
},
{
"Variable": "$.lambda.cursor",
"IsNull": true,
"Next": "EndOfUpdate"
}
]
},
"EndOfUpdate": {
"Type": "Pass",
"Result": "ProcessingComplete",
"End": true
}
}
}

Resources