How to turn off reasoning in the Grakn python client - reasoning

I am using the Grakn python client and I want to query for data without reasoning turned on.
client = GraknClient(uri=uri)
session = client.session(keyspace=keyspace)
tx = session.transaction().read()
Do I pass an argument in the transaction() method?

You can turn the reasoning off for every specific query by passing infer=False parameter like this
transaction.execute(query, infer=True, explain=False, batch_size=50);
Check out the documentation http://dev.grakn.ai/docs/client-api/python#lazily-execute-a-graql-query

Related

detect error on asynchronous write to influxdb using python influxdb_client

This is my code:
write_api = client.write_api(write_options=ASYNCHRONOUS)
write_api.write(bucket, org, data, write_precision=WritePrecision.US)
1 - How can I detect writing errors?
2 - Should I initialize write_api each time I want to write or I can initialize it once and use the same object all the time?
callback = write_api.write(bucket, org, data, write_precision=WritePrecision.US)
callback.wait()
callback.get()
Is the only way I found. Unfortunately the wait basically makes it synchronous decreasing the performance.

LocustIO: How to do batch request

I started to use LocustIO for load testing a 3rd party API which provides a way to do batch requests (http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_BatchRequests).
How can this be done using LocustIO?
I tried with the following:
def batch(self):
response = self.client.request(method="POST", url="/$batch", auth=("ABC", "DEF"), headers={"ContentType": "multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b"}, data="Content-Type: application/http\nContent-Transfer-Encoding: binary\n\nGET putyoururlhere HTTP/1.1\nAccept: application/json\n\n\n")
Auth is something I need to have authentication to the API, but that's not the point of the question and "putyoururlhere" should be replaced with the actual url. Either way, it gives errors when executing the test, so I must be doing something wrong.
People with experience how to do this?
Kind regards!
The data parameter should be your POST body (only), you cant put additional headers in it the way you did. You probably just want to add them as additional entries in the dict you pass as headers
Se the documentation for python requests library for more details. https://requests.readthedocs.io/en/master/

MssqlHook airflow connection

I am new to using airflow and what I need to do is to use MssqlHook but I do not know how. What elements should I give in the constructor?
I have a connection in airflow with name connection_test.
I do not fully understand the attributes in the class:
class MsSqlHook(DbApiHook):
"""
Interact with Microsoft SQL Server.
"""
conn_name_attr = 'mssql_conn_id'
default_conn_name = 'mssql_default'
supports_autocommit = True
I have the following code:
sqlhook=MsSqlHook(connection_test)
sqlhook.get_conn()
And when I do this the error is Connection failed for unknown reason.
How should I do in order to make it work with the airflow connection ?
What I need is to call function .get_conn() for the MsSqlHook.
See the standard examples of Airflow.
https://github.com/gtoonstra/etl-with-airflow/blob/master/examples/mssql-example/dags/mssql_bcp_example.py
E.g.:
t1 = MsSqlImportOperator(task_id='import_data',
table_name='test.test',
generate_synth_data=generate_synth_data,
mssql_conn_id='mssql',
dag=dag)
EDIT
hook = MsSqlHook(mssql_conn_id="my_mssql_conn")
hook.run(sql)
You need to provide the connection defined in Connections. Also if using Hooks looking in the respective Operators usually yields some information about usage. This code is from the MSSQLOperator.

How to use #GetDocField in IBM Lotus Domino for a database different than the current

I need to "compute when compose" a field in a document so Client+Formula are the only options I have here.
I am using a #DbLookup("" :"NoCache";"server" :"db" ;"View" ; "key" ; fieldName); command that looks into a different server/database and comes back with a UNID of a specific document. The UNID is valid for the server/db database, not the current one. How can I use this UNID to fetch/set a value on the remote document.
In IBM documentation I only found #GetDocField(UNID,fieldName) and #SetDocField(UNID, fieldName, value) that are for the local DB only!!!
How can one actually meaningfully use this UNID since it represents a document on a remote database. I searched for 40 minutes for an answer!
This is not possible using formula language.
In LotusScript you can use
Dim db as New NotesDatabase( "server" , "db" )
Dim doc as NotesDocument
Set doc = db.getDocumentByUnid( uuid )
Call doc.ReplaceItemValue( "fieldname" , value )
if you really are not able to use lotusscript in the context you have (normally there IS an option to use LotusScript wherever / whenever you need it, you probably only try to use the wrong context / event / whatever), then the possibility would be to write a litte LotusScript- Agent with the above code and hand the uuid to it via notes.ini- Parameter, profile- document or whatever fits best for you.
My reputation is too low to comment, so I have to resort to posting an answer to add a thought. Have you tried #UpdateFormulaContext?
UNID := #DbLookup(...[ReturnDocumentUniqueID]);
#Command([OpenDocument]....UNID);
#UpdateFormulaContext;
#SetDocField(#DocumentUniqueID; ...);
#UpdateFormulaContext definitely allows you to reset the 'current' document (from the IBM Domino Designer Help):
tempDate := #GetDocField(#DocumentUniqueID;"CreatedDate");
#Command([NavPrev]);
#Command([EditDocument]);
#UpdateFormulaContext;
#SetDocField(#DocumentUniqueID;"nextCreated";tempDate)
"You can use #UpdateFormulaContext to extract values from or set values in external documents. You can even access document- and database-specific information using functions such as #DbName, #DbTitle, #Created, #DocumentUniqueID, #GetDocField, #GetField, #GetProfileDocument."
Worth a punt.

Asterisk catch a Incoming call and transfer it to a specific exten

I have been building a Window Form desktop application using C# that interfaces with Asterisk using Asterisk.NET.
My first problem is catch a Incoming call and transfer it to specific exten.
The first my idea is using OriginateAction, when a call come, I use Dial event and catch it and use OriginateAction to call to a specific exten.
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
But it not work like my wish.
The second my idea is using RedirectAction:
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
And it not work.
I have find on many websites but the documents is very little.
How can I solve this issue?
Thanks!
I would suggest using some kind of dynamic dialplan instead of "catching" calls reactively. Why not use an AGI script?
Essentially, your application tells a database or other central system what to do when calls matching certain criteria come in. Then Asterisk runs the script you setup when calls reach a certain context (such as all incoming calls), and then the script routes the call dynamically based on the inputs given by your application.
Since you seem to like .NET, here's a .NET AGI project to help you get started: AsterNET. It looks like the library you mentioned, Asterisk.NET, is also capable of Fast CGI (what AGI uses), but the last release was in 2009, whereas AsterNet is active as recently as 3 months ago.
I personally use phpAGI to do all kinds of neat ACD and call routing stuff in our call center.
For more info on AGI, see the official docs.
Edit:
I should probably also explain some basic call flow terminology (from the docs):
Originate: Generates an outgoing call to a Extension/Context/Priority or Application/Data. Example: User clicks a button, Originate a call to their desk phone, when they answer that call, it executes dialplan, or a dialplan application.
Redirect: Redirect (transfer) a call. Example: Agent and Customer are talking, but Manager wants to take over the call. Use Redirect to "take" the call from Agent and ring the Manager.
Dial: (in dialplan only, not AMI) Dial the technology/channel specified. Note that you can only Originate from your .NET application, not Dial.
Can you show your event handler code? It looks like that library would say something like manager.NewChannel += new ManagerEventHandler(new_channel);

Resources