ERROR in the transition system (act) Circumstance in JaCaMo / Jason - agent

I am experiencing an error when trying to send an untell message. I have wrote a simple project to explain: When bob is sending an untell message an error in transition system is occurring. Is it possible to remove a belief by untell? So, how to send it?
Bob's code:
!start.
+!start <-
.print("Starting...");
.send(alice, tell, hi).
+hi <-
.print("Hi");
.send(alice, tell, marryMe).
+yes <-
.print("No no...");
.send(alice, untell, marryMe).
{ include("$jacamoJar/templates/common-cartago.asl") }
{ include("$jacamoJar/templates/common-moise.asl") }
Alice's code:
+hi <-
.print("Hi");
.send(bob, tell, hi).
+marryMe <-
.print("Yes!");
.send(bob, tell, yes).
-marryMe <- .print("Humm?").
{ include("$jacamoJar/templates/common-cartago.asl") }
{ include("$jacamoJar/templates/common-moise.asl") }
Project:
mas jacamotest {
agent bob
agent alice
}
Jacamo's output:
CArtAgO Http Server running on http://X.X.X.X:3273
Jason Http Server running on http://X.X.X.X:3272
[bob] Starting...
[alice] Hi
[bob] Hi
[alice] Yes!
[bob] No no...
[ArithExpr] The value of (-NS::CA) is not a number! Unifier = {Sender=bob, NS=default, Content=marryMe, _42=mid5,
CA=marryMe[source(bob)]}. Code: kqmlPlans.asl:43
[alice] *** ERROR in the transition system (act). Circumstance:
E =[]
I =[]
A =null
MB=[]
RP=null
AP=null
SE=+!kqml_received(bob,untell,marryMe,mid5)
SO=(#kqmlReceivedUnTell[source(self)] +!kqml_received(Sender,untell,NS::Content,_42) <- .add_nested_source(Content,Sender,CA); -(-NS::CA).,{Sender=bob,
NS=default, Content=marryMe, _42=mid5, CA=marryMe[source(bob)]})
SI=intention 6:
+!kqml_received(bob,untell,marryMe,mid5) <- ... -(-NS::CA) / {Sender=bob, NS=default, Content=marryMe, _42=mid5,
CA=marryMe[source(bob)]}
AI=null
AE=null
PA={}
PI={}
FA=[].
Creating a new C!
java.lang.ClassCastException: jason.asSyntax.NumberTermImpl cannot be cast to jason.asSyntax.Literal
at jason.asSemantics.TransitionSystem.prepareBodyForEvent(TransitionSystem.java:932)
at jason.asSemantics.TransitionSystem.applyExecInt(TransitionSystem.java:907)
at jason.asSemantics.TransitionSystem.applySemanticRuleAct(TransitionSystem.java:237)
at jason.asSemantics.TransitionSystem.act(TransitionSystem.java:1525)
at jason.infra.centralised.CentralisedAgArch.act(CentralisedAgArch.java:203)
at jason.infra.centralised.CentralisedAgArch.reasoningCycle(CentralisedAgArch.java:212)
at jason.infra.centralised.CentralisedAgArch.run(CentralisedAgArch.java:231)
at java.base/java.lang.Thread.run(Thread.java:844)

It is due to a bug in the SNAPSHOT version. The new jason-2.3-SNAPSHOT is fixing it.

Related

Is there a function to parse a ThreadId into an i32 or other primitive?

I'm looking for a solution to test which threadid my program is in:
let t1 = thread::spawn(move|| {
if thread::current().id() == 2 {
println!("yes");
}
});
The above fails since it is looking for a ThreadId
I have also tried using
if thread::current().id() == ThreadId(NonZeroU64::new(2).unwrap()) {
//do stuff
}
But since ThreadId is private this does not work
Also there is an issue currently with thread::current().id().as_u64() being unstable.
So I was wondering if there is an easy way to get the number from thread::current().id()?
Its possible to print the thread::current().id() to the console as ThreadId(2) but I'm having trouble trying to compare this to another variable before I join the thread..

Getting Error: http: read on closed response body from Transaction Processor function in Hyperledger Composer

