Got error "unknown keyword: version" when encode data using ruby gem avro turf with schema registry - ruby

I have used Ruby gem avro_turf to convert data to binary and publish it to Kafka. But I got an error unknown keyword: version when try to encode data.
I have started Confluent Schema Registry on localhost:8081. I can create and read subject on terminal.
I scan its source code, there is a "version" param in encode function.
I curl curl -X GET http://127.0.0.1:8081/subjects/avro-test/versions/1 to Schema Registry and get this data
{"subject":"avro-test","version":1,"id":1,"schema":"{\"type\":\"record\",\"name\":\"evolution\",\"namespace\":\"com.landoop\",\"doc\":\"This is a sample Avro schema to get you started. Please edit\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"phone\",\"type\":\"string\"},{\"name\":\"email\",\"type\":\"string\"}]}"}
This is my current code
require "avro_turf/messaging"
avro = AvroTurf::Messaging.new(registry_url: "http://localhost:8081/")
data = avro.encode('{ "name" => "hello, world", "phone": "01232323", "email": "hello#gmail.com" }', subject: 'avro-test', version: 1)
Please help me for solution.

I scan its source code, there is a "version" param in encode function.
Yes, the problem is, you're looking at the current state of master branch. As of now, it contains unreleased changes, this keyword included.
So either wait for next version to be released, or use master directly
gem "avro_turf", github: "dasch/avro_turf"

Related

Need a 'text' parameter to parse duckling rasa x

I am trying to run duckling locally. So with the help of this article I installed stack, and then
cloned duckling code
git clone https://github.com/facebook/duckling.git
download the zoneinfo and updated the reference in exe/ExampleMain.hs
let defaultPath = "duckling/exe/zoneinfo/"
let fallbackPath = "exe/zoneinfo/"
build using
stack build
then run using
stack exec duckling-example-exe
now if i hit http://localhost:8000/parse in the postman with request type POST and with following content
{
"text": "tommorow",
"locale": "de_DE",
"tz": "Europe/Berlin",
"dims": [
"time"
],
"reftime": 1616571265000
}
it shows 422 bad input
Need a 'text' parameter to parse
and if i hit the same request again it shows 200 OK
quack!
any help?
I see that you are trying to send the request as a JSON, however, the "http://localhost:8000/parse" endpoint expects the input to be sent as "form-encoded" data.
Refer to this image for a sample snapshot - https://i.stack.imgur.com/Cqdz4.png
You can check the source code of RASA open source. They are using requests python library to use duckling inside RASA for data parsing.
Here is the source code, here
It will be so useful to know the correct format of text data.
Also, I will show you how to use duckling through a simple example:
Be sure that you compile and run the binary:
$ stack build
$ stack exec duckling-example-exe
Insdie pythod code environment or any IDE that support python run the following:
import requests
t = requests.post('http://0.0.0.0:8000/parse', data={'text':'tomorrow at eight', 'locale':'en_GB'})
print(t.text)
The output is
[{"body":"tomorrow at eight","start":0,"value":{"values":[{"value":"2021-09-27T08:00:00.000-07:00","grain":"hour","type":"value"},{"value":"2021-09-27T20:00:00.000-07:00","grain":"hour","type":"value"}],"value":"2021-09-27T08:00:00.000-07:00","grain":"hour","type":"value"},"end":17,"dim":"time","latent":false}]

Generate Swagger json at Build time

I'm working on a ASP.NET Core WebAPI project and I'm trying to find a way to generate swagger json at build time ?
As i'm working with 4 environments, i'd like to have 4 swagger.json with a different name of my choice, like:
swagger_{appName}dev{buildNumber}.json
swagger_{appName}demo{buildNumber}.json
swagger_{appName}int{buildNumber}.json
swagger_{appName}staging{buildNumber}.json
Is it also possible to edit the fields in the json ? I'd like to edit (depending of the environment) the following fields : host, schemes and basePath.
I'm using Swashbuckle.AspNetCore but it appears it doesn't have an option to do such task or am I wrong ?
Thanks in advance
You have the option of generating OpenApi json file(s) from the command line without deploying using the Swashbuckle.AspNetCore.Cli nuget package.
The command will look something like this and can be added as a "post build" script
dotnet <nugetpackages>\Swashbuckle.AspNetCore.Cli\bin\$(Configuration)\netcoreapp<ver>\dotnet-swagger.dll tofile --host http://localhost --output swagger.json <bin>\<AssemblyName>.dll v1
more details can be found here https://github.com/domaindrivendev/Swashbuckle.AspNetCore#swashbuckleaspnetcorecli
I'm not sure about generating separate files for each environment offhand
The simple way is using PowerShell task to update json file and save with another name.
Simple workflow:
Read the file through Get-Content script
Using ConvertFrom-Json to converts content to object
Set the property value to update object
Using ConvertTo-Json to convert an object to a JSON-formatted string
Using Set-Content to write content to a file
For detail code, you can refer to this thread: how do I update json file using powershell.
The build number value is stored in the predefined variable: Build.BuildNumber (PowerShell: $env:BUILD_BUILDNUMBER)