I've a fabric network running with a simple BNA. This BNA defines two types of participants viz. Corporate and Person. Here, each Person has a relationship with the corporate as shown below (cto file):
participant Corporate identified by corporateId {
o String corporateId
o String corporateName
}
participant Person identified by personId {
o String personId
--> Corporate corporate
}
What I'm trying to do:
Create a Corporate using Transaction Processor Function: Success
Create a Person using Transaction Processor Function: Failure
Following is the snippet from transaction processor function for #2:
let corporateIdExpected = personDetails.corporate;
if(corporateIdExpected && corporateIdExpected != '') {
let corporateRetrieved = await query("GetCorporateByCorporateId", {corporateId: corporateIdExpected});
if(!corporateRetrieved || corporateRetrieved == '') {
throw new Error("Corporate details not valid. Please check if your corporate is present on the network.");
}
}
Snippet from my queries.qry:
query GetCorporateByCorporateId {
description: "Returns all corporates in the registry"
statement:
SELECT org.samplenetwork.participants.Corporate
WHERE (corporateId == _$corporateId)
}
So, I get the following error when I try the #2:
Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: Error: Error: http: read on closed response body
However, when I try to execute the query directly from the swagger, it runs successfully.
I'm using:
Hyperledger Fabric: 1.1
Hyperledger Composer: 0.19.8
Am I missing out any checks or steps for this one?
for item 2 - you don't really need to execute a named query each time.
You can do the equivalent check ("does he exist already?") as follows (where trxn below is the transaction object defined in your transaction definition etc):
const personRegistry = await getParticipantRegistry('org.acme.example.Person');
console.log("The person identifier to check is " + trxn.corporate.getIdentifier() )
const exists = await personRegistry.exists(trxn.corporate.getIdentifier() ) ;
console.log("exists is set to " + exists); // boolean
if (exists)
console.log("he exists")
else
console.log("he doesn't exist");

renderParts error in mime-mail package

I am trying to figure out how to send an email message through AWS SES using mime-mail-ses package. I used renderSendMailSES example from Yesod wiki to try the code below - I am using renderMail here to debug the error in mail body validation:
*Main> let textPart = Part {partType = "text/plain; charset=utf-8",
partEncoding = None, partFilename = Nothing, partHeaders = [], partContent = "Testing"}
*Main> let htmlPart = Part { partType = "text/html; charset=utf-8",
partEncoding = None, partFilename = Nothing, partHeaders = [], partContent = "Testing"}
*Main> renderMail' (emptyMail $ Address Nothing "noreply#example.com") {
mailTo = [Address Nothing "test#example.com"] , mailHeaders = [ ("Subject",
"Testing email address")], mailParts = [[textPart, htmlPart]]}
I get this error:
*** Exception: renderParts called with null parts
This is quite head-scratcher because the above example doesn't seem any different from Yesod Wiki. I can't add attachment either because of the above error. An attachment if I am not mistaken, will look like this for mailParts:
mailParts = [[textPart,htmlPart],[attachment1]]
I looked in the code that is causing the error but can't figure out what is wrong.
I will very much appreciate pointers to resolve this error.
This is a versioning issue. I had a local patched copy of http-client from github (to add some streaming validation that wasn't in stackage yet) which seems to be the culprit here. I fixed it by changing the http-client to point to http-client on stackage with the release version that had my fixes (0.4.31). Now, it works fine.

GeoCoder gives default value for invalid zip codes

I am using Geocoder to get a location based on the ZIP code (I am restricting it to just the US). Everything works fine except that if I input an invalid zip (90123, for example), it gives me a default value instead of giving ZERO_RESULTS. The default value happens to be Denton, Texas (for all invalid codes). How can I prevent this from happening, or tell whether a code is invalid to avoid this issue?
I am using this code:
geocoder.geocode({ 'address': zip, componentRestrictions: {country: 'us'} }, function (results, status) {
if (status == google.maps.GeocoderStatus.ZERO_RESULTS) {
jQuery('#zipErrorId').html("INVALID");
}
if (status == google.maps.GeocoderStatus.OK) {
geocoder.geocode({'latLng': results[0].geometry.location}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
var cityState = getCityState(results);
// like Apple Valley, Minnesota
var cityStateArr = cityState.split('|');
---------------------------
}
}
});
}
Currently it is returning Prudential Tower in Boston, MA. Don't know why.
It sends back the value you entered. So in results.address_components.short_name, will be the value it returned. So for example if I search on "00000,United States", the results.address_components.short_name will be "02199" (the zip of the aforementioned building). If that doesn't match the value you gave it, it was probably an invalid zip.

Get Jenkins upstream jobs

I would like to get all the upstream jobs, just like in the console output:
Started by upstream project "allocate" build number 31
originally caused by:
Started by upstream project "start" build number 12
originally caused by:
I've tried groovy postbuild with the following:
def build = Thread.currentThread().executable
def causes= manager.build.getCauses()
for (cause in causes)
{
manager.listener.logger.println "upstream build: " + cause.getShortDescription()
}
but then I only get "allocate", not the "start" job.
I've also tried
def build = Thread.currentThread().executable
def test = build.getUpstreamBuilds()
for (up in test)
{
manager.listener.logger.println "test build project: " + up
}
but this is empty...
Any ideas?
You were close with your first solution.
Actually, what you need to do is iterate over the ancestor of this Cause depending on it's type.
Here is a sample snippet of code that could get you started :
def printCausesRecursively(cause) {
if (cause.class.toString().contains("UpstreamCause")) {
println "This job was caused by " + cause.toString()
for (upCause in cause.upstreamCauses) {
printCausesRecursively(upCause)
}
} else {
println "Root cause : " + cause.toString()
}
}
for (cause in manager.build.causes)
{
printCausesRecursively(cause)
}
You may want to refer to the documentation to handle all Cause types : http://javadoc.jenkins-ci.org/hudson/model/Cause.html
Hope it helps,
Best

Resources