Get hiera value in puppet manifest with nested keys

I'm new to using hiera with puppet (and somewhat new to puppet).
I've written this bit of yaml:
---
web_mysql_server:
mysql_database: "my_production"
and then I try to use it in a puppet manifest thus:
database => hiera('web_mysql_server::mysql_database'),
And this does not work, generating the error
Error: Could not find data item web_mysql_server::mysql_database
in any Hiera data file and no default supplied at
/vagrant/puppet/modules/web_mysql_server/manifests/init.pp:33
on node railstest.vm
(where I've added some '\n''s for readability here).
I suspect (hope!) this is a simple syntax error that I'm not getting. Anyone see what I'm doing wrong?
Based in hiera documentation, the proper syntax for accessing nested keys is
hiera('web_mysql_server.mysql_database')
This syntax for qualified keys has not been around always, the documentation says it's from Hiera 2.0.
I know we use puppet 3.8.3 and qualified keys are not supported yet in our setup. We work around this limitation with this approach:
$mysql_configuration = hiera('web_mysql_server')
# ...
database => $mysql_configuration['mysql_database']

Export data from Elasticsearch to CSV using Logstash

How can I export data from Elasticsearch to CSV using Logstash? I need to include only specific columns.
Install 2 plugins: elasticsearch input plugin and csv output plugin.
Then create a configuration file. Here is a good example for this particular case.
You are ready to go now, just run:
bin/logstash -f /path/to/logstash-es-to-csv-example.conf
And check export.csv file specified in output -> csv -> path.
Important note:
There is a known bug in csv output plugin when working with Logstash 5.x. The plugin generates a string of %{host} %{message}%{host} %{message}%{host} %{message}.
There's an open issue for it: https://github.com/logstash-plugins/logstash-output-csv/issues/10
As a workaround you may:
downgrade to Logstash 2.x until this gets resolved
use the file output instead
file {
codec => line { format => "%{field1},%{field2}"}
path => "/path/to/data_export.csv"
}
modify the plugin's code according to the github discussion...

parse.exe not seeing my projects

I am trying to configure my machine to deploy Parse Cloud Code. This requires downloading and running ParseDeploy.exe, followed by parse new.
I am running Win 8.1, and using the latest parse-windows-2.0.7.exe.
The folder structure is correctly created.
After entering my email & password, I am meant to see a list of my apps. Instead I am seeing:
1: results
Select an App:
"results" is not the name of any of my 3 apps.
This is what the PowerShell output looks like:
PS E:\...\demo> parse new
Creating a new project in directory E:\...\demo\parse
Creating directory E:\...\demo\parse\config
Creating config file E:\...\demo\parse\config\global.js
on
Creating directory E:\...\demo\parse\cloud
Writing out sample file E:\...\demo\parse\cloud\main.js
Creating directory E:\...\demo\parse\public
Writing out sample file E:\...\demo\parse\public\index.
html
Email: richard#glowworm.mobi
Password:
1: results
Select an App:
Related post:
Parse: No list of apps from Parse in CTL windows 7
I have used this successfully on previous projects. What has changed?
Some very old versions of the Parse command line utility may run into this issue due to some backend changes. You can get around this issue by making sure you're running the latest version of the command line utility, available at https://parse.com/docs/downloads
I also recommend joining the Parse developer mailing list, where we made an announcement a couple of weeks ago recommending that people make sure they update their command line utility prior to the backend change going into effect: https://groups.google.com/forum/#!topic/parse-developers/WoRnDft4qmE
Update
v2.1.3 fixes this issue, and works correctly on my machine.
What has changed? Parse has made updates, requiring a new version of parse.exe to be downloaded.
Unfortunately the initial new versions do not work.
Workaround
I have rolled back to using v1.4.2 of parse.exe.
It is currently working for deploying projects.
However, it breaks when creating a new project with parse new (as per my question).
The file that breaks is .\config\global.json - it seems to be in a new format, and it tries to reference this non-existent "results" project.
What I have done is to an existing global.json file from an older project, and manually edit it to update the values for my new project. Here is an example:
{
"global": {
"parseVersion": "1.4.2"
},
"applications": {
"<< AppName >>": {
"applicationId": "<< app id >>",
"masterKey": "<< master key >>"
},
"_default": {
"link": "<< AppName >>"
}
}
}
Just update the following fields:
<< AppName >>
<< app id >>
<< master key >>
(works as of 2 June 2015)
Bug Reported
A bug has been opened related to this issue on Facebook Developers:
https://developers.facebook.com/bugs/971635999542789/
The following versions are not running on my machine:
v2.0.7
v2.0.8
v2.0.9
There are other reports on the support forum that these versions are broken for other people as well.

Resources